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: 5f76ad1a4c04
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 87a0e738a554
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Jan 8, 2018

  1. Copy the full SHA
    87a0e73 View commit details
10 changes: 3 additions & 7 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Original file line number Diff line number Diff line change
@@ -84,13 +84,9 @@ protected IRubyObject execute(Ruby runtime, IRScriptBody irScope, IRubyObject se
}

scope.setModule(currModule);
DynamicScope tlbScope = irScope.getScriptDynamicScope();
if (tlbScope == null) {
context.preMethodScopeOnly(scope);
} else {
context.preScopedBody(tlbScope);
tlbScope.growIfNeeded();
}

IRRuntimeHelpers.prepareScriptScope(context, scope);

context.setCurrentVisibility(Visibility.PRIVATE);

try {
20 changes: 20 additions & 0 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.jruby.ir.IRMethod;
import org.jruby.ir.IRScope;
import org.jruby.ir.IRScopeType;
import org.jruby.ir.IRScriptBody;
import org.jruby.ir.Interp;
import org.jruby.ir.JIT;
import org.jruby.ir.Tuple;
@@ -568,6 +569,25 @@ public static void checkForExtraUnwantedKeywordArgs(ThreadContext context, final
}
}

@JIT
public static DynamicScope prepareScriptScope(ThreadContext context, StaticScope scope) {
IRScope irScope = scope.getIRScope();

if (irScope.isScriptScope()) {
DynamicScope tlbScope = ((IRScriptBody) irScope).getScriptDynamicScope();
if (tlbScope != null) {
context.preScopedBody(tlbScope);
tlbScope.growIfNeeded();
return tlbScope;
}
}

DynamicScope dynScope = DynamicScope.newDynamicScope(scope);
context.pushScope(dynScope);

return dynScope;
}

private static class InvalidKeyException extends RuntimeException {}
private static final InvalidKeyException INVALID_KEY_EXCEPTION = new InvalidKeyException();
private static final RubyHash.VisitorWithState<StaticScope> CheckUnwantedKeywordsVisitor = new RubyHash.VisitorWithState<StaticScope>() {
38 changes: 8 additions & 30 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -1692,46 +1692,24 @@ public void PushBlockFrameInstr(PushBlockFrameInstr instr) {
@Override
public void PushMethodBindingInstr(PushMethodBindingInstr pushbindinginstr) {
IRScope scope = jvm.methodData().scope;
org.objectweb.asm.Label done = new org.objectweb.asm.Label();

if (scope.isScriptScope() &&
scope.getRootLexicalScope() != null) {

org.objectweb.asm.Label noTopLevel = new org.objectweb.asm.Label();

// 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), "getIRScope", sig(IRScope.class));
jvmAdapter().checkcast(p(IRScriptBody.class));
jvmAdapter().invokevirtual(p(IRScriptBody.class), "getScriptDynamicScope", sig(DynamicScope.class));

jvmAdapter().dup();
jvmAdapter().ifnull(noTopLevel);

jvmAdapter().dup();
jvmMethod().invokeIRHelper("prepareScriptScope", sig(DynamicScope.class, ThreadContext.class, StaticScope.class));
jvmStoreLocal(DYNAMIC_SCOPE);

return;
} else {
jvmMethod().loadContext();
jvmMethod().loadStaticScope();
jvmAdapter().invokestatic(p(DynamicScope.class), "newDynamicScope", sig(DynamicScope.class, StaticScope.class));
jvmAdapter().dup();
jvmAdapter().invokevirtual(p(DynamicScope.class), "growIfNeeded", sig(void.class));

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

jvmAdapter().go_to(done);

jvmAdapter().label(noTopLevel);
jvmAdapter().pop2(); // context, dynscope
jvmStoreLocal(DYNAMIC_SCOPE);
jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void pushScope(org.jruby.runtime.DynamicScope)"));
}

jvmMethod().loadContext();
jvmMethod().loadStaticScope();
jvmAdapter().invokestatic(p(DynamicScope.class), "newDynamicScope", sig(DynamicScope.class, StaticScope.class));
jvmAdapter().dup();
jvmStoreLocal(DYNAMIC_SCOPE);
jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void pushScope(org.jruby.runtime.DynamicScope)"));

jvmAdapter().label(done);
}

@Override