8063037: ApplySpecialization.hasApplies shouuld not descend into nested functions
Reviewed-by: hannesw, lagergren
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ApplySpecialization.java Wed Nov 12 14:40:05 2014 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ApplySpecialization.java Wed Nov 12 14:54:40 2014 +0100
@@ -141,6 +141,11 @@
try {
functionNode.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
@Override
+ public boolean enterFunctionNode(final FunctionNode fn) {
+ return fn == functionNode;
+ }
+
+ @Override
public boolean enterCallNode(final CallNode callNode) {
if (isApply(callNode)) {
throw HAS_APPLIES;
@@ -162,7 +167,7 @@
* scope, thus we are conservative and treat any access to arguments outside the
* apply call as a case of "we cannot apply the optimization".
*/
- private void checkValidTransform(final FunctionNode functionNode) {
+ private static void checkValidTransform(final FunctionNode functionNode) {
final Set<Expression> argumentsFound = new HashSet<>();
final Deque<Set<Expression>> stack = new ArrayDeque<>();