diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_common/variables_common.h b/com.oracle.truffle.r.native/fficall/src/truffle_common/variables_common.h index 50855e8d240ccfa9245a478fc4405100f234731e..b901507cebe10ac4296f925723f5efbbb2c21786 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle_common/variables_common.h +++ b/com.oracle.truffle.r.native/fficall/src/truffle_common/variables_common.h @@ -21,6 +21,7 @@ * questions. */ #define NO_FASTR_REDEFINE +#include <stdlib.h> #include <string.h> #include <Rinterface.h> #include <trufflenfi.h> diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BitwiseFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BitwiseFunctions.java index c6027138b595f76cc14e514c99d97ec7a2fbc756..1344118dc3320ab2f542f6e9e7f59f01c08639a3 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BitwiseFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BitwiseFunctions.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2015, Purdue University - * Copyright (c) 2014, 2017, Oracle and/or its affiliates + * Copyright (c) 2014, 2018, Oracle and/or its affiliates * * All rights reserved. */ @@ -21,6 +21,7 @@ import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.typeName; import static com.oracle.truffle.r.runtime.builtins.RBehavior.PURE; import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.profiles.LoopConditionProfile; @@ -248,12 +249,15 @@ public class BitwiseFunctions { } @Specialization - protected Object bitwNot(RAbstractIntVector a) { + protected Object bitwNot(RAbstractIntVector a, + @Cached("create()") NACheck naCheck) { int[] ans = new int[a.getLength()]; + naCheck.enable(a); for (int i = 0; i < a.getLength(); i++) { - ans[i] = ~a.getDataAt(i); + int val = a.getDataAt(i); + ans[i] = naCheck.check(val) ? RRuntime.INT_NA : ~val; } - return RDataFactory.createIntVector(ans, RDataFactory.COMPLETE_VECTOR); + return RDataFactory.createIntVector(ans, naCheck.neverSeenNA()); } } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EncodeString.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EncodeString.java index 9fe3d1452275081b70e808f932655b1cde53ab51..f9983772c23c872c045a53397e684e83b61150d3 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EncodeString.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EncodeString.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2014, Purdue University - * Copyright (c) 2014, 2017, Oracle and/or its affiliates + * Copyright (c) 2014, 2018, Oracle and/or its affiliates * * All rights reserved. */ @@ -69,6 +69,13 @@ public abstract class EncodeString extends RBuiltinNode.Arg5 { return str.append(snippet); } + private static StringBuilder append(String source, StringBuilder sb) { + if (sb == null) { + return new StringBuilder(source.length() * 2).append(source); + } + return sb.append(source); + } + @TruffleBoundary private static String encodeString(String value, char quote) { StringBuilder str = null; @@ -120,12 +127,12 @@ public abstract class EncodeString extends RBuiltinNode.Arg5 { break; default: if (codepoint < 32 || codepoint == 0x7f) { - str.append("\\").append(codepoint >>> 6).append((codepoint >>> 3) & 0x7).append(codepoint & 0x7); + str = append("\\", str).append(codepoint >>> 6).append((codepoint >>> 3) & 0x7).append(codepoint & 0x7); } else if (codepoint > 64967) { // determined by experimentation if (codepoint < 0x10000) { - str.append("\\u").append(String.format("%04x", codepoint)); + str = append("\\u", str).append(String.format("%04x", codepoint)); } else { - str.append("\\U").append(String.format("%08x", codepoint)); + str = append("\\U", str).append(String.format("%08x", codepoint)); } } else { if (str != null) { 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 08dc511069deb09535a9407207f0a7d224cb8414..a3303adb897288d010de203b728424b84c550eb7 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,6 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; 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.launcher.RCmdOptions.Client; import com.oracle.truffle.r.nodes.builtin.NodeWithArgumentCasts.Casts; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; @@ -157,8 +156,7 @@ public class FastRContext { // create eval threads which may already set values to shared slots for (int i = 0; i < length; i++) { threads[i] = new EvalThread(RContext.getInstance().threads, childContextInfos[i], - RSource.fromTextInternalInvisible(exprs.getDataAt(i % exprs.getLength()), RSource.Internal.CONTEXT_EVAL), - FastROptions.SpawnUsesPolyglot.getBooleanValue()); + RSource.fromTextInternalInvisible(exprs.getDataAt(i % exprs.getLength()), RSource.Internal.CONTEXT_EVAL)); } for (int i = 0; i < length; i++) { threads[i].start(); @@ -216,10 +214,10 @@ public class FastRContext { * for completion of all the sub-contexts. {@code args} provides the command line arguments to * the contexts - this is the same for all. * - * Each evaluation is run in a new {@link RContext}/{@link PolyglotEngine}. The result is a list - * of lists. The top level list has the same number of entries as the number of contexts. The - * sublist contains the result of the evaluation with name "result". It may also have an - * attribute "error" if the evaluation threw an exception, in which case the result will be NA. + * Each evaluation is run in a new {@link RContext}. The result is a list of lists. The top + * level list has the same number of entries as the number of contexts. The sublist contains the + * result of the evaluation with name "result". It may also have an attribute "error" if the + * evaluation threw an exception, in which case the result will be NA. */ @RBuiltin(name = ".fastr.context.eval", kind = PRIMITIVE, parameterNames = {"exprs", "kind"}, behavior = COMPLEX) public abstract static class Eval extends RBuiltinNode.Arg2 { @@ -255,7 +253,7 @@ public class FastRContext { int[] multiSlotIndices = new int[length]; for (int i = 0; i < length; i++) { ChildContextInfo info = createContextInfo(contextKind); - threads[i] = new EvalThread(RContext.getInstance().threads, info, RSource.fromTextInternalInvisible(exprs.getDataAt(i % exprs.getLength()), RSource.Internal.CONTEXT_EVAL), false); + threads[i] = new EvalThread(RContext.getInstance().threads, info, RSource.fromTextInternalInvisible(exprs.getDataAt(i % exprs.getLength()), RSource.Internal.CONTEXT_EVAL)); multiSlotIndices[i] = info.getMultiSlotInd(); } if (contextKind == ContextKind.SHARE_ALL) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmem.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmem.java index 4023e75743f2f89ed59332251971523e2c43434d..802b049011e4aa701e472058bccfd5a4b60ffa30 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmem.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,13 +32,9 @@ 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.r.runtime.instrument.memprof.MemAllocProfilerInstrument; -import com.oracle.truffle.api.vm.PolyglotEngine; -import com.oracle.truffle.api.vm.PolyglotRuntime.Instrument; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; -import com.oracle.truffle.r.runtime.RError; +import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.builtins.RBuiltin; -import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.data.RNull; @RBuiltin(name = ".fastr.profmem", visibility = OFF, kind = PRIMITIVE, parameterNames = {"on"}, behavior = IO) @@ -62,33 +58,8 @@ public abstract class FastRprofmem extends RBuiltinNode.Arg1 { @Specialization @TruffleBoundary - public Object doProfMem(boolean on) { - PolyglotEngine vm = RContext.getInstance().getVM(); - if (vm != null) { - Instrument profilerInstr = vm.getRuntime().getInstruments().get(MemAllocProfilerInstrument.ID); - if (profilerInstr != null && profilerInstr.isEnabled() != on) { - profilerInstr.setEnabled(on); - } - } else { - throw error(RError.Message.GENERIC, "No context VM found"); - } - return RNull.instance; - } - - static MemAllocProfilerPrinter getProfilerPrinter() { - PolyglotEngine vm = RContext.getInstance().getVM(); - MemAllocProfilerPrinter profPrinter = null; - if (vm != null) { - Instrument profilerInstr = vm.getRuntime().getInstruments().get(MemAllocProfilerInstrument.ID); - if (profilerInstr != null && profilerInstr.isEnabled()) { - profPrinter = profilerInstr.lookup(MemAllocProfilerPrinter.class); - } - } - - if (profPrinter == null) { - profPrinter = new MemAllocProfilerPrinter(System.out); - } - - return profPrinter; + public Object doProfMem(@SuppressWarnings("unused") boolean on) { + // TODO: port to new instrumentation API, original code can be found in git history + throw error(Message.GENERIC, ".fastr.profmem is not available."); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemShow.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemShow.java index b85dfe90a71c3f4139f114e8e635e2e814b22cbf..9179838da5c2224a0844e393344184772dbe981c 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemShow.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemShow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ 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.r.nodes.builtin.RBuiltinNode; +import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.data.RNull; @@ -59,27 +60,16 @@ public abstract class FastRprofmemShow extends RBuiltinNode.Arg6 { } @Specialization + @SuppressWarnings("unused") public Object doProfMem(int levels, boolean desc, @SuppressWarnings("unused") RNull n, boolean printParents, String view, TruffleObject snapshot) { - return show(levels, desc, null, printParents, view, snapshot); + // TODO: port to new instrumentation API, original code can be found in git history + throw error(Message.GENERIC, ".fastr.profmem.show is not available."); } @Specialization + @SuppressWarnings("unused") public Object doProfMem(int levels, boolean desc, int entryId, boolean printParents, String view, TruffleObject snapshot) { - return show(levels, desc, entryId, printParents, view, snapshot); - } - - @TruffleBoundary - private static Object show(int levels, boolean desc, Integer entryId, boolean printParents, String view, TruffleObject snapshotTO) { - MemAllocProfilerPaths snapshot = MemAllocProfilerPaths.fromTruffleObject(snapshotTO); - return show(levels, desc, entryId, printParents, view, snapshot); - } - - private static Object show(int levels, boolean desc, Integer entryId, boolean printParents, String view, MemAllocProfilerPaths snapshot) { - MemAllocProfilerPaths usedSnapshot = snapshot; - if (FastRprofmem.HOTSPOTS_VIEW.equals(view)) { - usedSnapshot = usedSnapshot.toHS(); - } - FastRprofmem.getProfilerPrinter().show(usedSnapshot, entryId, levels, desc, printParents); - return RNull.instance; + // TODO: port to new instrumentation API, original code can be found in git history + throw error(Message.GENERIC, ".fastr.profmem.show is not available."); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemSource.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemSource.java index 3c008c7eec1fbbdd89b1461b122cc9b5779c4654..5e3eac7f322bee7d3c639aea2071363f519d7639 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemSource.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ 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.r.nodes.builtin.RBuiltinNode; +import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.data.RNull; @@ -55,19 +56,9 @@ public abstract class FastRprofmemSource extends RBuiltinNode.Arg3 { @Specialization @TruffleBoundary + @SuppressWarnings("unused") public Object showSource(int entryId, String view, TruffleObject snapshotTO) { - MemAllocProfilerPaths paths = MemAllocProfilerPaths.fromTruffleObject(snapshotTO); - return showSource(entryId, view, paths); - } - - private static Object showSource(int entryId, String view, MemAllocProfilerPaths snap) { - MemAllocProfilerPaths snapshot = snap; - if (FastRprofmem.HOTSPOTS_VIEW.equals(view)) { - snapshot = snapshot.toHS(); - } - - FastRprofmem.getProfilerPrinter().source(snapshot, entryId); - - return RNull.instance; + // TODO: port to new instrumentation API, original code can be found in git history + throw error(Message.GENERIC, ".fastr.profmem.source is not available."); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTUtils.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTUtils.java index 5f534531966c819d5e53f5b7b430eb4ef260a273..7a8ffc3795c5d8b0b2d4a18ca4e7ead80dca0a6a 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTUtils.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTUtils.java @@ -325,7 +325,7 @@ public final class RASTUtils { // Store formal arguments argumentNames[i] = argName; - defaultValues[i] = defaultValue.asRNode(); + defaultValues[i] = defaultValue == null ? null : defaultValue.asRNode(); current = ((RPairList) current).cdr(); i++; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/RExplicitCallNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/RExplicitCallNode.java index d58a059ae2b47b59c9d1211d09d2a955a625fcc5..981da872f08fb57ac522812c5ccbb4a5cac959f6 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/RExplicitCallNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/RExplicitCallNode.java @@ -30,6 +30,7 @@ import com.oracle.truffle.api.frame.FrameSlot; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.r.nodes.function.RCallBaseNode; import com.oracle.truffle.r.nodes.function.RCallNode; import com.oracle.truffle.r.runtime.RCaller; import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames; @@ -60,7 +61,7 @@ public abstract class RExplicitCallNode extends Node { @Specialization protected Object doCall(VirtualFrame frame, RFunction function, RArgsValuesAndNames args, RCaller caller, - @Cached("createExplicitCall()") RCallNode call) { + @Cached("createExplicitCall()") RCallBaseNode call) { if (argsFrameSlot == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); argsFrameSlot = FrameSlotChangeMonitor.findOrAddFrameSlot(frame.getFrameDescriptor(), argsIdentifier, FrameSlotKind.Object); @@ -79,7 +80,7 @@ public abstract class RExplicitCallNode extends Node { } } - protected RCallNode createExplicitCall() { + protected RCallBaseNode createExplicitCall() { return RCallNode.createExplicitCall(argsIdentifier, callerIdentifier); } } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/FastROptions.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/FastROptions.java index a59a13641729c4c2a3ec344663cdad384ad2ae44..0067586b3386f2b1138f76bd97388965bde5adf9 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/FastROptions.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/FastROptions.java @@ -60,7 +60,6 @@ public enum FastROptions { EmitTmpSource("Write deparsed source code to temporary files for better debugging.", true), EmitTmpDir("The directory where to allocate temporary files with deparsed source code.", null, true), EmitTmpHashed("Use an SHA-256 hash as file name to reduce temporary file creation.", true), - SpawnUsesPolyglot("use PolyglotEngine for .fastr.context.spawn", false), SynchronizeNativeCode("allow only one thread to enter packages' native code", false), ForeignObjectWrappers("use wrappers for foreign objects (as opposed to full conversion)", false), diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java index 50b30322b05d0a863dbd637815fc8f92e00214b1..acd462de0fd8b1c62834f808878ea5b3ac484395 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,10 +38,9 @@ import java.util.Map; import java.util.TimeZone; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.vm.PolyglotEngine; import com.oracle.truffle.r.launcher.RCmdOptions; -import com.oracle.truffle.r.launcher.RVersionNumber; import com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption; +import com.oracle.truffle.r.launcher.RVersionNumber; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.ffi.BaseRFFI; @@ -201,7 +200,7 @@ public final class REnvVars implements RContext.ContextState { /** * In the case where {@code R_HOME} is not set, which should only occur when FastR is invoked - * from a {@link PolyglotEngine} created by another language, we try to locate the + * from a {@link org.graalvm.polyglot.Engine} created by another language, we try to locate the * {@code R_HOME} dynamically by using the location of this class. The logic varies depending on * whether this class was stored in a {@code .jar} file or in a {@code .class} file in a * directory. diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/ChildContextInfo.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/ChildContextInfo.java index 931b59fd2ad37b18af07cefc88851216fa83cc45..bddfcce075593eeb3ef0229e96b85adbdc9efc81 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/ChildContextInfo.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/ChildContextInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,12 +27,9 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Map; import java.util.concurrent.Executor; -import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import com.oracle.truffle.api.TruffleContext; -import com.oracle.truffle.api.vm.PolyglotEngine; -import com.oracle.truffle.api.vm.PolyglotEngine.Builder; import com.oracle.truffle.r.launcher.RCmdOptions; import com.oracle.truffle.r.launcher.RCmdOptions.Client; import com.oracle.truffle.r.launcher.RStartParams; @@ -60,9 +57,6 @@ final class ConsoleHandlerOutputStream extends OutputStream { * for the initial context, whether created by the {@code R/RScript} command or whether invoked from * another language. * - * There are some legacy functions that still use {@link PolyglotEngine} but the new way is to use - * {@link TruffleContext}. - * */ public final class ChildContextInfo { static final String CONFIG_KEY = "fastrContextInfo"; @@ -85,7 +79,6 @@ public final class ChildContextInfo { private final int id; private final int multiSlotInd; private TruffleContext truffleContext; - private PolyglotEngine vm; public Executor executor; private ChildContextInfo(RStartParams startParams, Map<String, String> env, ContextKind kind, RContext parent, InputStream stdin, OutputStream stdout, OutputStream stderr, @@ -115,32 +108,15 @@ public final class ChildContextInfo { } public TruffleContext createTruffleContext() { - this.truffleContext = RContext.getInstance().getEnv().newContextBuilder().config("parentContext", parent.getVM()).config(CONFIG_KEY, this).build(); + this.truffleContext = RContext.getInstance().getEnv().newContextBuilder().config(CONFIG_KEY, this).build(); return this.truffleContext; } public TruffleContext createVM(@SuppressWarnings("unused") ChildContextInfo childContextInfo) { - this.truffleContext = RContext.getInstance().getEnv().newContextBuilder().config("parentContext", parent.getVM()).config(CONFIG_KEY, this).build(); + this.truffleContext = RContext.getInstance().getEnv().newContextBuilder().config(CONFIG_KEY, this).build(); return this.truffleContext; } - public PolyglotEngine createVM() { - Builder builder = PolyglotEngine.newBuilder(); - if (startParams.isInteractive()) { - this.executor = Executors.newSingleThreadExecutor(); - builder = builder.executor(executor); - } - PolyglotEngine newVM = builder.config("application/x-r", CONFIG_KEY, this).setIn(stdin).setOut(stdout).setErr(stderr).build(); - this.vm = newVM; - return newVM; - } - - public PolyglotEngine createVM(PolyglotEngine.Builder builder) { - PolyglotEngine newVM = builder.config("application/x-r", CONFIG_KEY, this).setIn(stdin).setOut(stdout).setErr(stderr).build(); - this.vm = newVM; - return newVM; - } - /** * Create a context configuration object. * @@ -205,11 +181,6 @@ public final class ChildContextInfo { return truffleContext; } - @Deprecated - public PolyglotEngine getVM() { - return vm; - } - public InputStream getStdin() { return stdin; } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/Engine.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/Engine.java index 1199cf81f97e4ac29abd7e8c2025df05556ac486..7da65644548245c232c56cf9a89ba12cdebfe23b 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/Engine.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/Engine.java @@ -35,7 +35,6 @@ import com.oracle.truffle.api.nodes.ExecutableNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; -import com.oracle.truffle.api.vm.PolyglotEngine; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.RCaller; import com.oracle.truffle.r.runtime.RError; @@ -173,9 +172,9 @@ public interface Engine { RExpression parse(Source source) throws ParseException; /** - * This is the external interface from {@link PolyglotEngine#eval(Source)}. It is required to - * return a {@link CallTarget} which may be cached for future use, and the - * {@link PolyglotEngine} is responsible for actually invoking the call target. + * This is the external interface from {@link org.graalvm.polyglot.Context#eval(Source)}. It is + * required to return a {@link CallTarget} which may be cached for future use, and the + * {@link org.graalvm.polyglot.Context} is responsible for actually invoking the call target. */ CallTarget parseToCallTarget(Source source, MaterializedFrame executionFrame) throws ParseException; diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/EvalThread.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/EvalThread.java index 1f7f44cfd908b41d44562972e372863bb67212b5..002526c7f6f1e4ece87216d1f3bdfb0ff1062417 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/EvalThread.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/context/EvalThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,9 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleContext; -import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.vm.PolyglotEngine; import com.oracle.truffle.r.runtime.ExitException; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RInternalError; @@ -49,7 +47,6 @@ public class EvalThread extends Thread { private final Source source; private final ChildContextInfo info; private final TruffleContext truffleContext; - private final boolean usePolyglot; private RList evalResult; private Semaphore init = new Semaphore(0); @@ -61,27 +58,21 @@ public class EvalThread extends Thread { /** We use a separate counter for threads since ConcurrentHashMap.size() is not reliable. */ public static final AtomicInteger threadCnt = new AtomicInteger(0); - public EvalThread(Map<Integer, Thread> threadMap, ChildContextInfo info, Source source, boolean usePolyglot) { + public EvalThread(Map<Integer, Thread> threadMap, ChildContextInfo info, Source source) { this.threadMap = threadMap; this.info = info; this.source = source; threadCnt.incrementAndGet(); threadMap.put(info.getId(), this); idToMultiSlotTable.put(info.getId(), info.getMultiSlotInd()); - this.usePolyglot = usePolyglot; - this.truffleContext = usePolyglot ? null : info.createTruffleContext(); + this.truffleContext = info.createTruffleContext(); } @Override public void run() { init.release(); try { - if (usePolyglot) { - PolyglotEngine vm = info.createVM(PolyglotEngine.newBuilder()); - evalResult = run(vm, info, source); - } else { - evalResult = run(truffleContext, info, source); - } + evalResult = run(truffleContext, info, source); } finally { threadMap.remove(info.getId()); threadCnt.decrementAndGet(); @@ -133,30 +124,6 @@ public class EvalThread extends Thread { return result; } - public static RList run(PolyglotEngine vm, ChildContextInfo info, Source source) { - RList evalResult; - try { - PolyglotEngine.Value resultValue = vm.eval(source); - evalResult = createEvalResult(resultValue, true); - } catch (ParseException e) { - e.report(info.getStdout()); - evalResult = createErrorResult(e.getMessage()); - } catch (ExitException e) { - // termination, treat this as "success" - evalResult = RDataFactory.createList(new Object[]{e.getStatus()}); - } catch (RError e) { - // nothing to do - evalResult = RDataFactory.createList(new Object[]{RNull.instance}); - } catch (Throwable t) { - // some internal error - RInternalError.reportErrorAndConsoleLog(t, info.getId()); - evalResult = createErrorResult(t.getClass().getSimpleName()); - } finally { - vm.dispose(); - } - return evalResult; - } - /** * The result is an {@link RList} contain the value, plus an "error" attribute if the evaluation * resulted in an error. @@ -164,13 +131,7 @@ public class EvalThread extends Thread { @TruffleBoundary private static RList createEvalResult(Object result, boolean usePolyglot) { assert result != null; - Object listResult = result; - if (usePolyglot && result instanceof TruffleObject) { - listResult = ((PolyglotEngine.Value) result).as(Object.class); - } else { - listResult = result; - } - return RDataFactory.createList(new Object[]{listResult}); + return RDataFactory.createList(new Object[]{result}); } @TruffleBoundary 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 45ef9e3c0c79c927c42adc36b9981a6089c9617a..397beb38bea948cc542e58b231edfdb112fea8d7 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 @@ -68,7 +68,6 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.vm.PolyglotEngine; import com.oracle.truffle.r.launcher.RCmdOptions; import com.oracle.truffle.r.launcher.RCmdOptions.Client; import com.oracle.truffle.r.launcher.RStartParams; @@ -113,9 +112,9 @@ import com.oracle.truffle.r.runtime.rng.RRNG; * implementation <b>must</b> go through this class. There can be multiple instances * (multiple-tenancy) active within a single process/Java-VM. * - * Contexts are created during construction of the {@link PolyglotEngine} instance. In case a - * context needs to be configured, the PolyglotEngine needs to be created via the - * {@code RContextFactory} class, which takes a {@link ChildContextInfo} object for configuration. + * FastR contexts are created during construction of the {@link org.graalvm.polyglot.Context} + * instance. In case a FastR context needs to be configured, a {@link ChildContextInfo} instance + * should be passed in {@link Env} configuration under {@link ChildContextInfo#CONFIG_KEY} key. * * The context provides a so-called {@link Engine} (accessed via {@link #getEngine()}), which * provides basic parsing and execution functionality . @@ -251,7 +250,6 @@ public final class RContext { private final int id; private final int multiSlotIndex; private TruffleContext truffleContext; - private PolyglotEngine vm; public Executor executor; @@ -763,7 +761,7 @@ public final class RContext { /** * Allows another thread to schedule some code to be run in this context's thread. The action - * can be scheduled only if PolyglotEngine was created with an Executor. + * can be scheduled only if this context was created with an Executor. */ public void schedule(Runnable action) { assert hasExecutor() : "Cannot run RContext#schedule() when there is no executor."; @@ -797,10 +795,6 @@ public final class RContext { return truffleContext; } - public PolyglotEngine getVM() { - return vm; - } - public boolean isInitial() { return initial; } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index d27fa83b3560be5b58f74f526c82eb76d86beeb2..d606d1ca45d80460b2e8e0e214d2926d37694371 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -9246,7 +9246,7 @@ $bg #argv <- list(c(NA, NaN), 'logical'); .Internal(as.vector(argv[[1]], argv[[2]])) [1] NA NA -##com.oracle.truffle.r.test.builtins.TestBuiltin_asvector.testasvector41#Ignored.ImplementationError# +##com.oracle.truffle.r.test.builtins.TestBuiltin_asvector.testasvector41# #argv <- list(structure(list(`character(0)` = structure(integer(0), .Label = character(0), class = 'factor')), .Names = 'character(0)', row.names = character(0), class = 'data.frame'), 'pairlist'); .Internal(as.vector(argv[[1]], argv[[2]])) [1] character(0) <0 rows> (or 0-length row.names) @@ -9795,7 +9795,7 @@ Error in detach("string") : invalid 'name' argument #x <- c(1, 3); attr(x, 'abc') <- 42; attr(x, 'ab', exact=TRUE) NULL -##com.oracle.truffle.r.test.builtins.TestBuiltin_attr.testExactMatch#Ignored.Unimplemented# +##com.oracle.truffle.r.test.builtins.TestBuiltin_attr.testExactMatch# #x <- c(1,2); attr(x, 'row.namess') <- 42; attr(x, 'row.names') [1] 42 @@ -11386,6 +11386,10 @@ integer(0) #{ bitwNot(TRUE) } Error in bitwNot(TRUE) : unimplemented type 'logical' in 'bitwNot' +##com.oracle.truffle.r.test.builtins.TestBuiltin_bitwiseNot.testBitwiseFunctions# +#{ bitwNot(as.integer(NA)) } +[1] NA + ##com.oracle.truffle.r.test.builtins.TestBuiltin_bitwiseNot.testBitwiseFunctions# #{ bitwNot(c(0,100,200,50,70,20)) } [1] -1 -101 -201 -51 -71 -21 @@ -36827,7 +36831,7 @@ In print.default("Work dir: ", getwd()) : NAs introduced by coercion #argv <- list('mgcv', NULL, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE); .Internal(list.files(argv[[1]], argv[[2]], argv[[3]], argv[[4]], argv[[5]], argv[[6]], argv[[7]], argv[[8]])) character(0) -##com.oracle.truffle.r.test.builtins.TestBuiltin_lm.test#Ignored.ImplementationError# +##com.oracle.truffle.r.test.builtins.TestBuiltin_lm.test# #require(stats); lm(data = structure(list(y = c(43, 63, 71, 61, 81, 43, 58, 71, 72, 67, 64, 67, 69, 68, 77, 81, 74, 65, 65, 50, 50, 64, 53, 40, 63, 66, 82), x1 = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), x2 = c(51, 64, 70, 63, 78, 55, 67, 75, 82, 61, 53, 60, 62, 83, 77, 90, 85, 60, 70, 58, 40, 61, 66, 37, 54, 77, 82), x3 = c(30, 51, 68, 45, 56, 49, 42, 50, 72, 45, 53, 47, 57, 83, 54, 50, 64, 65, 46, 68, 33, 52, 52, 42, 42, 66, 39), x4 = c(47, 45, 48, 39, 57, 69, 66, 50, 59, 45, 72, 50, 59, 44, 75, 39, 45, 62, 47, 74, 75, 67, 47, 58, 54, 66, 62), x5 = c(61, 63, 76, 54, 71, 54, 66, 70, 71, 62, 58, 59, 55, 59, 79, 60, 79, 55, 75, 64, 43, 66, 63, 50, 66, 88, 64), x6 = c(92, 73, 86, 84, 83, 49, 68, 66, 83, 80, 67, 74, 63, 77, 77, 54, 79, 80, 85, 78, 64, 80, 80, 57, 75, 76, 78), x7 = c(45, 47, 48, 35, 47, 34, 35, 41, 31, 41, 34, 41, 25, 35, 46, 36, 63, 60, 46, 52, 33, 41, 37, 49, 33, 72, 39)), .Names = c('y', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7'), row.names = c('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '30'), class = 'data.frame'), formula = y ~ . + 0) Call: @@ -40700,7 +40704,7 @@ In mean.default(x = c(2L, 1L, 2L, 2L)) : #argv <- structure(list(x = structure(1412795929.08562, class = c('POSIXct', 'POSIXt'))), .Names = 'x');do.call('mean.POSIXct', argv) [1] "2014-10-08 19:18:49 GMT" -##com.oracle.truffle.r.test.builtins.TestBuiltin_meandefault.testmeandefault1#Output.IgnoreWarningContext# +##com.oracle.truffle.r.test.builtins.TestBuiltin_meandefault.testmeandefault1# #argv <- structure(list(x = structure(c(2L, 1L, 2L, 2L), .Label = c('FALSE', 'TRUE'), class = 'factor')), .Names = 'x');do.call('mean.default', argv) [1] NA Warning message: @@ -83989,7 +83993,7 @@ Error in unknownSymbol() : could not find function "unknownSymbol" foo <msg>[1] 123 -##com.oracle.truffle.r.test.library.base.TestConditionHandling.testWithCallingHandlers#Ignored.ImplementationError# +##com.oracle.truffle.r.test.library.base.TestConditionHandling.testWithCallingHandlers# #withCallingHandlers({warning("foo");123L},<<<NEWLINE>>> warning=function(e) {<<<NEWLINE>>> cat("<warn>")<<<NEWLINE>>> invokeRestart("muffleWarning")<<<NEWLINE>>> }) <warn>[1] 123 @@ -168627,7 +168631,7 @@ debug at #1: print(x) [1] 5 exiting from: f(5) -##com.oracle.truffle.r.test.library.utils.TestInteractiveDebug.testPromise#Ignored.Unknown# +##com.oracle.truffle.r.test.library.utils.TestInteractiveDebug.testPromise# #fun <- function(x) { cat({ cat(x); cat('<<<NEWLINE>>>') }) }; debug(fun); fun(3)<<<NEWLINE>>><<<NEWLINE>>><<<NEWLINE>>><<<NEWLINE>>><<<NEWLINE>>> debugging in: fun(3) debug at #1: { diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asvector.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asvector.java index a0bf8bc071fa90a0cf2916667f19e845fbddd894..3e46568e4f5c12099da298eb3c7af44c23ce9764 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asvector.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asvector.java @@ -240,8 +240,7 @@ public class TestBuiltin_asvector extends TestRBase { // FastR output: $`character(0)` // factor(0) // Levels: - assertEval(Ignored.ImplementationError, - "argv <- list(structure(list(`character(0)` = structure(integer(0), .Label = character(0), class = 'factor')), .Names = 'character(0)', row.names = character(0), class = 'data.frame'), 'pairlist'); .Internal(as.vector(argv[[1]], argv[[2]]))"); + assertEval("argv <- list(structure(list(`character(0)` = structure(integer(0), .Label = character(0), class = 'factor')), .Names = 'character(0)', row.names = character(0), class = 'data.frame'), 'pairlist'); .Internal(as.vector(argv[[1]], argv[[2]]))"); } @Test diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_attr.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_attr.java index b16c50dcc32ddff671d54807bb71c360f757d943..f0ebe45c8c40520b9b72bde05131e71acd1fe1e1 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_attr.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_attr.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2014, Purdue University - * Copyright (c) 2014, 2017, Oracle and/or its affiliates + * Copyright (c) 2014, 2018, Oracle and/or its affiliates * * All rights reserved. */ @@ -241,7 +241,7 @@ public class TestBuiltin_attr extends TestBase { @Test public void testExactMatch() { assertEval("x <- c(1, 3); attr(x, 'abc') <- 42; attr(x, 'ab', exact=TRUE)"); - assertEval(Ignored.Unimplemented, "x <- c(1,2); attr(x, 'row.namess') <- 42; attr(x, 'row.names')"); + assertEval("x <- c(1,2); attr(x, 'row.namess') <- 42; attr(x, 'row.names')"); } @Test diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_bitwiseNot.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_bitwiseNot.java index 1f872e33ec385efa606a90a211a881faa092f1f1..af385c944f83e0cff881d368f20de03db6ac614c 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_bitwiseNot.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_bitwiseNot.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2012-2014, Purdue University - * Copyright (c) 2013, 2017, Oracle and/or its affiliates + * Copyright (c) 2013, 2018, Oracle and/or its affiliates * * All rights reserved. */ @@ -26,6 +26,7 @@ public class TestBuiltin_bitwiseNot extends TestBase { public void testBitwiseFunctions() { assertEval("{ bitwNot(c(17,24,34,48,51,66,72,99)) }"); assertEval("{ bitwNot(c(0,100,200,50,70,20)) }"); + assertEval("{ bitwNot(as.integer(NA)) }"); assertEval("{ bitwNot(TRUE) }"); } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_lm.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_lm.java index 0ddf4f8e72562768d886e26eac389a61f6acccbe..131c0644a2cd7e8b66fe21f4c19193d03fd64009 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_lm.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_lm.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2014, Purdue University - * Copyright (c) 2014, 2017, Oracle and/or its affiliates + * Copyright (c) 2014, 2018, Oracle and/or its affiliates * * All rights reserved. */ @@ -72,7 +72,6 @@ public class TestBuiltin_lm extends TestBase { @Test public void test() { // FIXME test causes StackOverflow - assertEval(Ignored.ImplementationError, - "require(stats); lm(data = structure(list(y = c(43, 63, 71, 61, 81, 43, 58, 71, 72, 67, 64, 67, 69, 68, 77, 81, 74, 65, 65, 50, 50, 64, 53, 40, 63, 66, 82), x1 = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), x2 = c(51, 64, 70, 63, 78, 55, 67, 75, 82, 61, 53, 60, 62, 83, 77, 90, 85, 60, 70, 58, 40, 61, 66, 37, 54, 77, 82), x3 = c(30, 51, 68, 45, 56, 49, 42, 50, 72, 45, 53, 47, 57, 83, 54, 50, 64, 65, 46, 68, 33, 52, 52, 42, 42, 66, 39), x4 = c(47, 45, 48, 39, 57, 69, 66, 50, 59, 45, 72, 50, 59, 44, 75, 39, 45, 62, 47, 74, 75, 67, 47, 58, 54, 66, 62), x5 = c(61, 63, 76, 54, 71, 54, 66, 70, 71, 62, 58, 59, 55, 59, 79, 60, 79, 55, 75, 64, 43, 66, 63, 50, 66, 88, 64), x6 = c(92, 73, 86, 84, 83, 49, 68, 66, 83, 80, 67, 74, 63, 77, 77, 54, 79, 80, 85, 78, 64, 80, 80, 57, 75, 76, 78), x7 = c(45, 47, 48, 35, 47, 34, 35, 41, 31, 41, 34, 41, 25, 35, 46, 36, 63, 60, 46, 52, 33, 41, 37, 49, 33, 72, 39)), .Names = c('y', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7'), row.names = c('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '30'), class = 'data.frame'), formula = y ~ . + 0)"); + assertEval("require(stats); lm(data = structure(list(y = c(43, 63, 71, 61, 81, 43, 58, 71, 72, 67, 64, 67, 69, 68, 77, 81, 74, 65, 65, 50, 50, 64, 53, 40, 63, 66, 82), x1 = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), x2 = c(51, 64, 70, 63, 78, 55, 67, 75, 82, 61, 53, 60, 62, 83, 77, 90, 85, 60, 70, 58, 40, 61, 66, 37, 54, 77, 82), x3 = c(30, 51, 68, 45, 56, 49, 42, 50, 72, 45, 53, 47, 57, 83, 54, 50, 64, 65, 46, 68, 33, 52, 52, 42, 42, 66, 39), x4 = c(47, 45, 48, 39, 57, 69, 66, 50, 59, 45, 72, 50, 59, 44, 75, 39, 45, 62, 47, 74, 75, 67, 47, 58, 54, 66, 62), x5 = c(61, 63, 76, 54, 71, 54, 66, 70, 71, 62, 58, 59, 55, 59, 79, 60, 79, 55, 75, 64, 43, 66, 63, 50, 66, 88, 64), x6 = c(92, 73, 86, 84, 83, 49, 68, 66, 83, 80, 67, 74, 63, 77, 77, 54, 79, 80, 85, 78, 64, 80, 80, 57, 75, 76, 78), x7 = c(45, 47, 48, 35, 47, 34, 35, 41, 31, 41, 34, 41, 25, 35, 46, 36, 63, 60, 46, 52, 33, 41, 37, 49, 33, 72, 39)), .Names = c('y', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7'), row.names = c('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '30'), class = 'data.frame'), formula = y ~ . + 0)"); } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_meandefault.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_meandefault.java index dddae6feba6b33f225111fbc7b8958ec3a5f8d0c..ccb984ffad1186c8e5a429cc47abec8e72ee660a 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_meandefault.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_meandefault.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2014, Purdue University - * Copyright (c) 2014, 2016, Oracle and/or its affiliates + * Copyright (c) 2014, 2018, Oracle and/or its affiliates * * All rights reserved. */ @@ -20,7 +20,6 @@ public class TestBuiltin_meandefault extends TestBase { @Test public void testmeandefault1() { - assertEval(Output.IgnoreWarningContext, - "argv <- structure(list(x = structure(c(2L, 1L, 2L, 2L), .Label = c('FALSE', 'TRUE'), class = 'factor')), .Names = 'x');do.call('mean.default', argv)"); + assertEval("argv <- structure(list(x = structure(c(2L, 1L, 2L, 2L), .Label = c('FALSE', 'TRUE'), class = 'factor')), .Names = 'x');do.call('mean.default', argv)"); } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestConditionHandling.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestConditionHandling.java index 838512b20071769390eb163b9bd283278f9bd8c4..6969902fd60ecbbefa4980dff709f5572586b8e1 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestConditionHandling.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestConditionHandling.java @@ -74,7 +74,7 @@ public class TestConditionHandling extends TestRBase { @Test public void testWithCallingHandlers() { assertEval(Output.IgnoreWarningContext, "withCallingHandlers({warning(\"foo\");123L},\n warning=function(e) {cat(\"<warn>\")})"); - assertEval(Ignored.ImplementationError, "withCallingHandlers({warning(\"foo\");123L},\n warning=function(e) {\n cat(\"<warn>\")\n invokeRestart(\"muffleWarning\")\n })"); + assertEval("withCallingHandlers({warning(\"foo\");123L},\n warning=function(e) {\n cat(\"<warn>\")\n invokeRestart(\"muffleWarning\")\n })"); assertEval("withCallingHandlers({message(\"foo\");123L},\n message=function(e) {cat(\"<msg>\")})"); assertEval("withCallingHandlers({message(\"foo\");123L},\n message=function(e) {\n cat(\"<msg>\")\n invokeRestart(\"muffleMessage\")\n })"); assertEval("withCallingHandlers({message(\"foo\");packageStartupMessage(\"bar\");123L},\n packageStartupMessage=function(e) {\n cat(\"<msg>\")\n invokeRestart(\"muffleMessage\")\n })"); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/utils/TestInteractiveDebug.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/utils/TestInteractiveDebug.java index eb0a220065117c63446933e1294cc1288df0d59a..6b0b32d0ecba7905a3fa51d98a6595e683521fa6 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/utils/TestInteractiveDebug.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/utils/TestInteractiveDebug.java @@ -79,8 +79,7 @@ public class TestInteractiveDebug extends TestBase { @Test public void testPromise() { - // TODO test fails for unknown reason; the snippet runs correctly if used in REPL - assertEval(Ignored.Unknown, "fun <- function(x) { cat({ cat(x); cat('\n') }) }; debug(fun); fun(3)\n\n\n\n\n"); + assertEval("fun <- function(x) { cat({ cat(x); cat('\n') }) }; debug(fun); fun(3)\n\n\n\n\n"); } @Test diff --git a/documentation/tutorials/debugging/InteropDebugging/R/main.r b/documentation/tutorials/debugging/InteropDebugging/R/main.r index 383ea6ece226525c9655b32628a0ae1df3e6de50..364d8ae762e9b7a01257f32a7cdd844d914daadb 100644 --- a/documentation/tutorials/debugging/InteropDebugging/R/main.r +++ b/documentation/tutorials/debugging/InteropDebugging/R/main.r @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,6 @@ clazz <- new.java.class("com.oracle.truffle.r.JavaMessage") obj <- new.external(clazz, "Hi there") print(obj$getMessage()) -JS_MIME_TYPE <- "application/javascript" -eval.external(JS_MIME_TYPE, source='var s = "Hello from Javascript"; print(s)') -eval.external(JS_MIME_TYPE, path="JS/main.js") +eval.external('js', source='var s = "Hello from Javascript"; print(s)') +eval.external('js', path="JS/main.js") diff --git a/documentation/tutorials/debugging/InteropDebugging/src/com/oracle/truffle/r/Main.java b/documentation/tutorials/debugging/InteropDebugging/src/com/oracle/truffle/r/Main.java index 300a6e6390f598af2856a26f78a8fb2bfab53278..b8d073b0013f2e5c8e4c458f463ebefc1ef78a1f 100644 --- a/documentation/tutorials/debugging/InteropDebugging/src/com/oracle/truffle/r/Main.java +++ b/documentation/tutorials/debugging/InteropDebugging/src/com/oracle/truffle/r/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ */ package com.oracle.truffle.r; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.vm.PolyglotEngine; +import org.graalvm.polyglot.Context; +import org.graalvm.polyglot.Source; import java.io.File; import java.io.IOException; @@ -41,17 +41,14 @@ public class Main { * @throws java.io.IOException */ public static void main(String[] args) throws IOException { - PolyglotEngine newVM = PolyglotEngine.newBuilder().config(R_MIME_TYPE, "debugContext", null).build(); - newVM.eval(fromString("print('Hello, World! (from string)')")); - newVM.eval(fromFile("R/main.r")); - } - - private static Source fromString(String code) { - return Source.newBuilder(code).name("<shell_input>").mimeType(R_MIME_TYPE).interactive().build(); + Context context = Context.create(); + context.eval("R", "print('Hello, World! (from string)')"); + context.eval(fromFile("R/main.r")); } + private static Source fromFile(String path) throws IOException { - return Source.newBuilder(new File(path)).mimeType(R_MIME_TYPE).build(); + return Source.newBuilder("R", new File(path)).build(); } } diff --git a/documentation/tutorials/debugging/tutorial.md b/documentation/tutorials/debugging/tutorial.md index 136bc7f1c50e793ffa4d43835429de6ce32b219b..bc6869a13c6083a150bfaef3a3c2735544e16fd3 100644 --- a/documentation/tutorials/debugging/tutorial.md +++ b/documentation/tutorials/debugging/tutorial.md @@ -150,8 +150,8 @@ It is also possible to cross language boundaries during stepping when using the ### Inter-language Debugging -File `Main.java` creates a `PolyglotEngine` object that can execute R code. This is basically the FastR engine. -The engine object can now run R code by creating a source object (representing R code) and submitting the source to the engine. +File `Main.java` creates a `Context` object that can execute R code. This is basically the FastR engine. +The engine object can now run R code by creating a source object (representing R code) and submitting the source to the context object. The expression `fromString("print('Hello, World! (from string)')")` creates a source code from a string. Expression `fromFile("R/main.r")` creates source code from file *R/main.r*. diff --git a/mx.fastr/native-image.properties b/mx.fastr/native-image.properties index a70e3e70200bde35bb5e1ac05f92ce3cbaca2019..2350ea4bf0cdbd6b4bd3f997e2a314b6d1819770 100644 --- a/mx.fastr/native-image.properties +++ b/mx.fastr/native-image.properties @@ -12,5 +12,5 @@ JavaArgs = \ Args = -H:Class=com.oracle.truffle.r.launcher.RCommand \ -H:MaxRuntimeCompileMethods=8000 \ - -H:TruffleCheckFrameImplementation=false \ - -H:TruffleCheckNeverPartOfCompilation=true + -H:-TruffleCheckFrameImplementation \ + -H:+TruffleCheckNeverPartOfCompilation