Skip to content

Commit

Permalink
This code appears to be dead. Remove it to resolve #315.
Browse files Browse the repository at this point in the history
Note that the arguments passed to the IRRuntimeHelpers method
restoreExceptionVar were both IRubyObject, and the only work done
in the method would be if the first one were an instance of
IRReturnJump and IRBreakJump. However neither of these classes
implements IRubyObject, and they are not extended. Similar logic
was removed in the interpreter. Local test:jruby and
spec:ruby:fast passed muster.
  • Loading branch information
headius committed Sep 19, 2018
1 parent 5e57d43 commit ae777f0
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 30 deletions.
4 changes: 0 additions & 4 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -2659,10 +2659,6 @@ public Operand buildEnsureInternal(Node ensureBodyNode, Node ensurerNode) {
addInstr(new LabelInstr(ebi.dummyRescueBlockLabel));
addInstr(new ReceiveJRubyExceptionInstr(exc));

// Emit code to conditionally restore $!
Variable ret = createTemporaryVariable();
addInstr(new RuntimeHelperCall(ret, RESTORE_EXCEPTION_VAR, new Operand[]{exc, savedGlobalException} ));

// Now emit the ensure body's stashed instructions
if (ensurerNode != null) {
ebi.emitBody(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public enum Methods {
HANDLE_PROPAGATED_BREAK, HANDLE_NONLOCAL_RETURN, HANDLE_BREAK_AND_RETURNS_IN_LAMBDA,
IS_DEFINED_BACKREF, IS_DEFINED_NTH_REF, IS_DEFINED_GLOBAL, IS_DEFINED_INSTANCE_VAR,
IS_DEFINED_CLASS_VAR, IS_DEFINED_SUPER, IS_DEFINED_METHOD, IS_DEFINED_CALL,
IS_DEFINED_CONSTANT_OR_METHOD, MERGE_KWARGS, RESTORE_EXCEPTION_VAR;
IS_DEFINED_CONSTANT_OR_METHOD, MERGE_KWARGS;

public static Methods fromOrdinal(int value) {
return value < 0 || value >= values().length ? null : values()[value];
Expand Down Expand Up @@ -158,16 +158,6 @@ public IRubyObject callHelper(ThreadContext context, StaticScope currScope, Dyna
case MERGE_KWARGS:
return IRRuntimeHelpers.mergeKeywordArguments(context, (IRubyObject) arg1,
(IRubyObject) getArgs()[1].retrieve(context, self, currScope, currDynScope, temp));
case RESTORE_EXCEPTION_VAR:
Object exc = getArgs()[0].retrieve(context, self, currScope, currDynScope, temp);
// SSS FIXME: These are non-local control-flow exit scenarios that just
// happen to use exceptions for exiting scopes and we should
// continue to clear $! for them.
if (exc instanceof IRReturnJump || exc instanceof IRBreakJump) {
IRubyObject savedExc = (IRubyObject)getArgs()[1].retrieve(context, self, currScope, currDynScope, temp);
context.runtime.getGlobalVariables().set("$!", savedExc);
}
return null;
}

throw new RuntimeException("Unknown IR runtime helper method: " + helperMethod + "; INSTR: " + this);
Expand Down
8 changes: 0 additions & 8 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -871,14 +871,6 @@ public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyOb
}
}

@JIT
public static IRubyObject restoreExceptionVar(ThreadContext context, IRubyObject exc, IRubyObject savedExc) {
if (exc instanceof IRReturnJump || exc instanceof IRBreakJump) {
context.runtime.getGlobalVariables().set("$!", savedExc);
}
return null;
}

public static RubyModule findInstanceMethodContainer(ThreadContext context, DynamicScope currDynScope, IRubyObject self) {
boolean inBindingEval = currDynScope.inBindingEval();

Expand Down
7 changes: 0 additions & 7 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2084,13 +2084,6 @@ public void RuntimeHelperCall(RuntimeHelperCall runtimehelpercall) {
jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "mergeKeywordArguments", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class));
jvmStoreLocal(runtimehelpercall.getResult());
break;
case RESTORE_EXCEPTION_VAR:
jvmMethod().loadContext();
visit(runtimehelpercall.getArgs()[0]);
visit(runtimehelpercall.getArgs()[1]);
jvmAdapter().invokestatic(p(IRRuntimeHelpers.class), "restoreExceptionVar", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class));
jvmStoreLocal(runtimehelpercall.getResult());
break;
default:
throw new NotCompilableException("Unknown IR runtime helper method: " + runtimehelpercall.getHelperMethod() + "; INSTR: " + this);
}
Expand Down

0 comments on commit ae777f0

Please sign in to comment.