diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRContext.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRContext.java index f05e725df8d080ffe2a4a919546fba07c06ea187..58ec42838ec390e5b089ad19bfcf1620112fbe46 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRContext.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRContext.java @@ -36,6 +36,8 @@ import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.interop.java.JavaInterop; import com.oracle.truffle.api.vm.PolyglotEngine; import com.oracle.truffle.r.nodes.builtin.NodeWithArgumentCasts.Casts; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; @@ -87,8 +89,8 @@ public class FastRContext { public abstract static class Get extends RBuiltinNode { @Specialization @TruffleBoundary - protected Object get() { - return RContext.getInstance(); + protected TruffleObject get() { + return JavaInterop.asTruffleObject(RContext.getInstance()); } } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/ContextInfo.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/ContextInfo.java index 5e7770a8eaeb9140f95c3644caaea817a0a685f7..d048d228286590d1bedb946e5ebe84c5ccaab5c7 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/ContextInfo.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/ContextInfo.java @@ -25,8 +25,7 @@ package com.oracle.truffle.r.runtime.context; import java.util.TimeZone; import java.util.concurrent.atomic.AtomicInteger; -import com.oracle.truffle.api.interop.ForeignAccess; -import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.interop.java.JavaInterop; import com.oracle.truffle.api.vm.PolyglotEngine; import com.oracle.truffle.r.runtime.RCmdOptions; import com.oracle.truffle.r.runtime.RCmdOptions.Client; @@ -39,7 +38,7 @@ import com.oracle.truffle.r.runtime.context.RContext.ContextKind; * Use {@link #createVM()} to apply this information to a newly-built {@link PolyglotEngine} * instance (it will be stored in the "fastrContextInfo" global symbol). */ -public final class ContextInfo implements TruffleObject { +public final class ContextInfo { public static final String GLOBAL_SYMBOL = "fastrContextInfo"; private static final AtomicInteger contextInfoIds = new AtomicInteger(); @@ -69,13 +68,13 @@ public final class ContextInfo implements TruffleObject { } public PolyglotEngine createVM() { - PolyglotEngine newVM = PolyglotEngine.newBuilder().globalSymbol(GLOBAL_SYMBOL, this).build(); + PolyglotEngine newVM = PolyglotEngine.newBuilder().globalSymbol(GLOBAL_SYMBOL, JavaInterop.asTruffleObject(this)).build(); this.vm = newVM; return newVM; } public PolyglotEngine createVM(PolyglotEngine.Builder builder) { - PolyglotEngine newVM = builder.globalSymbol(GLOBAL_SYMBOL, this).build(); + PolyglotEngine newVM = builder.globalSymbol(GLOBAL_SYMBOL, JavaInterop.asTruffleObject(this)).build(); this.vm = newVM; return newVM; } @@ -150,9 +149,4 @@ public final class ContextInfo implements TruffleObject { public PolyglotEngine getVM() { return vm; } - - @Override - public ForeignAccess getForeignAccess() { - throw new IllegalStateException("cannot access " + ContextInfo.class.getSimpleName() + " via Truffle"); - } } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/RContext.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/RContext.java index 7edb1892a27dde5ba94a6a0cc9a87446697476fa..28176f11483e5ce4c3950fddf397549d706061a8 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/RContext.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/RContext.java @@ -39,8 +39,8 @@ import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.TruffleLanguage.Env; import com.oracle.truffle.api.instrumentation.Instrumenter; -import com.oracle.truffle.api.interop.ForeignAccess; import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.interop.java.JavaInterop; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.vm.PolyglotEngine; import com.oracle.truffle.r.runtime.ExitException; @@ -97,7 +97,7 @@ import com.oracle.truffle.r.runtime.rng.RRNG; * * Contexts can be destroyed */ -public final class RContext extends ExecutionContext implements TruffleObject { +public final class RContext extends ExecutionContext { public static final int CONSOLE_WIDTH = 80; @@ -445,7 +445,7 @@ public final class RContext extends ExecutionContext implements TruffleObject { * @param isInitial {@code true} if this is the initial (primordial) context. */ private RContext(Env env, Instrumenter instrumenter, boolean isInitial) { - ContextInfo initialInfo = (ContextInfo) env.importSymbol(ContextInfo.GLOBAL_SYMBOL); + Object initialInfo = env.importSymbol(ContextInfo.GLOBAL_SYMBOL); if (initialInfo == null) { /* * This implies that FastR is being invoked initially from another Truffle language and @@ -455,7 +455,7 @@ public final class RContext extends ExecutionContext implements TruffleObject { this.info = ContextInfo.create(new RStartParams(RCmdOptions.parseArguments(Client.R, new String[]{"--no-restore"}, false), false), null, ContextKind.SHARE_NOTHING, null, new DefaultConsoleHandler(env.in(), env.out())); } else { - this.info = initialInfo; + this.info = JavaInterop.asJavaObject(ContextInfo.class, (TruffleObject) initialInfo); } this.initial = isInitial; @@ -834,11 +834,6 @@ public final class RContext extends ExecutionContext implements TruffleObject { nameSpaceName = name; } - @Override - public ForeignAccess getForeignAccess() { - throw new IllegalStateException("cannot access " + RContext.class.getSimpleName() + " via Truffle"); - } - public interface RCloseable extends Closeable { @Override void close();