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: 806d858594bb
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d3289dd23d83
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Jan 8, 2018

  1. Copy the full SHA
    4fc1444 View commit details
  2. Copy the full SHA
    d3289dd View commit details
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/compiler/FullBuildTask.java
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ class FullBuildTask implements Runnable {

public void run() {
try {
method.getIRScope().getTopLevelScope().prepareFullBuild();
method.getIRScope().getRootLexicalScope().prepareFullBuild();

method.completeBuild(method.getIRScope().prepareFullBuild());

4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -3473,7 +3473,7 @@ private InterpreterContext buildPrePostExeInner(Node body) {
}

public Operand buildPostExe(PostExeNode postExeNode) {
IRScope topLevel = scope.getTopLevelScope();
IRScope topLevel = scope.getRootLexicalScope();
IRScope nearestLVarScope = scope.getNearestTopLocalVariableScope();

IRClosure endClosure = new IRClosure(manager, scope, postExeNode.getLine(), nearestLVarScope.getStaticScope(), Signature.from(postExeNode), "_END_", true);
@@ -3489,7 +3489,7 @@ public Operand buildPostExe(PostExeNode postExeNode) {
}

public Operand buildPreExe(PreExeNode preExeNode) {
IRScope topLevel = scope.getTopLevelScope();
IRScope topLevel = scope.getRootLexicalScope();
IRClosure beginClosure = new IRFor(manager, scope, preExeNode.getLine(), topLevel.getStaticScope(),
Signature.from(preExeNode), "_BEGIN_");
// Create a new nested builder to ensure this gets its own IR builder state like the ensure block stack
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -344,11 +344,11 @@ public String getName() {
}

public void setFileName(String filename) {
getTopLevelScope().setFileName(filename);
getRootLexicalScope().setFileName(filename);
}

public String getFileName() {
return getTopLevelScope().getFileName();
return getRootLexicalScope().getFileName();
}

public int getLineNumber() {
@@ -358,7 +358,7 @@ public int getLineNumber() {
/**
* Returns the top level scope
*/
public IRScope getTopLevelScope() {
public IRScope getRootLexicalScope() {
IRScope current = this;

for (; current != null && !current.isScriptScope(); current = current.getLexicalParent()) {}
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ir/IRScriptBody.java
Original file line number Diff line number Diff line change
@@ -26,11 +26,11 @@ public IRScriptBody(IRManager manager, String sourceName, StaticScope staticScop
}
}

public DynamicScope getToplevelScope() {
public DynamicScope getScriptDynamicScope() {
return toplevelScope;
}

public void setTopLevelScope(DynamicScope tlbScope) {
public void setScriptDynamicScope(DynamicScope tlbScope) {
this.toplevelScope = tlbScope;
}

2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/IRTranslator.java
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ public R execute(Ruby runtime, ParseResult result, S specificObject) {
// FIXME: In terms of writing and reading we should emit enough to rebuild IC + minimal IRScope state
InterpreterContext ic = IRBuilder.buildRoot(runtime.getIRManager(), (RootNode) result);
scope = (IRScriptBody) ic.getScope();
scope.setTopLevelScope(((RootNode) result).getScope());
scope.setScriptDynamicScope(((RootNode) result).getScope());

if (RubyInstanceConfig.IR_WRITING) {
try {
3 changes: 1 addition & 2 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
import java.util.List;
import org.jruby.EvalType;
import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;
import org.jruby.RubyModule;
import org.jruby.RubyString;
import org.jruby.ast.RootNode;
@@ -85,7 +84,7 @@ protected IRubyObject execute(Ruby runtime, IRScriptBody irScope, IRubyObject se
}

scope.setModule(currModule);
DynamicScope tlbScope = irScope.getToplevelScope();
DynamicScope tlbScope = irScope.getScriptDynamicScope();
if (tlbScope == null) {
context.preMethodScopeOnly(scope);
} else {
10 changes: 5 additions & 5 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jruby.ir.targets;

import com.headius.invokebinder.Signature;
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.Encoding;
import org.jruby.*;
import org.jruby.compiler.NotCompilableException;
@@ -1694,18 +1693,19 @@ public void PushBlockFrameInstr(PushBlockFrameInstr instr) {
public void PushMethodBindingInstr(PushMethodBindingInstr pushbindinginstr) {
IRScope scope = jvm.methodData().scope;
if (scope.isScriptScope() &&
scope.getTopLevelScope() != null) {
scope.getRootLexicalScope() != null) {
// script scope, so we don't push a new scope; instead we push the top-level scope it provides
jvmMethod().loadContext();

jvmMethod().loadStaticScope();
jvmAdapter().invokevirtual(p(StaticScope.class), "getScope", sig(IRScope.class));
jvmAdapter().invokevirtual(p(IRScope.class), "getTopLevelScope", sig(DynamicScope.class));
jvmAdapter().invokevirtual(p(StaticScope.class), "getIRScope", sig(IRScope.class));
jvmAdapter().checkcast(p(IRScriptBody.class));
jvmAdapter().invokevirtual(p(IRScriptBody.class), "getScriptDynamicScope", sig(DynamicScope.class));

jvmAdapter().dup();
jvmStoreLocal(DYNAMIC_SCOPE);

jvmAdapter().dup_x1();
jvmAdapter().dup();
jvmAdapter().invokevirtual(p(DynamicScope.class), "growIfNeeded", sig(void.class));

jvmAdapter().invokevirtual(p(ThreadContext.class), "preScopedBody", sig(void.class, DynamicScope.class));