diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/AttributesAccessNodes.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/AttributesAccessNodes.java index 074f05de92d8cc3327a71442b52e550048fe47e4..fe2516186b964aedba1c7f43c913dfc0f4da7993 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/AttributesAccessNodes.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/AttributesAccessNodes.java @@ -126,7 +126,7 @@ public final class AttributesAccessNodes { public Object doArgs(RArgsValuesAndNames obj) { ArgumentsSignature signature = obj.getSignature(); if (signature.getLength() > 0 && signature.getName(0) != null) { - return RDataFactory.createSymbol(signature.getName(0)); + return getSymbol(signature.getName(0)); } return RNull.instance; } @@ -141,7 +141,7 @@ public final class AttributesAccessNodes { @Cached("create()") GetNamesAttributeNode getNamesAttributeNode) { RStringVector names = getNamesAttributeNode.getNames(obj); if (names != null && names.getLength() > 0) { - return RDataFactory.createSymbol(names.getDataAt(0)); + return getSymbol(names.getDataAt(0)); } return RNull.instance; } @@ -152,6 +152,11 @@ public final class AttributesAccessNodes { throw RInternalError.unimplemented("TAG is not implemented for type " + obj.getClass().getSimpleName()); } + @TruffleBoundary + private Object getSymbol(String name) { + return RDataFactory.createSymbol(name); + } + public static TAG create() { return TAGNodeGen.create(); } diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/DuplicateNodes.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/DuplicateNodes.java index 10bb45981df3c1f039b316bf528ea6632d3599fd..4eab0d8673373a401ed93d7e7091d7ae122d7e62 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/DuplicateNodes.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/DuplicateNodes.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 @@ -22,6 +22,7 @@ */ package com.oracle.truffle.r.ffi.impl.nodes; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.r.ffi.impl.nodes.DuplicateNodesFactory.DuplicateNodeGen; import com.oracle.truffle.r.runtime.data.RExternalPtr; @@ -36,6 +37,7 @@ public final class DuplicateNodes { public abstract static class DuplicateNode extends FFIUpCallNode.Arg2 { @Specialization + @TruffleBoundary public Object duplicateShareable(RShareable x, int deep) { assert !isReusableForDuplicate(x); return deep == 1 ? x.deepCopy() : x.copy(); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java index 37d8da2fa8707921e44f38ef3b1093974fe2838c..1c4b0ccacda2e302a8fcf926258288a9f4065699 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.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 @@ -171,7 +171,7 @@ public abstract class IsNA extends RBuiltinNode.Arg1 { @Fallback protected byte isNA(Object value) { - warning(RError.Message.IS_NA_TO_NON_VECTOR, Predef.typeName().apply(value)); + warning(RError.Message.IS_NA_TO_NON_VECTOR, Predef.getTypeName(value)); return RRuntime.LOGICAL_FALSE; } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NamespaceFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NamespaceFunctions.java index 6c3e1267f3eb3ea8a561ed6083059a903b88a6bc..8abbd97ce0e9cd1b5d1acd2ebd5f1689884ea1f9 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NamespaceFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NamespaceFunctions.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,6 +29,7 @@ import static com.oracle.truffle.r.runtime.builtins.RBehavior.PURE; import static com.oracle.truffle.r.runtime.builtins.RBehavior.READS_STATE; import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.r.nodes.builtin.NodeWithArgumentCasts.Casts; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; @@ -115,6 +116,7 @@ public class NamespaceFunctions { } @Specialization + @TruffleBoundary protected byte doIsNamespaceEnv(REnvironment env) { return RRuntime.asLogical(env.isNamespaceEnv()); } @@ -180,6 +182,7 @@ public class NamespaceFunctions { return RNull.instance; } + @TruffleBoundary private void doUnregisterNamespace(String name) { Object ns = REnvironment.unregisterNamespace(name); if (ns == null) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Prod.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Prod.java index 2ca65bc6427b9c391f9faf31de90e40cd2c9bb8e..88613eccd735bfcd7d622c7bac9f396aea59a68a 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Prod.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Prod.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. */ @@ -154,7 +154,7 @@ public abstract class Prod extends RBuiltinNode.Arg2 { if (i == length) { return complexValue; } - throw error(RError.Message.INVALID_TYPE_ARGUMENT, Predef.typeName().apply(args.getArgument(i))); + throw error(RError.Message.INVALID_TYPE_ARGUMENT, Predef.getTypeName(args.getArgument(i))); } protected static double prodDouble(Object v, VectorAccess access, boolean naRm) { @@ -193,6 +193,6 @@ public abstract class Prod extends RBuiltinNode.Arg2 { @Fallback protected Object prod(Object v, @SuppressWarnings("unused") Object naRm) { - throw error(RError.Message.INVALID_TYPE_ARGUMENT, Predef.typeName().apply(v)); + throw error(RError.Message.INVALID_TYPE_ARGUMENT, Predef.getTypeName(v)); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRTrace.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRTrace.java index 86630d20ab20901ca32ede6c9867912b0b7326bd..c12826198a44eddd1ba0ed230626252cfc04815b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRTrace.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRTrace.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 @@ -50,6 +50,7 @@ import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.RError; 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.builtins.RBuiltin; import com.oracle.truffle.r.runtime.data.Closure; import com.oracle.truffle.r.runtime.data.RDataFactory; @@ -164,7 +165,7 @@ public class FastRTrace { } complexCase(func, tracer, exit, at, print, signature); visibility.execute(frame, true); - return func.toString(); + return Utils.toString(func); } @SuppressWarnings("unused") @@ -217,7 +218,7 @@ public class FastRTrace { throw RError.nyi(this, "method tracing"); } - return func.toString(); + return Utils.toString(func); } } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/DebugHandling.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/DebugHandling.java index a00ce86a35117ccee226c2c042f03d9dc7ff378f..499760e739d7ab87e8ef483aeccb2a2c71aa6ab7 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/DebugHandling.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/DebugHandling.java @@ -52,6 +52,7 @@ import com.oracle.truffle.r.runtime.RArguments; import com.oracle.truffle.r.runtime.RDeparse; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RSource; +import com.oracle.truffle.r.runtime.Utils; import com.oracle.truffle.r.runtime.conn.StdConnections; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.context.RContext.ConsoleIO; @@ -750,7 +751,7 @@ public class DebugHandling { } private boolean isEnabled(EventContext ctx) { - return !disabled() && loopSourceSection != null && loopSourceSection.equals(ctx.getInstrumentedNode().getSourceSection()); + return !disabled() && loopSourceSection != null && Utils.equals(loopSourceSection, ctx.getInstrumentedNode().getSourceSection()); } private void returnCleanup() { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/TraceHandling.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/TraceHandling.java index c7e0be6ae92111eef9d4f595660328e6f1df8434..633f882effc0137b3e5933fdd929b4ab70affe4d 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/TraceHandling.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/helpers/TraceHandling.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 @@ -27,6 +27,7 @@ import java.io.IOException; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrumentation.EventBinding; import com.oracle.truffle.api.instrumentation.EventContext; @@ -208,15 +209,26 @@ public class TraceHandling { @Override public void onEnter(EventContext context, VirtualFrame frame) { if (!disabled()) { + MaterializedFrame materializedFrame = frame.materialize(); if (print) { - try { - String callString = getCallSource(frame); - outputHandler.writeString("Tracing " + callString + " on entry", true); - } catch (IOException ex) { - throw RError.ioError(RError.SHOW_CALLER2, ex); - } + printEnter(materializedFrame); } - RContext.getEngine().eval(tracer, frame.materialize()); + evalTracer(materializedFrame); + } + } + + @TruffleBoundary + private void evalTracer(MaterializedFrame frame) { + RContext.getEngine().eval(tracer, frame); + } + + @TruffleBoundary + private void printEnter(MaterializedFrame frame) { + try { + String callString = getCallSource(frame); + outputHandler.writeString("Tracing " + callString + " on entry", true); + } catch (IOException ex) { + throw RError.ioError(RError.SHOW_CALLER2, ex); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessSlotNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessSlotNode.java index c8d8a6c3f14dd2757d50fe7c23c020ae2a20632b..bc99584c8518c803e716d61942f0b79e28d08440 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessSlotNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessSlotNode.java @@ -6,12 +6,13 @@ * Copyright (c) 1995, 1996, 1997 Robert Gentleman and Ross Ihaka * Copyright (c) 1995-2014, The R Core Team * Copyright (c) 2002-2008, The R Foundation - * Copyright (c) 2015, 2017, Oracle and/or its affiliates + * Copyright (c) 2015, 2018, Oracle and/or its affiliates * * All rights reserved. */ package com.oracle.truffle.r.nodes.access; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; @@ -67,9 +68,8 @@ public abstract class AccessSlotNode extends BaseAccessSlotNode { return RContext.getEngine().evalFunction(dataPart, methodsNamespace.getFrame(), RCaller.create(null, RASTUtils.getOriginalCall(this)), true, null, object); } - // this is really a fallback specialization but @Fallback does not work here (because of the - // type of "object"?) @Specialization(guards = {"!slotAccessAllowed(object)", "!isDotData(name)"}) + @TruffleBoundary protected Object getSlot(RAttributable object, String name, @Cached("create()") GetClassAttributeNode getClassNode) { RStringVector classAttr = getClassNode.getClassAttr(object); @@ -84,6 +84,7 @@ public abstract class AccessSlotNode extends BaseAccessSlotNode { } @Fallback + @TruffleBoundary protected Object getSlot(Object object, String name) { throw error(RError.Message.SLOT_CANNOT_GET, name, RRuntime.getRTypeName(object)); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java index 16eff7b81bda2afbecdd030ceed8d1bcff4ab35c..c8504c82d60d66b60584a15524a320f1ca3116b2 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ExtractVectorNode.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 @@ -363,6 +363,6 @@ public abstract class ExtractVectorNode extends RBaseNode { @Fallback protected Object access(Object object, Object[] positions, Object exact, Object dropDimensions) { CompilerDirectives.transferToInterpreter(); - throw error(RError.Message.OBJECT_NOT_SUBSETTABLE, Predef.typeName().apply(object)); + throw error(RError.Message.OBJECT_NOT_SUBSETTABLE, Predef.getTypeName(object)); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.java index 093cee2ae201e89012aeceffd2e85c97560758a4..d667e9f75d0bce4a0f49df31fec5c80cfca05ee9 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/ReplaceVectorNode.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 @@ -351,6 +351,6 @@ public abstract class ReplaceVectorNode extends RBaseNode { @Fallback protected Object access(Object object, Object[] positions, Object value) { CompilerDirectives.transferToInterpreter(); - throw error(RError.Message.OBJECT_NOT_SUBSETTABLE, Predef.typeName().apply(object)); + throw error(RError.Message.OBJECT_NOT_SUBSETTABLE, Predef.getTypeName(object)); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java index 61e9e4df60d5743ee398a0867d426b3c3e286acf..0a63fd0fac65179d8f49c05307d3fb10b0147caa 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.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 @@ -234,6 +234,7 @@ public abstract class BinaryBooleanNode extends RBuiltinNode.Arg2 { } @Specialization(guards = {"(isRMissing(left) || isRMissing(right))"}) + @TruffleBoundary protected Object doOneArg(@SuppressWarnings("unused") Object left, @SuppressWarnings("unused") Object right) { throw error(RError.Message.IS_OF_WRONG_ARITY, 1, factory.createOperation().opName(), 2); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/CastBuilder.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/CastBuilder.java index fd5623610a9552872f86e3b83b2733dd132bd987..55fe8e2651d98a3d6ede32a5e920b6675cfed6be 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/CastBuilder.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/CastBuilder.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 @@ -25,7 +25,9 @@ package com.oracle.truffle.r.nodes.builtin; import java.util.Arrays; import java.util.function.Function; +import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.r.nodes.builtin.casts.Filter; import com.oracle.truffle.r.nodes.builtin.casts.Filter.AndFilter; @@ -789,7 +791,13 @@ public final class CastBuilder { * @return a function returning the type name of its argument */ public static Function<Object, String> typeName() { + CompilerAsserts.neverPartOfCompilation(); return arg -> RRuntime.getRTypeName(arg); } + + @TruffleBoundary + public static String getTypeName(Object arg) { + return RRuntime.getRTypeName(arg); + } } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/EnvironmentNodes.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/EnvironmentNodes.java index 9a24476c921bfef057050c580bd012c974b4fd9a..5d6db966d17c912b1a435b364e729497ee889351 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/EnvironmentNodes.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/EnvironmentNodes.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 @@ -23,6 +23,7 @@ package com.oracle.truffle.r.nodes.builtin; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +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.FrameDescriptor; @@ -61,15 +62,16 @@ public final class EnvironmentNodes { public abstract REnvironment execute(Object listOrNull, REnvironment target, String envName, REnvironment parentEnv); @Specialization(guards = "isEmpty(list)") - protected REnvironment doEmptyList(@SuppressWarnings("unused") RAbstractListVector list, REnvironment target, String envName, REnvironment parentEnv) { - REnvironment createNewEnv; - if (target == null) { - createNewEnv = RDataFactory.createNewEnv(envName); - RArguments.initializeEnclosingFrame(createNewEnv.getFrame(), parentEnv.getFrame()); - createNewEnv.setParent(parentEnv); - } else { - createNewEnv = target; - } + protected REnvironment doEmptyList(@SuppressWarnings("unused") RAbstractListVector list, REnvironment target, String envName, REnvironment parentEnv, + @Cached("createBinaryProfile()") ConditionProfile nullTargetProfile) { + return nullTargetProfile.profile(target == null) ? createNewEnv(envName, parentEnv) : target; + } + + @TruffleBoundary + private REnvironment createNewEnv(String envName, REnvironment parentEnv) { + REnvironment createNewEnv = RDataFactory.createNewEnv(envName); + RArguments.initializeEnclosingFrame(createNewEnv.getFrame(), parentEnv.getFrame()); + createNewEnv.setParent(parentEnv); return createNewEnv; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryArithmeticReduceNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryArithmeticReduceNode.java index 4f24d6d8301a6fab12cd0855d891e837b1abeb33..eed047314b63368a1b61d4a10b973cecaad0d324 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryArithmeticReduceNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/UnaryArithmeticReduceNode.java @@ -419,7 +419,7 @@ public abstract class UnaryArithmeticReduceNode extends RBaseNode { @Fallback protected Object doFallback(Object obj, @SuppressWarnings("unused") boolean naRm, @SuppressWarnings("unused") boolean infinite) { - throw error(RError.Message.INVALID_TYPE_ARGUMENT, Predef.typeName().apply(obj)); + throw error(RError.Message.INVALID_TYPE_ARGUMENT, Predef.getTypeName(obj)); } protected UnaryArithmeticReduceNode createRecursive() { diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Utils.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Utils.java index 976c45f6f8587ff5cff1fd65ab42005a6ccea158..18e5348b3ee43b2a24cdbb2b02af25f91018d2e5 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Utils.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/Utils.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 @@ -700,6 +700,11 @@ public final class Utils { return obj.toString(); } + @TruffleBoundary + public static boolean equals(Object a, Object b) { + return a.equals(b); + } + @TruffleBoundary public static String stringFormat(String format, Object... objects) { return String.format(format, objects); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RPairList.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RPairList.java index feced1226c62318a28ca3a25b8aea4e7361ba6f7..089225a7db7a1f979fb5b02e0359f783130d70de 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RPairList.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RPairList.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 @@ -271,6 +271,7 @@ public final class RPairList extends RSharingAttributeStorage implements RAbstra } @Override + @TruffleBoundary public RPairList copy() { BaseVectorFactory dataFactory = RDataFactory.getInstance(); RPairList curr = dataFactory.createPairList(); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RSymbol.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RSymbol.java index 903fd638fde1b7af7ef77d0d6d91db62ea5939ca..578551775506ea54418e40c37a262316d1f40883 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RSymbol.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RSymbol.java @@ -28,6 +28,7 @@ import java.util.function.Function; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.ValueType; import com.oracle.truffle.r.runtime.RType; @@ -51,8 +52,8 @@ public final class RSymbol extends RAttributeStorage { this.name = name; } + @TruffleBoundary public static RSymbol install(String name) { - CompilerAsserts.neverPartOfCompilation(); return symbolTable.computeIfAbsent(name, RSymbol::new); } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/FastPathVectorAccess.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/FastPathVectorAccess.java index 4d8948d3f6913035d3a0c070767e2f138e3f0ab3..aacb25a85f18e33758065ad68185ab0913a8f9c9 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/FastPathVectorAccess.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/FastPathVectorAccess.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 @@ -22,7 +22,8 @@ */ package com.oracle.truffle.r.runtime.data.nodes; -import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.RInternalError; @@ -43,6 +44,7 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractContainer; public abstract class FastPathVectorAccess extends VectorAccess { protected boolean naReported; // TODO: move this into the iterator + private final BranchProfile warningReportedProfile = BranchProfile.create(); protected FastPathVectorAccess(Object value) { super(value.getClass(), value instanceof RAbstractContainer ? ((RAbstractContainer) value).getInternalStore() != null : true); @@ -54,8 +56,8 @@ public abstract class FastPathVectorAccess extends VectorAccess { } protected final void warning(RError.Message message) { - CompilerAsserts.neverPartOfCompilation(); if (!naReported) { + warningReportedProfile.enter(); RError.warning(RError.SHOW_CALLER, message); naReported = true; } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/SlowPathVectorAccess.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/SlowPathVectorAccess.java index 5aeab7e21738e334fe5fdf795fc6e12b7ad5f227..47b915f3314cf328be13d6a643a54bd827938b34 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/SlowPathVectorAccess.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/nodes/SlowPathVectorAccess.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 @@ -23,6 +23,8 @@ package com.oracle.truffle.r.runtime.data.nodes; import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RError.Message; import com.oracle.truffle.r.runtime.RInternalError; @@ -41,6 +43,7 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractContainer; public abstract class SlowPathVectorAccess extends VectorAccess { protected boolean naReported; // TODO: move this into the iterator + private final BranchProfile warningReportedProfile = BranchProfile.create(); protected SlowPathVectorAccess() { // VectorAccess.supports has an assertion that relies on this being Object.class @@ -53,8 +56,8 @@ public abstract class SlowPathVectorAccess extends VectorAccess { } protected final void warning(RError.Message message) { - CompilerAsserts.neverPartOfCompilation(); if (!naReported) { + warningReportedProfile.enter(); RError.warning(RError.SHOW_CALLER, message); naReported = true; } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Chisq.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Chisq.java index 3d79d3d43fb006c09b9c96d7dff88e2d9ae1ebc8..79c51e48654260ba4932b95ac124ca27fb5c2e56 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Chisq.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Chisq.java @@ -5,7 +5,7 @@ * * Copyright (C) 1998 Ross Ihaka * Copyright (c) 2000, The R Core Team - * Copyright (c) 2016, 2017, Oracle and/or its affiliates + * Copyright (c) 2016, 2018, Oracle and/or its affiliates * * All rights reserved. */ @@ -48,16 +48,14 @@ public final class Chisq { } public static final class RChisq extends RandFunction1_Double { - public static double rchisq(double df, RandomNumberProvider rand) { + @Child private RGamma rGamma = new RGamma(); + + @Override + public double execute(double df, RandomNumberProvider rand) { if (!Double.isFinite(df) || df < 0.0) { return RMathError.defaultError(); } - return new RGamma().execute(df / 2.0, 2.0, rand); - } - - @Override - public double execute(double a, RandomNumberProvider rand) { - return rchisq(a, rand); + return rGamma.execute(df / 2.0, 2.0, rand); } } } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/RNchisq.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/RNchisq.java index ca4115c927ff218251d09ecb7faf05bb18507ade..2ac0cbee0c03ed40d08221820ecd384b3806924d 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/RNchisq.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/RNchisq.java @@ -5,7 +5,7 @@ * * Copyright (c) 1995-2015, The R Core Team * Copyright (c) 2015, The R Foundation - * Copyright (c) 2016, 2017, Oracle and/or its affiliates + * Copyright (c) 2016, 2018, Oracle and/or its affiliates * * All rights reserved. */ @@ -16,9 +16,11 @@ package com.oracle.truffle.r.runtime.nmath.distr; import com.oracle.truffle.r.runtime.nmath.RMathError; import com.oracle.truffle.r.runtime.nmath.RandomFunctions.RandFunction2_Double; import com.oracle.truffle.r.runtime.nmath.RandomFunctions.RandomNumberProvider; +import com.oracle.truffle.r.runtime.nmath.distr.Chisq.RChisq; public final class RNchisq extends RandFunction2_Double { - private final RGamma rgamma = new RGamma(); + @Child private RGamma rgamma = new RGamma(); + @Child private RChisq rchisq = new RChisq(); @Override public double execute(double df, double lambda, RandomNumberProvider rand) { @@ -31,7 +33,7 @@ public final class RNchisq extends RandFunction2_Double { } else { double r = RPois.rpois(lambda / 2., rand); if (r > 0.) { - r = Chisq.RChisq.rchisq(2. * r, rand); + r = rchisq.execute(2. * r, rand); } if (df > 0.) { r += rgamma.execute(df / 2., 2., rand); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Rf.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Rf.java index 56dfc48308801cc95c9b7a8144c4a2c85b18b029..52837bccfcace628e22680017711bab1f9cb9dcd 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Rf.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Rf.java @@ -5,7 +5,7 @@ * * Copyright (C) 1998 Ross Ihaka * Copyright (c) 1998--2008, The R Core Team - * Copyright (c) 2016, 2017, Oracle and/or its affiliates + * Copyright (c) 2016, 2018, Oracle and/or its affiliates * * All rights reserved. */ @@ -14,8 +14,11 @@ package com.oracle.truffle.r.runtime.nmath.distr; import com.oracle.truffle.r.runtime.nmath.RMathError; import com.oracle.truffle.r.runtime.nmath.RandomFunctions.RandFunction2_Double; import com.oracle.truffle.r.runtime.nmath.RandomFunctions.RandomNumberProvider; +import com.oracle.truffle.r.runtime.nmath.distr.Chisq.RChisq; public final class Rf extends RandFunction2_Double { + @Child private RChisq rchisq = new RChisq(); + @Override public double execute(double n1, double n2, RandomNumberProvider rand) { if (Double.isNaN(n1) || Double.isNaN(n2) || n1 <= 0. || n2 <= 0.) { @@ -24,8 +27,8 @@ public final class Rf extends RandFunction2_Double { double v1; double v2; - v1 = Double.isFinite(n1) ? (Chisq.RChisq.rchisq(n1, rand) / n1) : 1; - v2 = Double.isFinite(n2) ? (Chisq.RChisq.rchisq(n2, rand) / n2) : 1; + v1 = Double.isFinite(n1) ? (rchisq.execute(n1, rand) / n1) : 1; + v2 = Double.isFinite(n2) ? (rchisq.execute(n2, rand) / n2) : 1; return v1 / v2; } } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Rt.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Rt.java index dffa27a4e7759f3b8e62f70a07aecabf29493f4b..74cb57b6462933f073ffaf181eb26ae05cfbd4df 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Rt.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/distr/Rt.java @@ -5,7 +5,7 @@ * * Copyright (C) 1998 Ross Ihaka * Copyright (c) 1998--2008, The R Core Team - * Copyright (c) 2016, 2017, Oracle and/or its affiliates + * Copyright (c) 2016, 2018, Oracle and/or its affiliates * * All rights reserved. */ @@ -17,6 +17,8 @@ import com.oracle.truffle.r.runtime.nmath.RandomFunctions.RandomNumberProvider; import com.oracle.truffle.r.runtime.nmath.distr.Chisq.RChisq; public final class Rt extends RandFunction1_Double { + @Child private RChisq rchisq = new RChisq(); + @Override public double execute(double df, RandomNumberProvider rand) { if (Double.isNaN(df) || df <= 0.0) { @@ -26,7 +28,7 @@ public final class Rt extends RandFunction1_Double { if (!Double.isFinite(df)) { return rand.normRand(); } else { - return rand.normRand() / Math.sqrt(RChisq.rchisq(df, rand) / df); + return rand.normRand() / Math.sqrt(rchisq.execute(df, rand) / df); } } } diff --git a/mx.fastr/native-image.properties b/mx.fastr/native-image.properties index bc39dee0193ce6fe9ee71b3c8f9ccdab91df0961..a70e3e70200bde35bb5e1ac05f92ce3cbaca2019 100644 --- a/mx.fastr/native-image.properties +++ b/mx.fastr/native-image.properties @@ -10,4 +10,7 @@ JavaArgs = \ -Dfastr.internal.grid.awt.support=false \ -Xmx6G -Args = -H:Class=com.oracle.truffle.r.launcher.RCommand +Args = -H:Class=com.oracle.truffle.r.launcher.RCommand \ + -H:MaxRuntimeCompileMethods=8000 \ + -H:TruffleCheckFrameImplementation=false \ + -H:TruffleCheckNeverPartOfCompilation=true