@@ -583,15 +583,18 @@ private void runCompilerPasses(List<CompilerPass> passes) {
583583
584584 private void optimizeSimpleScopes () {
585585 // For safe scopes that don't require a dynamic scope,
586- // inline-add lvar loads/store to tmp-var loads/stores.
586+ // run DCE since the analysis is less likely to be
587+ // stymied by escaped bindings.
587588 if (!isUnsafeScope () && !flags .contains (REQUIRES_DYNSCOPE )) {
588589 (new DeadCodeElimination ()).run (this );
589590 (new OptimizeDynScopesPass ()).run (this );
590591 }
591592 }
592593
593- /** Run any necessary passes to get the IR ready for interpretation */
594- public synchronized Instr [] prepareForInterpretation (boolean isLambda ) {
594+ public void initScope (boolean isLambda ) {
595+ // Reset linearization, if any exists
596+ resetLinearizationData ();
597+
595598 // Build CFG and run compiler passes, if necessary
596599 if (getCFG () == null ) {
597600 buildCFG ();
@@ -614,6 +617,11 @@ public synchronized Instr[] prepareForInterpretation(boolean isLambda) {
614617 // on the commandline, skip this opt.
615618 optimizeSimpleScopes ();
616619 }
620+ }
621+
622+ /** Run any necessary passes to get the IR ready for interpretation */
623+ public synchronized Instr [] prepareForInterpretation (boolean isLambda ) {
624+ initScope (isLambda );
617625
618626 checkRelinearization ();
619627
@@ -628,27 +636,14 @@ public synchronized Instr[] prepareForInterpretation(boolean isLambda) {
628636 /* SSS FIXME: Do we need to synchronize on this? Cache this info in a scope field? */
629637 /** Run any necessary passes to get the IR ready for compilation */
630638 public synchronized List <BasicBlock > prepareForCompilation () {
631- // Reset linearization, since we will add JIT-specific flow and instrs
632- resetLinearizationData ();
633-
634- // Build CFG and run compiler passes, if necessary
635- if (getCFG () == null ) {
636- buildCFG ();
637- }
638-
639- // Add this always since we dont re-JIT a previously
640- // JIT-ted closure. But, check if there are other
641- // smarts available to us and eliminate adding this
642- // code to every closure there is.
639+ // For lambdas, we need to add a global ensure block to catch
640+ // uncaught breaks and throw a LocalJumpError.
643641 //
644- // Add a global ensure block to catch uncaught breaks
645- // and throw a LocalJumpError.
646- if (this instanceof IRClosure ) {
647- if (((IRClosure )this ).addGEBForUncaughtBreaks ()) {
648- resetState ();
649- computeScopeFlags ();
650- }
651- }
642+ // Since we dont re-JIT a previously JIT-ted closure,
643+ // mark all closures lambdas always. But, check if there are
644+ // other smarts available to us and eliminate adding
645+ // this code to every closure there is.
646+ initScope (this instanceof IRClosure );
652647
653648 runCompilerPasses (getManager ().getJITPasses (this ));
654649
0 commit comments