Skip to content

Commit c3f9361

Browse files
committed
[Truffle] Be more clear about errors that go all the way to the top.
1 parent c4ddf94 commit c3f9361

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

core/src/main/java/org/jruby/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ public static void main(String[] args) {
206206
// If a Truffle exception gets this far it's a hard failure - don't try and dress it up as a Ruby exception
207207

208208
if (main.config.getCompileMode() == RubyInstanceConfig.CompileMode.TRUFFLE) {
209+
System.err.println("Truffle internal error: " + t);
209210
t.printStackTrace(System.err);
210211
} else {
211212
// print out as a nice Ruby backtrace

core/src/main/java/org/jruby/Ruby.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -804,33 +804,34 @@ public IRubyObject runScriptBody(Script script) {
804804
}
805805

806806
public IRubyObject runInterpreter(ThreadContext context, ParseResult parseResult, IRubyObject self) {
807-
try {
808-
if (getInstanceConfig().getCompileMode() == CompileMode.TRUFFLE) {
809-
assert parseResult instanceof RootNode;
810-
getTruffleBridge().execute(TranslatorDriver.ParserContext.TOP_LEVEL, getTruffleBridge().toTruffle(self), null, (RootNode) parseResult);
811-
return getNil();
807+
if (getInstanceConfig().getCompileMode() == CompileMode.TRUFFLE) {
808+
assert parseResult instanceof RootNode;
809+
getTruffleBridge().execute(TranslatorDriver.ParserContext.TOP_LEVEL, getTruffleBridge().toTruffle(self), null, (RootNode) parseResult);
810+
return getNil();
811+
} else {
812+
try {
813+
return Interpreter.getInstance().execute(this, parseResult, self);
814+
} catch (JumpException.ReturnJump rj) {
815+
return (IRubyObject) rj.getValue();
812816
}
813-
814-
return Interpreter.getInstance().execute(this, parseResult, self);
815-
} catch (JumpException.ReturnJump rj) {
816-
return (IRubyObject) rj.getValue();
817817
}
818818
}
819819

820820
public IRubyObject runInterpreter(ThreadContext context, Node rootNode, IRubyObject self) {
821821
assert rootNode != null : "scriptNode is not null";
822822

823-
try {
824-
if (getInstanceConfig().getCompileMode() == CompileMode.TRUFFLE) {
825-
assert rootNode instanceof RootNode;
826-
getTruffleBridge().execute(TranslatorDriver.ParserContext.TOP_LEVEL, getTruffleBridge().toTruffle(self), null, (RootNode) rootNode);
827-
return getNil();
828-
}
823+
if (getInstanceConfig().getCompileMode() == CompileMode.TRUFFLE) {
824+
assert rootNode instanceof RootNode;
825+
getTruffleBridge().execute(TranslatorDriver.ParserContext.TOP_LEVEL, getTruffleBridge().toTruffle(self), null, (RootNode) rootNode);
826+
return getNil();
827+
} else {
828+
try {
829829

830-
// FIXME: retrieve from IRManager unless lifus does it later
831-
return Interpreter.getInstance().execute(this, rootNode, self);
832-
} catch (JumpException.ReturnJump rj) {
833-
return (IRubyObject) rj.getValue();
830+
// FIXME: retrieve from IRManager unless lifus does it later
831+
return Interpreter.getInstance().execute(this, rootNode, self);
832+
} catch (JumpException.ReturnJump rj) {
833+
return (IRubyObject) rj.getValue();
834+
}
834835
}
835836
}
836837

0 commit comments

Comments
 (0)