Skip to content
Permalink
Browse files
[IR] Fix ordering of passes in prepareFor*
  • Loading branch information
subbuss committed Sep 17, 2014
1 parent b55585c commit e3d30370ca7a180dac7cd25937e13344ecab4cc4
Showing 1 changed file with 29 additions and 19 deletions.
@@ -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.