8063037: ApplySpecialization.hasApplies shouuld not descend into nested functions
authorattila
Wed, 12 Nov 2014 14:54:40 +0100
changeset 27527 c2e4499ac40a
parent 27526 1ed00adaaed0
child 27528 4a61cb4dfc6c
8063037: ApplySpecialization.hasApplies shouuld not descend into nested functions Reviewed-by: hannesw, lagergren
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ApplySpecialization.java
--- 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<>();