src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java

Print this page




3266                 loadAndDiscard(test);
3267                 if(testHasLiveConversion) {
3268                     method.beforeJoinPoint(test);
3269                 }
3270             }
3271         } else if (test != null) {
3272             if (testHasLiveConversion) {
3273                 emitBranch(test.getExpression(), body.getEntryLabel(), true);
3274                 method.beforeJoinPoint(test);
3275                 method._goto(breakLabel);
3276             } else {
3277                 emitBranch(test.getExpression(), breakLabel, false);
3278             }
3279         }
3280 
3281         body.accept(this);
3282         if(repeatLabel != continueLabel) {
3283             emitContinueLabel(continueLabel, liveLocalsOnContinue);
3284         }
3285 
3286         if (loopNode.hasPerIterationScope() && lc.getParentBlock().needsScope()) {
3287             // ES6 for loops with LET init need a new scope for each iteration. We just create a shallow copy here.
3288             method.loadCompilerConstant(SCOPE);
3289             method.invoke(virtualCallNoLookup(ScriptObject.class, "copy", ScriptObject.class));
3290             method.storeCompilerConstant(SCOPE);
3291         }
3292 
3293         if(method.isReachable()) {
3294             if(modify != null) {
3295                 lineNumber(loopNode);
3296                 loadAndDiscard(modify);
3297                 method.beforeJoinPoint(modify);
3298             }
3299             method._goto(repeatLabel);
3300         }
3301 
3302         method.breakLabel(breakLabel, liveLocalsOnBreak);
3303     }
3304 
3305     private void emitContinueLabel(final Label continueLabel, final int liveLocals) {
3306         final boolean reachable = method.isReachable();




3266                 loadAndDiscard(test);
3267                 if(testHasLiveConversion) {
3268                     method.beforeJoinPoint(test);
3269                 }
3270             }
3271         } else if (test != null) {
3272             if (testHasLiveConversion) {
3273                 emitBranch(test.getExpression(), body.getEntryLabel(), true);
3274                 method.beforeJoinPoint(test);
3275                 method._goto(breakLabel);
3276             } else {
3277                 emitBranch(test.getExpression(), breakLabel, false);
3278             }
3279         }
3280 
3281         body.accept(this);
3282         if(repeatLabel != continueLabel) {
3283             emitContinueLabel(continueLabel, liveLocalsOnContinue);
3284         }
3285 
3286         if (loopNode.hasPerIterationScope() && lc.getCurrentBlock().needsScope()) {
3287             // ES6 for loops with LET init need a new scope for each iteration. We just create a shallow copy here.
3288             method.loadCompilerConstant(SCOPE);
3289             method.invoke(virtualCallNoLookup(ScriptObject.class, "copy", ScriptObject.class));
3290             method.storeCompilerConstant(SCOPE);
3291         }
3292 
3293         if(method.isReachable()) {
3294             if(modify != null) {
3295                 lineNumber(loopNode);
3296                 loadAndDiscard(modify);
3297                 method.beforeJoinPoint(modify);
3298             }
3299             method._goto(repeatLabel);
3300         }
3301 
3302         method.breakLabel(breakLabel, liveLocalsOnBreak);
3303     }
3304 
3305     private void emitContinueLabel(final Label continueLabel, final int liveLocals) {
3306         final boolean reachable = method.isReachable();