Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Truffle] PolyglotEngine no longer throws IOException.
Browse files Browse the repository at this point in the history
eregon committed Aug 25, 2016
1 parent 54a9259 commit 3f5e725
Showing 2 changed files with 4 additions and 21 deletions.
18 changes: 3 additions & 15 deletions truffle/src/main/java/org/jruby/truffle/JRubyTruffleImpl.java
Original file line number Diff line number Diff line change
@@ -11,13 +11,10 @@

import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.vm.PolyglotEngine;
import java.io.IOException;

import org.jruby.JRubyTruffleInterface;
import org.jruby.Ruby;
import org.jruby.truffle.interop.JRubyContextWrapper;
import org.jruby.truffle.language.control.ExitException;
import org.jruby.truffle.language.control.JavaException;
import org.jruby.truffle.platform.graal.Graal;
import org.jruby.util.cli.Options;

@@ -32,11 +29,7 @@ public JRubyTruffleImpl(Ruby runtime) {
engine = PolyglotEngine.newBuilder()
.globalSymbol(JRubyTruffleInterface.RUNTIME_SYMBOL, new JRubyContextWrapper(runtime))
.build();
try {
context = (RubyContext) engine.eval(loadSource("Truffle::Boot.context", "context")).get();
} catch (IOException e) {
throw new JavaException(e);
}
context = (RubyContext) engine.eval(loadSource("Truffle::Boot.context", "context")).get();
}

@Override
@@ -51,13 +44,8 @@ public Object execute(org.jruby.ast.RootNode rootNode) {

try {
return engine.eval(loadSource("Truffle::Boot.run_jruby_root", "run_jruby_root")).get();
} catch (IOException e) {
if (e.getCause() instanceof ExitException) {
final ExitException exit = (ExitException) e.getCause();
throw new org.jruby.exceptions.MainExitException(exit.getCode());
}

throw new JavaException(e);
} catch (ExitException e) {
throw new org.jruby.exceptions.MainExitException(e.getCode());
}
}

Original file line number Diff line number Diff line change
@@ -648,12 +648,7 @@ protected CallTarget parse(DynamicObject mimeType, DynamicObject source) {
final String mimeTypeString = mimeType.toString();
final Source sourceObject = Source.newBuilder(source.toString()).name("(eval)").mimeType(mimeTypeString).build();

try {
return getContext().getEnv().parse(sourceObject);
} catch (IOException e) {
CompilerDirectives.transferToInterpreterAndInvalidate();
throw new JavaException(e);
}
return getContext().getEnv().parse(sourceObject);
}

protected int getCacheLimit() {

1 comment on commit 3f5e725

@jtulach
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this commit is clean in adopting to most recent Truffle changes. The only drawaback is that it doesn't compile with Truffle @ 0.16 as well as latest Truffle, but if you want to give up on that, the commit is perfectly OK.

Please sign in to comment.