Skip to content

Commit

Permalink
Fix OptimizeDynScopesPass issue from last commit. We were using a nul…
Browse files Browse the repository at this point in the history
…l check to initialize

which is no longer possible with new InterpreterContext.
  • Loading branch information
enebo committed Oct 14, 2014
1 parent a78963b commit ec53bfb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ protected void pre(ThreadContext context, IRubyObject self, String name, Block b
public void ensureInstrsReady() {
// SSS FIXME: Move this out of here to some other place?
// Prepare method if not yet done so we know if the method has an explicit/implicit call protocol
if (method.getInstrsForInterpretation() == null) {
InterpreterContext context = method.prepareForInterpretation();
this.pushScope = !context.getFlags().contains(IRFlags.DYNSCOPE_ELIMINATED);
}
// FIXME: This is resetting this flag per call and I now may want to push interpretercontext through to interpreter
InterpreterContext context = method.prepareForInterpretation();
this.pushScope = !context.getFlags().contains(IRFlags.DYNSCOPE_ELIMINATED);
}

public DynamicMethod getMethodForCaching() {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ private void optimizeSimpleScopes() {
// dynscopes for these scopes.
if (!isUnsafeScope() && !flags.contains(REQUIRES_DYNSCOPE)) {
(new DeadCodeElimination()).run(this);
//(new OptimizeDynScopesPass()).run(this);
(new OptimizeDynScopesPass()).run(this);
}
}

Expand Down
22 changes: 11 additions & 11 deletions core/src/main/java/org/jruby/runtime/InterpretedIRBlockBody.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ public InterpretedIRBlockBody(IRClosure closure, Arity arity, int argumentType)
}

public void ensureInstrsReady(Block.Type blockType) {
// FIXME: probably save interpcontext as a field and use that as a check so we are not retrieving per call
// Prepare closure if not yet done so we know if the method requires a dynscope or not
if (closure.getInstrsForInterpretation() == null) {
InterpreterContext context = closure.prepareForInterpretation();
this.pushScope = !context.getFlags().contains(IRFlags.DYNSCOPE_ELIMINATED);
this.reuseParentScope = context.getFlags().contains(IRFlags.REUSE_PARENT_DYNSCOPE);
if (IRRuntimeHelpers.isDebug()) {
LOG.info("Executing '" + closure + "'");
// The base IR may not have been processed yet
CFG cfg = closure.getCFG();
LOG.info("Graph:\n" + cfg.toStringGraph());
LOG.info("CFG:\n" + cfg.toStringInstrs());
}
InterpreterContext context = closure.prepareForInterpretation();
pushScope = !context.getFlags().contains(IRFlags.DYNSCOPE_ELIMINATED);
reuseParentScope = context.getFlags().contains(IRFlags.REUSE_PARENT_DYNSCOPE);

if (IRRuntimeHelpers.isDebug()) {
LOG.info("Executing '" + closure + "' (pushScope=" + pushScope + ", reuseParentScope=" + reuseParentScope);
// The base IR may not have been processed yet
CFG cfg = closure.getCFG();
LOG.info("Graph:\n" + cfg.toStringGraph());
LOG.info("CFG:\n" + cfg.toStringInstrs());
}
}

Expand Down

0 comments on commit ec53bfb

Please sign in to comment.