diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RInteropExecuteNode.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RInteropExecuteNode.java index c0ba64a4b7892861ef69a5b26f97c09dd64308bd..9d0e64de79fbe8863c0ac03ef4fc22036c522035 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RInteropExecuteNode.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RInteropExecuteNode.java @@ -36,7 +36,6 @@ import com.oracle.truffle.api.interop.ForeignAccess; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.r.engine.TruffleRLanguage; -import com.oracle.truffle.r.nodes.function.CallMatcherNode; import com.oracle.truffle.r.nodes.function.RCallNode; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.RArguments; @@ -51,7 +50,6 @@ class RInteropExecuteNode extends RootNode { private final FrameSlot slot = emptyFrameDescriptor.addFrameSlot(argsIdentifier, FrameSlotKind.Object); @Child private RCallNode call = RCallNode.createExplicitCall(argsIdentifier); - @Child private CallMatcherNode callMatcher = CallMatcherNode.create(false, true); @Child private Node findContext = TruffleRLanguage.INSTANCE.actuallyCreateFindContextNode(); private final ArgumentsSignature suppliedSignature; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Lapply.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Lapply.java index 830ee2595ed20a68d9fdf3e9c74b04211d48acc8..21381401026866c1b35231224bf56b32d3c65113 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Lapply.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Lapply.java @@ -14,13 +14,17 @@ package com.oracle.truffle.r.nodes.builtin.base; import static com.oracle.truffle.r.runtime.RBuiltinKind.INTERNAL; import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.Frame; +import com.oracle.truffle.api.frame.FrameSlot; +import com.oracle.truffle.api.frame.FrameSlotTypeException; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; -import com.oracle.truffle.r.nodes.access.WriteVariableNode; -import com.oracle.truffle.r.nodes.access.WriteVariableNode.Mode; import com.oracle.truffle.r.nodes.access.variables.ReadVariableNode; import com.oracle.truffle.r.nodes.access.vector.ElementAccessMode; import com.oracle.truffle.r.nodes.access.vector.ExtractVectorNode; @@ -28,19 +32,25 @@ import com.oracle.truffle.r.nodes.access.vector.ExtractVectorNodeGen; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.builtin.base.LapplyNodeGen.LapplyInternalNodeGen; import com.oracle.truffle.r.nodes.control.RLengthNode; -import com.oracle.truffle.r.nodes.control.RLengthNodeGen; import com.oracle.truffle.r.nodes.function.RCallNode; -import com.oracle.truffle.r.runtime.AnonymousFrameVariable; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.RBuiltin; +import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.RRuntime; +import com.oracle.truffle.r.runtime.RSerialize.State; import com.oracle.truffle.r.runtime.RType; import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RFunction; import com.oracle.truffle.r.runtime.data.model.RAbstractVector; +import com.oracle.truffle.r.runtime.env.REnvironment; import com.oracle.truffle.r.runtime.nodes.InternalRSyntaxNodeChildren; import com.oracle.truffle.r.runtime.nodes.RBaseNode; +import com.oracle.truffle.r.runtime.nodes.RSourceSectionNode; +import com.oracle.truffle.r.runtime.nodes.RSyntaxCall; +import com.oracle.truffle.r.runtime.nodes.RSyntaxElement; +import com.oracle.truffle.r.runtime.nodes.RSyntaxLookup; +import com.oracle.truffle.r.runtime.nodes.RSyntaxNode; /** * The {@code lapply} builtin. {@code lapply} is an important implicit iterator in R. This @@ -66,24 +76,80 @@ public abstract class Lapply extends RBuiltinNode { return RDataFactory.createList(result, vec.getNames(attrProfiles)); } - public abstract static class LapplyInternalNode extends RBaseNode implements InternalRSyntaxNodeChildren { + private static final class ExtractElementInternal extends RSourceSectionNode implements RSyntaxCall { - private static final String VECTOR_ELEMENT = AnonymousFrameVariable.create("LAPPLY_VEC_ELEM"); + protected ExtractElementInternal() { + super(RSyntaxNode.LAZY_DEPARSE); + } - @Child private RLengthNode lengthNode = RLengthNodeGen.create(); - @Child private WriteVariableNode writeVectorElement = WriteVariableNode.createAnonymous(VECTOR_ELEMENT, null, Mode.REGULAR); @Child private ExtractVectorNode extractElementNode = ExtractVectorNodeGen.create(ElementAccessMode.SUBSCRIPT, false); - @Child private RCallNode callNode = createCallNode(); + @CompilationFinal private FrameSlot vectorSlot; + @CompilationFinal private FrameSlot indexSlot; + + @Override + public Object execute(VirtualFrame frame) { + if (vectorSlot == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + vectorSlot = frame.getFrameDescriptor().findFrameSlot("X"); + indexSlot = frame.getFrameDescriptor().findFrameSlot("i"); + } + try { + return extractElementNode.apply(frame, frame.getObject(vectorSlot), new Object[]{frame.getInt(indexSlot)}, RRuntime.LOGICAL_TRUE, RRuntime.LOGICAL_TRUE); + } catch (FrameSlotTypeException e) { + CompilerDirectives.transferToInterpreter(); + throw RInternalError.shouldNotReachHere("frame type mismatch in lapply"); + } + } + + @Override + public RSyntaxElement getSyntaxLHS() { + return RSyntaxLookup.createDummyLookup(LAZY_DEPARSE, "[[", true); + } + + @Override + public ArgumentsSignature getSyntaxSignature() { + return ArgumentsSignature.empty(2); + } + + @Override + public RSyntaxElement[] getSyntaxArguments() { + return new RSyntaxElement[]{RSyntaxLookup.createDummyLookup(LAZY_DEPARSE, "X", false), RSyntaxLookup.createDummyLookup(LAZY_DEPARSE, "i", false)}; + } + + @Override + public RSyntaxNode substituteImpl(REnvironment env) { + throw RInternalError.shouldNotReachHere(); + } + + @Override + public void serializeImpl(State state) { + throw RInternalError.shouldNotReachHere(); + } + } + + public abstract static class LapplyInternalNode extends RBaseNode implements InternalRSyntaxNodeChildren { + + protected static final String INDEX_NAME = "i"; + protected static final String VECTOR_NAME = "X"; public abstract Object[] execute(VirtualFrame frame, Object vector, RFunction function); + protected static FrameSlot createSlot(Frame frame, String name) { + return frame.getFrameDescriptor().findOrAddFrameSlot(name); + } + @Specialization - protected Object[] cachedLApply(VirtualFrame frame, Object vector, RFunction function) { + protected Object[] cachedLApply(VirtualFrame frame, Object vector, RFunction function, // + @Cached("createSlot(frame, INDEX_NAME)") FrameSlot indexSlot, // + @Cached("createSlot(frame, VECTOR_NAME)") FrameSlot vectorSlot, // + @Cached("create()") RLengthNode lengthNode, // + @Cached("createCallNode()") RCallNode callNode) { // TODO: R switches to double if x.getLength() is greater than 2^31-1 + frame.setObject(vectorSlot, vector); int length = lengthNode.executeInteger(frame, vector); Object[] result = new Object[length]; for (int i = 1; i <= length; i++) { - writeVectorElement.execute(frame, extractElementNode.apply(frame, vector, new Object[]{i}, RRuntime.LOGICAL_TRUE, RRuntime.LOGICAL_TRUE)); + frame.setInt(indexSlot, i); result[i - 1] = callNode.execute(frame, function); } return result; @@ -95,10 +161,10 @@ public abstract class Lapply extends RBuiltinNode { protected RCallNode createCallNode() { CompilerAsserts.neverPartOfCompilation(); - ReadVariableNode readVector = ReadVariableNode.createSilent(VECTOR_ELEMENT, RType.Any); + ExtractElementInternal element = new ExtractElementInternal(); ReadVariableNode readArgs = ReadVariableNode.createSilent(ArgumentsSignature.VARARG_NAME, RType.Any); - return RCallNode.createCall(createCallSourceSection(), null, ArgumentsSignature.get(null, "..."), readVector, readArgs); + return RCallNode.createCall(createCallSourceSection(), ReadVariableNode.create("FUN"), ArgumentsSignature.get(null, "..."), element, readArgs); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTBuilder.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTBuilder.java index da6c3c3242a5235a27cb6416132d5626e25bf949..a6180e8412cc12e88dec053e53a938e48e3f39e4 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTBuilder.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTBuilder.java @@ -56,12 +56,7 @@ import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.data.FastPathFactory; -import com.oracle.truffle.r.runtime.data.RComplex; import com.oracle.truffle.r.runtime.data.REmpty; -import com.oracle.truffle.r.runtime.data.RFunction; -import com.oracle.truffle.r.runtime.data.RNull; -import com.oracle.truffle.r.runtime.data.RSymbol; -import com.oracle.truffle.r.runtime.data.model.RAbstractVector; import com.oracle.truffle.r.runtime.env.frame.FrameSlotChangeMonitor; import com.oracle.truffle.r.runtime.nodes.RCodeBuilder; import com.oracle.truffle.r.runtime.nodes.RNode; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessArgumentNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessArgumentNode.java index 1a429c573ebff80811f76d01390c7ddaec2dd03e..6abe44bf87025ba374fdee50f41b3416ea4e6f31 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessArgumentNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessArgumentNode.java @@ -162,10 +162,11 @@ public final class AccessArgumentNode extends RNode { private boolean checkInsertOptDefaultArg() { if (optDefaultArgNode == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + RNode defaultArg = formals.getDefaultArgument(index); RNode arg = (RNode) RASTUtils.unwrap(defaultArg); - CompilerDirectives.transferToInterpreterAndInvalidate(); // TODO: all tests pass without it but perhaps we should "re-wrap" promises here? if (isOptimizableDefault(arg)) { optDefaultArgNode = new OptVariableDefaultPromiseNode(factory, (ReadVariableNode) RASTUtils.cloneNode(arg), ArgumentStatePush.INVALID_INDEX); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/ReadVariableNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/ReadVariableNode.java index f6a101e149dab4e47ce4ee036603b8643db9eb9f..1bf4c9fcea7536b40a4f6823587a97eaded66f77 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/ReadVariableNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/variables/ReadVariableNode.java @@ -191,6 +191,7 @@ public final class ReadVariableNode extends RSourceSectionNode implements RSynta } public Object execute(VirtualFrame frame, Frame variableFrame) { + assert frame != null; return executeInternal(frame, kind == ReadKind.Super ? superEnclosingFrameProfile.profile(RArguments.getEnclosingFrame(variableFrame)) : variableFrame); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/ClassHierarchyNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/ClassHierarchyNode.java index 69037c6399a16f843fe699d9e9199287543b6f78..516a88ad1537d6d600a75df1ddb2a1e98337caf6 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/ClassHierarchyNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/ClassHierarchyNode.java @@ -170,7 +170,6 @@ abstract class S4Class extends RBaseNode { public abstract RStringVector executeRStringVector(String classAttr); - @Child private ReadVariableNode sExtendsForS3Find = ReadVariableNode.createFunctionLookup(RSyntaxNode.INTERNAL, ".extendsForS3"); @Child private CastToVectorNode castToVector = CastToVectorNode.create(); @TruffleBoundary @@ -180,8 +179,8 @@ abstract class S4Class extends RBaseNode { RStringVector s4Extends = RContext.getInstance().getS4Extends(classAttr); if (s4Extends == null) { REnvironment methodsEnv = REnvironment.getRegisteredNamespace("methods"); - RFunction sExtendsForS3Function = (RFunction) sExtendsForS3Find.execute(null, methodsEnv.getFrame()); - // the assumption here is that R function can only return either a String or + RFunction sExtendsForS3Function = ReadVariableNode.lookupFunction(".extendsForS3", methodsEnv.getFrame(), false); + // the assumption here is that the R function can only return either a String or // RStringVector s4Extends = (RStringVector) castToVector.execute(RContext.getEngine().evalFunction(sExtendsForS3Function, methodsEnv.getFrame(), classAttr)); RContext.getInstance().putS4Extends(classAttr, s4Extends); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java index 06593f0cd3b723173cda71c2377d482b23d90489..17fbe3f13c5742daf0efece284c86588ddcb4070 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java @@ -794,15 +794,19 @@ public abstract class RCallNode extends RNode implements RSyntaxNode, RSyntaxCal } } - protected PrepareArguments createArguments(RFunction function) { + protected PrepareArguments createArguments(RFunction function, boolean noOpt) { if (explicitArgs) { return PrepareArguments.createExplicit(function); } else { CallArgumentsNode args = originalCall.createArguments(dispatchTempIdentifiers, !function.isBuiltin(), true); - return PrepareArguments.create(function, args); + return PrepareArguments.create(function, args, noOpt); } } + protected PrepareArguments createArguments(RFunction function) { + return createArguments(function, false); + } + @Specialization(limit = "CACHE_SIZE", guards = "function == cachedFunction") protected Object dispatch(VirtualFrame frame, @SuppressWarnings("unused") RFunction function, Object varArgs, Object s3Args, // @Cached("function") RFunction cachedFunction, // @@ -825,8 +829,9 @@ public abstract class RCallNode extends RNode implements RSyntaxNode, RSyntaxCal @TruffleBoundary public Object execute(MaterializedFrame materializedFrame, RFunction function, Object varArgs, Object s3Args) { if (cachedFunction != function) { + cachedFunction = function; leafCall = insert(createCacheNode(function)); - prepareArguments = insert(createArguments(function)); + prepareArguments = insert(createArguments(function, true)); } VirtualFrame frame = SubstituteVirtualFrame.create(materializedFrame); Object[] orderedArguments = prepareArguments.execute(frame, (RArgsValuesAndNames) varArgs, originalCall); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RMissingHelper.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RMissingHelper.java index 8eabdccc3ccbffe3010be2b0e08209fac31793c5..12483dc1a616ec10ca9a3bd043de8026d72b7c9f 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RMissingHelper.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RMissingHelper.java @@ -151,9 +151,19 @@ public class RMissingHelper { } try { - // TODO Profile necessary here??? + if (promise.isEvaluated()) { + return false; + } if (promise instanceof EagerPromise) { - ((EagerPromise) promise).materialize(); + EagerPromise eagerPromise = (EagerPromise) promise; + if (!eagerPromise.isDeoptimized()) { + Object eagerValue = eagerPromise.getEagerValue(); + if (eagerValue instanceof RPromise) { + return isMissingName((RPromise) eagerValue); + } else { + return isMissing(eagerValue); + } + } } // promise.materialize(globalMissingPromiseProfile); promise.setUnderEvaluation(true); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/S3FunctionLookupNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/S3FunctionLookupNode.java index 342c1c1a3d049fbe6c8321862e5b57364d4d36d8..256121fac1b8cbef61921677994e72deaa0d943b 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/S3FunctionLookupNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/S3FunctionLookupNode.java @@ -170,7 +170,8 @@ public abstract class S3FunctionLookupNode extends RBaseNode { public abstract S3FunctionLookupNode.Result execute(VirtualFrame frame, String genericName, RStringVector type, String group, MaterializedFrame callerFrame, MaterializedFrame genericDefFrame); - private static UseMethodFunctionLookupCachedNode specialize(String genericName, RStringVector type, String group, MaterializedFrame callerFrame, MaterializedFrame genericDefFrame, + private static UseMethodFunctionLookupCachedNode specialize(VirtualFrame frame, String genericName, RStringVector type, String group, MaterializedFrame callerFrame, + MaterializedFrame genericDefFrame, S3FunctionLookupNode next) { ArrayList<ReadVariableNode> unsuccessfulReadsCaller = new ArrayList<>(); ArrayList<LocalReadVariableNode> unsuccessfulReadsTable = new ArrayList<>(); @@ -185,7 +186,7 @@ public abstract class S3FunctionLookupNode extends RBaseNode { Object result; if (inMethodsTable) { LocalReadVariableNode read = LocalReadVariableNode.create(name, true); - result = read.execute(null, lookupFrame); + result = read.execute(frame, lookupFrame); if (result == null) { unsuccessfulReadsTable.add(read); } else { @@ -193,7 +194,7 @@ public abstract class S3FunctionLookupNode extends RBaseNode { } } else { ReadVariableNode read = ReadVariableNode.createSilent(name, RType.Function); - result = read.execute(null, lookupFrame); + result = read.execute(frame, lookupFrame); if (result == null) { unsuccessfulReadsCaller.add(read); } else { @@ -206,7 +207,7 @@ public abstract class S3FunctionLookupNode extends RBaseNode { GetMethodsTable getTable = () -> { if (genericDefFrame != null) { reads.methodsTableRead = LocalReadVariableNode.create(RRuntime.RS3MethodsTable, true); - return reads.methodsTableRead.execute(null, genericDefFrame); + return reads.methodsTableRead.execute(frame, genericDefFrame); } else { return null; } @@ -241,7 +242,7 @@ public abstract class S3FunctionLookupNode extends RBaseNode { if (++depth > MAX_CACHE_DEPTH) { return replace(new UseMethodFunctionLookupGenericNode(throwsError, nextMethod)).execute(frame, genericName, type, group, callerFrame, genericDefFrame); } else { - UseMethodFunctionLookupCachedNode cachedNode = replace(specialize(genericName, type, group, callerFrame, genericDefFrame, this)); + UseMethodFunctionLookupCachedNode cachedNode = replace(specialize(frame, genericName, type, group, callerFrame, genericDefFrame, this)); return cachedNode.execute(frame, genericName, type, group, callerFrame, genericDefFrame); } } @@ -297,7 +298,7 @@ public abstract class S3FunctionLookupNode extends RBaseNode { if ((genericIdentityProfile.profile(genericName != cachedGenericName) && !cachedGenericName.equals(genericName)) || !isEqualType(type) || group != cachedGroup) { return next.execute(frame, genericName, type, group, callerFrame, genericDefFrame); } - if (!executeReads(unsuccessfulReadsCallerFrame, callerFrame)) { + if (!executeReads(frame, unsuccessfulReadsCallerFrame, callerFrame)) { break; } REnvironment methodsTable; @@ -311,7 +312,7 @@ public abstract class S3FunctionLookupNode extends RBaseNode { } if (successfulRead != null || successfulReadTable != null) { - Object actualFunction = successfulRead != null ? successfulRead.execute(null, callerFrame) : successfulReadTable.execute(null, methodsTable.getFrame()); + Object actualFunction = successfulRead != null ? successfulRead.execute(frame, callerFrame) : successfulReadTable.execute(frame, methodsTable.getFrame()); if (actualFunction != result.function) { break; } @@ -327,13 +328,13 @@ public abstract class S3FunctionLookupNode extends RBaseNode { } } while (true); CompilerDirectives.transferToInterpreterAndInvalidate(); - return replace(specialize(genericName, type, group, callerFrame, genericDefFrame, next)).execute(frame, genericName, type, group, callerFrame, genericDefFrame); + return replace(specialize(frame, genericName, type, group, callerFrame, genericDefFrame, next)).execute(frame, genericName, type, group, callerFrame, genericDefFrame); } @ExplodeLoop - private static boolean executeReads(ReadVariableNode[] reads, Frame callerFrame) { + private static boolean executeReads(VirtualFrame frame, ReadVariableNode[] reads, Frame callerFrame) { for (ReadVariableNode read : reads) { - if (read.execute(null, callerFrame) != null) { + if (read.execute(frame, callerFrame) != null) { CompilerDirectives.transferToInterpreterAndInvalidate(); return false; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/WrapArgumentBaseNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/WrapArgumentBaseNode.java index 5210945655fb09e4166587e604b7aef188cbf9f4..b54a2b7daf74a520f530cb33fb92f9dcf08e85e0 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/WrapArgumentBaseNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/WrapArgumentBaseNode.java @@ -39,7 +39,6 @@ public abstract class WrapArgumentBaseNode extends RNode { @Child protected RNode operand; private final BranchProfile everSeenVector; - private final BranchProfile everSeenFactor; private final BranchProfile everSeenLanguage; private final BranchProfile everSeenFunction; private final BranchProfile everSeenS4Object; @@ -51,7 +50,6 @@ public abstract class WrapArgumentBaseNode extends RNode { this.operand = operand; if (initProfiles) { everSeenVector = BranchProfile.create(); - everSeenFactor = BranchProfile.create(); everSeenLanguage = BranchProfile.create(); everSeenFunction = BranchProfile.create(); everSeenS4Object = BranchProfile.create(); @@ -59,7 +57,6 @@ public abstract class WrapArgumentBaseNode extends RNode { nonShareable = BranchProfile.create(); } else { everSeenVector = null; - everSeenFactor = null; everSeenLanguage = null; everSeenFunction = null; everSeenS4Object = null; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/PrepareArguments.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/PrepareArguments.java index 2630a51f78a5d5e4a28cf2878fe0a7cdaaa1872c..d7bd5e7ee3c82cb6e62f2602a9b1e265b690dc1c 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/PrepareArguments.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/call/PrepareArguments.java @@ -50,8 +50,8 @@ public abstract class PrepareArguments extends Node { public abstract Object[] execute(VirtualFrame frame, RArgsValuesAndNames varArgs, RCallNode call); - public static PrepareArguments create(RFunction function, CallArgumentsNode args) { - return new UninitializedPrepareArguments(function, args); + public static PrepareArguments create(RFunction function, CallArgumentsNode args, boolean noOpt) { + return new UninitializedPrepareArguments(function, args, noOpt); } public static PrepareArguments createExplicit(RFunction function) { @@ -62,11 +62,13 @@ public abstract class PrepareArguments extends Node { private final RFunction function; private final CallArgumentsNode sourceArguments; // not used as a node + private final boolean noOpt; private int depth = CACHE_SIZE; - UninitializedPrepareArguments(RFunction function, CallArgumentsNode sourceArguments) { + UninitializedPrepareArguments(RFunction function, CallArgumentsNode sourceArguments, boolean noOpt) { this.function = function; this.sourceArguments = sourceArguments; + this.noOpt = noOpt; } @Override @@ -74,7 +76,7 @@ public abstract class PrepareArguments extends Node { CompilerDirectives.transferToInterpreterAndInvalidate(); PrepareArguments next; if (depth-- > 0) { - next = new CachedPrepareArguments(this, function, call, sourceArguments, varArgs == null ? null : varArgs.getSignature()); + next = new CachedPrepareArguments(this, function, call, sourceArguments, varArgs == null ? null : varArgs.getSignature(), noOpt); } else { next = new GenericPrepareArguments(function, sourceArguments); } @@ -88,10 +90,10 @@ public abstract class PrepareArguments extends Node { @Children private final RNode[] matchedArguments; private final ArgumentsSignature cachedVarArgSignature; - CachedPrepareArguments(PrepareArguments next, RFunction function, RCallNode call, CallArgumentsNode args, ArgumentsSignature varArgSignature) { + CachedPrepareArguments(PrepareArguments next, RFunction function, RCallNode call, CallArgumentsNode args, ArgumentsSignature varArgSignature, boolean noOpt) { this.next = next; cachedVarArgSignature = varArgSignature; - matchedArguments = ArgumentMatcher.matchArguments(function, args.unrollArguments(varArgSignature), call, false); + matchedArguments = ArgumentMatcher.matchArguments(function, args.unrollArguments(varArgSignature), call, noOpt); } @Override diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/helpers/RFactorNodes.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/helpers/RFactorNodes.java index 8c901661b6f0d128b10fa1a2ec0ab39cc727abda..01dddaea70456d5bcb251fc7059de851b75cc994 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/helpers/RFactorNodes.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/helpers/RFactorNodes.java @@ -71,7 +71,6 @@ public final class RFactorNodes { @Child private CastStringNode castString; @Child private AttributeAccess attrAccess = AttributeAccess.create(RRuntime.LEVELS_ATTR_KEY); - private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); private final BranchProfile notVectorBranch = BranchProfile.create(); private final ConditionProfile nonScalarLevels = ConditionProfile.createBinaryProfile(); private final ConditionProfile stringVectorLevels = ConditionProfile.createBinaryProfile(); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/objects/LoadMethod.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/objects/LoadMethod.java index 3f7cfee8b4ab7a915e5e5e7814141b0290cc3ae2..f11df1e5baaacd88078af09ba8fdf1f8b8495c5d 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/objects/LoadMethod.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/objects/LoadMethod.java @@ -119,7 +119,7 @@ abstract class LoadMethod extends RBaseNode { if (loadMethodFind == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); loadMethodFind = insert(ReadVariableNode.createFunctionLookup(RSyntaxNode.INTERNAL, RRuntime.R_LOAD_METHOD_NAME)); - currentFunction = (RFunction) loadMethodFind.execute(null, methodsEnv.getFrame()); + currentFunction = (RFunction) loadMethodFind.execute(frame, methodsEnv.getFrame()); loadMethodFunction = currentFunction; loadMethodCall = insert(Truffle.getRuntime().createDirectCallNode(loadMethodFunction.getTarget())); RError.performanceWarning("loadMethod executing slow path"); diff --git a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/ParserGeneration.java b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/ParserGeneration.java index 9d38acca780944b083d0fb1eba77228cfdad191c..cc9aa1d5be5ec95f4d7f494dfcb86d592f2c67ee 100644 --- a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/ParserGeneration.java +++ b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/ParserGeneration.java @@ -80,6 +80,7 @@ public class ParserGeneration { "remove source section identifiers", "transform parser to a generic class via the annotation processor", "use RComplex.createNA()", - "inlined ParseUtils" + "inlined ParseUtils", + "properly throw errors in lexer" }; } diff --git a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g index 16eb660b178e7b17c91092318099a6250dd08fe0..df8ab94e9a4bd4b75dc52cc178dffb4c2c0f856e 100644 --- a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g +++ b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g @@ -135,6 +135,12 @@ package com.oracle.truffle.r.parser; value &= 0xff; // octal escape sequences are clamped the 0-255 range return new String(new int[]{value}, 0, 1); } + + // without this override, the parser will not throw exceptions if it can recover + @Override + public void reportError(RecognitionException e) { + throw new IllegalArgumentException(e); + } } @lexer::init{ diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java index 0ec6b5a67f16a248918d74a24ec8c47fdf7ce15b..b012e5c19bd9a9ec9e111e3a8bd860878aab9883 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/REnvironment.java @@ -38,6 +38,7 @@ import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.RType; import com.oracle.truffle.r.runtime.Utils; +import com.oracle.truffle.r.runtime.VirtualEvalFrame; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.data.RAttributeProfiles; import com.oracle.truffle.r.runtime.data.RAttributeStorage; @@ -610,12 +611,13 @@ public abstract class REnvironment extends RAttributeStorage implements RTypedVa * be materialized. */ public static REnvironment frameToEnvironment(MaterializedFrame frame) { - REnvironment env = RArguments.getEnvironment(frame); + MaterializedFrame f = frame instanceof VirtualEvalFrame ? ((VirtualEvalFrame) frame).getOriginalFrame() : frame; + REnvironment env = RArguments.getEnvironment(f); if (env == null) { - if (RArguments.getFunction(frame) == null) { + if (RArguments.getFunction(f) == null) { throw RInternalError.shouldNotReachHere(); } - env = createEnclosingEnvironments(frame); + env = createEnclosingEnvironments(f); } return env; } @@ -628,10 +630,11 @@ public abstract class REnvironment extends RAttributeStorage implements RTypedVa */ @TruffleBoundary public static REnvironment createEnclosingEnvironments(MaterializedFrame frame) { - REnvironment env = RArguments.getEnvironment(frame); + MaterializedFrame f = frame instanceof VirtualEvalFrame ? ((VirtualEvalFrame) frame).getOriginalFrame() : frame; + REnvironment env = RArguments.getEnvironment(f); if (env == null) { // parent is the env of the enclosing frame - env = REnvironment.Function.create(frame); + env = REnvironment.Function.create(f); } return env; } 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 846e76d24e58dc7301d7675e8b800cad6c2be110..bc0423887fbda4250acd462114793c150c56657c 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 @@ -106558,6 +106558,10 @@ NULL [28] plot.tskernel* plot.TukeyHSD* see '?methods' for accessing help and source code +##com.oracle.truffle.r.test.parser.TestParser.testLexerError +#%0 +Error: unexpected input in "%0" + ##com.oracle.truffle.r.test.parser.TestParser.testNegativePow #10^(1+1) [1] 100 diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java index 7677301bd5c062a2c191fee6d495cfcfe0ebf487..b4a87cb576a31271e9dfabd0abbaf80e4c189b2b 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java @@ -67,7 +67,8 @@ public class TestBase { ContainsAmbiguousError, // the actual error message is ignored ContainsWarning, // the warning context is ignored MayContainError, - MayContainWarning; + MayContainWarning, + IgnoreWhitespace; } public enum Ignored implements TestTrait { @@ -327,6 +328,8 @@ public class TestBase { private static int ignoredInputCount; private static int failedInputCount; + protected static String explicitTestContext; + /** * A way to limit which tests are actually run. TODO requires more JUnit support for filtering * in the wrapper. @@ -427,6 +430,9 @@ public class TestBase { } private static String getTestContext() { + if (explicitTestContext != null) { + return explicitTestContext; + } // We want the stack trace as if the JUnit test failed RuntimeException ex = new RuntimeException(); // The first method not in TestBase is the culprit @@ -451,6 +457,7 @@ public class TestBase { boolean mayContainWarning = TestTrait.contains(traits, Output.MayContainWarning); boolean mayContainError = TestTrait.contains(traits, Output.MayContainError); boolean ambiguousError = TestTrait.contains(traits, Output.ContainsAmbiguousError); + boolean ignoreWhitespace = TestTrait.contains(traits, Output.IgnoreWhitespace); boolean nonSharedContext = TestTrait.contains(traits, Context.NonShared); ContextInfo contextInfo = nonSharedContext ? fastROutputManager.fastRSession.createContextInfo(ContextKind.SHARE_NOTHING) : null; @@ -463,6 +470,10 @@ public class TestBase { ignoredInputCount++; } else { String result = fastREval(input, contextInfo); + if (ignoreWhitespace) { + expected = expected.replaceAll("\\s+", ""); + result = result.replaceAll("\\s+", ""); + } CheckResult checkResult = checkResult(whiteLists, input, expected, result, containsWarning, mayContainWarning, containsError, mayContainError, ambiguousError); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java index a089f96f36a1acab73b792cd839bdb55b485b280..055d9d1d320556cef983e049d613c941439bf215 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java @@ -74,6 +74,7 @@ public class TestRBase extends TestBase { return; } for (int i = 0; i < files.length; i++) { + explicitTestContext = testDirName + "/R/" + files[i].getName(); try { BufferedReader bf = new BufferedReader(new FileReader(files[i])); TestTrait testTrait = null; @@ -98,6 +99,8 @@ public class TestRBase extends TestBase { } } catch (IOException x) { Assert.fail("error reading: " + files[i].getPath() + ": " + x); + } finally { + explicitTestContext = null; } } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asdouble.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asdouble.java index 3e63435074a1fbd26f4d9d962ae38b276fffed52..51298bb032db60ac1f807eb2273cadccdaf1d898 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asdouble.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_asdouble.java @@ -120,8 +120,7 @@ public class TestBuiltin_asdouble extends TestBase { @Test public void testasdouble21() { - assertEval(Ignored.Unknown, - "argv <- list(structure(list(foo = 5L, Species = 2L), .Names = c('foo', 'Species'), out.attrs = structure(list(dim = structure(c(6L, 3L), .Names = c('foo', 'Species')), dimnames = structure(list(foo = c('foo=1', 'foo=2', 'foo=3', 'foo=4', 'foo=5', 'foo=6'), Species = c('Species=1', 'Species=2', 'Species=3')), .Names = c('foo', 'Species'))), .Names = c('dim', 'dimnames')), row.names = 11L, class = 'data.frame'));as.double(argv[[1]]);"); + assertEval("argv <- list(structure(list(foo = 5L, Species = 2L), .Names = c('foo', 'Species'), out.attrs = structure(list(dim = structure(c(6L, 3L), .Names = c('foo', 'Species')), dimnames = structure(list(foo = c('foo=1', 'foo=2', 'foo=3', 'foo=4', 'foo=5', 'foo=6'), Species = c('Species=1', 'Species=2', 'Species=3')), .Names = c('foo', 'Species'))), .Names = c('dim', 'dimnames')), row.names = 11L, class = 'data.frame'));as.double(argv[[1]]);"); } @Test diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_c.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_c.java index 2e90ba15b537a6a6fe77a4b6e8eb9c05672d5b48..b3fe43da16d732f65ee0fda8883c1163fb5ac5fd 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_c.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_c.java @@ -110,8 +110,7 @@ public class TestBuiltin_c extends TestBase { @Test public void testc18() { - assertEval(Ignored.Unknown, - "argv <- list(structure(list(V1 = c(1L, 1L, 2L, 3L), V2 = structure(c(1L, 1L, 2L, 3L), .Label = c('A', 'D', 'E'), class = 'factor'), V3 = c(6, 6, 9, 10)), .Names = c('V1', 'V2', 'V3'), row.names = c(NA, 4L), class = 'data.frame'), sep = '\\r');c(argv[[1]],argv[[2]]);"); + assertEval("argv <- list(structure(list(V1 = c(1L, 1L, 2L, 3L), V2 = structure(c(1L, 1L, 2L, 3L), .Label = c('A', 'D', 'E'), class = 'factor'), V3 = c(6, 6, 9, 10)), .Names = c('V1', 'V2', 'V3'), row.names = c(NA, 4L), class = 'data.frame'), sep = '\\r');c(argv[[1]],argv[[2]]);"); } @Test @@ -380,8 +379,7 @@ public class TestBuiltin_c extends TestBase { @Test public void testc70() { - assertEval(Ignored.Unknown, - "argv <- list(structure(list(Topic = character(0), File = character(0)), .Names = c('Topic', 'File'), class = 'data.frame', row.names = integer(0)), sep = '\\r');c(argv[[1]],argv[[2]]);"); + assertEval("argv <- list(structure(list(Topic = character(0), File = character(0)), .Names = c('Topic', 'File'), class = 'data.frame', row.names = integer(0)), sep = '\\r');c(argv[[1]],argv[[2]]);"); } @Test diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_levelsassign.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_levelsassign.java index fbe012c27ee6f00cea90a414011cbb0a21414ec7..bb64dbd4c40dc4760829452212d100a00d8938fa 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_levelsassign.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_levelsassign.java @@ -19,20 +19,17 @@ public class TestBuiltin_levelsassign extends TestBase { @Test public void testlevelsassign1() { - assertEval(Ignored.Unknown, - "argv <- list(structure(1:2, .Label = c('a', 'b'), class = 'factor'), value = structure(list(C = 'C', A = 'a', B = 'b'), .Names = c('C', 'A', 'B')));`levels<-`(argv[[1]],argv[[2]]);"); + assertEval("argv <- list(structure(1:2, .Label = c('a', 'b'), class = 'factor'), value = structure(list(C = 'C', A = 'a', B = 'b'), .Names = c('C', 'A', 'B')));`levels<-`(argv[[1]],argv[[2]]);"); } @Test public void testlevelsassign2() { - assertEval(Ignored.Unknown, - "argv <- list(structure(c(24L, 13L, 15L, 68L, 39L, 74L, 22L, 1L, 8L, 55L, 24L, 20L, 51L, 13L, 3L, 4L, 5L, 6L, 15L, 2L, 8L, 60L, 67L, 23L, 58L, 24L, 22L, 21L, 37L, 74L, 59L, 39L, 14L, 14L, 19L, 23L, 70L, 21L, 22L, 31L, 29L, 30L, 45L, 58L, 17L, 7L, 19L, 26L, 39L, 74L, 57L, 59L, 12L, 72L, 70L, 37L, 64L, 16L, 18L, 21L, 22L, 8L, 62L, 61L, 63L, 71L, 105L, 64L, 10L, 41L, 8L, 27L, 11L, 34L, 32L, 33L, 68L, 107L, NA, 66L, NA, 65L, 48L, 52L, 43L, 47L, 46L, 44L, 41L, 54L, 28L, 50L, 40L, NA, 69L, NA, 75L, 109L, NA, 86L, 112L, 110L, 104L, 24L, 111L, 87L, NA, NA, 92L, 73L, 85L, 90L, 89L, NA, 83L, NA, 102L, NA, 108L, 88L, 91L, 93L, NA, 94L, 84L, NA, 106L, NA, 95L, 82L, 56L, 87L, 109L, 75L, 104L, 110L, 112L, 111L, 24L, 73L, 85L, 86L, 90L, 89L, 102L, 88L, 92L, 9L, 49L, 42L, 38L, 35L, 36L, 25L, NA, NA, 9L, 49L, 42L, NA, 36L, 38L, 25L, 53L, 79L, 78L, 103L, 77L, 80L, 114L, 97L, 113L, 76L, 96L, 81L, 116L, 99L, 117L, 115L, 98L, 101L, 100L), .Label = c('1008', '1011', '1013', '1014', '1015', '1016', '1027', '1028', '1030', '1032', '1051', '1052', '1083', '1093', '1095', '1096', '110', '1102', '111', '1117', '112', '113', '116', '117', '1219', '125', '1250', '1251', '126', '127', '128', '1291', '1292', '1293', '1298', '1299', '130', '1308', '135', '1376', '1377', '1383', '1408', '1409', '141', '1410', '1411', '1413', '1418', '1422', '1438', '1445', '1456', '1492', '2001', '2316', '262', '266', '269', '270', '2708', '2714', '2715', '272', '2728', '2734', '280', '283', '286', '290', '3501', '411', '412', '475', '5028', '5042', '5043', '5044', '5045', '5047', '5049', '5050', '5051', '5052', '5053', '5054', '5055', '5056', '5057', '5058', '5059', '5060', '5061', '5062', '5066', '5067', '5068', '5069', '5070', '5072', '5073', '5115', '5160', '5165', '655', '724', '885', '931', '942', '952', '955', '958', 'c118', 'c168', 'c203', 'c204', 'c266'), class = 'factor'), value = c('1008', '1011', '1013', '1014', '1015', '1016', '1027', '1028', '1030', '1032', '1051', '1052', '1083', '1093', '1095', '1096', '110', '1102', '111', '1117', '112', '113', '116', 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz', '1219', '125', '1250', '1251', '126', '127', '128', '1291', '1292', '1293', '1298', '1299', '130', '1308', '135', '1376', '1377', '1383', '1408', '1409', '141', '1410', '1411', '1413', '1418', '1422', '1438', '1445', '1456', '1492', '2001', '2316', '262', '266', '269', '270', '2708', '2714', '2715', '272', '2728', '2734', '280', '283', '286', '290', '3501', '411', '412', '475', '5028', '5042', '5043', '5044', '5045', '5047', '5049', '5050', '5051', '5052', '5053', '5054', '5055', '5056', '5057', '5058', '5059', '5060', '5061', '5062', '5066', '5067', '5068', '5069', '5070', '5072', '5073', '5115', '5160', '5165', '655', '724', '885', '931', '942', '952', '955', '958', 'c118', 'c168', 'c203', 'c204', 'c266'));`levels<-`(argv[[1]],argv[[2]]);"); + assertEval("argv <- list(structure(c(24L, 13L, 15L, 68L, 39L, 74L, 22L, 1L, 8L, 55L, 24L, 20L, 51L, 13L, 3L, 4L, 5L, 6L, 15L, 2L, 8L, 60L, 67L, 23L, 58L, 24L, 22L, 21L, 37L, 74L, 59L, 39L, 14L, 14L, 19L, 23L, 70L, 21L, 22L, 31L, 29L, 30L, 45L, 58L, 17L, 7L, 19L, 26L, 39L, 74L, 57L, 59L, 12L, 72L, 70L, 37L, 64L, 16L, 18L, 21L, 22L, 8L, 62L, 61L, 63L, 71L, 105L, 64L, 10L, 41L, 8L, 27L, 11L, 34L, 32L, 33L, 68L, 107L, NA, 66L, NA, 65L, 48L, 52L, 43L, 47L, 46L, 44L, 41L, 54L, 28L, 50L, 40L, NA, 69L, NA, 75L, 109L, NA, 86L, 112L, 110L, 104L, 24L, 111L, 87L, NA, NA, 92L, 73L, 85L, 90L, 89L, NA, 83L, NA, 102L, NA, 108L, 88L, 91L, 93L, NA, 94L, 84L, NA, 106L, NA, 95L, 82L, 56L, 87L, 109L, 75L, 104L, 110L, 112L, 111L, 24L, 73L, 85L, 86L, 90L, 89L, 102L, 88L, 92L, 9L, 49L, 42L, 38L, 35L, 36L, 25L, NA, NA, 9L, 49L, 42L, NA, 36L, 38L, 25L, 53L, 79L, 78L, 103L, 77L, 80L, 114L, 97L, 113L, 76L, 96L, 81L, 116L, 99L, 117L, 115L, 98L, 101L, 100L), .Label = c('1008', '1011', '1013', '1014', '1015', '1016', '1027', '1028', '1030', '1032', '1051', '1052', '1083', '1093', '1095', '1096', '110', '1102', '111', '1117', '112', '113', '116', '117', '1219', '125', '1250', '1251', '126', '127', '128', '1291', '1292', '1293', '1298', '1299', '130', '1308', '135', '1376', '1377', '1383', '1408', '1409', '141', '1410', '1411', '1413', '1418', '1422', '1438', '1445', '1456', '1492', '2001', '2316', '262', '266', '269', '270', '2708', '2714', '2715', '272', '2728', '2734', '280', '283', '286', '290', '3501', '411', '412', '475', '5028', '5042', '5043', '5044', '5045', '5047', '5049', '5050', '5051', '5052', '5053', '5054', '5055', '5056', '5057', '5058', '5059', '5060', '5061', '5062', '5066', '5067', '5068', '5069', '5070', '5072', '5073', '5115', '5160', '5165', '655', '724', '885', '931', '942', '952', '955', '958', 'c118', 'c168', 'c203', 'c204', 'c266'), class = 'factor'), value = c('1008', '1011', '1013', '1014', '1015', '1016', '1027', '1028', '1030', '1032', '1051', '1052', '1083', '1093', '1095', '1096', '110', '1102', '111', '1117', '112', '113', '116', 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz', '1219', '125', '1250', '1251', '126', '127', '128', '1291', '1292', '1293', '1298', '1299', '130', '1308', '135', '1376', '1377', '1383', '1408', '1409', '141', '1410', '1411', '1413', '1418', '1422', '1438', '1445', '1456', '1492', '2001', '2316', '262', '266', '269', '270', '2708', '2714', '2715', '272', '2728', '2734', '280', '283', '286', '290', '3501', '411', '412', '475', '5028', '5042', '5043', '5044', '5045', '5047', '5049', '5050', '5051', '5052', '5053', '5054', '5055', '5056', '5057', '5058', '5059', '5060', '5061', '5062', '5066', '5067', '5068', '5069', '5070', '5072', '5073', '5115', '5160', '5165', '655', '724', '885', '931', '942', '952', '955', '958', 'c118', 'c168', 'c203', 'c204', 'c266'));`levels<-`(argv[[1]],argv[[2]]);"); } @Test public void testlevelsassign4() { - assertEval(Ignored.Unknown, - "argv <- list(structure(c(1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L), .Label = c('1', '2', '3'), class = 'factor'), value = structure(list(A = c(1, 3), B = 2), .Names = c('A', 'B')));`levels<-`(argv[[1]],argv[[2]]);"); + assertEval("argv <- list(structure(c(1L, 1L, 2L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 3L, 3L), .Label = c('1', '2', '3'), class = 'factor'), value = structure(list(A = c(1, 3), B = 2), .Names = c('A', 'B')));`levels<-`(argv[[1]],argv[[2]]);"); } @Test diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_levelsassign_.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_levelsassign_.java index 5de8cd8bec3d751e5b8dfd52b14db1fc91f2d876..8758cfbfc0f85b9c40b102da12207e6c3f073dbf 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_levelsassign_.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_levelsassign_.java @@ -20,8 +20,7 @@ public class TestBuiltin_levelsassign_ extends TestBase { @Test public void testlevelsassign_1() { - assertEval(Ignored.Unknown, - "argv <- structure(list(structure(c(4L, 4L, 3L, 6L, 5L, 4L, 4L, 5L, 4L, 4L, 2L, 1L, 3L, 2L, 2L, 3L, 4L, 3L, 2L, 2L, 2L, 4L, 3L, 2L, 6L, 3L, 6L, 2L, 3L, 5L, 2L, 6L, 4L, 2L, 1L, 6L, 6L, 4L, 5L, 3L, 5L, 5L, 6L, 2L, 4L, 3L, 4L, 5L, 4L, 4L, 2L, 6L, 1L, 3L, 5L, 4L, 5L, 2L, 5L, 1L, 6L, 5L, 3L, 6L, 3L, 6L, 3L, 6L, 4L, 6L, 1L, 3L, 2L, 5L, 3L, 3L, 2L, 4L, 3L, 4L, 2L, 1L, 4L, 5L, 3L, 6L, 3L, 6L, 6L, 6L, 4L, 4L, 6L, 4L, 2L, 2L, 3L, 3L, 3L, 5L, 3L, 1L, 5L, 6L, 6L, 6L, 2L, 3L, 3L, 5L, 4L, 2L, 2L, 5L, 2L, 3L, 1L, 3L, 3L, 6L, 1L, 6L, 5L, 4L, 3L, 1L, 1L, 1L, 3L, 5L, 4L, 4L, 1L, 1L, 6L, 2L, 6L, 6L, 1L, 5L, 6L, 6L, 2L,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 3L, 2L, 2L, 2L, 2L, 4L, 4L, 2L, 5L, 4L, 1L, 2L, 3L, 1L, 4L, 2L, 1L, 6L, 4L, 1L, 4L, 2L, 5L, 4L, 3L, 5L, 2L, 1L, 1L, 4L, 3L, 2L, 3L, 1L, 2L, 6L, 6L, 1L, 3L, 4L, 1L, 5L, 6L, 4L, 4L), .Label = c('(0,25]', '(25,35]', '(35,45]', '(45,55]', '(55,65]', '(65,99]'), class = 'factor'), value = c('age1824', 'age2534', 'age3544', 'age4554', 'age5564', 'age6599')), .Names = c('', 'value'));" + - "do.call('levels<-', argv)"); + assertEval("argv <- structure(list(structure(c(4L, 4L, 3L, 6L, 5L, 4L, 4L, 5L, 4L, 4L, 2L, 1L, 3L, 2L, 2L, 3L, 4L, 3L, 2L, 2L, 2L, 4L, 3L, 2L, 6L, 3L, 6L, 2L, 3L, 5L, 2L, 6L, 4L, 2L, 1L, 6L, 6L, 4L, 5L, 3L, 5L, 5L, 6L, 2L, 4L, 3L, 4L, 5L, 4L, 4L, 2L, 6L, 1L, 3L, 5L, 4L, 5L, 2L, 5L, 1L, 6L, 5L, 3L, 6L, 3L, 6L, 3L, 6L, 4L, 6L, 1L, 3L, 2L, 5L, 3L, 3L, 2L, 4L, 3L, 4L, 2L, 1L, 4L, 5L, 3L, 6L, 3L, 6L, 6L, 6L, 4L, 4L, 6L, 4L, 2L, 2L, 3L, 3L, 3L, 5L, 3L, 1L, 5L, 6L, 6L, 6L, 2L, 3L, 3L, 5L, 4L, 2L, 2L, 5L, 2L, 3L, 1L, 3L, 3L, 6L, 1L, 6L, 5L, 4L, 3L, 1L, 1L, 1L, 3L, 5L, 4L, 4L, 1L, 1L, 6L, 2L, 6L, 6L, 1L, 5L, 6L, 6L, 2L, 4L, 6L, 6L, 4L, 4L, 5L, 4L, 4L, 1L, 3L, 1L, 2L, 6L, 6L, 1L, 2L, 6L, 3L, 5L, 4L, 6L, 5L, 3L, 4L, 2L, 5L, 2L, 3L, 2L, 1L, 5L, 1L,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 3L, 1L, 2L, 6L, 6L, 1L, 3L, 4L, 1L, 5L, 6L, 4L, 4L), .Label = c('(0,25]', '(25,35]', '(35,45]', '(45,55]', '(55,65]', '(65,99]'), class = 'factor'), value = c('age1824', 'age2534', 'age3544', 'age4554', 'age5564', 'age6599')), .Names = c('', 'value'));" + + "do.call('levels<-', argv)"); } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_parentframe.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_parentframe.java index f3b0a6ced721b28ffc050b792ae45ac3d762ed75..24c720e2780c87ab7bd3e69c89039aed5f00cbbd 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_parentframe.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_parentframe.java @@ -52,5 +52,4 @@ public class TestBuiltin_parentframe extends TestBase { assertEval("{ f <- function(frame) frame; g <- function() f(parent.frame()); g() }"); assertEval("{ f <- function(frame) frame; g <- function() f(parent.frame(3)); g() }"); } - } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleTruffle.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleTruffle.java index 06729e91d0dba53060de59a76042388070003f20..88f2f6aff3be4b0fe8484b4667f9b5670dbc53b3 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleTruffle.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleTruffle.java @@ -14,7 +14,6 @@ import org.junit.Test; import com.oracle.truffle.r.test.TestBase; -// FIXME: I've seen tests crash when run by JUnit, but pass when run manually through console... public class TestSimpleTruffle extends TestBase { @Test @@ -35,7 +34,6 @@ public class TestSimpleTruffle extends TestBase { @Test public void test1Ignore() { - // FIXME these incorrectly output NULL assertEval("{ f<-function(i) { if(i==1) { i } } ; f(1) ; f(2) }"); assertEval("{ f<-function() { if (!1) TRUE } ; f(); f() }"); assertEval("{ f<-function() { if (!TRUE) 1 } ; f(); f() }"); @@ -56,6 +54,6 @@ public class TestSimpleTruffle extends TestBase { public void testWarningsAndErrors() { assertEval("{ (c(1, 2) < c(1, 2, 3)) == (c(1, 2) < c(1, 3, 4)) }"); assertEval(Output.ContainsError, Output.ContainsWarning, "{ 1i > (c(1, 2) < c(1, 2, 3)) }"); - assertEval(Output.ContainsError, Output.ContainsWarning, "{ 1i > ((c(1, 2) < c(1, 2, 3)) == (c(1, 2) < c(1, 3, 4))) }"); + assertEval("{ 1i > ((c(1, 2) < c(1, 2, 3)) == (c(1, 2) < c(1, 3, 4))) }"); } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java index 3c3544f2570b07a6a0f402f75765b2556473ba63..ac2c877be13cb47e943d1d537efc81fead017770 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java @@ -73,6 +73,12 @@ public class TestParser extends TestBase { assertEval(Output.ContainsAmbiguousError, "a <- 1:100; y <- 2; z <- 5; x <- (a[[{y \n * z}]])"); } + @Test + public void testLexerError() { + // FastR provides a more accurate error message + assertEval(Output.ContainsAmbiguousError, "%0"); + } + /** * Recursively look for .r source files in the args[0] directory and parse them. */