Skip to content

Commit

Permalink
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -583,7 +583,19 @@ private void runDeadCodeAndVarLoadStorePasses() {
/** Run any necessary passes to get the IR ready for interpretation */
public synchronized Instr[] prepareForInterpretation(boolean isLambda) {
// Build CFG and run compiler passes, if necessary
boolean runPasses = false;
if (getCFG() == null) {
buildCFG();
runPasses = true;
}

if (isLambda) {
// Add a global ensure block to catch uncaught breaks
// and throw a LocalJumpError.
((IRClosure)this).addGEBForUncaughtBreaks();
}

if (runPasses) {
runCompilerPasses(getManager().getCompilerPasses(this));

if (RubyInstanceConfig.IR_COMPILER_PASSES == null) {
@@ -594,14 +606,6 @@ public synchronized Instr[] prepareForInterpretation(boolean isLambda) {
}
}

if (isLambda) {
// Add a global ensure block to catch uncaught breaks
// and throw a LocalJumpError.
if (((IRClosure)this).addGEBForUncaughtBreaks()) {
this.relinearizeCFG = true;
}
}

checkRelinearization();

if (linearizedInstrArray != null) return linearizedInstrArray;
@@ -614,7 +618,24 @@ public synchronized Instr[] prepareForInterpretation(boolean isLambda) {
/** Run any necessary passes to get the IR ready for compilation */
public synchronized List<BasicBlock> prepareForCompilation() {
// Build CFG and run compiler passes, if necessary
boolean runPasses = false;
if (getCFG() == null) {
buildCFG();
runPasses = true;
}

// Add this always since we dont re-JIT a previously
// JIT-ted closure. But, check if there are other
// smarts available to us and eliminate adding this
// code to every closure there is.
//
// Add a global ensure block to catch uncaught breaks
// and throw a LocalJumpError.
if (this instanceof IRClosure) {
((IRClosure)this).addGEBForUncaughtBreaks();
}

if (runPasses) {
runCompilerPasses(getManager().getJITPasses(this));

if (RubyInstanceConfig.IR_COMPILER_PASSES == null) {
@@ -627,17 +648,6 @@ public synchronized List<BasicBlock> prepareForCompilation() {
}
}

// Add this always since we dont re-JIT a previously
// JIT-ted closure. But, check if there are other
// smarts available to us and eliminate adding this
// code to every closure there is.
//
// Add a global ensure block to catch uncaught breaks
// and throw a LocalJumpError.
if (this instanceof IRClosure && ((IRClosure)this).addGEBForUncaughtBreaks()) {
this.relinearizeCFG = true;
}

checkRelinearization();

prepareInstructionsForInterpretation();

0 comments on commit e3d3037

Please sign in to comment.