Skip to content

Commit

Permalink
Showing 3 changed files with 15 additions and 15 deletions.
16 changes: 1 addition & 15 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -1360,7 +1360,6 @@ private Operand protectCodeWithRescue(CodeBlock protectedCode, CodeBlock rescueB
}

public Operand buildGetDefinition(Node node) {
// FIXME: Do we still have MASGN and MASGN19?
switch (node.getNodeType()) {
case CLASSVARASGNNODE: case CLASSVARDECLNODE: case CONSTDECLNODE:
case DASGNNODE: case GLOBALASGNNODE: case LOCALASGNNODE:
@@ -3156,20 +3155,7 @@ private void buildRescueBodyInternal(RescueBodyNode rescueBodyNode, Variable rv,
outputExceptionCheck(build(exceptionList), exc, caughtLabel);
}
} else {
// SSS FIXME:
// rescue => e AND rescue implicitly EQQ the exception object with StandardError
// We generate explicit IR for this test here. But, this can lead to inconsistent
// behavior (when compared to MRI) in certain scenarios. See example:
//
// self.class.const_set(:StandardError, 1)
// begin; raise TypeError.new; rescue; puts "AHA"; end
//
// MRI rescues the error, but we will raise an exception because of reassignment
// of StandardError. I am ignoring this for now and treating this as undefined behavior.
//
// Solution: Create a 'StandardError' operand type to eliminate this.
Variable v = addResultInstr(new InheritanceSearchConstInstr(createTemporaryVariable(), new ObjectClass(), "StandardError", false));
outputExceptionCheck(v, exc, caughtLabel);
outputExceptionCheck(manager.getStandardError(), exc, caughtLabel);
}

// Uncaught exception -- build other rescue nodes or rethrow!
5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/ir/IRManager.java
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ public class IRManager {
private final Nil nil = new Nil();
private final Boolean tru = new Boolean(true);
private final Boolean fals = new Boolean(false);
private final StandardError standardError = new StandardError();
public final ToggleBacktraceInstr needsBacktrace = new ToggleBacktraceInstr(true);
public final ToggleBacktraceInstr needsNoBacktrace = new ToggleBacktraceInstr(false);

@@ -83,6 +84,10 @@ public Nil getNil() {
return nil;
}

public StandardError getStandardError() {
return standardError;
}

public org.jruby.ir.operands.Boolean getTrue() {
return tru;
}
9 changes: 9 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/StandardError.java
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@
import org.jruby.ir.transformations.inlining.CloneInfo;

import java.util.List;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

// Represents the StandardError object -- this operand used in rescue blocks
// for when the rescue block doesn't specify an exception object class
@@ -36,4 +40,9 @@ public Operand cloneForInlining(CloneInfo ii) {
public void visit(IRVisitor visitor) {
visitor.StandardError(this);
}

@Override
public Object retrieve(ThreadContext context, IRubyObject self, StaticScope currScope, DynamicScope currDynScope, Object[] temp) {
return context.runtime.getStandardError();
}
}

0 comments on commit 20acc1b

Please sign in to comment.