Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a64705f6105f
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: bbb7bbea78d2
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Jan 23, 2015

  1. Copy the full SHA
    4f29d27 View commit details
  2. Copy the full SHA
    d42b726 View commit details
  3. Copy the full SHA
    bbb7bbe View commit details
23 changes: 12 additions & 11 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
import org.jruby.ir.operands.*;
import org.jruby.ir.operands.Float;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.CallType;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.RubyEvent;
@@ -276,12 +275,14 @@ public IRLoop getCurrentLoop() {
return loopStack.isEmpty() ? null : loopStack.peek();
}

protected IRBuilder parent;
protected IRManager manager;
protected IRScope scope;

public IRBuilder(IRManager manager, IRScope scope) {
public IRBuilder(IRManager manager, IRScope scope, IRBuilder parent) {
this.manager = manager;
this.scope = scope;
this.parent = parent;
this.activeRescuers.push(Label.UNRESCUED_REGION_LABEL);
}

@@ -434,8 +435,12 @@ private boolean hasListener() {
return manager.getIRScopeListener() != null;
}

public static IRBuilder newIRBuilder(IRManager manager, IRScope scope) {
return new IRBuilder(manager, scope);
public IRBuilder newIRBuilder(IRManager manager, IRScope newScope) {
return new IRBuilder(manager, newScope, this);
}

public static IRBuilder topIRBuilder(IRManager manager, IRScope newScope) {
return new IRBuilder(manager, newScope, null);
}

public Node skipOverNewlines(Node n) {
@@ -3200,13 +3205,9 @@ public void buildEvalRoot(RootNode rootNode) {
}

public static IRScriptBody buildRoot(IRManager manager, RootNode rootNode) {
String file = rootNode.getPosition().getFile();
StaticScope staticScope = rootNode.getStaticScope();

// Top-level script!
IRScriptBody script = new IRScriptBody(manager, file, staticScope);
IRScriptBody script = new IRScriptBody(manager, rootNode.getPosition().getFile(), rootNode.getStaticScope());

newIRBuilder(manager, script).buildRootInner(script, rootNode);
topIRBuilder(manager, script).buildRootInner(rootNode);

return script;
}
@@ -3216,7 +3217,7 @@ private void addCurrentScopeAndModule() {
addInstr(new CopyInstr(scope.getCurrentModuleVariable(), SCOPE_MODULE[0])); // %current_module
}

private void buildRootInner(IRScriptBody script, RootNode rootNode) {
private void buildRootInner(RootNode rootNode) {
prepareImplicitState(); // recv_self, add frame block, etc)
addCurrentScopeAndModule(); // %current_scope/%current_module

2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/IRMethod.java
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ public IRMethod(IRManager manager, IRScope lexicalParent, MethodDefNode defn, St
/** Run any necessary passes to get the IR ready for interpretation */
public synchronized InterpreterContext prepareForInterpretation() {
if (defn != null) {
IRBuilder.newIRBuilder(getManager(), this).defineMethodInner(defn, getLexicalParent());
IRBuilder.topIRBuilder(getManager(), this).defineMethodInner(defn, getLexicalParent());

defn = null;
}
Original file line number Diff line number Diff line change
@@ -747,7 +747,7 @@ private static BeginEndInterpreterContext prepareIC(ThreadContext context, Dynam
// we end up growing dynamicscope potentially based on any changes made.
staticScope.setIRScope(script);

IRBuilder.newIRBuilder(runtime.getIRManager(), script).buildEvalRoot(rootNode);
IRBuilder.topIRBuilder(runtime.getIRManager(), script).buildEvalRoot(rootNode);
BeginEndInterpreterContext ic = (BeginEndInterpreterContext) script.prepareForInterpretation();

if (IRRuntimeHelpers.isDebug()) {
2 changes: 1 addition & 1 deletion core/src/main/ruby/jruby/jruby.rb
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ def compile(content = nil, filename = (default_filename = true; '-'), extra_posi
end

runtime = JRuby.runtime
irscope = org.jruby.ir.IRBuilder.createIRBuilder(runtime, runtime.getIRManager()).build_root(node);
irscope = org.jruby.ir.IRBuilder.build_root runtime.getIRManager(), node

visitor = org.jruby.ir.targets.JVMVisitor.new
bytes = visitor.compile_to_bytecode(irscope);
2 changes: 1 addition & 1 deletion spec/compiler/general_spec.rb
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ def compile_to_method(src, filename, lineno)
scope.setModule(currModule)
end

method = oj.ir.IRBuilder.createIRBuilder(JRuby.runtime, JRuby.runtime.getIRManager()).buildRoot(node)
method = oj.ir.IRBuilder.build_root JRuby.runtime.getIRManager(), node

method.prepareForCompilation