Skip to content

Commit

Permalink
[Truffle] Place a boundary on all source loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Oct 15, 2016
1 parent 239bcc6 commit c9ca611
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/JRubyTruffleImpl.java
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.vm.PolyglotEngine;
import org.jruby.JRubyTruffleInterface;
Expand Down Expand Up @@ -49,6 +50,7 @@ public void dispose() {
engine.dispose();
}

@TruffleBoundary
private Source loadSource(String source, String name) {
return Source.newBuilder(source).name(name).mimeType(RubyLanguage.MIME_TYPE).build();
}
Expand Down
Expand Up @@ -155,7 +155,7 @@ public class CoreLibrary {

private final RubyContext context;

private final Source source = Source.newBuilder("").name("(core)").mimeType(RubyLanguage.MIME_TYPE).build();
private final Source source = initCoreSource();

This comment has been minimized.

Copy link
@eregon

eregon Oct 18, 2016

Member

This could be static and then it would not need a boundary (minor but it avoids redoing it at startup).

private final SourceSection sourceSection = source.createUnavailableSection();

private final DynamicObject argumentErrorClass;
Expand Down Expand Up @@ -290,6 +290,11 @@ public class CoreLibrary {

private final String coreLoadPath;

@TruffleBoundary
private static Source initCoreSource() {
return Source.newBuilder("").name("(core)").mimeType(RubyLanguage.MIME_TYPE).build();
}

private String buildCoreLoadPath() {
String path = context.getOptions().CORE_LOAD_PATH;

Expand Down
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.debug;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.frame.FrameDescriptor;
Expand All @@ -33,6 +34,7 @@ public static Object eval(String code, Object... arguments) {
}

@Deprecated
@TruffleBoundary
public static Object eval(RubyContext context, String code, Object... arguments) {
final FrameInstance currentFrameInstance = Truffle.getRuntime().getCurrentFrame();

Expand Down
Expand Up @@ -9,6 +9,7 @@
*/
package org.jruby.truffle.language.loader;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.source.Source;
import org.jruby.Ruby;
import org.jruby.truffle.RubyContext;
Expand Down Expand Up @@ -36,6 +37,7 @@ public SourceLoader(RubyContext context) {
this.context = context;
}

@TruffleBoundary
public Source load(String canonicalPath) throws IOException {
if (canonicalPath.equals("-e")) {
return loadFragment(new String(context.getJRubyRuntime().getInstanceConfig().inlineScript(), StandardCharsets.UTF_8), "-e");
Expand All @@ -57,10 +59,12 @@ public Source load(String canonicalPath) throws IOException {
}
}

@TruffleBoundary
public Source loadFragment(String fragment, String name) {
return Source.newBuilder(fragment).name(name).mimeType(RubyLanguage.MIME_TYPE).build();
}

@TruffleBoundary
private Source loadResource(String path) throws IOException {
if (!path.toLowerCase(Locale.ENGLISH).endsWith(".rb")) {
throw new FileNotFoundException(path);
Expand Down

0 comments on commit c9ca611

Please sign in to comment.