diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Formals.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Formals.java index 0ab4c0723e0e61922cc4de8b24938a5e615eab89..d333030a981313d1e74458f4616ddab525d7b9fc 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Formals.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Formals.java @@ -27,6 +27,7 @@ import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL; 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; import com.oracle.truffle.r.nodes.RASTUtils; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; @@ -55,6 +56,12 @@ public abstract class Formals extends RBuiltinNode { return createFormals(fun); } + @Fallback + protected Object formals(Object fun) { + // for anything that is not a function, GnuR returns NULL + return RNull.instance; + } + @TruffleBoundary protected Object createFormals(RFunction fun) { if (fun.isBuiltin()) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Gc.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Gc.java index 977dadd9b36be16b65c0ca63acd22ac2c6dfd601..365e13a7d3de20f47b6c32d1c1a6e8ec26d5eeb0 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Gc.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Gc.java @@ -22,25 +22,32 @@ */ package com.oracle.truffle.r.nodes.builtin.base; +import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.toBoolean; import static com.oracle.truffle.r.runtime.builtins.RBehavior.COMPLEX; import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL; import java.util.Arrays; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RDoubleVector; -import com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector; @RBuiltin(name = "gc", kind = INTERNAL, parameterNames = {"verbose", "reset"}, behavior = COMPLEX) public abstract class Gc extends RBuiltinNode { + @Override + protected void createCasts(CastBuilder casts) { + casts.arg("verbose").asLogicalVector().findFirst().map(toBoolean()); + casts.arg("reset").asLogicalVector().findFirst().map(toBoolean()); + } + @SuppressWarnings("unused") @Specialization - protected RDoubleVector gc(RAbstractLogicalVector verbose, RAbstractLogicalVector reset) { + protected RDoubleVector gc(boolean verbose, boolean reset) { System.gc(); // TODO: somehow produce the (semi?) correct values double[] data = new double[14]; 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 7fe3e749de501ad8ed7e44ee8299225157f7a38b..a38cea8f3dd5a5708088eea885f8b69d797d6bf2 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 @@ -115,14 +115,14 @@ public abstract class ClassHierarchyNode extends UnaryNode { @Specialization protected RStringVector getClassHrAttributable(RAttributable arg, // - @Cached("createBinaryProfile()") ConditionProfile attrStoraeProfile, // + @Cached("createBinaryProfile()") ConditionProfile attrStorageProfile, // @Cached("createClassProfile()") ValueProfile argProfile) { RAttributes attributes; RAttributable profiledArg; - if (attrStoraeProfile.profile(arg instanceof RAttributeStorage)) { + if (attrStorageProfile.profile(arg instanceof RAttributeStorage)) { + // Note: the seemingly unnecessary cast is here to ensure the method can be inlined attributes = ((RAttributeStorage) arg).getAttributes(); - profiledArg = arg; } else { profiledArg = argProfile.profile(arg); attributes = profiledArg.getAttributes();