Skip to content

Commit

Permalink
Include null check to mimic logic in interpreter.
Browse files Browse the repository at this point in the history
Why? Because compiler specs failed. Should this check really be
needed? Beats me. I just work here.
headius committed Jan 8, 2018

Verified

This commit was signed with the committer’s verified signature.
headius Charles Oliver Nutter
1 parent 8c2426f commit 5f76ad1
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -1692,8 +1692,13 @@ 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();

@@ -1702,21 +1707,31 @@ public void PushMethodBindingInstr(PushMethodBindingInstr pushbindinginstr) {
jvmAdapter().checkcast(p(IRScriptBody.class));
jvmAdapter().invokevirtual(p(IRScriptBody.class), "getScriptDynamicScope", sig(DynamicScope.class));

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

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

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

jvmAdapter().invokevirtual(p(ThreadContext.class), "preScopedBody", sig(void.class, DynamicScope.class));
} else {
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().go_to(done);

jvmAdapter().label(noTopLevel);
jvmAdapter().pop2(); // context, dynscope
}

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

0 comments on commit 5f76ad1

Please sign in to comment.