Skip to content

Commit

Permalink
All hail the third IC to IRScope
Browse files Browse the repository at this point in the history
enebo committed Jan 25, 2017
1 parent ece8446 commit 8c93786
Showing 3 changed files with 13 additions and 13 deletions.
21 changes: 12 additions & 9 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -114,6 +114,9 @@ public abstract class IRScope implements ParseResult {
/** -X-C full interpretation OR JIT depends on this */
protected FullInterpreterContext fullInterpreterContext;

/** speculative optimizations */
protected FullInterpreterContext optimizedInterpreterContext;

protected int temporaryVariableIndex;
protected int floatVariableIndex;
protected int fixnumVariableIndex;
@@ -139,7 +142,6 @@ public abstract class IRScope implements ParseResult {
private Compilable compilable;
// FIXME: A hack to limit number of inlines to 1
public boolean alreadyHasInline;
private boolean deoptimizable;

// Used by cloning code
protected IRScope(IRScope s, IRScope lexicalParent) {
@@ -611,6 +613,11 @@ public boolean isFullBuildComplete() {

/** Run any necessary passes to get the IR ready for compilation */
public synchronized BasicBlock[] prepareForCompilation() {
if (optimizedInterpreterContext != null) {
System.out.println("OIC BBLISTY: " + optimizedInterpreterContext.getLinearizedBBList());
return optimizedInterpreterContext.getLinearizedBBList();
}

// Don't run if same method was queued up in the tiny race for scheduling JIT/Full Build OR
// for any nested closures which got a a fullInterpreterContext but have not run any passes
// or generated instructions.
@@ -1090,10 +1097,10 @@ public void inlineMethod(Compilable method, RubyModule implClass, int classToken
FullInterpreterContext newContext = inlineMethodCommon(method, implClass, classToken, basicBlock, call, cloneHost);

newContext.generateInstructionsForIntepretation();
this.fullInterpreterContext = newContext;
this.optimizedInterpreterContext = newContext;

System.out.println(fullInterpreterContext.toStringInstrs());
compilable.setInterpreterContext(fullInterpreterContext);
compilable.setInterpreterContext(newContext);
alreadyHasInline = true;
}

@@ -1105,7 +1112,7 @@ public void inlineMethodJIT(Compilable method, RubyModule implClass, int classTo
Ruby runtime = implClass.getRuntime();

newContext.linearizeBasicBlocks();
this.fullInterpreterContext = newContext;
this.optimizedInterpreterContext = newContext;

if (compilable instanceof MixedModeIRMethod) {
runtime.getJITCompiler().getTaskFor(runtime.getCurrentContext(), compilable).run();
@@ -1253,11 +1260,7 @@ public boolean needsBinding() {
return reuseParentScope() || !getFlags().contains(IRFlags.DYNSCOPE_ELIMINATED);
}

public void setDeoptimizable(boolean deoptimizable) {
this.deoptimizable = deoptimizable;
}

public boolean isDeoptimizable() {
return deoptimizable;
return false; // optimizedInterpreterContext != null;
}
}
Original file line number Diff line number Diff line change
@@ -278,9 +278,6 @@ public void inlineMethod(IRScope methodScope, RubyModule implClass, int classTok
beforeInlineBB.addInstr(new ModuleVersionGuardInstr(classToken, call.getReceiver(), fallbackIPC));
call.blockInlining(); // we will not inline on this inlined call (FIXME: for now anyways)

// set deopt flag
hostScope.setDeoptimizable(true);

// Inline any closure argument passed into the call.
Operand closureArg = call.getClosureArg(null);
List yieldSites = ii.getYieldSites();
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -2194,7 +2194,7 @@ public static boolean isGenerationEqual(IRubyObject object, int generation) {
@JIT
public static void checkGeneration(IRubyObject object, int generation, int ipc) {
if (!isGenerationEqual(object, generation)) {
throw new IRDeoptimization(ipc);
// throw new IRDeoptimization(ipc);
}
}

0 comments on commit 8c93786

Please sign in to comment.