diff --git a/.hgignore b/.hgignore index a259529a1d26fd4739ffe6f2bbba4439a71a9839..8e2b424b4d1b20b6c49da899fb79ba4ffe9eaf60 100644 --- a/.hgignore +++ b/.hgignore @@ -13,6 +13,7 @@ ^com.oracle.truffle.r.native/gnur/R-* ^Rpkgsource/* ^library/ +^include/ ^build/ ^build-nograal/ ^dist/ diff --git a/com.oracle.truffle.r.native/run/Makefile b/com.oracle.truffle.r.native/run/Makefile index 21f12fb1935b8490acf52a0708aec683d2083fab..0a684b9a7db16dc65fdc670364e1819f65bcacff 100644 --- a/com.oracle.truffle.r.native/run/Makefile +++ b/com.oracle.truffle.r.native/run/Makefile @@ -41,6 +41,7 @@ FASTR_R_HOME := $(abspath $(TOPDIR)/..) FASTR_BIN_DIR := $(FASTR_R_HOME)/bin FASTR_ETC_DIR := $(FASTR_R_HOME)/etc FASTR_SHARE_DIR := $(FASTR_R_HOME)/share +FASTR_INCLUDE_DIR := $(FASTR_R_HOME)/include R_SCRIPT := $(addprefix $(GNUR_HOME)/bin/,R) SUPPORT_SCRIPTS := $(addprefix $(GNUR_HOME)/bin/,BATCH COMPILE INSTALL Rcmd) @@ -50,7 +51,7 @@ ETC_FILES := $(addprefix $(GNUR_HOME)/etc/,javaconf ldpaths Renviron repositorie SHARE_FILES := $(addprefix $(GNUR_HOME)/share/,R make) -all: rundirs rcmds +all: rundirs rcmds includedir rundirs: mkdir -p $(FASTR_BIN_DIR) @@ -78,7 +79,11 @@ $(FASTR_BIN_DIR)/R: Makefile R.sh Rscript.sh Rscript_exec.sh # overrides cp examples-header.R examples-footer.R $(FASTR_SHARE_DIR)/R +includedir: Makefile $(TOPDIR)/include/jni/include/R.h + cp -rp $(TOPDIR)/include/jni/include $(FASTR_R_HOME)/include + clean: rm -rf $(FASTR_BIN_DIR) rm -rf $(FASTR_ETC_DIR) rm -rf $(FASTR_SHARE_DIR) + rm -rf $(FASTR_INCLUDE_DIR) diff --git a/com.oracle.truffle.r.native/run/R.sh b/com.oracle.truffle.r.native/run/R.sh index 231d5a85bb625a75444ae9d3ab2de3ee0d035c5f..c59f02c5579b62db71209da87cf10ece03830c3d 100644 --- a/com.oracle.truffle.r.native/run/R.sh +++ b/com.oracle.truffle.r.native/run/R.sh @@ -33,4 +33,17 @@ source="${BASH_SOURCE[0]}" while [ -h "$source" ] ; do source="$(readlink "$source")"; done PRIMARY_PATH="$( cd -P "$( dirname "$source" )" && pwd )"/../.. -exec mx $MX_R_GLOBAL_ARGS --primary-suite-path $PRIMARY_PATH R $MX_R_CMD_ARGS "$@" +which mx >/dev/null 2>&1 +whichrc=$? +if [ $whichrc == 1 ] ; then + if [ -z "$MX_HOME" ] ; then + echo "Error: mx cannot be found: add to PATH or set MX_HOME" + exit 1 + else + mx=$MX_HOME/mx + fi +else + mx=`which mx` +fi + +exec $mx $MX_R_GLOBAL_ARGS R $MX_R_CMD_ARGS "$@" diff --git a/com.oracle.truffle.r.native/run/Rscript_exec.sh b/com.oracle.truffle.r.native/run/Rscript_exec.sh index 69517e11853485bc6c0f15c48588d0cde4c8b2b9..fab2fc1f0ef8b1afbf862a04abbdfa7f782b76f5 100644 --- a/com.oracle.truffle.r.native/run/Rscript_exec.sh +++ b/com.oracle.truffle.r.native/run/Rscript_exec.sh @@ -29,4 +29,17 @@ source="${BASH_SOURCE[0]}" while [ -h "$source" ] ; do source="$(readlink "$source")"; done PRIMARY_PATH="$( cd -P "$( dirname "$source" )" && pwd )"/../.. -mx $MX_R_GLOBAL_ARGS --primary-suite-path $PRIMARY_PATH Rscript $MX_R_CMD_ARGS "$@" +which mx >/dev/null 2>&1 +whichrc=$? +if [ $whichrc == 1 ] ; then + if [ -z "$MX_HOME" ] ; then + echo "Error: mx cannot be found: add to PATH or set MX_HOME" + exit 1 + else + mx=$MX_HOME/mx + fi +else + mx=`which mx` +fi + +exec $mx $MX_R_GLOBAL_ARGS Rscript $MX_R_CMD_ARGS "$@" diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/RBuiltinPackages.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/RBuiltinPackages.java index 507ff85a7466d93ce1aeacf831c4d3e454b73542..027974bddad2b1415d9601482b41b1c42d388cda 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/RBuiltinPackages.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/RBuiltinPackages.java @@ -141,7 +141,7 @@ public final class RBuiltinPackages implements RBuiltinLookup { private static RFunction createFunction(RBuiltinFactory builtinFactory, String methodName) { try { RootCallTarget callTarget = RBuiltinNode.createArgumentsCallTarget(builtinFactory); - return RContext.cacheBuiltin(methodName, RDataFactory.createFunction(builtinFactory.getName(), callTarget, builtinFactory, REnvironment.baseEnv().getFrame())); + return RContext.cacheBuiltin(methodName, RDataFactory.createFunction(builtinFactory.getName(), callTarget, builtinFactory, REnvironment.baseEnv().getFrame(), false)); } catch (Throwable t) { throw new RuntimeException("error while creating builtin " + methodName + " / " + builtinFactory, t); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/All.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/All.java index fda4f357f0c92aa675cc9e61a9605c556dad9055..b4117cc6f68b7083f1562bbaeed4058c11d01de1 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/All.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/All.java @@ -26,7 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; @@ -38,7 +37,7 @@ public abstract class All extends RBuiltinNode { @Child private CastLogicalNode castLogicalNode; - public abstract Object execute(VirtualFrame frame, Object o); + public abstract Object execute(Object o); @CreateCast("arguments") protected RNode[] castArguments(RNode[] arguments) { @@ -71,7 +70,7 @@ public abstract class All extends RBuiltinNode { } @Specialization - protected byte all(VirtualFrame frame, RArgsValuesAndNames args) { + protected byte all(RArgsValuesAndNames args) { if (castLogicalNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castLogicalNode = insert(CastLogicalNodeGen.create(null, true, false, false)); @@ -81,9 +80,9 @@ public abstract class All extends RBuiltinNode { for (Object argValue : argValues) { byte result; if (argValue instanceof RVector || argValue instanceof RSequence) { - result = accumulate((RLogicalVector) castLogicalNode.executeLogical(frame, argValue)); + result = accumulate((RLogicalVector) castLogicalNode.executeLogical(argValue)); } else { - result = (byte) castLogicalNode.executeByte(frame, argValue); + result = (byte) castLogicalNode.executeLogical(argValue); } if (result != RRuntime.LOGICAL_TRUE) { return result; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Any.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Any.java index 9c10f9703698369329bfa284c10a7e8eb5c90a02..66d0f6733c78f3ae0fd0bf108dced8eceae50887 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Any.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Any.java @@ -26,7 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; @@ -41,7 +40,7 @@ public abstract class Any extends RBuiltinNode { @Child private CastLogicalNode castLogicalNode; - public abstract Object execute(VirtualFrame frame, Object o); + public abstract Object execute(Object o); @CreateCast("arguments") protected RNode[] castArguments(RNode[] arguments) { @@ -74,7 +73,7 @@ public abstract class Any extends RBuiltinNode { } @Specialization - protected byte any(VirtualFrame frame, RArgsValuesAndNames args) { + protected byte any(RArgsValuesAndNames args) { if (castLogicalNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castLogicalNode = insert(CastLogicalNodeGen.create(null, true, false, false)); @@ -85,11 +84,11 @@ public abstract class Any extends RBuiltinNode { for (Object argValue : argValues) { byte result; if (argValue instanceof RVector || argValue instanceof RSequence) { - result = accumulate((RLogicalVector) castLogicalNode.executeLogical(frame, argValue)); + result = accumulate((RLogicalVector) castLogicalNode.executeLogical(argValue)); } else if (argValue == RNull.instance) { result = RRuntime.LOGICAL_FALSE; } else { - result = (byte) castLogicalNode.executeByte(frame, argValue); + result = (byte) castLogicalNode.executeLogical(argValue); } if (RRuntime.isNA(result)) { seenNA = true; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AnyNA.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AnyNA.java index 61ebb8e43c1796d9da2f1c2299b7537882bf8800..eef6397e2f900565306254e061e2a999defa3d2d 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AnyNA.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AnyNA.java @@ -24,7 +24,6 @@ package com.oracle.truffle.r.nodes.builtin.base; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.runtime.*; @@ -43,11 +42,11 @@ public abstract class AnyNA extends RBuiltinNode { @Specialization // TODO recursive == TRUE - protected Object anyNA(VirtualFrame frame, Object x, byte recursive) { + protected Object anyNA(Object x, byte recursive) { if (RRuntime.fromLogical(recursive)) { CompilerDirectives.transferToInterpreter(); throw RError.nyi(getEncapsulatingSourceSection(), "recursive = TRUE"); } - return any.execute(frame, isna.execute(frame, x)); + return any.execute(isna.execute(x)); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Args.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Args.java index 95d0b111e4243804aa2a4900cec43a19a78a33fd..d84c02f8d37cde7ba54f43fefa869ef5fe8600f1 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Args.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Args.java @@ -70,12 +70,11 @@ public abstract class Args extends RBuiltinNode { FunctionBodyNode newBody = new FunctionBodyNode(SaveArgumentsNode.NO_ARGS, nullBody); String newDesc = "args(" + rootNode.getDescription() + ")"; FunctionDefinitionNode newNode = new FunctionDefinitionNode(null, rootNode.getFrameDescriptor(), newBody, formals, newDesc, false); - return RDataFactory.createFunction(newDesc, Truffle.getRuntime().createCallTarget(newNode), REnvironment.globalEnv().getFrame(), false); + return RDataFactory.createFunction(newDesc, Truffle.getRuntime().createCallTarget(newNode), null, REnvironment.globalEnv().getFrame(), false); } @Fallback protected Object args(@SuppressWarnings("unused") Object fun) { return RNull.instance; } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Array.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Array.java index e1f94a29abd1346f1b3941a9c58ae6259be12ea8..2e2c9d665384c0ad33c7700715ca4480a2555e5b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Array.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Array.java @@ -26,7 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; @@ -50,12 +49,12 @@ public abstract class Array extends RBuiltinNode { @Child private UpdateDimNames updateDimNames; // it's OK for the following method to update dimnames in-place as the container is "fresh" - private void updateDimNames(VirtualFrame frame, RAbstractContainer container, Object o) { + private void updateDimNames(RAbstractContainer container, Object o) { if (updateDimNames == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); updateDimNames = insert(UpdateDimNamesNodeGen.create(new RNode[2], null, null)); } - updateDimNames.executeRAbstractContainer(frame, container, o); + updateDimNames.executeRAbstractContainer(container, o); } @CreateCast({"arguments"}) @@ -99,9 +98,9 @@ public abstract class Array extends RBuiltinNode { } @Specialization - protected RIntVector doArray(VirtualFrame frame, RAbstractIntVector vec, RAbstractIntVector dim, RList dimnames) { + protected RIntVector doArray(RAbstractIntVector vec, RAbstractIntVector dim, RList dimnames) { RIntVector ret = doArrayInt(vec, dim); - updateDimNames(frame, ret, dimnames); + updateDimNames(ret, dimnames); controlVisibility(); return ret; } @@ -123,9 +122,9 @@ public abstract class Array extends RBuiltinNode { } @Specialization - protected RDoubleVector doArray(VirtualFrame frame, RAbstractDoubleVector vec, RAbstractIntVector dim, RList dimnames) { + protected RDoubleVector doArray(RAbstractDoubleVector vec, RAbstractIntVector dim, RList dimnames) { RDoubleVector ret = doArrayDouble(vec, dim); - updateDimNames(frame, ret, dimnames); + updateDimNames(ret, dimnames); controlVisibility(); return ret; } @@ -147,9 +146,9 @@ public abstract class Array extends RBuiltinNode { } @Specialization - protected RLogicalVector doArray(VirtualFrame frame, RAbstractLogicalVector vec, RAbstractIntVector dim, RList dimnames) { + protected RLogicalVector doArray(RAbstractLogicalVector vec, RAbstractIntVector dim, RList dimnames) { RLogicalVector ret = doArrayLogical(vec, dim); - updateDimNames(frame, ret, dimnames); + updateDimNames(ret, dimnames); controlVisibility(); return ret; } @@ -171,9 +170,9 @@ public abstract class Array extends RBuiltinNode { } @Specialization - protected RStringVector doArray(VirtualFrame frame, RAbstractStringVector vec, RAbstractIntVector dim, RList dimnames) { + protected RStringVector doArray(RAbstractStringVector vec, RAbstractIntVector dim, RList dimnames) { RStringVector ret = doArrayString(vec, dim); - updateDimNames(frame, ret, dimnames); + updateDimNames(ret, dimnames); controlVisibility(); return ret; } @@ -198,9 +197,9 @@ public abstract class Array extends RBuiltinNode { } @Specialization - protected RComplexVector doArray(VirtualFrame frame, RAbstractComplexVector vec, RAbstractIntVector dim, RList dimnames) { + protected RComplexVector doArray(RAbstractComplexVector vec, RAbstractIntVector dim, RList dimnames) { RComplexVector ret = doArrayComplex(vec, dim); - updateDimNames(frame, ret, dimnames); + updateDimNames(ret, dimnames); controlVisibility(); return ret; } @@ -222,9 +221,9 @@ public abstract class Array extends RBuiltinNode { } @Specialization - protected RRawVector doArray(VirtualFrame frame, RAbstractRawVector vec, RAbstractIntVector dim, RList dimnames) { + protected RRawVector doArray(RAbstractRawVector vec, RAbstractIntVector dim, RList dimnames) { RRawVector ret = doArrayRaw(vec, dim); - updateDimNames(frame, ret, dimnames); + updateDimNames(ret, dimnames); controlVisibility(); return ret; } @@ -247,9 +246,9 @@ public abstract class Array extends RBuiltinNode { } @Specialization - protected RList doArray(VirtualFrame frame, RList vec, RAbstractIntVector dim, RList dimnames) { + protected RList doArray(RList vec, RAbstractIntVector dim, RList dimnames) { RList ret = doArrayList(vec, dim); - updateDimNames(frame, ret, dimnames); + updateDimNames(ret, dimnames); controlVisibility(); return ret; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCharacter.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCharacter.java index 8bdbbd3dc206035b5889c8527c8f73c0add39c86..691a89bdef9116c07435d0f77a5cf3c3d4104d34 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCharacter.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsCharacter.java @@ -54,49 +54,49 @@ public abstract class AsCharacter extends RBuiltinNode { } } - private String castString(VirtualFrame frame, int o) { + private String castString(int o) { initCast(); - return (String) castStringNode.executeString(frame, o); + return (String) castStringNode.executeString(o); } - private String castString(VirtualFrame frame, double o) { + private String castString(double o) { initCast(); - return (String) castStringNode.executeString(frame, o); + return (String) castStringNode.executeString(o); } - private String castString(VirtualFrame frame, byte o) { + private String castString(byte o) { initCast(); - return (String) castStringNode.executeString(frame, o); + return (String) castStringNode.executeString(o); } - private RStringVector castStringVector(VirtualFrame frame, Object o) { + private RStringVector castStringVector(Object o) { initCast(); - return (RStringVector) ((RStringVector) castStringNode.executeString(frame, o)).copyDropAttributes(); + return (RStringVector) ((RStringVector) castStringNode.executeString(o)).copyDropAttributes(); } @Specialization - protected String doInt(VirtualFrame frame, int value) { + protected String doInt(int value) { controlVisibility(); - return castString(frame, value); + return castString(value); } @Specialization - protected String doDouble(VirtualFrame frame, double value) { + protected String doDouble(double value) { controlVisibility(); - return castString(frame, value); + return castString(value); } @Specialization - protected String doLogical(VirtualFrame frame, byte value) { + protected String doLogical(byte value) { controlVisibility(); - return castString(frame, value); + return castString(value); } @Specialization - protected String doRaw(VirtualFrame frame, RRaw value) { + protected String doRaw(RRaw value) { controlVisibility(); initCast(); - return (String) castStringNode.executeString(frame, value); + return (String) castStringNode.executeString(value); } @Specialization @@ -124,8 +124,7 @@ public abstract class AsCharacter extends RBuiltinNode { } @Specialization(guards = "!isObject(frame, list)") - @SuppressWarnings("unused") - protected RStringVector doList(VirtualFrame frame, RList list) { + protected RStringVector doList(@SuppressWarnings("unused") VirtualFrame frame, RList list) { controlVisibility(); // partial implementation for simple special case if (list.getLength() == 1 && list.getDataAt(0) instanceof RStringVector && ((RStringVector) list.getDataAt(0)).getLength() == 1) { @@ -136,9 +135,9 @@ public abstract class AsCharacter extends RBuiltinNode { } @Specialization(guards = "!isObject(frame, container)") - protected RStringVector doVector(VirtualFrame frame, RAbstractContainer container) { + protected RStringVector doVector(@SuppressWarnings("unused") VirtualFrame frame, RAbstractContainer container) { controlVisibility(); - return castStringVector(frame, container); + return castStringVector(container); } @Specialization(guards = "isObject(frame, container)") @@ -151,7 +150,7 @@ public abstract class AsCharacter extends RBuiltinNode { try { return dcn.execute(frame, container.getClassHierarchy(), new Object[]{container}); } catch (S3FunctionLookupNode.NoGenericMethodException e) { - return castStringVector(frame, container); + return castStringVector(container); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsComplex.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsComplex.java index e3cd7d7c969aea661120d22a54e4bf5d85c69aee..e07b3ca919a4ae73bcb4016c5c909b457a1cf1a4 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsComplex.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsComplex.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -26,8 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; -import com.oracle.truffle.api.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -35,13 +33,10 @@ import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; @RBuiltin(name = "as.complex", kind = PRIMITIVE, parameterNames = {"x", "..."}) -@SuppressWarnings("unused") public abstract class AsComplex extends RBuiltinNode { @Child private CastComplexNode castComplexNode; - public abstract RComplexVector executeRComplexVector(VirtualFrame frame, Object o) throws UnexpectedResultException; - private void initCast() { if (castComplexNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -49,29 +44,29 @@ public abstract class AsComplex extends RBuiltinNode { } } - private RComplex castComplex(VirtualFrame frame, int o) { + private RComplex castComplex(int o) { initCast(); - return (RComplex) castComplexNode.executeComplex(frame, o); + return (RComplex) castComplexNode.executeComplex(o); } - private RComplex castComplex(VirtualFrame frame, double o) { + private RComplex castComplex(double o) { initCast(); - return (RComplex) castComplexNode.executeComplex(frame, o); + return (RComplex) castComplexNode.executeComplex(o); } - private RComplex castComplex(VirtualFrame frame, byte o) { + private RComplex castComplex(byte o) { initCast(); - return (RComplex) castComplexNode.executeComplex(frame, o); + return (RComplex) castComplexNode.executeComplex(o); } - private RComplex castComplex(VirtualFrame frame, Object o) { + private RComplex castComplex(Object o) { initCast(); - return (RComplex) castComplexNode.executeComplex(frame, o); + return (RComplex) castComplexNode.executeComplex(o); } - private RComplexVector castComplexVector(VirtualFrame frame, Object o) { + private RComplexVector castComplexVector(Object o) { initCast(); - return (RComplexVector) castComplexNode.executeComplex(frame, o); + return (RComplexVector) castComplexNode.executeComplex(o); } @Specialization @@ -81,44 +76,44 @@ public abstract class AsComplex extends RBuiltinNode { } @Specialization - protected RComplex doInt(VirtualFrame frame, int value) { + protected RComplex doInt(int value) { controlVisibility(); - return castComplex(frame, value); + return castComplex(value); } @Specialization - protected RComplex doDouble(VirtualFrame frame, double value) { + protected RComplex doDouble(double value) { controlVisibility(); - return castComplex(frame, value); + return castComplex(value); } @Specialization - protected RComplex doLogical(VirtualFrame frame, byte value) { + protected RComplex doLogical(byte value) { controlVisibility(); - return castComplex(frame, value); + return castComplex(value); } @Specialization - protected RComplex doString(VirtualFrame frame, String value) { + protected RComplex doString(String value) { controlVisibility(); - return castComplex(frame, value); + return castComplex(value); } @Specialization - protected RComplexVector doNull(RNull value) { + protected RComplexVector doNull(@SuppressWarnings("unused") RNull value) { controlVisibility(); return RDataFactory.createComplexVector(0); } @Specialization - protected RComplexVector doComplexVector(VirtualFrame frame, RComplexVector vector) { + protected RComplexVector doComplexVector(RComplexVector vector) { controlVisibility(); return RDataFactory.createComplexVector(vector.getDataCopy(), vector.isComplete()); } @Specialization - protected RComplexVector doIntVector(VirtualFrame frame, RAbstractVector vector) { + protected RComplexVector doIntVector(RAbstractVector vector) { controlVisibility(); - return castComplexVector(frame, vector); + return castComplexVector(vector); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsDouble.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsDouble.java index 7437c8851e992b61e684801a2a3c3fea9dbf77b9..654c867639aa37e72b7446c390e508ce8defad7e 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsDouble.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsDouble.java @@ -26,7 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -47,29 +46,29 @@ public abstract class AsDouble extends RBuiltinNode { } } - private double castDouble(VirtualFrame frame, int o) { + private double castDouble(int o) { initCast(); - return (double) castDoubleNode.executeDouble(frame, o); + return (double) castDoubleNode.executeDouble(o); } - private double castDouble(VirtualFrame frame, double o) { + private double castDouble(double o) { initCast(); - return (double) castDoubleNode.executeDouble(frame, o); + return (double) castDoubleNode.executeDouble(o); } - private double castDouble(VirtualFrame frame, byte o) { + private double castDouble(byte o) { initCast(); - return (double) castDoubleNode.executeDouble(frame, o); + return (double) castDoubleNode.executeDouble(o); } - private double castDouble(VirtualFrame frame, Object o) { + private double castDouble(Object o) { initCast(); - return (double) castDoubleNode.executeDouble(frame, o); + return (double) castDoubleNode.executeDouble(o); } - private RDoubleVector castDoubleVector(VirtualFrame frame, Object o) { + private RDoubleVector castDoubleVector(Object o) { initCast(); - return (RDoubleVector) castDoubleNode.executeDouble(frame, o); + return (RDoubleVector) castDoubleNode.executeDouble(o); } @Specialization @@ -79,27 +78,27 @@ public abstract class AsDouble extends RBuiltinNode { } @Specialization - protected double asDoubleInt(VirtualFrame frame, int value) { + protected double asDoubleInt(int value) { controlVisibility(); - return castDouble(frame, value); + return castDouble(value); } @Specialization - protected double asDouble(VirtualFrame frame, byte value) { + protected double asDouble(byte value) { controlVisibility(); - return castDouble(frame, value); + return castDouble(value); } @Specialization - protected double asDouble(VirtualFrame frame, RComplex value) { + protected double asDouble(RComplex value) { controlVisibility(); - return castDouble(frame, value); + return castDouble(value); } @Specialization - protected double asDouble(VirtualFrame frame, String value) { + protected double asDouble(String value) { controlVisibility(); - return castDouble(frame, value); + return castDouble(value); } @Specialization @@ -121,20 +120,19 @@ public abstract class AsDouble extends RBuiltinNode { } @Specialization - protected RDoubleSequence asDouble(VirtualFrame frame, RIntSequence sequence) { + protected RDoubleSequence asDouble(RIntSequence sequence) { controlVisibility(); return RDataFactory.createDoubleSequence(sequence.getStart(), sequence.getStride(), sequence.getLength()); } @Specialization - protected RDoubleVector asDouble(VirtualFrame frame, RAbstractVector vector) { + protected RDoubleVector asDouble(RAbstractVector vector) { controlVisibility(); - return castDoubleVector(frame, vector); + return castDoubleVector(vector); } @Specialization - protected RDoubleVector asDouble(VirtualFrame frame, RFactor vector) { - return asDouble(frame, vector.getVector()); + protected RDoubleVector asDouble(RFactor vector) { + return asDouble(vector.getVector()); } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsInteger.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsInteger.java index ce5601082ad6b4330c3fe28ab6e3691e9f8ea21d..ba7280a964a5922fd4446103331b144ad2ce614c 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsInteger.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsInteger.java @@ -26,7 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -47,29 +46,29 @@ public abstract class AsInteger extends RBuiltinNode { } } - private int castInt(VirtualFrame frame, int o) { + private int castInt(int o) { initCast(); - return (int) castIntNode.executeInt(frame, o); + return (int) castIntNode.executeInt(o); } - private int castInt(VirtualFrame frame, double o) { + private int castInt(double o) { initCast(); - return (int) castIntNode.executeInt(frame, o); + return (int) castIntNode.executeInt(o); } - private int castInt(VirtualFrame frame, byte o) { + private int castInt(byte o) { initCast(); - return (int) castIntNode.executeInt(frame, o); + return (int) castIntNode.executeInt(o); } - private int castInt(VirtualFrame frame, Object o) { + private int castInt(Object o) { initCast(); - return (int) castIntNode.executeInt(frame, o); + return (int) castIntNode.executeInt(o); } - private RAbstractIntVector castIntVector(VirtualFrame frame, Object o) { + private RAbstractIntVector castIntVector(Object o) { initCast(); - return (RAbstractIntVector) castIntNode.executeInt(frame, o); + return (RAbstractIntVector) castIntNode.executeInt(o); } @Specialization @@ -79,37 +78,37 @@ public abstract class AsInteger extends RBuiltinNode { } @Specialization - protected int asInteger(VirtualFrame frame, double value) { + protected int asInteger(double value) { controlVisibility(); - return castInt(frame, value); + return castInt(value); } @Specialization - protected int asInteger(VirtualFrame frame, byte value) { + protected int asInteger(byte value) { controlVisibility(); - return castInt(frame, value); + return castInt(value); } @Specialization - protected int asInteger(VirtualFrame frame, RComplex value) { + protected int asInteger(RComplex value) { controlVisibility(); - return castInt(frame, value); + return castInt(value); } @Specialization - protected int asInteger(VirtualFrame frame, RRaw value) { + protected int asInteger(RRaw value) { controlVisibility(); - return castInt(frame, value); + return castInt(value); } @Specialization - protected int asInteger(VirtualFrame frame, String value) { + protected int asInteger(String value) { controlVisibility(); - return castInt(frame, value); + return castInt(value); } @Specialization - protected RIntVector asInteger(VirtualFrame frame, RNull value) { + protected RIntVector asInteger(RNull value) { controlVisibility(); return RDataFactory.createEmptyIntVector(); } @@ -127,9 +126,9 @@ public abstract class AsInteger extends RBuiltinNode { } @Specialization - protected RAbstractIntVector asInteger(VirtualFrame frame, RAbstractVector vector) { + protected RAbstractIntVector asInteger(RAbstractVector vector) { controlVisibility(); - return castIntVector(frame, vector); + return castIntVector(vector); } @Specialization @@ -141,5 +140,4 @@ public abstract class AsInteger extends RBuiltinNode { protected int asInteger(RConnection conn) { return conn.getDescriptor(); } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsLogical.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsLogical.java index 7a3186857584d730a6eba920dc02fac5bb863f4c..d3f1737713b6a3704f736ff856295b033f6aa749 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsLogical.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsLogical.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, 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 @@ -26,8 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; -import com.oracle.truffle.api.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -35,27 +33,24 @@ import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; @RBuiltin(name = "as.logical", kind = PRIMITIVE, parameterNames = {"x", "..."}) -@SuppressWarnings("unused") public abstract class AsLogical extends RBuiltinNode { @Child private CastLogicalNode castLogicalNode; - public abstract RLogicalVector executeRLogicalVector(VirtualFrame frame, Object o) throws UnexpectedResultException; - - private byte castLogical(VirtualFrame frame, Object o) { + private byte castLogical(Object o) { if (castLogicalNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castLogicalNode = insert(CastLogicalNodeGen.create(null, false, false, false)); } - return (byte) castLogicalNode.executeByte(frame, o); + return (byte) castLogicalNode.executeLogical(o); } - private RLogicalVector castLogicalVector(VirtualFrame frame, Object o) { + private RLogicalVector castLogicalVector(Object o) { if (castLogicalNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castLogicalNode = insert(CastLogicalNodeGen.create(null, false, false, false)); } - return (RLogicalVector) castLogicalNode.executeLogical(frame, o); + return (RLogicalVector) castLogicalNode.executeLogical(o); } @Specialization @@ -65,31 +60,31 @@ public abstract class AsLogical extends RBuiltinNode { } @Specialization - protected byte asLogical(VirtualFrame frame, int value) { + protected byte asLogical(int value) { controlVisibility(); - return castLogical(frame, value); + return castLogical(value); } @Specialization - protected byte asLogical(VirtualFrame frame, double value) { + protected byte asLogical(double value) { controlVisibility(); - return castLogical(frame, value); + return castLogical(value); } @Specialization - protected byte asLogical(VirtualFrame frame, RComplex value) { + protected byte asLogical(RComplex value) { controlVisibility(); - return castLogical(frame, value); + return castLogical(value); } @Specialization - protected byte asLogical(VirtualFrame frame, String value) { + protected byte asLogical(String value) { controlVisibility(); - return castLogical(frame, value); + return castLogical(value); } @Specialization - protected RLogicalVector asLogical(RNull vector) { + protected RLogicalVector asLogical(@SuppressWarnings("unused") RNull vector) { controlVisibility(); return RDataFactory.createLogicalVector(0); } @@ -101,8 +96,8 @@ public abstract class AsLogical extends RBuiltinNode { } @Specialization - protected RLogicalVector asLogical(VirtualFrame frame, RAbstractContainer container) { + protected RLogicalVector asLogical(RAbstractContainer container) { controlVisibility(); - return castLogicalVector(frame, container); + return castLogicalVector(container); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsRaw.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsRaw.java index 4751b4a4e6c07b766fd0711b31e0696441a7a834..93837df56b088c5ca2c859a15e64fc6cc4e43b99 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsRaw.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsRaw.java @@ -26,7 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -48,32 +47,32 @@ public abstract class AsRaw extends RBuiltinNode { } } - private RRaw castRaw(VirtualFrame frame, int o) { + private RRaw castRaw(int o) { initCast(); - return (RRaw) castRawNode.executeRaw(frame, o); + return (RRaw) castRawNode.executeRaw(o); } - private RRaw castRaw(VirtualFrame frame, double o) { + private RRaw castRaw(double o) { initCast(); - return (RRaw) castRawNode.executeRaw(frame, o); + return (RRaw) castRawNode.executeRaw(o); } - private RRaw castRaw(VirtualFrame frame, byte o) { + private RRaw castRaw(byte o) { initCast(); - return (RRaw) castRawNode.executeRaw(frame, o); + return (RRaw) castRawNode.executeRaw(o); } - private RRaw castRaw(VirtualFrame frame, Object o) { + private RRaw castRaw(Object o) { initCast(); - return (RRaw) castRawNode.executeRaw(frame, o); + return (RRaw) castRawNode.executeRaw(o); } - private RRawVector castRawVector(VirtualFrame frame, Object o) { + private RRawVector castRawVector(Object o) { initCast(); - return (RRawVector) castRawNode.executeRaw(frame, o); + return (RRawVector) castRawNode.executeRaw(o); } - public abstract Object executeRaw(VirtualFrame frame, Object o); + public abstract Object executeRaw(Object o); @Specialization protected RRawVector asRaw(RNull vector) { @@ -82,33 +81,33 @@ public abstract class AsRaw extends RBuiltinNode { } @Specialization - protected RRaw asRaw(VirtualFrame frame, byte logical) { + protected RRaw asRaw(byte logical) { controlVisibility(); - return castRaw(frame, logical); + return castRaw(logical); } @Specialization - protected RRaw asRaw(VirtualFrame frame, int value) { + protected RRaw asRaw(int value) { controlVisibility(); - return castRaw(frame, value); + return castRaw(value); } @Specialization - protected RRaw asRaw(VirtualFrame frame, double value) { + protected RRaw asRaw(double value) { controlVisibility(); - return castRaw(frame, value); + return castRaw(value); } @Specialization - protected RRaw asRaw(VirtualFrame frame, RComplex value) { + protected RRaw asRaw(RComplex value) { controlVisibility(); - return castRaw(frame, value); + return castRaw(value); } @Specialization - protected RRaw asRaw(VirtualFrame frame, String value) { + protected RRaw asRaw(String value) { controlVisibility(); - return castRaw(frame, value); + return castRaw(value); } @Specialization @@ -118,9 +117,9 @@ public abstract class AsRaw extends RBuiltinNode { } @Specialization(guards = {"!isListVector(vector)", "!isRawVector(vector)"}) - protected RRawVector asRaw(VirtualFrame frame, RAbstractVector vector) { + protected RRawVector asRaw(RAbstractVector vector) { controlVisibility(); - return castRawVector(frame, vector); + return castRawVector(vector); } @Specialization @@ -130,12 +129,12 @@ public abstract class AsRaw extends RBuiltinNode { } @Specialization - protected RRawVector asRaw(VirtualFrame frame, RList value) { + protected RRawVector asRaw(RList value) { controlVisibility(); int length = value.getLength(); RRawVector result = RDataFactory.createRawVector(length); for (int i = 0; i < length; i++) { - result.updateDataAt(i, castRaw(frame, value.getDataAt(i))); + result.updateDataAt(i, castRaw(value.getDataAt(i))); } return result; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsVector.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsVector.java index 235538af042fced2b69b0ae56df4d9bf47938a3c..4d60cd226604972a25e61d23644f25737259a7eb 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsVector.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/AsVector.java @@ -26,7 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -48,76 +47,76 @@ public abstract class AsVector extends RBuiltinNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - private RIntVector castInteger(VirtualFrame frame, Object operand) { + private RIntVector castInteger(Object operand) { if (castInteger == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castInteger = insert(CastIntegerNodeGen.create(null, false, false, false)); } - return (RIntVector) castInteger.executeInt(frame, operand); + return (RIntVector) castInteger.executeInt(operand); } - private RDoubleVector castDouble(VirtualFrame frame, Object operand) { + private RDoubleVector castDouble(Object operand) { if (castDouble == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castDouble = insert(CastDoubleNodeGen.create(null, false, false, false)); } - return (RDoubleVector) castDouble.executeDouble(frame, operand); + return (RDoubleVector) castDouble.executeDouble(operand); } - private RComplexVector castComplex(VirtualFrame frame, Object operand) { + private RComplexVector castComplex(Object operand) { if (castComplex == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castComplex = insert(CastComplexNodeGen.create(null, false, false, false)); } - return (RComplexVector) castComplex.executeComplex(frame, operand); + return (RComplexVector) castComplex.executeComplex(operand); } - private RLogicalVector castLogical(VirtualFrame frame, Object operand) { + private RLogicalVector castLogical(Object operand) { if (castLogical == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castLogical = insert(CastLogicalNodeGen.create(null, false, false, false)); } - return (RLogicalVector) castLogical.executeLogical(frame, operand); + return (RLogicalVector) castLogical.executeLogical(operand); } - private RStringVector castString(VirtualFrame frame, Object operand) { + private RStringVector castString(Object operand) { if (castString == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castString = insert(CastStringNodeGen.create(null, false, false, false, false)); } - return (RStringVector) castString.executeString(frame, operand); + return (RStringVector) castString.executeString(operand); } - private RSymbol castSymbol(VirtualFrame frame, Object operand) { + private RSymbol castSymbol(Object operand) { if (castSymbol == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castSymbol = insert(CastSymbolNodeGen.create(null, false, false, false)); } - return (RSymbol) castSymbol.executeSymbol(frame, operand); + return (RSymbol) castSymbol.executeSymbol(operand); } - private RExpression castExpression(VirtualFrame frame, Object operand) { + private RExpression castExpression(Object operand) { if (castExpression == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castExpression = insert(CastExpressionNodeGen.create(null, false, false, false)); } - return (RExpression) castExpression.executeExpression(frame, operand); + return (RExpression) castExpression.executeExpression(operand); } - private RRawVector castRaw(VirtualFrame frame, Object operand) { + private RRawVector castRaw(Object operand) { if (castRaw == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castRaw = insert(CastRawNodeGen.create(null, false, false, false)); } - return (RRawVector) castRaw.executeRaw(frame, operand); + return (RRawVector) castRaw.executeRaw(operand); } - private RList castList(VirtualFrame frame, Object operand) { + private RList castList(Object operand) { if (castList == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castList = insert(CastListNodeGen.create(null, true, false, false)); } - return castList.executeList(frame, operand); + return castList.executeList(operand); } @Specialization @@ -127,45 +126,45 @@ public abstract class AsVector extends RBuiltinNode { } @Specialization(guards = "castToInt(x, mode)") - protected RAbstractVector asVectorInt(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { + protected RAbstractVector asVectorInt(RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); - return castInteger(frame, x); + return castInteger(x); } @Specialization(guards = "castToDouble(x, mode)") - protected RAbstractVector asVectorDouble(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { + protected RAbstractVector asVectorDouble(RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); - return castDouble(frame, x); + return castDouble(x); } @Specialization(guards = "castToComplex(x, mode)") - protected RAbstractVector asVectorComplex(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { + protected RAbstractVector asVectorComplex(RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); - return castComplex(frame, x); + return castComplex(x); } @Specialization(guards = "castToLogical(x, mode)") - protected RAbstractVector asVectorLogical(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { + protected RAbstractVector asVectorLogical(RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); - return castLogical(frame, x); + return castLogical(x); } @Specialization(guards = "castToString(x, mode)") - protected RAbstractVector asVectorString(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { + protected RAbstractVector asVectorString(RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); - return castString(frame, x); + return castString(x); } @Specialization(guards = "castToRaw(x, mode)") - protected RAbstractVector asVectorRaw(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { + protected RAbstractVector asVectorRaw(RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); - return castRaw(frame, x); + return castRaw(x); } @Specialization(guards = "castToList(x, mode)") - protected RAbstractVector asVectorList(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { + protected RAbstractVector asVectorList(RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); - return castList(frame, x); + return castList(x); } @Specialization(guards = "castToList(x, mode)") @@ -175,9 +174,9 @@ public abstract class AsVector extends RBuiltinNode { } @Specialization(guards = "castToSymbol(x, mode)") - protected RSymbol asVectorSymbol(VirtualFrame frame, RAbstractContainer x, @SuppressWarnings("unused") String mode) { + protected RSymbol asVectorSymbol(RAbstractContainer x, @SuppressWarnings("unused") String mode) { controlVisibility(); - return castSymbol(frame, x); + return castSymbol(x); } @Specialization(guards = "isSymbol(x, mode)") @@ -227,9 +226,9 @@ public abstract class AsVector extends RBuiltinNode { } @Specialization(guards = "castToExpression(x, mode)") - protected RExpression asVectorExpression(VirtualFrame frame, Object x, @SuppressWarnings("unused") String mode) { + protected RExpression asVectorExpression(Object x, @SuppressWarnings("unused") String mode) { controlVisibility(); - return castExpression(frame, x); + return castExpression(x); } @Specialization(guards = "modeIsAnyOrMatches(x, mode)") diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java index ff6dbee05eaeb673a3fb5ff7d1b89f89dfa64a1c..8a78269e7a9d538261d39efa68b1ccc60c04ed80 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Bind.java @@ -57,12 +57,12 @@ public abstract class Bind extends RPrecedenceBuiltinNode { return null; } - protected RAbstractVector castVector(VirtualFrame frame, Object value) { + protected RAbstractVector castVector(Object value) { if (castVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVector = insert(CastToVectorNodeGen.create(null, false, false, false, false)); } - return (RAbstractVector) castVector.executeObject(frame, value); + return (RAbstractVector) castVector.executeObject(value); } @SuppressWarnings("unused") @@ -102,10 +102,10 @@ public abstract class Bind extends RPrecedenceBuiltinNode { vecNames[ind] = signature.getName(i); naCheck.check(vecNames[ind]); } - Object result = castNode.executeCast(frame, array[i]); + Object result = castNode.executeCast(array[i]); RAbstractVector vector; if (needsVectorCast) { - vector = castVector(frame, result); + vector = castVector(result); } else { vector = (RAbstractVector) result; } @@ -153,7 +153,7 @@ public abstract class Bind extends RPrecedenceBuiltinNode { } protected Object allOneElem(VirtualFrame frame, Object deparseLevelObj, RArgsValuesAndNames args, boolean cbind) { - RAbstractVector vec = castVector(frame, args.getArgument(0)); + RAbstractVector vec = castVector(args.getArgument(0)); if (vec.isMatrix()) { return vec; } @@ -165,7 +165,7 @@ public abstract class Bind extends RPrecedenceBuiltinNode { ArgumentsSignature signature = args.getSignature(); if (signature.getNonNullCount() == 0) { - int deparseLevel = deparseLevel(frame, deparseLevelObj); + int deparseLevel = deparseLevel(deparseLevelObj); if (deparseLevel == 0) { dimNamesB = RNull.instance; } else { @@ -255,7 +255,7 @@ public abstract class Bind extends RPrecedenceBuiltinNode { return -ind; } else if (!vec.isArray() || vec.getDimensions().length == 1) { if (argNames == null) { - int deparseLevel = deparseLevel(frame, deparseLevelObj); + int deparseLevel = deparseLevel(deparseLevelObj); if (deparseLevel == 0) { dimNamesArray[ind++] = RRuntime.NAMES_ATTR_EMPTY_VALUE; return -ind; @@ -320,8 +320,8 @@ public abstract class Bind extends RPrecedenceBuiltinNode { return notEqualDims; } - protected int deparseLevel(VirtualFrame frame, Object deparseLevelObj) { - RAbstractLogicalVector v = (RAbstractLogicalVector) castLogical(frame, castVector(frame, deparseLevelObj), true); + protected int deparseLevel(Object deparseLevelObj) { + RAbstractLogicalVector v = (RAbstractLogicalVector) castLogical(castVector(deparseLevelObj), true); if (v.getLength() == 0 || v.getDataAt(0) == 0) { return 0; } else { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BitwiseFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BitwiseFunctions.java index 215cf280e041150373ab18f42878f8f19edae12c..399c23fc723d46799d14f5da1a1b6736156655dc 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BitwiseFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BitwiseFunctions.java @@ -12,7 +12,6 @@ package com.oracle.truffle.r.nodes.builtin.base; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.binary.*; import com.oracle.truffle.r.nodes.builtin.*; @@ -48,10 +47,10 @@ public class BitwiseFunctions { } } - protected Object basicBit(VirtualFrame frame, RAbstractVector a, RAbstractVector b, Operation op) { + protected Object basicBit(RAbstractVector a, RAbstractVector b, Operation op) { checkBasicBit(a, b, op); - RAbstractIntVector aVec = (RAbstractIntVector) castTypeA.execute(frame, a, RType.Integer); - RAbstractIntVector bVec = (RAbstractIntVector) castTypeB.execute(frame, b, RType.Integer); + RAbstractIntVector aVec = (RAbstractIntVector) castTypeA.execute(a, RType.Integer); + RAbstractIntVector bVec = (RAbstractIntVector) castTypeB.execute(b, RType.Integer); int aLen = aVec.getLength(); int bLen = bVec.getLength(); int ansSize = (aLen != 0 && bLen != 0) ? Math.max(aLen, bLen) : 0; @@ -98,8 +97,8 @@ public class BitwiseFunctions { return RDataFactory.createIntVector(ans, completeVector); } - protected Object bitNot(VirtualFrame frame, RAbstractVector a) { - RAbstractIntVector aVec = (RAbstractIntVector) castTypeA.execute(frame, a, RType.Integer); + protected Object bitNot(RAbstractVector a) { + RAbstractIntVector aVec = (RAbstractIntVector) castTypeA.execute(a, RType.Integer); int[] ans = new int[aVec.getLength()]; for (int i = 0; i < aVec.getLength(); i++) { ans[i] = ~aVec.getDataAt(i); @@ -155,83 +154,76 @@ public class BitwiseFunctions { public abstract static class BitwiseAnd extends BasicBitwise { @Specialization - protected Object bitwAnd(VirtualFrame frame, RAbstractVector a, RAbstractVector b) { + protected Object bitwAnd(RAbstractVector a, RAbstractVector b) { controlVisibility(); - return basicBit(frame, a, b, Operation.AND); + return basicBit(a, b, Operation.AND); } - } @RBuiltin(name = "bitwiseOr", kind = RBuiltinKind.INTERNAL, parameterNames = {"a", "b"}) public abstract static class BitwiseOr extends BasicBitwise { @Specialization - protected Object bitwOr(VirtualFrame frame, RAbstractVector a, RAbstractVector b) { + protected Object bitwOr(RAbstractVector a, RAbstractVector b) { controlVisibility(); - return basicBit(frame, a, b, Operation.OR); + return basicBit(a, b, Operation.OR); } - } @RBuiltin(name = "bitwiseXor", kind = RBuiltinKind.INTERNAL, parameterNames = {"a", "b"}) public abstract static class BitwiseXor extends BasicBitwise { @Specialization - protected Object bitwXor(VirtualFrame frame, RAbstractVector a, RAbstractVector b) { + protected Object bitwXor(RAbstractVector a, RAbstractVector b) { controlVisibility(); - return basicBit(frame, a, b, Operation.XOR); + return basicBit(a, b, Operation.XOR); } - } @RBuiltin(name = "bitwiseShiftR", kind = RBuiltinKind.INTERNAL, parameterNames = {"a", "n"}) public abstract static class BitwiseShiftR extends BasicBitwise { @Specialization(guards = {"!shiftByCharacter(n)"}) - protected Object bitwShiftR(VirtualFrame frame, RAbstractVector a, RAbstractVector n) { + protected Object bitwShiftR(RAbstractVector a, RAbstractVector n) { controlVisibility(); - return basicBit(frame, a, n, Operation.SHIFTR); + return basicBit(a, n, Operation.SHIFTR); } @Specialization(guards = {"shiftByCharacter(n)"}) @SuppressWarnings("unused") - protected Object bitwShiftRChar(VirtualFrame frame, RAbstractVector a, RAbstractVector n) { + protected Object bitwShiftRChar(RAbstractVector a, RAbstractVector n) { controlVisibility(); checkShiftOrNot(a, Operation.SHIFTR); return makeNA(a.getLength()); } - } @RBuiltin(name = "bitwiseShiftL", kind = RBuiltinKind.INTERNAL, parameterNames = {"a", "n"}) public abstract static class BitwiseShiftL extends BasicBitwise { @Specialization(guards = {"!shiftByCharacter(n)"}) - protected Object bitwShiftR(VirtualFrame frame, RAbstractVector a, RAbstractVector n) { + protected Object bitwShiftR(RAbstractVector a, RAbstractVector n) { controlVisibility(); - return basicBit(frame, a, n, Operation.SHIFTL); + return basicBit(a, n, Operation.SHIFTL); } @Specialization(guards = {"shiftByCharacter(n)"}) @SuppressWarnings("unused") - protected Object bitwShiftRChar(VirtualFrame frame, RAbstractVector a, RAbstractVector n) { + protected Object bitwShiftRChar(RAbstractVector a, RAbstractVector n) { controlVisibility(); checkShiftOrNot(a, Operation.SHIFTL); return makeNA(a.getLength()); } - } @RBuiltin(name = "bitwiseNot", kind = RBuiltinKind.INTERNAL, parameterNames = {"a"}) public abstract static class BitwiseNot extends BasicBitwise { @Specialization - protected Object bitwNot(VirtualFrame frame, RAbstractVector a) { + protected Object bitwNot(RAbstractVector a) { controlVisibility(); checkShiftOrNot(a, Operation.NOT); - return bitNot(frame, a); + return bitNot(a); } - } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Cat.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Cat.java index 8b48f474c24138f6e6f923f0d7e9c12397fb1fc5..705fa0b1c8ec0bd0971bee577937f6945bcda91d 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Cat.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Cat.java @@ -29,7 +29,6 @@ import java.io.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -54,7 +53,7 @@ public abstract class Cat extends RInvisibleBuiltinNode { } @Specialization - protected RNull cat(VirtualFrame frame, RList args, RConnection conn, RAbstractStringVector sepVec, Object fillObj, @SuppressWarnings("unused") RNull labels, byte append) { + protected RNull cat(RList args, RConnection conn, RAbstractStringVector sepVec, Object fillObj, @SuppressWarnings("unused") RNull labels, byte append) { if (RRuntime.fromLogical(append)) { throw RError.nyi(getEncapsulatingSourceSection(), "append = TRUE"); } @@ -69,7 +68,7 @@ public abstract class Cat extends RInvisibleBuiltinNode { if (zeroLength(obj)) { values[i] = ""; } else { - values[i] = toString.executeString(frame, obj, false, sep); + values[i] = toString.executeString(obj, false, sep); } } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java index 87d05143055963e00f689e0b17fdd5678b0488ef..c471f5b0156195d5d885b4e6136fdb46dd3e6a37 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java @@ -102,9 +102,9 @@ public abstract class Combine extends RCastingBuiltinNode { private Object readAndCast(VirtualFrame frame, CastNode castNode, Object[] values, int index, boolean hasNames) { Object value = inputCast.execute(frame, values[index]); if (hasNames) { - value = namesMerge(castVector(frame, value), getSuppliedSignature().getName(index)); + value = namesMerge(castVector(value), getSuppliedSignature().getName(index)); } - return castNode.executeCast(frame, value); + return castNode.executeCast(value); } protected RAbstractVector namesMerge(RAbstractVector vector, String name) { @@ -118,12 +118,12 @@ public abstract class Combine extends RCastingBuiltinNode { return mergeNamesSlow(vector, name, orgNamesObject); } - private RAbstractVector castVector(VirtualFrame frame, Object value) { + private RAbstractVector castVector(Object value) { if (castVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVector = insert(CastToVectorNodeGen.create(null, false, false, false, false)); } - RVector resultVector = ((RAbstractVector) castVector.executeObject(frame, value)).materialize(); + RVector resultVector = ((RAbstractVector) castVector.executeObject(value)).materialize(); // need to copy if vector is shared in case the same variable is used in combine, e.g. : // x <- 1:2 ; names(x) <- c("A",NA) ; c(x,test=x) if (resultVector.isShared()) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Crossprod.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Crossprod.java index d8306f74abeb4f86ad8b5dfe7fa91f58fe8f48ba..7e1b25beca0c0eddc1b70f26f1673bb79d73b126 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Crossprod.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Crossprod.java @@ -26,7 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.runtime.*; @@ -46,17 +45,17 @@ public abstract class Crossprod extends RBuiltinNode { } } - private Object matMult(VirtualFrame frame, Object op1, Object op2) { + private Object matMult(Object op1, Object op2) { ensureMatMult(); - return matMult.executeObject(frame, op1, op2); + return matMult.executeObject(op1, op2); } - private Object transpose(VirtualFrame frame, Object value) { + private Object transpose(Object value) { if (transpose == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); transpose = insert(TransposeNodeGen.create(new RNode[1], null, null)); } - return transpose.execute(frame, value); + return transpose.execute(value); } @Specialization(guards = {"isMatrix(x)", "isMatrix(y)"}) @@ -91,9 +90,9 @@ public abstract class Crossprod extends RBuiltinNode { } @Specialization - protected Object crossprod(VirtualFrame frame, RAbstractVector x, RAbstractVector y) { + protected Object crossprod(RAbstractVector x, RAbstractVector y) { controlVisibility(); - return matMult(frame, transpose(frame, x), y); + return matMult(transpose(x), y); } @Specialization(guards = "isMatrix(x)") @@ -106,9 +105,9 @@ public abstract class Crossprod extends RBuiltinNode { } @Specialization - protected Object crossprod(VirtualFrame frame, RAbstractVector x, @SuppressWarnings("unused") RNull y) { + protected Object crossprod(RAbstractVector x, @SuppressWarnings("unused") RNull y) { controlVisibility(); - return matMult(frame, transpose(frame, x), x); + return matMult(transpose(x), x); } protected static boolean isMatrix(RAbstractVector v) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMax.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMax.java index 7960ca83a28ccc7df75abe1906198ea72f88d09f..595363c5c72f1ea29bcdd2ecb32bb4108cd58539 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMax.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMax.java @@ -16,7 +16,6 @@ import java.util.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -147,13 +146,13 @@ public abstract class CumMax extends RBuiltinNode { } @Specialization - protected RDoubleVector cummax(VirtualFrame frame, RStringVector v) { + protected RDoubleVector cummax(RStringVector v) { controlVisibility(); if (castDouble == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castDouble = insert(CastDoubleNodeGen.create(null, false, false, false)); } - return cummax((RDoubleVector) castDouble.executeDouble(frame, v)); + return cummax((RDoubleVector) castDouble.executeDouble(v)); } @Specialization diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMin.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMin.java index d9bd398139c4892d549c085e800ee7869b3d7108..d856f4c23a1c52d9d07f340955c7e89cec9e0b41 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMin.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CumMin.java @@ -16,7 +16,6 @@ import java.util.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -148,13 +147,13 @@ public abstract class CumMin extends RBuiltinNode { } @Specialization - protected RDoubleVector cummin(VirtualFrame frame, RStringVector v) { + protected RDoubleVector cummin(RStringVector v) { controlVisibility(); if (castDouble == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castDouble = insert(CastDoubleNodeGen.create(null, false, false, false)); } - return cummin((RDoubleVector) castDouble.executeDouble(frame, v)); + return cummin((RDoubleVector) castDouble.executeDouble(v)); } @Specialization @@ -162,5 +161,4 @@ public abstract class CumMin extends RBuiltinNode { controlVisibility(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.CUMMIN_UNDEFINED_FOR_COMPLEX); } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DuplicatedFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DuplicatedFunctions.java index f2e1a6d726b93a29b368fb3e3e99a0cd28d2a01c..78cea4f3d16544a3f74720b869d6bbcc6fbbe39b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DuplicatedFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/DuplicatedFunctions.java @@ -16,7 +16,6 @@ import java.util.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.binary.*; import com.oracle.truffle.r.nodes.builtin.*; @@ -138,18 +137,18 @@ public class DuplicatedFunctions { } @Specialization(guards = {"isIncomparable(incomparables)", "!empty(x)"}) - protected RLogicalVector duplicatedTrueIncomparables(VirtualFrame frame, RAbstractVector x, byte incomparables, byte fromLast, @SuppressWarnings("unused") int nmax) { + protected RLogicalVector duplicatedTrueIncomparables(RAbstractVector x, byte incomparables, byte fromLast, @SuppressWarnings("unused") int nmax) { initChildren(); RType xType = typeof.execute(x); - RAbstractVector vector = (RAbstractVector) (castTypeNode.execute(frame, incomparables, xType)); + RAbstractVector vector = (RAbstractVector) (castTypeNode.execute(incomparables, xType)); return analyzeAndCreateResult(x, vector, fromLast); } @Specialization(guards = {"!empty(x)"}) - protected RLogicalVector duplicated(VirtualFrame frame, RAbstractContainer x, RAbstractContainer incomparables, byte fromLast, @SuppressWarnings("unused") int nmax) { + protected RLogicalVector duplicated(RAbstractContainer x, RAbstractContainer incomparables, byte fromLast, @SuppressWarnings("unused") int nmax) { initChildren(); RType xType = typeof.execute(x); - return analyzeAndCreateResult(x, (RAbstractContainer) (castTypeNode.execute(frame, incomparables, xType)), fromLast); + return analyzeAndCreateResult(x, (RAbstractContainer) (castTypeNode.execute(incomparables, xType)), fromLast); } @SuppressWarnings("unused") @@ -176,18 +175,18 @@ public class DuplicatedFunctions { } @Specialization(guards = {"isIncomparable(incomparables)", "!empty(x)"}) - protected int anyDuplicatedTrueIncomparables(VirtualFrame frame, RAbstractVector x, byte incomparables, byte fromLast) { + protected int anyDuplicatedTrueIncomparables(RAbstractVector x, byte incomparables, byte fromLast) { initChildren(); RType xType = typeof.execute(x); - RAbstractVector vector = (RAbstractVector) (castTypeNode.execute(frame, incomparables, xType)); + RAbstractVector vector = (RAbstractVector) (castTypeNode.execute(incomparables, xType)); return analyze(x, vector, true, RRuntime.fromLogical(fromLast)).index; } @Specialization(guards = {"!empty(x)"}) - protected int anyDuplicated(VirtualFrame frame, RAbstractContainer x, RAbstractContainer incomparables, byte fromLast) { + protected int anyDuplicated(RAbstractContainer x, RAbstractContainer incomparables, byte fromLast) { initChildren(); RType xType = typeof.execute(x); - return analyze(x, (RAbstractContainer) (castTypeNode.execute(frame, incomparables, xType)), true, RRuntime.fromLogical(fromLast)).index; + return analyze(x, (RAbstractContainer) (castTypeNode.execute(incomparables, xType)), true, RRuntime.fromLogical(fromLast)).index; } @SuppressWarnings("unused") @@ -195,7 +194,5 @@ public class DuplicatedFunctions { protected int anyDuplicatedEmpty(RAbstractContainer x, RAbstractContainer incomparables, byte fromLast) { return 0; } - } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EnvFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EnvFunctions.java index 9137f9cb283b3d7790ac12520eb221d9de7186fb..93e34e9ebb9af6ebb1006c9e8aed28894e0575a0 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EnvFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EnvFunctions.java @@ -439,7 +439,7 @@ public class EnvFunctions { @Specialization RFunction copy(RFunction f) { - return f.copy(); + return RDataFactory.createFunction(f.getName(), f.getTarget(), f.getRBuiltin(), f.getEnclosingFrame(), f.containsDispatch()); } @Specialization diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FastR.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FastR.java index 70a943f5442f079f7163f5e1456035ed85e73ef0..2192101a37215b72dbcb5985d5173b403efa8d93 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FastR.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FastR.java @@ -22,6 +22,7 @@ */ package com.oracle.truffle.r.nodes.builtin.base; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.builtin.fastr.*; @@ -35,6 +36,7 @@ import com.oracle.truffle.r.runtime.data.model.*; @RBuiltin(name = ".FastR", kind = RBuiltinKind.PRIMITIVE, parameterNames = {".NAME", "..."}) public abstract class FastR extends RBuiltinNode { @Specialization + @TruffleBoundary protected Object doFastR(RAbstractStringVector name, RArgsValuesAndNames args) { controlVisibility(); Object[] argValues = args.getArguments(); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FileFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FileFunctions.java index 017d8b61ebc4772efe3c4cdf5daf903e46a15f10..b27e5171a68be0f66881afcc24291501eeb7ff92 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FileFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FileFunctions.java @@ -23,9 +23,8 @@ import java.util.regex.*; import java.util.stream.*; import com.oracle.truffle.api.*; -import com.oracle.truffle.api.CompilerDirectives.*; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; @@ -86,7 +85,7 @@ public class FileFunctions { * There are two simple (non-trivial) cases and one tricky 1. 1. Append one or more * files to a single file (len1 == 1, len2 >= 1) 2. Append one file to one file for * several files (len1 == len2) - * + * * The tricky case is when len1 > 1 && len2 > len1. E.g. f1,f2 <- g1,g2,g3 In this case, * this is really f1,f2,f1 <- g1,g2,g3 */ @@ -225,7 +224,7 @@ public class FileFunctions { * the information. The R closure that called the .Internal turns the result into a * dataframe and sets the row.names attributes to the paths in vec. It also updates the * mtime, ctime, atime fields using .POSIXct. - * + * * We try to use the JDK classes, even though they provide a more abstract interface * than R. In particular there seems to be no way to get the uid/gid values. We might be * better off justing using a native call. @@ -714,7 +713,7 @@ public class FileFunctions { } @Specialization(guards = "!lengthZero(args)") - protected RStringVector doFilePath(VirtualFrame frame, RList args, RAbstractStringVector fsepVec) { + protected RStringVector doFilePath(RList args, RAbstractStringVector fsepVec) { Object[] argValues = args.getDataWithoutCopying(); int resultLength = 0; for (int i = 0; i < argValues.length; i++) { @@ -737,7 +736,7 @@ public class FileFunctions { for (int i = 0; i < argValues.length; i++) { Object elem = argValues[i]; if (!(elem instanceof String || elem instanceof RStringVector)) { - elem = initCastStringNode().executeString(frame, elem); + elem = initCastStringNode().executeString(elem); } if (elem instanceof String) { inputs[i] = new String[]{(String) elem}; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ForeignFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ForeignFunctions.java index 1e1af15110f28d2f6c153811287215764b0f4b0b..b2477a039bbdd872e7376db58d03d8ea848f3667 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ForeignFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/ForeignFunctions.java @@ -305,12 +305,12 @@ public class ForeignFunctions { // TODO: handle more argument types (this is sufficient to run the b25 benchmarks) @SuppressWarnings("unused") @Specialization(guards = "fft(f)") - protected RComplexVector callFFT(VirtualFrame frame, RList f, RArgsValuesAndNames args, RMissing packageName) { + protected RComplexVector callFFT(RList f, RArgsValuesAndNames args, RMissing packageName) { controlVisibility(); Object[] argValues = args.getArguments(); - RComplexVector zVec = castComplexVector(frame, castVector(frame, argValues[0])); + RComplexVector zVec = castComplexVector(castVector(argValues[0])); double[] z = zVec.getDataTemp(); - byte inverse = castLogical(frame, castVector(frame, argValues[1])); + byte inverse = castLogical(castVector(argValues[1])); int inv = RRuntime.isNA(inverse) || inverse == RRuntime.LOGICAL_FALSE ? -2 : 2; int retCode = 7; if (zVecLgt1.profile(zVec.getLength() > 1)) { @@ -537,8 +537,8 @@ public class ForeignFunctions { } @Specialization(guards = "isCor(f)") - protected Object doCor(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { - return doCovCor(frame, false, args); + protected Object doCor(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + return doCovCor(false, args); } public boolean isCor(RList f) { @@ -546,15 +546,15 @@ public class ForeignFunctions { } @Specialization(guards = "isCov(f)") - protected Object doCov(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { - return doCovCor(frame, true, args); + protected Object doCov(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + return doCovCor(true, args); } public boolean isCov(RList f) { return matchName(f, "cov"); } - private Object doCovCor(VirtualFrame frame, boolean isCov, RArgsValuesAndNames args) { + private Object doCovCor(boolean isCov, RArgsValuesAndNames args) { controlVisibility(); Object[] argValues = args.getArguments(); if (argValues[0] == RNull.instance) { @@ -567,16 +567,16 @@ public class ForeignFunctions { if (method != 4) { throw RError.nyi(getEncapsulatingSourceSection(), "method"); } - boolean iskendall = RRuntime.fromLogical(castLogical(frame, castVector(frame, argValues[3]))); + boolean iskendall = RRuntime.fromLogical(castLogical(castVector(argValues[3]))); return Covcor.getInstance().corcov(x.materialize(), y != null ? y.materialize() : null, method, iskendall, !isCov, getEncapsulatingSourceSection()); } @Specialization(guards = "isSplineCoef(f)") - protected RList splineCoef(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { - int method = castInt(frame, castVector(frame, args.getArguments()[0])); - RAbstractDoubleVector x = (RAbstractDoubleVector) castVector(frame, args.getArguments()[1]); - RAbstractDoubleVector y = (RAbstractDoubleVector) castVector(frame, args.getArguments()[2]); + protected RList splineCoef(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + int method = castInt(castVector(args.getArguments()[0])); + RAbstractDoubleVector x = (RAbstractDoubleVector) castVector(args.getArguments()[1]); + RAbstractDoubleVector y = (RAbstractDoubleVector) castVector(args.getArguments()[2]); return SplineFunctions.splineCoef(method, x.materialize(), y.materialize()); } @@ -585,8 +585,8 @@ public class ForeignFunctions { } @Specialization(guards = "isSplineEval(f)") - protected RDoubleVector splineEval(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { - RAbstractDoubleVector xout = (RAbstractDoubleVector) castVector(frame, args.getArgument(0)); + protected RDoubleVector splineEval(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + RAbstractDoubleVector xout = (RAbstractDoubleVector) castVector(args.getArgument(0)); // This is called with the result of SplineCoef, so it is surely an RList return SplineFunctions.splineEval(attrProfiles, xout.materialize(), (RList) args.getArgument(1)); } @@ -596,9 +596,9 @@ public class ForeignFunctions { } @Specialization(guards = "isDoTabExpand(f)") - protected RStringVector tabExpand(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { - RAbstractStringVector strings = (RAbstractStringVector) castVector(frame, args.getArgument(0)); - RAbstractIntVector starts = (RAbstractIntVector) castVector(frame, args.getArgument(1)); + protected RStringVector tabExpand(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + RAbstractStringVector strings = (RAbstractStringVector) castVector(args.getArgument(0)); + RAbstractIntVector starts = (RAbstractIntVector) castVector(args.getArgument(1)); return ToolsText.doTabExpand(strings.materialize(), starts.materialize()); } @@ -607,9 +607,9 @@ public class ForeignFunctions { } @Specialization(guards = "isCodeFilesAppend(f)") - protected RLogicalVector codeFilesAppend(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { - RStringVector file1 = (RStringVector) castVector(frame, args.getArgument(0)); - RStringVector file2 = (RStringVector) castVector(frame, args.getArgument(1)); + protected RLogicalVector codeFilesAppend(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + RStringVector file1 = (RStringVector) castVector(args.getArgument(0)); + RStringVector file2 = (RStringVector) castVector(args.getArgument(1)); if (file1.getLength() != 1) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_ARGUMENT, "file1"); } @@ -624,8 +624,8 @@ public class ForeignFunctions { } @Specialization(guards = "isRmd5(f)") - protected RStringVector rmd5(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { - RStringVector files = (RStringVector) castVector(frame, args.getArgument(0)); + protected RStringVector rmd5(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + RStringVector files = (RStringVector) castVector(args.getArgument(0)); return ToolsRmd5.rmd5(files); } @@ -634,12 +634,12 @@ public class ForeignFunctions { } @Specialization(guards = "isDirChmod(f)") - protected RNull dirChmod(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { - RAbstractVector dir = castVector(frame, args.getArgument(0)); + protected RNull dirChmod(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + RAbstractVector dir = castVector(args.getArgument(0)); if (!(dir instanceof RStringVector && ((RStringVector) dir).getLength() == 1)) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_ARGUMENT, "dir"); } - byte gws = castLogical(frame, castVector(frame, args.getArgument(1))); + byte gws = castLogical(castVector(args.getArgument(1))); ToolsDirChmod.dirChmod(((RStringVector) dir).getDataAt(0), RRuntime.fromLogical(gws)); return RNull.instance; } @@ -694,44 +694,44 @@ public class ForeignFunctions { protected final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - protected byte castLogical(VirtualFrame frame, RAbstractVector operand) { + protected byte castLogical(RAbstractVector operand) { if (castLogical == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castLogical = insert(CastLogicalNodeGen.create(null, false, false, false)); } - return ((RAbstractLogicalVector) castLogical.executeCast(frame, operand)).getDataAt(0); + return ((RAbstractLogicalVector) castLogical.executeCast(operand)).getDataAt(0); } - protected int castInt(VirtualFrame frame, RAbstractVector operand) { + protected int castInt(RAbstractVector operand) { if (castInt == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castInt = insert(CastIntegerNodeGen.create(null, false, false, false)); } - return ((RAbstractIntVector) castInt.executeCast(frame, operand)).getDataAt(0); + return ((RAbstractIntVector) castInt.executeCast(operand)).getDataAt(0); } - protected RAbstractDoubleVector castDouble(VirtualFrame frame, RAbstractVector operand) { + protected RAbstractDoubleVector castDouble(RAbstractVector operand) { if (castDouble == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castDouble = insert(CastDoubleNodeGen.create(null, false, false, false)); } - return (RAbstractDoubleVector) castDouble.executeCast(frame, operand); + return (RAbstractDoubleVector) castDouble.executeCast(operand); } - protected RComplexVector castComplexVector(VirtualFrame frame, Object operand) { + protected RComplexVector castComplexVector(Object operand) { if (castComplex == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castComplex = insert(CastComplexNodeGen.create(null, true, true, false)); } - return (RComplexVector) castComplex.executeCast(frame, operand); + return (RComplexVector) castComplex.executeCast(operand); } - protected RAbstractVector castVector(VirtualFrame frame, Object value) { + protected RAbstractVector castVector(Object value) { if (castVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVector = insert(CastToVectorNodeGen.create(null, false, false, false, false)); } - return (RAbstractVector) castVector.executeObject(frame, value); + return (RAbstractVector) castVector.executeObject(value); } /** @@ -762,15 +762,15 @@ public class ForeignFunctions { // Transcribed from GnuR, library/utils/src/io.c @SuppressWarnings("unused") @Specialization(guards = "isCountFields(f)") - protected Object countFields(VirtualFrame frame, RList f, RArgsValuesAndNames args, RMissing packageName) { + protected Object countFields(RList f, RArgsValuesAndNames args, RMissing packageName) { controlVisibility(); Object[] argValues = args.getArguments(); RConnection conn = (RConnection) argValues[0]; Object sepArg = argValues[1]; char sepChar; Object quoteArg = argValues[2]; - int nskip = castInt(frame, castVector(frame, argValues[3])); - byte blskip = castLogical(frame, castVector(frame, argValues[4])); + int nskip = castInt(castVector(argValues[3])); + byte blskip = castLogical(castVector(argValues[4])); String commentCharArg = isString(argValues[5]); char comChar; if (!(commentCharArg != null && commentCharArg.length() == 1)) { @@ -824,12 +824,12 @@ public class ForeignFunctions { } @Specialization(guards = "isReadTableHead(f)") - protected Object doReadTableHead(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + protected Object doReadTableHead(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { // TODO This is quite incomplete and just uses readLines, which works for some inputs controlVisibility(); Object[] argValues = args.getArguments(); RConnection conn = (RConnection) argValues[0]; - int nlines = castInt(frame, castVector(frame, argValues[1])); + int nlines = castInt(castVector(argValues[1])); try (RConnection openConn = conn.forceOpen("r")) { return RDataFactory.createStringVector(openConn.readLines(nlines), RDataFactory.COMPLETE_VECTOR); } catch (IOException ex) { @@ -843,10 +843,10 @@ public class ForeignFunctions { } @Specialization(guards = "isRnorm(f)") - protected Object doRnorm(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + protected Object doRnorm(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { controlVisibility(); Object[] argValues = args.getArguments(); - int n = castInt(frame, castVector(frame, argValues[0])); + int n = castInt(castVector(argValues[0])); // TODO full error checks double mean = (double) argValues[1]; double standardd = (double) argValues[2]; @@ -858,13 +858,13 @@ public class ForeignFunctions { } @Specialization(guards = "isRunif(f)") - protected Object doRunif(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + protected Object doRunif(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { controlVisibility(); Object[] argValues = args.getArguments(); // TODO full error checks - int n = castInt(frame, castVector(frame, argValues[0])); - double min = (castDouble(frame, castVector(frame, argValues[1]))).getDataAt(0); - double max = (castDouble(frame, castVector(frame, argValues[2]))).getDataAt(0); + int n = castInt(castVector(argValues[0])); + double min = (castDouble(castVector(argValues[1]))).getDataAt(0); + double max = (castDouble(castVector(argValues[2]))).getDataAt(0); return Runif.runif(n, min, max); } @@ -873,17 +873,17 @@ public class ForeignFunctions { } @Specialization(guards = "isQgamma(f)") - protected RAbstractDoubleVector doQgamma(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + protected RAbstractDoubleVector doQgamma(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { controlVisibility(); Object[] argValues = args.getArguments(); - RAbstractDoubleVector p = (RAbstractDoubleVector) castVector(frame, argValues[0]); - RAbstractDoubleVector shape = (RAbstractDoubleVector) castVector(frame, argValues[1]); - RAbstractDoubleVector scale = (RAbstractDoubleVector) castVector(frame, argValues[2]); + RAbstractDoubleVector p = (RAbstractDoubleVector) castVector(argValues[0]); + RAbstractDoubleVector shape = (RAbstractDoubleVector) castVector(argValues[1]); + RAbstractDoubleVector scale = (RAbstractDoubleVector) castVector(argValues[2]); if (shape.getLength() == 0 || scale.getLength() == 0) { return RDataFactory.createEmptyDoubleVector(); } - byte lowerTail = castLogical(frame, castVector(frame, argValues[3])); - byte logP = castLogical(frame, castVector(frame, argValues[4])); + byte lowerTail = castLogical(castVector(argValues[3])); + byte logP = castLogical(castVector(argValues[4])); return GammaFunctions.Qgamma.getInstance().qgamma(p, shape, scale, lowerTail, logP, attrProfiles); } @@ -892,14 +892,14 @@ public class ForeignFunctions { } @Specialization(guards = "isDownload(f)") - protected int doDownload(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { + protected int doDownload(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args, @SuppressWarnings("unused") RMissing packageName) { controlVisibility(); Object[] argValues = args.getArguments(); String url = isString(argValues[0]); String destFile = isString(argValues[1]); - byte quiet = castLogical(frame, castVector(frame, argValues[2])); + byte quiet = castLogical(castVector(argValues[2])); String mode = isString(argValues[3]); - byte cacheOK = castLogical(frame, castVector(frame, argValues[4])); + byte cacheOK = castLogical(castVector(argValues[4])); if (url == null || destFile == null || mode == null) { errorProfile.enter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_UNNAMED_ARGUMENTS); @@ -931,7 +931,7 @@ public class ForeignFunctions { // Transcribed from GnuR, library/utils/src/io.c @Specialization(guards = "isWriteTable(f)") - protected Object doWriteTable(VirtualFrame frame, @SuppressWarnings("unused") RList f, RArgsValuesAndNames args) { + protected Object doWriteTable(@SuppressWarnings("unused") RList f, RArgsValuesAndNames args) { controlVisibility(); Object[] argValues = args.getArguments(); Object conArg = argValues[1]; @@ -944,15 +944,15 @@ public class ForeignFunctions { } // TODO check connection writeable - int nr = castInt(frame, castVector(frame, argValues[2])); - int nc = castInt(frame, castVector(frame, argValues[3])); + int nr = castInt(castVector(argValues[2])); + int nc = castInt(castVector(argValues[3])); Object rnamesArg = argValues[4]; Object sepArg = argValues[5]; Object eolArg = argValues[6]; Object naArg = argValues[7]; Object decArg = argValues[8]; Object quoteArg = argValues[9]; - byte qmethod = castLogical(frame, castVector(frame, argValues[10])); + byte qmethod = castLogical(castVector(argValues[10])); String csep; String ceol; @@ -989,7 +989,7 @@ public class ForeignFunctions { } boolean[] quoteCol = new boolean[nc]; boolean quoteRn = false; - RAbstractIntVector quote = (RAbstractIntVector) castVector(frame, quoteArg); + RAbstractIntVector quote = (RAbstractIntVector) castVector(quoteArg); for (int i = 0; i < quote.getLength(); i++) { int qi = quote.getDataAt(i); if (qi == 0) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Format.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Format.java index f361a68a206069bd6f00cb900defb5d6edb0bbdd..1a81cbaa1e7b51c0fe3f74dd1ac2929881ca7287 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Format.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Format.java @@ -16,7 +16,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; @@ -62,12 +61,12 @@ public abstract class Format extends RBuiltinNode { return setPrintDefaults(); } - private RAbstractIntVector castInteger(VirtualFrame frame, Object operand) { + private RAbstractIntVector castInteger(Object operand) { if (castInteger == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castInteger = insert(CastIntegerNodeGen.create(null, true, false, false)); } - return (RAbstractIntVector) castInteger.executeCast(frame, operand); + return (RAbstractIntVector) castInteger.executeCast(operand); } @CreateCast("arguments") @@ -180,9 +179,9 @@ public abstract class Format extends RBuiltinNode { // TODO: even though format's arguments are not used at this point, their processing mirrors // what GNU R does - private int computeSciArg(VirtualFrame frame, RAbstractVector sciVec) { + private int computeSciArg(RAbstractVector sciVec) { assert sciVec.getLength() > 0; - int tmp = castInteger(frame, sciVec).getDataAt(0); + int tmp = castInteger(sciVec).getDataAt(0); int ret; if (sciVec.getElementClass() == RLogical.class) { if (RRuntime.isNA(tmp)) { @@ -233,8 +232,7 @@ public abstract class Format extends RBuiltinNode { } @SuppressWarnings("unused") - private void processArguments(VirtualFrame frame, RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, RLogicalVector naEncodeVec, - RAbstractVector sciVec) { + private void processArguments(RLogicalVector trimVec, RIntVector digitsVec, RIntVector nsmallVec, RIntVector widthVec, RIntVector justifyVec, RLogicalVector naEncodeVec, RAbstractVector sciVec) { byte trim = trimVec.getLength() > 0 ? trimVec.getDataAt(0) : RRuntime.LOGICAL_NA; int digits = digitsVec.getLength() > 0 ? digitsVec.getDataAt(0) : RRuntime.INT_NA; getConfig().digits = digits; @@ -242,7 +240,7 @@ public abstract class Format extends RBuiltinNode { int width = widthVec.getLength() > 0 ? widthVec.getDataAt(0) : 0; int justify = justifyVec.getLength() > 0 ? justifyVec.getDataAt(0) : RRuntime.INT_NA; byte naEncode = naEncodeVec.getLength() > 0 ? naEncodeVec.getDataAt(0) : RRuntime.LOGICAL_NA; - int sci = computeSciArg(frame, sciVec); + int sci = computeSciArg(sciVec); } @Specialization diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FormatC.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FormatC.java index 299831a0fac4e9d0ee5c012b4c960d57aeaf05d5..9378980af97b31acf46ffb6744c0df7e23e79f80 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FormatC.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/FormatC.java @@ -15,7 +15,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; @@ -31,12 +30,12 @@ public abstract class FormatC extends RBuiltinNode { protected final BranchProfile errorProfile = BranchProfile.create(); - private RStringVector castStringVector(VirtualFrame frame, Object o) { + private RStringVector castStringVector(Object o) { if (castStringNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castStringNode = insert(CastStringNodeGen.create(null, true, true, true, false)); } - return (RStringVector) ((RStringVector) castStringNode.executeString(frame, o)).copyDropAttributes(); + return (RStringVector) ((RStringVector) castStringNode.executeString(o)).copyDropAttributes(); } @CreateCast("arguments") @@ -54,10 +53,9 @@ public abstract class FormatC extends RBuiltinNode { @SuppressWarnings("unused") @Specialization - RAttributable formatC(VirtualFrame frame, RAbstractContainer x, RAbstractStringVector modeVec, RAbstractIntVector widthVec, RAbstractIntVector digitsVec, RAbstractStringVector formatVec, + RAttributable formatC(RAbstractContainer x, RAbstractStringVector modeVec, RAbstractIntVector widthVec, RAbstractIntVector digitsVec, RAbstractStringVector formatVec, RAbstractStringVector flagVec, RAbstractIntVector iStrlen) { - RStringVector res = castStringVector(frame, x); + RStringVector res = castStringVector(x); return res.setClassAttr(null, false); } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GetText.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GetText.java index cacd3542eceaf32f7afbc433684850d91c5b38ec..6e2dbc8e109f18eca3d8c14b6779989e7fce403b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GetText.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GetText.java @@ -28,14 +28,10 @@ import java.util.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; -import com.oracle.truffle.r.nodes.*; -import com.oracle.truffle.r.nodes.access.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; -import com.oracle.truffle.r.runtime.data.model.*; import com.oracle.truffle.r.runtime.ops.na.*; @SuppressWarnings("unused") @@ -47,32 +43,32 @@ public abstract class GetText extends RBuiltinNode { private final NACheck elementNACheck = NACheck.create(); - private Object castString(VirtualFrame frame, Object operand) { + private Object castString(Object operand) { if (castString == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castString = insert(CastStringNodeGen.create(null, false, true, false, false)); } - return castString.executeCast(frame, operand); + return castString.executeCast(operand); } - private Object castVector(VirtualFrame frame, Object value) { + private Object castVector(Object value) { if (castVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVector = insert(CastToVectorNodeGen.create(null, false, false, false, false)); } - return castVector.executeObject(frame, value); + return castVector.executeObject(value); } @Specialization - protected RStringVector getText(VirtualFrame frame, RArgsValuesAndNames varargs, Object domain) { + protected RStringVector getText(RArgsValuesAndNames varargs, Object domain) { Object[] argValues = varargs.getArguments(); String[] a = new String[0]; int aLength = 0; int index = 0; for (int i = 0; i < argValues.length; i++) { - Object v = castVector(frame, argValues[i]); + Object v = castVector(argValues[i]); if (v != RNull.instance) { - RStringVector vector = (RStringVector) castString(frame, v); + RStringVector vector = (RStringVector) castString(v); elementNACheck.enable(vector); aLength += vector.getLength(); a = Utils.resizeArray(a, Math.max(aLength, a.length * 2)); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/HiddenInternalFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/HiddenInternalFunctions.java index 13e6c2682f604f49bb56d8555336feb1b4e71c9e..2337d9acc793d8c0243d04f9060db59821296d12 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/HiddenInternalFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/HiddenInternalFunctions.java @@ -345,8 +345,8 @@ public class HiddenInternalFunctions { throw RError.error(Message.GENERIC, "zlib uncompress error"); } int[] intData = new int[2]; - intData[1] = (int) cdatalen[0]; - intData[0] = appendFile(file.getDataAt(0), cdata, intData[1]); + intData[1] = (int) cdatalen[0] + 4; // include outlen + intData[0] = appendFile(file.getDataAt(0), cdata, data.length, (int) cdatalen[0]); return RDataFactory.createIntVector(intData, RDataFactory.COMPLETE_VECTOR); } @@ -356,10 +356,26 @@ public class HiddenInternalFunctions { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_OR_UNIMPLEMENTED_ARGUMENTS); } - private int appendFile(String path, byte[] data, int len) { + /** + * Append the compressed data to {@code path}. N.B The uncompressed length is stored as an + * int in the first four bytes of the data. See {@link LazyLoadDBFetch}. + * + * @param path path of file + * @param data the compressed data + * @param ulen length of uncompressed data + * @param len length of compressed data + * @return offset in file of appended data + */ + private int appendFile(String path, byte[] data, int ulen, int len) { File file = new File(path); try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file, true))) { int result = (int) file.length(); + ByteBuffer dataLengthBuf = ByteBuffer.allocate(4); + dataLengthBuf.putInt(ulen); + dataLengthBuf.position(0); + byte[] ulenData = new byte[4]; + dataLengthBuf.get(ulenData); + out.write(ulenData); out.write(data, 0, len); return result; } catch (IOException ex) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/InfixEmulationFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/InfixEmulationFunctions.java index 4e672d14279c7bd007f01ed643fd52f619d22f30..bb7245b5513f30fba9ab1dbcabe9de578c385f6b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/InfixEmulationFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/InfixEmulationFunctions.java @@ -71,7 +71,7 @@ public class InfixEmulationFunctions { } @ExplodeLoop - public Object execute(VirtualFrame frame, Object vector, Object[] pos, byte exact, Object[] newPos) { + public Object execute(Object vector, Object[] pos, byte exact, Object[] newPos) { Object[] newPositions = newPos; int ind = 0; int i = 0; @@ -80,9 +80,9 @@ public class InfixEmulationFunctions { // RMissing is really "missing" - empty indices are now represented by REmpty continue; } - newPositions[ind] = executeArg(frame, vector, executeConvert(frame, vector, pos[i], exact, i), i); + newPositions[ind] = executeArg(vector, executeConvert(vector, pos[i], exact, i), i); if (multiDimOperatorConverters != null) { - newPositions[ind] = executeMultiConvert(frame, vector, newPositions[ind], ind); + newPositions[ind] = executeMultiConvert(vector, newPositions[ind], ind); } ind++; } @@ -99,7 +99,6 @@ public class InfixEmulationFunctions { public static AccessPositions create(boolean isSubset, int length) { return new AccessPositions(isSubset, length); } - } private static class UpdatePositions extends PositionsArrayConversionValueNodeMultiDimAdapter { @@ -109,11 +108,11 @@ public class InfixEmulationFunctions { } @ExplodeLoop - public Object execute(VirtualFrame frame, Object vector, Object[] pos, Object[] newPositions, Object value) { + public Object execute(Object vector, Object[] pos, Object[] newPositions, Object value) { for (int i = 0; i < getLength(); i++) { - newPositions[i] = executeArg(frame, vector, executeConvert(frame, vector, pos[i], RRuntime.LOGICAL_TRUE, i), i); + newPositions[i] = executeArg(vector, executeConvert(vector, pos[i], RRuntime.LOGICAL_TRUE, i), i); if (multiDimOperatorConverters != null) { - newPositions[i] = executeMultiConvert(frame, vector, value, newPositions[i], i); + newPositions[i] = executeMultiConvert(vector, value, newPositions[i], i); } } if (positionCasts.length == 1) { @@ -126,7 +125,6 @@ public class InfixEmulationFunctions { public static UpdatePositions create(boolean isSubset, int length) { return new UpdatePositions(isSubset, length); } - } @NodeChild(value = "op") @@ -203,7 +201,7 @@ public class InfixEmulationFunctions { positions = insert(AccessPositions.create(isSubset, len)); } Object[] pos = inds.getArguments(); - return accessNode.executeAccess(frame, vector, exact, 0, positions.execute(frame, vector, pos, exact, pos), dropDim); + return accessNode.executeAccess(frame, vector, exact, 0, positions.execute(vector, pos, exact, pos), dropDim); } protected boolean noInd(RArgsValuesAndNames inds) { @@ -476,8 +474,8 @@ public class InfixEmulationFunctions { } else { pos = new Object[]{RMissing.instance}; } - Object newPositions = positions.execute(frame, vector, pos, pos, value); - return updateNode.executeUpdate(frame, vector, value, newPositions, coerceVector.executeEvaluated(frame, value, vector, newPositions)); + Object newPositions = positions.execute(vector, pos, pos, value); + return updateNode.executeUpdate(frame, vector, value, newPositions, coerceVector.executeEvaluated(value, vector, newPositions)); } @SuppressWarnings("unused") @@ -489,7 +487,6 @@ public class InfixEmulationFunctions { protected boolean noInd(RArgsValuesAndNames args) { return args.isEmpty(); } - } @RBuiltin(name = "[<-", kind = RBuiltinKind.PRIMITIVE, parameterNames = {"", "..."}) 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 efa9249f0dadd1101f0b246989d85651f2d7f2ea..f1220dd71cefaa1093a9b31547181f6f3757a7c4 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 @@ -27,14 +27,12 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; -@SuppressWarnings("unused") @RBuiltin(name = "is.na", kind = PRIMITIVE, parameterNames = {"x"}) public abstract class IsNA extends RBuiltinNode { @@ -42,15 +40,15 @@ public abstract class IsNA extends RBuiltinNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - private Object isNARecursive(VirtualFrame frame, Object o) { + private Object isNARecursive(Object o) { if (recursiveIsNA == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); recursiveIsNA = insert(IsNANodeGen.create(new RNode[1], null, null)); } - return recursiveIsNA.execute(frame, o); + return recursiveIsNA.execute(o); } - public abstract Object execute(VirtualFrame frame, Object o); + public abstract Object execute(Object o); @Specialization protected byte isNA(int value) { @@ -112,11 +110,11 @@ public abstract class IsNA extends RBuiltinNode { } @Specialization - protected RLogicalVector isNA(VirtualFrame frame, RList list) { + protected RLogicalVector isNA(RList list) { controlVisibility(); byte[] resultVector = new byte[list.getLength()]; for (int i = 0; i < list.getLength(); i++) { - Object result = isNARecursive(frame, list.getDataAt(i)); + Object result = isNARecursive(list.getDataAt(i)); byte isNAResult; if (result instanceof Byte) { isNAResult = (Byte) result; @@ -161,7 +159,7 @@ public abstract class IsNA extends RBuiltinNode { } @Specialization - protected byte isNA(RNull value) { + protected byte isNA(@SuppressWarnings("unused") RNull value) { controlVisibility(); return RRuntime.LOGICAL_FALSE; } @@ -172,7 +170,7 @@ public abstract class IsNA extends RBuiltinNode { } @Specialization - protected byte isNA(RRaw value) { + protected byte isNA(@SuppressWarnings("unused") RRaw value) { controlVisibility(); return RRuntime.LOGICAL_FALSE; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MakeNames.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MakeNames.java index 0da3716f91ac89aaa8b7a8dbd3c01331731f9dab..462662238227eb667ad8a9ce867b362df3cb8a0d 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MakeNames.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MakeNames.java @@ -26,7 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.source.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; @@ -191,9 +190,9 @@ public abstract class MakeNames extends RBuiltinNode { @Child private CastToVectorNode castVector = CastToVectorNodeGen.create(null, false, false, false, false); @Specialization - protected RAbstractLogicalVector convert(VirtualFrame frame, Object allowUnderScoreArg) { + protected RAbstractLogicalVector convert(Object allowUnderScoreArg) { try { - return (RLogicalVector) castLogical.executeCast(frame, castVector.executeCast(frame, allowUnderScoreArg)); + return (RLogicalVector) castLogical.executeCast(castVector.executeCast(allowUnderScoreArg)); } catch (RError x) { throw invalidAllowValue(getEncapsulatingSourceSection()); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MatMult.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MatMult.java index 7f2a02d4c5ef297a8563db203f2db67f15bab0e8..88e0770f0eef325b8e8ba7a4c9ec6a4df73b6ed8 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MatMult.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/MatMult.java @@ -25,7 +25,6 @@ package com.oracle.truffle.r.nodes.builtin.base; import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.binary.*; import com.oracle.truffle.r.nodes.builtin.*; @@ -49,7 +48,7 @@ public abstract class MatMult extends RBuiltinNode { private final ConditionProfile notOneRow = ConditionProfile.createBinaryProfile(); private final ConditionProfile notOneColumn = ConditionProfile.createBinaryProfile(); - protected abstract Object executeObject(VirtualFrame frame, Object a, Object b); + protected abstract Object executeObject(Object a, Object b); private final NACheck na; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Match.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Match.java index d66b5c109a6e7dd3d838ab832678cc03ce4f5454..d91a69d472cc324be1470c4a9d67f911ecdc521b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Match.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Match.java @@ -55,20 +55,20 @@ public abstract class Match extends RBuiltinNode { private final ConditionProfile bigTableProfile = ConditionProfile.createBinaryProfile(); private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - private String castString(VirtualFrame frame, Object operand) { + private String castString(Object operand) { if (castString == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castString = insert(CastStringNodeGen.create(null, false, false, false, false)); } - return (String) castString.executeCast(frame, operand); + return (String) castString.executeCast(operand); } - private int castInt(VirtualFrame frame, Object operand) { + private int castInt(Object operand) { if (castInt == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castInt = insert(CastIntegerNodeGen.create(null, false, false, false)); } - return (int) castInt.executeCast(frame, operand); + return (int) castInt.executeCast(operand); } private RIntVector matchRecursive(VirtualFrame frame, Object x, Object table, Object noMatch, Object incomparables) { @@ -102,9 +102,9 @@ public abstract class Match extends RBuiltinNode { @Specialization @SuppressWarnings("unused") - protected RIntVector match(VirtualFrame frame, RAbstractIntVector x, RAbstractIntVector table, Object nomatchObj, Object incomparables) { + protected RIntVector match(RAbstractIntVector x, RAbstractIntVector table, Object nomatchObj, Object incomparables) { controlVisibility(); - int nomatch = castInt(frame, nomatchObj); + int nomatch = castInt(nomatchObj); int[] result = initResult(x.getLength(), nomatch); boolean matchAll = true; NonRecursiveHashMapInt hashTable; @@ -140,9 +140,9 @@ public abstract class Match extends RBuiltinNode { @Specialization @SuppressWarnings("unused") - protected RIntVector match(VirtualFrame frame, RAbstractDoubleVector x, RAbstractIntVector table, Object nomatchObj, Object incomparables) { + protected RIntVector match(RAbstractDoubleVector x, RAbstractIntVector table, Object nomatchObj, Object incomparables) { controlVisibility(); - int nomatch = castInt(frame, nomatchObj); + int nomatch = castInt(nomatchObj); int[] result = initResult(x.getLength(), nomatch); boolean matchAll = true; NonRecursiveHashMapDouble hashTable; @@ -178,9 +178,9 @@ public abstract class Match extends RBuiltinNode { @Specialization @SuppressWarnings("unused") - protected RIntVector match(VirtualFrame frame, RAbstractIntVector x, RAbstractDoubleVector table, Object nomatchObj, Object incomparables) { + protected RIntVector match(RAbstractIntVector x, RAbstractDoubleVector table, Object nomatchObj, Object incomparables) { controlVisibility(); - int nomatch = castInt(frame, nomatchObj); + int nomatch = castInt(nomatchObj); int[] result = initResult(x.getLength(), nomatch); boolean matchAll = true; NonRecursiveHashMapInt hashTable; @@ -223,9 +223,9 @@ public abstract class Match extends RBuiltinNode { @Specialization @SuppressWarnings("unused") - protected RIntVector match(VirtualFrame frame, RAbstractDoubleVector x, RAbstractDoubleVector table, Object nomatchObj, Object incomparables) { + protected RIntVector match(RAbstractDoubleVector x, RAbstractDoubleVector table, Object nomatchObj, Object incomparables) { controlVisibility(); - int nomatch = castInt(frame, nomatchObj); + int nomatch = castInt(nomatchObj); int[] result = initResult(x.getLength(), nomatch); boolean matchAll = true; NonRecursiveHashMapDouble hashTable; @@ -261,9 +261,9 @@ public abstract class Match extends RBuiltinNode { @Specialization() @SuppressWarnings("unused") - protected RIntVector match(VirtualFrame frame, RAbstractIntVector x, RAbstractLogicalVector table, Object nomatchObj, Object incomparables) { + protected RIntVector match(RAbstractIntVector x, RAbstractLogicalVector table, Object nomatchObj, Object incomparables) { controlVisibility(); - int nomatch = castInt(frame, nomatchObj); + int nomatch = castInt(nomatchObj); int[] result = initResult(x.getLength(), nomatch); boolean matchAll = true; int[] values = {RRuntime.LOGICAL_TRUE, RRuntime.LOGICAL_FALSE, RRuntime.LOGICAL_NA}; @@ -294,9 +294,9 @@ public abstract class Match extends RBuiltinNode { } @Specialization - protected RIntVector match(VirtualFrame frame, RAbstractStringVector x, RAbstractStringVector table, Object nomatchObj, @SuppressWarnings("unused") Object incomparables) { + protected RIntVector match(RAbstractStringVector x, RAbstractStringVector table, Object nomatchObj, @SuppressWarnings("unused") Object incomparables) { controlVisibility(); - int nomatch = castInt(frame, nomatchObj); + int nomatch = castInt(nomatchObj); int[] result = initResult(x.getLength(), nomatch); boolean matchAll = true; NonRecursiveHashMapCharacter hashTable; @@ -331,16 +331,16 @@ public abstract class Match extends RBuiltinNode { } @Specialization - protected RIntVector match(VirtualFrame frame, RAbstractLogicalVector x, RAbstractStringVector table, Object nomatchObj, Object incomparables) { + protected RIntVector match(RAbstractLogicalVector x, RAbstractStringVector table, Object nomatchObj, Object incomparables) { naCheck.enable(x); - return match(frame, RClosures.createLogicalToStringVector(x), table, nomatchObj, incomparables); + return match(RClosures.createLogicalToStringVector(x), table, nomatchObj, incomparables); } @Specialization @SuppressWarnings("unused") - protected RIntVector match(VirtualFrame frame, RAbstractLogicalVector x, RAbstractLogicalVector table, Object nomatchObj, Object incomparables) { + protected RIntVector match(RAbstractLogicalVector x, RAbstractLogicalVector table, Object nomatchObj, Object incomparables) { controlVisibility(); - int nomatch = castInt(frame, nomatchObj); + int nomatch = castInt(nomatchObj); int[] result = initResult(x.getLength(), nomatch); boolean matchAll = true; byte[] values = {RRuntime.LOGICAL_TRUE, RRuntime.LOGICAL_FALSE, RRuntime.LOGICAL_NA}; @@ -371,14 +371,14 @@ public abstract class Match extends RBuiltinNode { @Specialization(guards = "!isStringVectorTable(table)") @SuppressWarnings("unused") - protected RIntVector match(VirtualFrame frame, RAbstractStringVector x, RAbstractVector table, Object nomatchObj, Object incomparables) { + protected RIntVector match(RAbstractStringVector x, RAbstractVector table, Object nomatchObj, Object incomparables) { controlVisibility(); - int nomatch = castInt(frame, nomatchObj); + int nomatch = castInt(nomatchObj); int[] result = initResult(x.getLength(), nomatch); boolean matchAll = true; NonRecursiveHashMapCharacter hashTable = new NonRecursiveHashMapCharacter(table.getLength()); for (int i = table.getLength() - 1; i >= 0; i--) { - hashTable.put(castString(frame, table.getDataAtAsObject(i)), i); + hashTable.put(castString(table.getDataAtAsObject(i)), i); } for (int i = 0; i < result.length; i++) { String xx = x.getDataAt(i); @@ -394,9 +394,9 @@ public abstract class Match extends RBuiltinNode { @Specialization @SuppressWarnings("unused") - protected RIntVector match(VirtualFrame frame, RAbstractComplexVector x, RAbstractComplexVector table, Object nomatchObj, Object incomparables) { + protected RIntVector match(RAbstractComplexVector x, RAbstractComplexVector table, Object nomatchObj, Object incomparables) { controlVisibility(); - int nomatch = castInt(frame, nomatchObj); + int nomatch = castInt(nomatchObj); int[] result = initResult(x.getLength(), nomatch); boolean matchAll = true; NonRecursiveHashMapComplex hashTable; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Matrix.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Matrix.java index 5e9fb6a9e70a872e1ab72aedf3efeb385bda7d3d..818d939111a058605ed800c4acd4ec41f1849608 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Matrix.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Matrix.java @@ -26,7 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; @@ -46,12 +45,12 @@ public abstract class Matrix extends RBuiltinNode { private final BinaryConditionProfile bothNrowNcolMissing = (BinaryConditionProfile) ConditionProfile.createBinaryProfile(); private final BinaryConditionProfile empty = (BinaryConditionProfile) ConditionProfile.createBinaryProfile(); - private RAbstractVector updateDimNames(VirtualFrame frame, RAbstractVector vector, Object o) { + private RAbstractVector updateDimNames(RAbstractVector vector, Object o) { if (updateDimNames == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); updateDimNames = insert(UpdateDimNamesNodeGen.create(new RNode[2], null, null)); } - return (RAbstractVector) updateDimNames.executeRAbstractContainer(frame, vector, o); + return (RAbstractVector) updateDimNames.executeRAbstractContainer(vector, o); } @CreateCast("arguments") @@ -81,7 +80,7 @@ public abstract class Matrix extends RBuiltinNode { @Specialization(guards = "!isTrue(byrow)") @SuppressWarnings("unused") - protected RAbstractVector matrixbc(VirtualFrame frame, RAbstractVector data, int nrow, int ncol, byte byrow, RList dimnames, byte missingNr, byte missingNc) { + protected RAbstractVector matrixbc(RAbstractVector data, int nrow, int ncol, byte byrow, RList dimnames, byte missingNr, byte missingNc) { int[] dim = computeDimByCol(data.getLength(), nrow, ncol, missingNr, missingNc); RAbstractVector res; if (empty.profile(data.getLength() == 0)) { @@ -89,7 +88,7 @@ public abstract class Matrix extends RBuiltinNode { res.setDimensions(dim); } else { res = data.copyResizedWithDimensions(dim); - res = updateDimNames(frame, res, dimnames); + res = updateDimNames(res, dimnames); } controlVisibility(); return res; @@ -97,7 +96,7 @@ public abstract class Matrix extends RBuiltinNode { @Specialization(guards = "isTrue(byrow)") @SuppressWarnings("unused") - protected RAbstractVector matrixbr(VirtualFrame frame, RAbstractVector data, int nrow, int ncol, byte byrow, RNull dimnames, byte missingNr, byte missingNc) { + protected RAbstractVector matrixbr(RAbstractVector data, int nrow, int ncol, byte byrow, RNull dimnames, byte missingNr, byte missingNc) { controlVisibility(); int[] dim = computeDimByRow(data.getLength(), nrow, ncol, missingNr, missingNc); if (transpose == null) { @@ -111,12 +110,12 @@ public abstract class Matrix extends RBuiltinNode { } else { res = data.copyResizedWithDimensions(dim); } - return (RAbstractVector) transpose.execute(frame, res); + return (RAbstractVector) transpose.execute(res); } @Specialization(guards = "isTrue(byrow)") @SuppressWarnings("unused") - protected RAbstractVector matrixbr(VirtualFrame frame, RAbstractVector data, int nrow, int ncol, byte byrow, RList dimnames, byte missingNr, byte missingNc) { + protected RAbstractVector matrixbr(RAbstractVector data, int nrow, int ncol, byte byrow, RList dimnames, byte missingNr, byte missingNc) { int[] dim = computeDimByRow(data.getLength(), nrow, ncol, missingNr, missingNc); if (transpose == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -128,8 +127,8 @@ public abstract class Matrix extends RBuiltinNode { res.setDimensions(dim); } else { - res = (RVector) transpose.execute(frame, data.copyResizedWithDimensions(dim)); - res = updateDimNames(frame, res, dimnames); + res = (RVector) transpose.execute(data.copyResizedWithDimensions(dim)); + res = updateDimNames(res, dimnames); } controlVisibility(); return res; @@ -205,5 +204,4 @@ public abstract class Matrix extends RBuiltinNode { protected static boolean isTrue(byte byrow) { return RRuntime.fromLogical(byrow); } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java index 06885670bc9a4aff778a538394313da137e13d36..ded57e3688d09565b1553220819c95119c922b85 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java @@ -41,13 +41,13 @@ public abstract class NChar extends RBuiltinNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - private String coerceContent(VirtualFrame frame, Object content) { + private String coerceContent(Object content) { if (convertString == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); convertString = insert(CastStringNodeGen.create(null, false, false, false, false)); } try { - return (String) convertString.executeString(frame, content); + return (String) convertString.executeString(content); } catch (ConversionFailedException e) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.TYPE_EXPECTED, RType.Character.getName()); } @@ -62,23 +62,23 @@ public abstract class NChar extends RBuiltinNode { @SuppressWarnings("unused") @Specialization - protected int nchar(VirtualFrame frame, int value, String type, byte allowNA) { + protected int nchar(int value, String type, byte allowNA) { controlVisibility(); - return coerceContent(frame, value).length(); + return coerceContent(value).length(); } @SuppressWarnings("unused") @Specialization - protected int nchar(VirtualFrame frame, double value, String type, byte allowNA) { + protected int nchar(double value, String type, byte allowNA) { controlVisibility(); - return coerceContent(frame, value).length(); + return coerceContent(value).length(); } @SuppressWarnings("unused") @Specialization - protected int nchar(VirtualFrame frame, byte value, String type, byte allowNA) { + protected int nchar(byte value, String type, byte allowNA) { controlVisibility(); - return coerceContent(frame, value).length(); + return coerceContent(value).length(); } @SuppressWarnings("unused") @@ -109,7 +109,7 @@ public abstract class NChar extends RBuiltinNode { @SuppressWarnings("unused") @Fallback - protected RIntVector nchar(VirtualFrame frame, Object obj, Object type, Object allowNA) { + protected RIntVector nchar(Object obj, Object type, Object allowNA) { controlVisibility(); if (obj instanceof RFactor) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.REQUIRES_CHAR_VECTOR, "nchar"); @@ -119,7 +119,7 @@ public abstract class NChar extends RBuiltinNode { int len = vector.getLength(); int[] result = new int[len]; for (int i = 0; i < len; i++) { - result[i] = coerceContent(frame, vector.getDataAtAsObject(i)).length(); + result[i] = coerceContent(vector.getDataAtAsObject(i)).length(); } return RDataFactory.createIntVector(result, vector.isComplete(), vector.getNames(attrProfiles)); } else { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NZChar.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NZChar.java index 11fbd683e1950db5666fedb7a0717eff78ab1f66..c84f174e43c4d1aa4813ea6d7c18ac3198953278 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NZChar.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/NZChar.java @@ -37,13 +37,13 @@ import com.oracle.truffle.r.runtime.data.model.*; public abstract class NZChar extends RBuiltinNode { @Child private CastStringNode convertString; - private String coerceContent(VirtualFrame frame, Object content) { + private String coerceContent(Object content) { if (convertString == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); convertString = insert(CastStringNodeGen.create(null, false, true, false, false)); } try { - return (String) convertString.executeCast(frame, content); + return (String) convertString.executeCast(content); } catch (ConversionFailedException e) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.TYPE_EXPECTED, RType.Character.getName()); } @@ -61,21 +61,21 @@ public abstract class NZChar extends RBuiltinNode { } @Specialization - protected byte rev(VirtualFrame frame, int value) { + protected byte rev(int value) { controlVisibility(); - return isNonZeroLength(coerceContent(frame, value)); + return isNonZeroLength(coerceContent(value)); } @Specialization - protected byte rev(VirtualFrame frame, double value) { + protected byte rev(double value) { controlVisibility(); - return isNonZeroLength(coerceContent(frame, value)); + return isNonZeroLength(coerceContent(value)); } @Specialization - protected byte rev(VirtualFrame frame, byte value) { + protected byte rev(byte value) { controlVisibility(); - return isNonZeroLength(coerceContent(frame, value)); + return isNonZeroLength(coerceContent(value)); } @Specialization @@ -90,14 +90,13 @@ public abstract class NZChar extends RBuiltinNode { } @Specialization - protected RLogicalVector rev(VirtualFrame frame, RAbstractVector vector) { + protected RLogicalVector rev(RAbstractVector vector) { controlVisibility(); int len = vector.getLength(); byte[] result = new byte[len]; for (int i = 0; i < len; i++) { - result[i] = isNonZeroLength(coerceContent(frame, vector.getDataAtAsObject(i))); + result[i] = isNonZeroLength(coerceContent(vector.getDataAtAsObject(i))); } return RDataFactory.createLogicalVector(result, RDataFactory.COMPLETE_VECTOR); } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Order.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Order.java index 168f1b41fd0aa9a0532f62871b039421017399f3..a2f9f24870ae2a875bc3e746e164a04c93049937 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Order.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Order.java @@ -40,12 +40,12 @@ public abstract class Order extends RPrecedenceBuiltinNode { private static final int[] SINCS = {1073790977, 268460033, 67121153, 16783361, 4197377, 1050113, 262913, 65921, 16577, 4193, 1073, 281, 77, 23, 8, 1, 0}; - private RAbstractVector castVector(VirtualFrame frame, Object value) { + private RAbstractVector castVector(Object value) { if (castVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVector = insert(CastToVectorNodeGen.create(null, false, false, false, false)); } - return (RAbstractVector) castVector.executeObject(frame, value); + return (RAbstractVector) castVector.executeObject(value); } private int cmp(VirtualFrame frame, Object v, int i, int j, byte naLast) { @@ -63,9 +63,9 @@ public abstract class Order extends RPrecedenceBuiltinNode { } @Specialization(guards = {"oneVec(args)", "isFirstIntegerPrecedence(args)"}) - Object orderInt(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { + Object orderInt(RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { Object[] vectors = args.getArguments(); - RAbstractIntVector v = (RAbstractIntVector) castVector(frame, vectors[0]); + RAbstractIntVector v = (RAbstractIntVector) castVector(vectors[0]); int n = v.getLength(); boolean naLast = true; @@ -91,9 +91,9 @@ public abstract class Order extends RPrecedenceBuiltinNode { } @Specialization(guards = {"oneVec(args)", "isFirstDoublePrecedence(args)"}) - Object orderDouble(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { + Object orderDouble(RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { Object[] vectors = args.getArguments(); - RAbstractDoubleVector v = (RAbstractDoubleVector) castVector(frame, vectors[0]); + RAbstractDoubleVector v = (RAbstractDoubleVector) castVector(vectors[0]); int n = v.getLength(); boolean naLast = true; @@ -119,16 +119,16 @@ public abstract class Order extends RPrecedenceBuiltinNode { } @Specialization(guards = {"oneVec(args)", "isFirstLogicalPrecedence(args)"}) - Object orderLogical(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { + Object orderLogical(RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { Object[] vectors = args.getArguments(); - vectors[0] = RClosures.createLogicalToIntVector((RAbstractLogicalVector) castVector(frame, vectors[0])); - return orderInt(frame, naLastVec, decVec, args); + vectors[0] = RClosures.createLogicalToIntVector((RAbstractLogicalVector) castVector(vectors[0])); + return orderInt(naLastVec, decVec, args); } @Specialization(guards = {"oneVec(args)", "isFirstStringPrecedence(args)"}) - Object orderString(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { + Object orderString(RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { Object[] vectors = args.getArguments(); - RAbstractStringVector v = (RAbstractStringVector) castVector(frame, vectors[0]); + RAbstractStringVector v = (RAbstractStringVector) castVector(vectors[0]); int n = v.getLength(); boolean naLast = true; @@ -154,9 +154,9 @@ public abstract class Order extends RPrecedenceBuiltinNode { } @Specialization(guards = {"oneVec(args)", "isFirstComplexPrecedence( args)"}) - Object orderComplex(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { + Object orderComplex(RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { Object[] vectors = args.getArguments(); - RAbstractComplexVector v = (RAbstractComplexVector) castVector(frame, vectors[0]); + RAbstractComplexVector v = (RAbstractComplexVector) castVector(vectors[0]); int n = v.getLength(); boolean naLast = true; @@ -181,13 +181,13 @@ public abstract class Order extends RPrecedenceBuiltinNode { return RDataFactory.createIntVector(indx, RDataFactory.COMPLETE_VECTOR); } - private int preprocessVectors(VirtualFrame frame, RArgsValuesAndNames args) { + private int preprocessVectors(RArgsValuesAndNames args) { Object[] vectors = args.getArguments(); - RAbstractVector v = castVector(frame, vectors[0]); + RAbstractVector v = castVector(vectors[0]); int n = v.getLength(); vectors[0] = v; for (int i = 1; i < vectors.length; i++) { - v = castVector(frame, vectors[i]); + v = castVector(vectors[i]); if (n != v.getLength()) { error.enter(); throw RError.error(RError.Message.ARGUMENT_LENGTHS_DIFFER); @@ -199,7 +199,7 @@ public abstract class Order extends RPrecedenceBuiltinNode { @Specialization(guards = {"!oneVec(args)", "!noVec(args)"}) Object orderMulti(VirtualFrame frame, RAbstractLogicalVector naLastVec, RAbstractLogicalVector decVec, RArgsValuesAndNames args) { - int n = preprocessVectors(frame, args); + int n = preprocessVectors(args); byte naLast = RRuntime.LOGICAL_TRUE; boolean dec = true; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PMinMax.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PMinMax.java index a7c41366377410d13062a74cba236340360f7aff..619cd3dfbf9453ec1a7d3ec6801dbcd33151ee6b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PMinMax.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PMinMax.java @@ -26,7 +26,6 @@ import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; @@ -64,20 +63,20 @@ public abstract class PMinMax extends RBuiltinNode { this(other.semantics, other.factory); } - private byte handleString(VirtualFrame frame, Object[] argValues, byte naRm, int offset, int ind, int maxLength, byte warning, Object data) { + private byte handleString(Object[] argValues, byte naRm, int offset, int ind, int maxLength, byte warning, Object data) { if (stringHandler == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); stringHandler = insert(MultiElemStringHandlerNodeGen.create(semantics, factory, na, null, null, null, null, null, null, null)); } - return stringHandler.executeByte(frame, argValues, naRm, offset, ind, maxLength, warning, data); + return stringHandler.executeByte(argValues, naRm, offset, ind, maxLength, warning, data); } - private RAbstractVector castVector(VirtualFrame frame, Object value) { + private RAbstractVector castVector(Object value) { if (castVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVector = insert(CastToVectorNodeGen.create(null, true, true, true, false)); } - return ((RAbstractVector) castVector.executeObject(frame, value)).materialize(); + return ((RAbstractVector) castVector.executeObject(value)).materialize(); } private CastNode getIntegerCastNode() { @@ -104,11 +103,11 @@ public abstract class PMinMax extends RBuiltinNode { return castString; } - private int convertToVectorAndEnableNACheck(VirtualFrame frame, RArgsValuesAndNames args, CastNode castNode) { + private int convertToVectorAndEnableNACheck(RArgsValuesAndNames args, CastNode castNode) { int length = 0; Object[] argValues = args.getArguments(); for (int i = 0; i < args.getLength(); i++) { - RAbstractVector v = castVector(frame, argValues[i]); + RAbstractVector v = castVector(argValues[i]); na.enable(v); int vecLength = v.getLength(); if (vecLength == 0) { @@ -116,19 +115,19 @@ public abstract class PMinMax extends RBuiltinNode { return vecLength; } length = Math.max(length, vecLength); - argValues[i] = castNode.executeCast(frame, v); + argValues[i] = castNode.executeCast(v); } return length; } @Specialization(guards = {"isIntegerPrecedence(args)", "oneVector(args)"}) - protected Object pMinMaxOneVecInt(@SuppressWarnings("unused") VirtualFrame frame, @SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + protected Object pMinMaxOneVecInt(@SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { return args.getArgument(0); } @Specialization(guards = {"isIntegerPrecedence(args)", "!oneVector(args)"}) - protected RIntVector pMinMaxInt(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { - int maxLength = convertToVectorAndEnableNACheck(frame, args, getIntegerCastNode()); + protected RIntVector pMinMaxInt(byte naRm, RArgsValuesAndNames args) { + int maxLength = convertToVectorAndEnableNACheck(args, getIntegerCastNode()); if (lengthProfile.profile(maxLength == 0)) { return RDataFactory.createEmptyIntVector(); } else { @@ -164,24 +163,24 @@ public abstract class PMinMax extends RBuiltinNode { } @Specialization(guards = {"isLogicalPrecedence(args)", "oneVector(args)"}) - protected Object pMinMaxOneVecLogical(@SuppressWarnings("unused") VirtualFrame frame, @SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { + protected Object pMinMaxOneVecLogical(@SuppressWarnings("unused") byte naRm, RArgsValuesAndNames args) { return args.getArgument(0); } @Specialization(guards = {"isLogicalPrecedence(args)", "!oneVector(args)"}) - protected RIntVector pMinMaxLogical(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { - return pMinMaxInt(frame, naRm, args); + protected RIntVector pMinMaxLogical(byte naRm, RArgsValuesAndNames args) { + return pMinMaxInt(naRm, args); } @Specialization(guards = {"isDoublePrecedence(args)", "oneVector(args)"}) @SuppressWarnings("unused") - protected Object pMinMaxOneVecDouble(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { + protected Object pMinMaxOneVecDouble(byte naRm, RArgsValuesAndNames args) { return args.getArgument(0); } @Specialization(guards = {"isDoublePrecedence(args)", "!oneVector(args)"}) - protected RDoubleVector pMinMaxDouble(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { - int maxLength = convertToVectorAndEnableNACheck(frame, args, getDoubleCastNode()); + protected RDoubleVector pMinMaxDouble(byte naRm, RArgsValuesAndNames args) { + int maxLength = convertToVectorAndEnableNACheck(args, getDoubleCastNode()); if (lengthProfile.profile(maxLength == 0)) { return RDataFactory.createEmptyDoubleVector(); } else { @@ -218,13 +217,13 @@ public abstract class PMinMax extends RBuiltinNode { @Specialization(guards = {"isStringPrecedence(args)", "oneVector(args)"}) @SuppressWarnings("unused") - protected Object pMinMaxOneVecString(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { + protected Object pMinMaxOneVecString(byte naRm, RArgsValuesAndNames args) { return args.getArgument(0); } @Specialization(guards = {"isStringPrecedence(args)", "!oneVector(args)"}) - protected RStringVector pMinMaxString(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { - int maxLength = convertToVectorAndEnableNACheck(frame, args, getStringCastNode()); + protected RStringVector pMinMaxString(byte naRm, RArgsValuesAndNames args) { + int maxLength = convertToVectorAndEnableNACheck(args, getStringCastNode()); if (lengthProfile.profile(maxLength == 0)) { return RDataFactory.createEmptyStringVector(); } else { @@ -233,7 +232,7 @@ public abstract class PMinMax extends RBuiltinNode { Object[] argValues = args.getArguments(); byte warningAdded = RRuntime.LOGICAL_FALSE; for (int i = 0; i < maxLength; i++) { - warningAdded = handleString(frame, argValues, naRm, 0, i, maxLength, warningAdded, data); + warningAdded = handleString(argValues, naRm, 0, i, maxLength, warningAdded, data); } return RDataFactory.createStringVector(data, na.neverSeenNA() || profiledNaRm); } @@ -241,13 +240,13 @@ public abstract class PMinMax extends RBuiltinNode { @SuppressWarnings("unused") @Specialization(guards = "isComplexPrecedence(args)") - protected RComplexVector pMinMaxComplex(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { + protected RComplexVector pMinMaxComplex(byte naRm, RArgsValuesAndNames args) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_INPUT_TYPE); } @SuppressWarnings("unused") @Specialization(guards = "isRawPrecedence(args)") - protected RRawVector pMinMaxRaw(VirtualFrame frame, byte naRm, RArgsValuesAndNames args) { + protected RRawVector pMinMaxRaw(byte naRm, RArgsValuesAndNames args) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_INPUT_TYPE); } @@ -311,7 +310,7 @@ public abstract class PMinMax extends RBuiltinNode { @NodeChildren({@NodeChild("argValues"), @NodeChild("naRm"), @NodeChild("offset"), @NodeChild("ind"), @NodeChild("maxLength"), @NodeChild("warning"), @NodeChild("data")}) protected abstract static class MultiElemStringHandler extends RNode { - public abstract byte executeByte(VirtualFrame frame, Object[] argValues, byte naRm, int offset, int ind, int maxLength, byte warning, Object data); + public abstract byte executeByte(Object[] argValues, byte naRm, int offset, int ind, int maxLength, byte warning, Object data); @Child private MultiElemStringHandler recursiveStringHandler; private final ReduceSemantics semantics; @@ -331,16 +330,16 @@ public abstract class PMinMax extends RBuiltinNode { this(other.semantics, other.factory, other.na); } - private byte handleString(VirtualFrame frame, Object[] argValues, byte naRm, int offset, int ind, int maxLength, byte warning, Object data) { + private byte handleString(Object[] argValues, byte naRm, int offset, int ind, int maxLength, byte warning, Object data) { if (recursiveStringHandler == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); recursiveStringHandler = insert(MultiElemStringHandlerNodeGen.create(semantics, factory, na, null, null, null, null, null, null, null)); } - return recursiveStringHandler.executeByte(frame, argValues, naRm, offset, ind, maxLength, warning, data); + return recursiveStringHandler.executeByte(argValues, naRm, offset, ind, maxLength, warning, data); } @Specialization - protected byte doStringVectorMultiElem(VirtualFrame frame, Object[] argValues, byte naRm, int offset, int ind, int maxLength, byte warning, Object d) { + protected byte doStringVectorMultiElem(Object[] argValues, byte naRm, int offset, int ind, int maxLength, byte warning, Object d) { String[] data = (String[]) d; byte warningAdded = warning; RAbstractStringVector vec = (RAbstractStringVector) argValues[offset]; @@ -357,7 +356,7 @@ public abstract class PMinMax extends RBuiltinNode { // last element - all other are NAs data[ind] = semantics.getStringStart(); } else { - return handleString(frame, argValues, naRm, offset + 1, ind, maxLength, warningAdded, data); + return handleString(argValues, naRm, offset + 1, ind, maxLength, warningAdded, data); } return warningAdded; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java index 561d51157d791da4db6481bb2760fd3f987fc01b..1a822bf471f98ffd16bcf7ef5ef844ca616ddcbc 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java @@ -29,7 +29,6 @@ import java.io.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.nodes.*; import com.oracle.truffle.api.source.*; import com.oracle.truffle.r.nodes.builtin.*; @@ -77,39 +76,39 @@ public abstract class Parse extends RBuiltinNode { @Child private CastStringNode castStringNode; @Child private CastToVectorNode castVectorNode; - private int castInt(VirtualFrame frame, Object n) { + private int castInt(Object n) { if (castIntNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castIntNode = insert(CastIntegerNodeGen.create(null, false, false, false)); } - int result = (int) castIntNode.executeInt(frame, n); + int result = (int) castIntNode.executeInt(n); if (RRuntime.isNA(result)) { result = -1; } return result; } - private RStringVector castString(VirtualFrame frame, Object s) { + private RStringVector castString(Object s) { if (castStringNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVectorNode = insert(CastToVectorNodeGen.create(null, false, false, false, false)); castStringNode = insert(CastStringNodeGen.create(null, false, false, false, false)); } - return (RStringVector) castStringNode.executeString(frame, castVectorNode.executeObject(frame, s)); + return (RStringVector) castStringNode.executeString(castVectorNode.executeObject(s)); } @Specialization - protected Object parse(VirtualFrame frame, RConnection conn, Object n, Object text, RAbstractStringVector prompt, Object srcFile, RAbstractStringVector encoding) { + protected Object parse(RConnection conn, Object n, Object text, RAbstractStringVector prompt, Object srcFile, RAbstractStringVector encoding) { controlVisibility(); int nAsInt; if (n != RNull.instance) { - nAsInt = castInt(frame, n); + nAsInt = castInt(n); } else { nAsInt = -1; } Object textVec = text; if (textVec != RNull.instance) { - textVec = castString(frame, textVec); + textVec = castString(textVec); } return doParse(conn, nAsInt, textVec, prompt, srcFile, encoding); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Paste.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Paste.java index a71e8ea0c1e38c083740c67ad2b6f97e0a88b2d1..a300bcbf787191cfe4b8b74dc27f5ac9396e80bf 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Paste.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Paste.java @@ -71,12 +71,12 @@ public abstract class Paste extends RBuiltinNode { * there are problem using it here, so we retain the previous implementation that just uses * {@link CastStringNode}. */ - private RStringVector castCharacterVector(VirtualFrame frame, Object o) { + private RStringVector castCharacterVector(Object o) { if (castCharacterNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castCharacterNode = insert(CastStringNodeGen.create(null, false, true, false, false)); } - Object ret = castCharacterNode.executeString(frame, o); + Object ret = castCharacterNode.executeString(o); if (ret instanceof String) { return RDataFactory.createStringVector((String) ret); } else { @@ -102,7 +102,7 @@ public abstract class Paste extends RBuiltinNode { Object element = values.getDataAt(i); String[] array; if (vectorOrSequence.profile(element instanceof RVector || element instanceof RSequence)) { - array = castCharacterVector(frame, element).getDataWithoutCopying(); + array = castCharacterVector(element).getDataWithoutCopying(); } else { array = castCharacter(frame, element).getDataWithoutCopying(); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Paste0.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Paste0.java index 1d8524011e050e8901c1cbfa78f2e99cddb30c24..110813bf4590538d36532a1bc8961dffaea4791d 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Paste0.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Paste0.java @@ -54,5 +54,4 @@ public abstract class Paste0 extends RBuiltinNode { controlVisibility(); return paste(frame, values, collapse); } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PrettyPrinterNode.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PrettyPrinterNode.java index b940d9e28c3a1a1903b92d688bfa71eb8c7d490a..c1b98dc20a284210f351a89b10545225ead3c391 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PrettyPrinterNode.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/PrettyPrinterNode.java @@ -1169,7 +1169,7 @@ public abstract class PrettyPrinterNode extends RNode { // TODO: this should be handled by an S3 function @Specialization - protected String prettyPrintListElement(VirtualFrame frame, RFactor operand, Object listElementName, byte quote, byte right) { + protected String prettyPrintListElement(RFactor operand, Object listElementName, byte quote, byte right) { RVector vec = operand.getLevels(attrProfiles); String[] strings; if (vec == null) { @@ -1178,7 +1178,7 @@ public abstract class PrettyPrinterNode extends RNode { initCast(); strings = new String[vec.getLength()]; for (int i = 0; i < vec.getLength(); i++) { - strings[i] = (String) castStringNode.executeString(frame, vec.getDataAtAsObject(i)); + strings[i] = (String) castStringNode.executeString(vec.getDataAtAsObject(i)); } } return formatLevelStrings(operand, listElementName, right, vec, strings); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Scan.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Scan.java index eca05ae4b1fa5f13b053001a58613dc3344d917e..752a08c18b4265e93ed553fd143f0aeda368c140 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Scan.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Scan.java @@ -47,12 +47,12 @@ public abstract class Scan extends RBuiltinNode { @Child private CastToVectorNode castVector; - private RAbstractVector castVector(VirtualFrame frame, Object value) { + private RAbstractVector castVector(Object value) { if (castVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVector = insert(CastToVectorNodeGen.create(null, false, false, false, false)); } - return ((RAbstractVector) castVector.executeObject(frame, value)).materialize(); + return ((RAbstractVector) castVector.executeObject(value)).materialize(); } private static class LocalData { @@ -380,7 +380,7 @@ public abstract class Scan extends RBuiltinNode { errorProfile.enter(); throw RError.error(RError.Message.INVALID_ARGUMENT, "what"); } else { - RAbstractVector vec = castVector(frame, what.getDataAt(i)); + RAbstractVector vec = castVector(what.getDataAt(i)); list.updateDataAt(i, vec.createEmptySameType(blockSize, RDataFactory.COMPLETE_VECTOR), null); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Split.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Split.java index 95cc940394f5725b81f69f2f4706444e61f3ba2a..3cb6d370c0c213428fb9e4e8cac450ce22fd7752 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Split.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Split.java @@ -28,7 +28,6 @@ import java.util.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; @@ -54,7 +53,7 @@ public abstract class Split extends RBuiltinNode { private static final int SCALE_FACTOR = 2; @Specialization - protected RList split(VirtualFrame frame, RAbstractIntVector x, RFactor f) { + protected RList split(RAbstractIntVector x, RFactor f) { int[] factor = f.getVector().getDataWithoutCopying(); final int nLevels = f.getNLevels(attrProfiles); @@ -82,11 +81,11 @@ public abstract class Split extends RBuiltinNode { results[i] = RDataFactory.createIntVector(Arrays.copyOfRange(collectResults[i], 0, collectResultSize[i]), x.isComplete()); } - return RDataFactory.createList(results, makeNames(frame, f)); + return RDataFactory.createList(results, makeNames(f)); } @Specialization - protected RList split(VirtualFrame frame, RAbstractDoubleVector x, RFactor f) { + protected RList split(RAbstractDoubleVector x, RFactor f) { int[] factor = f.getVector().getDataWithoutCopying(); final int nLevels = f.getNLevels(attrProfiles); @@ -114,11 +113,11 @@ public abstract class Split extends RBuiltinNode { results[i] = RDataFactory.createDoubleVector(Arrays.copyOfRange(collectResults[i], 0, collectResultSize[i]), RDataFactory.COMPLETE_VECTOR); } - return RDataFactory.createList(results, makeNames(frame, f)); + return RDataFactory.createList(results, makeNames(f)); } @Specialization - protected RList split(VirtualFrame frame, RAbstractStringVector x, RFactor f) { + protected RList split(RAbstractStringVector x, RFactor f) { int[] factor = f.getVector().getDataWithoutCopying(); final int nLevels = f.getNLevels(attrProfiles); @@ -146,11 +145,11 @@ public abstract class Split extends RBuiltinNode { results[i] = RDataFactory.createStringVector(Arrays.copyOfRange(collectResults[i], 0, collectResultSize[i]), RDataFactory.COMPLETE_VECTOR); } - return RDataFactory.createList(results, makeNames(frame, f)); + return RDataFactory.createList(results, makeNames(f)); } @Specialization - protected RList split(VirtualFrame frame, RAbstractLogicalVector x, RFactor f) { + protected RList split(RAbstractLogicalVector x, RFactor f) { int[] factor = f.getVector().getDataWithoutCopying(); final int nLevels = f.getNLevels(attrProfiles); @@ -178,17 +177,17 @@ public abstract class Split extends RBuiltinNode { results[i] = RDataFactory.createLogicalVector(Arrays.copyOfRange(collectResults[i], 0, collectResultSize[i]), x.isComplete()); } - return RDataFactory.createList(results, makeNames(frame, f)); + return RDataFactory.createList(results, makeNames(f)); } - private RStringVector makeNames(VirtualFrame frame, RFactor f) { + private RStringVector makeNames(RFactor f) { RVector levels = f.getLevels(attrProfiles); if (noStringLevels.profile(!(levels instanceof RStringVector))) { if (castString == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castString = insert(CastStringNodeGen.create(null, false, false, false, false)); } - RStringVector slevels = (RStringVector) castString.executeString(frame, f.getLevels(attrProfiles)); + RStringVector slevels = (RStringVector) castString.executeString(f.getLevels(attrProfiles)); return RDataFactory.createStringVector(slevels.getDataWithoutCopying(), RDataFactory.COMPLETE_VECTOR); } else { return RDataFactory.createStringVector(((RStringVector) levels).getDataCopy(), RDataFactory.COMPLETE_VECTOR); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Switch.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Switch.java index 20c529d91ddf7d91ccaddffab6ee0fa039c7c096..464b49fad7544359a4b02697468a019c3edec6f8 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Switch.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Switch.java @@ -132,7 +132,7 @@ public abstract class Switch extends RBuiltinNode { CompilerDirectives.transferToInterpreterAndInvalidate(); castIntNode = insert(CastIntegerNodeGen.create(null, false, false, false)); } - Object objIndex = castIntNode.executeCast(frame, x); + Object objIndex = castIntNode.executeCast(x); if (!(objIndex instanceof Integer)) { notIntType.enter(); return null; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Transpose.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Transpose.java index 5e6dce5a38acf3b7b814a85551c18bf60ae53c4e..fa8ec9c5ef9be6ad3f5355fc7cef54ca7ec3280d 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Transpose.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Transpose.java @@ -12,31 +12,24 @@ */ package com.oracle.truffle.r.nodes.builtin.base; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import static com.oracle.truffle.r.runtime.RBuiltinKind.*; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; -import com.oracle.truffle.r.nodes.*; -import com.oracle.truffle.r.nodes.access.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; -import com.oracle.truffle.r.runtime.ops.na.*; @RBuiltin(name = "t.default", kind = SUBSTITUTE, parameterNames = {"x"}) // TODO INTERNAL -@SuppressWarnings("unused") public abstract class Transpose extends RBuiltinNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); private final BranchProfile hasDimNamesProfile = BranchProfile.create(); - private final NACheck check = NACheck.create(); - - public abstract Object execute(VirtualFrame frame, Object o); + public abstract Object execute(Object o); @Specialization @TruffleBoundary diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttr.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttr.java index 999cd7a5875f592dce5240e35ba6f3a56e65d96a..00d3acbdcf42ed9a608b30f055a4d1bb9d6d587e 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttr.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttr.java @@ -22,14 +22,13 @@ */ package com.oracle.truffle.r.nodes.builtin.base; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; -import com.oracle.truffle.api.CompilerDirectives.*; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.frame.*; -import com.oracle.truffle.api.source.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; @@ -37,9 +36,6 @@ import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; -import com.oracle.truffle.r.runtime.env.*; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @RBuiltin(name = "attr<-", kind = PRIMITIVE, parameterNames = {"x", "which", ""}) // 2nd parameter is "value", but should not be matched against, so "" @@ -58,44 +54,44 @@ public abstract class UpdateAttr extends RInvisibleBuiltinNode { @CompilationFinal private String cachedName = ""; @CompilationFinal private String cachedInternedName = ""; - private RAbstractContainer updateNames(VirtualFrame frame, RAbstractContainer container, Object o) { + private RAbstractContainer updateNames(RAbstractContainer container, Object o) { if (updateNames == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); updateNames = insert(UpdateNamesNodeGen.create(new RNode[2], null, null)); } - return (RAbstractContainer) updateNames.executeStringVector(frame, container, o); + return (RAbstractContainer) updateNames.executeStringVector(container, o); } - private RAbstractContainer updateDimNames(VirtualFrame frame, RAbstractContainer container, Object o) { + private RAbstractContainer updateDimNames(RAbstractContainer container, Object o) { if (updateDimNames == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); updateDimNames = insert(UpdateDimNamesNodeGen.create(new RNode[2], null, null)); } - return updateDimNames.executeRAbstractContainer(frame, container, o); + return updateDimNames.executeRAbstractContainer(container, o); } - private RAbstractIntVector castInteger(VirtualFrame frame, RAbstractVector vector) { + private RAbstractIntVector castInteger(RAbstractVector vector) { if (castInteger == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castInteger = insert(CastIntegerNodeGen.create(null, true, false, false)); } - return (RAbstractIntVector) castInteger.executeCast(frame, vector); + return (RAbstractIntVector) castInteger.executeCast(vector); } - private RAbstractVector castVector(VirtualFrame frame, Object value) { + private RAbstractVector castVector(Object value) { if (castVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVector = insert(CastToVectorNodeGen.create(null, false, false, false, false)); } - return (RAbstractVector) castVector.executeObject(frame, value); + return (RAbstractVector) castVector.executeObject(value); } - private RList castList(VirtualFrame frame, Object value) { + private RList castList(Object value) { if (castList == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castList = insert(CastListNodeGen.create(null, true, false, false)); } - return castList.executeList(frame, value); + return castList.executeList(value); } private String intern(String name) { @@ -121,7 +117,7 @@ public abstract class UpdateAttr extends RInvisibleBuiltinNode { } @Specialization - protected RAbstractContainer updateAttr(VirtualFrame frame, RAbstractContainer container, String name, RNull value) { + protected RAbstractContainer updateAttr(RAbstractContainer container, String name, RNull value) { controlVisibility(); String internedName = intern(name); RAbstractContainer result = container.materializeNonShared(); @@ -129,9 +125,9 @@ public abstract class UpdateAttr extends RInvisibleBuiltinNode { if (internedName == RRuntime.DIM_ATTR_KEY) { result.setDimensions(null); } else if (internedName == RRuntime.NAMES_ATTR_KEY) { - return updateNames(frame, result, value); + return updateNames(result, value); } else if (internedName == RRuntime.DIMNAMES_ATTR_KEY) { - return updateDimNames(frame, result, value); + return updateDimNames(result, value); } else if (internedName == RRuntime.CLASS_ATTR_KEY) { return (RAbstractContainer) result.setClassAttr(null, false); } else if (internedName == RRuntime.ROWNAMES_ATTR_KEY) { @@ -154,26 +150,26 @@ public abstract class UpdateAttr extends RInvisibleBuiltinNode { } @Specialization(guards = "!nullValue(value)") - protected RAbstractContainer updateAttr(VirtualFrame frame, RAbstractContainer container, String name, Object value) { + protected RAbstractContainer updateAttr(RAbstractContainer container, String name, Object value) { controlVisibility(); String internedName = intern(name); RAbstractContainer result = container.materializeNonShared(); // the name is interned, so identity comparison is sufficient if (internedName == RRuntime.DIM_ATTR_KEY) { - RAbstractIntVector dimsVector = castInteger(frame, castVector(frame, value)); + RAbstractIntVector dimsVector = castInteger(castVector(value)); if (dimsVector.getLength() == 0) { errorProfile.enter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.LENGTH_ZERO_DIM_INVALID); } result.setDimensions(dimsVector.materialize().getDataCopy()); } else if (internedName == RRuntime.NAMES_ATTR_KEY) { - return updateNames(frame, result, value); + return updateNames(result, value); } else if (internedName == RRuntime.DIMNAMES_ATTR_KEY) { - return updateDimNames(frame, result, value); + return updateDimNames(result, value); } else if (internedName == RRuntime.CLASS_ATTR_KEY) { return (RAbstractContainer) result.setClassAttr(convertClassAttrFromObject(value), false); } else if (internedName == RRuntime.ROWNAMES_ATTR_KEY) { - result.setRowNames(castVector(frame, value)); + result.setRowNames(castVector(value)); } else { // generic attribute result.setAttr(internedName, value); @@ -183,9 +179,9 @@ public abstract class UpdateAttr extends RInvisibleBuiltinNode { } @Specialization(guards = "!nullValue(value)") - protected RAbstractContainer updateAttr(VirtualFrame frame, RAbstractVector vector, RStringVector name, Object value) { + protected RAbstractContainer updateAttr(RAbstractVector vector, RStringVector name, Object value) { controlVisibility(); - return updateAttr(frame, vector, name.getDataAt(0), value); + return updateAttr(vector, name.getDataAt(0), value); } // the guard is necessary as RNull and Object cannot be distinguished in case of multiple diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttributes.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttributes.java index 59dae9b08cfc01db1e6a4999a8d7eb27e4394d43..c80c472ee9e83b98406a06cce4225c696572baa6 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttributes.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttributes.java @@ -22,14 +22,13 @@ */ package com.oracle.truffle.r.nodes.builtin.base; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; -import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.utilities.ConditionProfile; +import com.oracle.truffle.api.nodes.*; +import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; @@ -53,48 +52,48 @@ public abstract class UpdateAttributes extends RInvisibleBuiltinNode { // it's OK for the following two methods to update attributes in-place as the container has been // already materialized to non-shared - private void updateNames(VirtualFrame frame, RAbstractContainer container, Object o) { + private void updateNames(RAbstractContainer container, Object o) { if (updateNames == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); updateNames = insert(UpdateNamesNodeGen.create(new RNode[2], null, null)); } - updateNames.executeStringVector(frame, container, o); + updateNames.executeStringVector(container, o); } - private void updateDimNames(VirtualFrame frame, RAbstractContainer container, Object o) { + private void updateDimNames(RAbstractContainer container, Object o) { if (updateDimNames == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); updateDimNames = insert(UpdateDimNamesNodeGen.create(new RNode[2], null, null)); } - updateDimNames.executeRAbstractContainer(frame, container, o); + updateDimNames.executeRAbstractContainer(container, o); } - private RAbstractIntVector castInteger(VirtualFrame frame, RAbstractVector vector) { + private RAbstractIntVector castInteger(RAbstractVector vector) { if (castInteger == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castInteger = insert(CastIntegerNodeGen.create(null, true, false, false)); } - return (RAbstractIntVector) castInteger.executeCast(frame, vector); + return (RAbstractIntVector) castInteger.executeCast(vector); } - private RAbstractVector castVector(VirtualFrame frame, Object value) { + private RAbstractVector castVector(Object value) { if (castVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVector = insert(CastToVectorNodeGen.create(null, false, false, false, false)); } - return (RAbstractVector) castVector.executeObject(frame, value); + return (RAbstractVector) castVector.executeObject(value); } - private RList castList(VirtualFrame frame, Object value) { + private RList castList(Object value) { if (castList == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castList = insert(CastListNodeGen.create(null, true, false, false)); } - return castList.executeList(frame, value); + return castList.executeList(value); } @Specialization - protected RAbstractVector updateAttributes(VirtualFrame frame, RAbstractVector abstractVector, RNull list) { + protected RAbstractVector updateAttributes(RAbstractVector abstractVector, RNull list) { controlVisibility(); RVector resultVector = abstractVector.materialize(); resultVector.resetAllAttributes(true); @@ -102,7 +101,7 @@ public abstract class UpdateAttributes extends RInvisibleBuiltinNode { } @Specialization - protected RAbstractContainer updateAttributes(VirtualFrame frame, RAbstractContainer container, RList list) { + protected RAbstractContainer updateAttributes(RAbstractContainer container, RList list) { controlVisibility(); Object listNamesObject = list.getNames(attrProfiles); if (listNamesObject == null || listNamesObject == RNull.instance) { @@ -124,9 +123,9 @@ public abstract class UpdateAttributes extends RInvisibleBuiltinNode { throw RError.error(getEncapsulatingSourceSection(), RError.Message.ZERO_LENGTH_VARIABLE); } // set the dim attribute first - setDimAttribute(frame, result, list); + setDimAttribute(result, list); // set the remaining attributes in order - result = setRemainingAttributes(frame, container, result, list); + result = setRemainingAttributes(container, result, list); } return result; } @@ -146,7 +145,7 @@ public abstract class UpdateAttributes extends RInvisibleBuiltinNode { } @ExplodeLoop - private void setDimAttribute(VirtualFrame virtualFrame, RAbstractContainer result, RList sourceList) { + private void setDimAttribute(RAbstractContainer result, RList sourceList) { RStringVector listNames = sourceList.getNames(attrProfiles); int length = sourceList.getLength(); assert length > 0 : "Length should be > 0 for ExplodeLoop"; @@ -157,7 +156,7 @@ public abstract class UpdateAttributes extends RInvisibleBuiltinNode { if (value == RNull.instance) { result.setDimensions(null); } else { - RAbstractIntVector dimsVector = castInteger(virtualFrame, castVector(virtualFrame, value)); + RAbstractIntVector dimsVector = castInteger(castVector(value)); if (dimsVector.getLength() == 0) { throw RError.error(getEncapsulatingSourceSection(), RError.Message.LENGTH_ZERO_DIM_INVALID); } @@ -168,7 +167,7 @@ public abstract class UpdateAttributes extends RInvisibleBuiltinNode { } @ExplodeLoop - private RAbstractContainer setRemainingAttributes(VirtualFrame virtualFrame, RAbstractContainer container, RAbstractContainer result, RList sourceList) { + private RAbstractContainer setRemainingAttributes(RAbstractContainer container, RAbstractContainer result, RList sourceList) { RStringVector listNames = sourceList.getNames(attrProfiles); int length = sourceList.getLength(); assert length > 0 : "Length should be > 0 for ExplodeLoop"; @@ -179,9 +178,9 @@ public abstract class UpdateAttributes extends RInvisibleBuiltinNode { if (attrName.equals(RRuntime.DIM_ATTR_KEY)) { continue; } else if (attrName.equals(RRuntime.NAMES_ATTR_KEY)) { - updateNames(virtualFrame, res, value); + updateNames(res, value); } else if (attrName.equals(RRuntime.DIMNAMES_ATTR_KEY)) { - updateDimNames(virtualFrame, res, value); + updateDimNames(res, value); } else if (attrName.equals(RRuntime.CLASS_ATTR_KEY)) { if (value == RNull.instance) { res = (RAbstractContainer) result.setClassAttr(null, false); @@ -189,7 +188,7 @@ public abstract class UpdateAttributes extends RInvisibleBuiltinNode { res = (RAbstractContainer) result.setClassAttr(UpdateAttr.convertClassAttrFromObject(value), false); } } else if (attrName.equals(RRuntime.ROWNAMES_ATTR_KEY)) { - res.setRowNames(castVector(virtualFrame, value)); + res.setRowNames(castVector(value)); } else { if (value == RNull.instance) { res.removeAttr(attrProfiles, attrName); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateClass.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateClass.java index 421f6b2743aafaf30d4cbbc69d1cd9a85e2cf901..0c1944c33524c257ad761437a2f06c36a70b83cc 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateClass.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateClass.java @@ -11,12 +11,11 @@ package com.oracle.truffle.r.nodes.builtin.base; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.binary.*; import com.oracle.truffle.r.nodes.builtin.*; @@ -38,16 +37,14 @@ public abstract class UpdateClass extends RBuiltinNode { private final ValueProfile modeProfile = ValueProfile.createIdentityProfile(); private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - public abstract Object execute(VirtualFrame frame, RAbstractContainer vector, Object o); - @Specialization(guards = "!isStringVector(className)") - protected Object setClass(VirtualFrame frame, RAbstractContainer arg, RAbstractVector className) { + protected Object setClass(RAbstractContainer arg, RAbstractVector className) { controlVisibility(); if (className.getLength() == 0) { return setClass(arg, RNull.instance); } initCastStringNode(); - Object result = castStringNode.executeCast(frame, className); + Object result = castStringNode.executeCast(className); return setClass(arg, (RStringVector) result); } @@ -68,7 +65,7 @@ public abstract class UpdateClass extends RBuiltinNode { } @Specialization - protected Object setClass(VirtualFrame frame, RAbstractContainer arg, String className) { + protected Object setClass(RAbstractContainer arg, String className) { controlVisibility(); initTypeof(); if (!arg.isObject(attrProfiles)) { @@ -81,7 +78,7 @@ public abstract class UpdateClass extends RBuiltinNode { initCastTypeNode(); RType mode = RType.fromMode(modeProfile.profile(className)); if (mode != null) { - Object result = castTypeNode.execute(frame, arg, mode); + Object result = castTypeNode.execute(arg, mode); if (result != null) { return setClass((RAbstractVector) result, RNull.instance); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDiag.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDiag.java index 5369afde2d09bad324549ad30f4839c8e07bfdd0..2114cf9d7f648ac8b63147391feef43688c9dc3e 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDiag.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDiag.java @@ -22,12 +22,11 @@ */ package com.oracle.truffle.r.nodes.builtin.base; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -103,10 +102,10 @@ public abstract class UpdateDiag extends RInvisibleBuiltinNode { } @Specialization(guards = {"isMatrix(vector)", "correctReplacementLength(vector, valueVector)"}) - protected RAbstractDoubleVector updateDiag(VirtualFrame frame, RIntVector vector, RAbstractDoubleVector valueVector) { + protected RAbstractDoubleVector updateDiag(RIntVector vector, RAbstractDoubleVector valueVector) { controlVisibility(); initCastDoubleNode(); - RDoubleVector resultVector = (RDoubleVector) castDouble.executeDouble(frame, vector); + RDoubleVector resultVector = (RDoubleVector) castDouble.executeDouble(vector); resultVector.copyAttributesFrom(attrProfiles, vector); return updateDiag(resultVector, valueVector); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDim.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDim.java index 30dab531e163b154dee26aadaf93384136fde0e0..97a55cc6b3486b5f39ab5482740f17baf9f8a667 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDim.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDim.java @@ -22,12 +22,11 @@ */ package com.oracle.truffle.r.nodes.builtin.base; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -36,14 +35,13 @@ import com.oracle.truffle.r.runtime.data.model.*; @RBuiltin(name = "dim<-", kind = PRIMITIVE, parameterNames = {"x", ""}) // 2nd parameter is "value", but should not be matched against, so "" -@SuppressWarnings("unused") public abstract class UpdateDim extends RInvisibleBuiltinNode { @Child private CastIntegerNode castInteger; - private RAbstractIntVector castInteger(VirtualFrame frame, RAbstractVector vector) { + private RAbstractIntVector castInteger(RAbstractVector vector) { updateCastInteger(); - return (RAbstractIntVector) castInteger.executeCast(frame, vector); + return (RAbstractIntVector) castInteger.executeCast(vector); } @TruffleBoundary @@ -55,7 +53,7 @@ public abstract class UpdateDim extends RInvisibleBuiltinNode { } @Specialization - protected RAbstractVector updateDim(RAbstractVector vector, RNull dimensions) { + protected RAbstractVector updateDim(RAbstractVector vector, @SuppressWarnings("unused") RNull dimensions) { controlVisibility(); RVector result = (RVector) vector.materializeNonShared(); result.resetDimensions(null); @@ -63,17 +61,16 @@ public abstract class UpdateDim extends RInvisibleBuiltinNode { } @Specialization - protected RAbstractVector updateDim(VirtualFrame frame, RAbstractVector vector, RAbstractVector dimensions) { + protected RAbstractVector updateDim(RAbstractVector vector, RAbstractVector dimensions) { controlVisibility(); if (dimensions.getLength() == 0) { CompilerDirectives.transferToInterpreter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.LENGTH_ZERO_DIM_INVALID); } - int[] dimsData = castInteger(frame, dimensions).materialize().getDataCopy(); + int[] dimsData = castInteger(dimensions).materialize().getDataCopy(); vector.verifyDimensions(dimsData, getEncapsulatingSourceSection()); RVector result = (RVector) vector.materializeNonShared(); result.resetDimensions(dimsData); return result; } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDimNames.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDimNames.java index 3e55a0197a22c65010c28dcf9f23e061781de8a2..abddc97cbbc1a9bbca465dd0b043bef97d853e83 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDimNames.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDimNames.java @@ -22,12 +22,11 @@ */ package com.oracle.truffle.r.nodes.builtin.base; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import com.oracle.truffle.api.*; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -42,9 +41,9 @@ public abstract class UpdateDimNames extends RInvisibleBuiltinNode { @Child private CastStringNode castStringNode; @Child private CastToVectorNode castVectorNode; - private Object castString(VirtualFrame frame, Object o) { + private Object castString(Object o) { initCastStringNode(); - return castStringNode.executeCast(frame, o); + return castStringNode.executeCast(o); } private void initCastStringNode() { @@ -54,9 +53,9 @@ public abstract class UpdateDimNames extends RInvisibleBuiltinNode { } } - private RAbstractVector castVector(VirtualFrame frame, Object value) { + private RAbstractVector castVector(Object value) { initCastVectorNode(); - return ((RAbstractVector) castVectorNode.executeObject(frame, value)).materialize(); + return ((RAbstractVector) castVectorNode.executeObject(value)).materialize(); } private void initCastVectorNode() { @@ -66,9 +65,9 @@ public abstract class UpdateDimNames extends RInvisibleBuiltinNode { } } - public abstract RAbstractContainer executeRAbstractContainer(VirtualFrame frame, RAbstractContainer container, Object o); + public abstract RAbstractContainer executeRAbstractContainer(RAbstractContainer container, Object o); - public RList convertToListOfStrings(VirtualFrame frame, RList oldList) { + public RList convertToListOfStrings(RList oldList) { RList list = oldList; if (list.isShared()) { list = (RList) list.copy(); @@ -76,7 +75,7 @@ public abstract class UpdateDimNames extends RInvisibleBuiltinNode { for (int i = 0; i < list.getLength(); i++) { Object element = list.getDataAt(i); if (element != RNull.instance) { - Object s = castString(frame, castVector(frame, element)); + Object s = castString(castVector(element)); list.updateDataAt(i, s, null); } } @@ -102,9 +101,9 @@ public abstract class UpdateDimNames extends RInvisibleBuiltinNode { } @Specialization(guards = "!isZeroLength(list)") - protected RAbstractContainer updateDimnames(VirtualFrame frame, RAbstractContainer container, RList list) { + protected RAbstractContainer updateDimnames(RAbstractContainer container, RList list) { RAbstractContainer result = container.materializeNonShared(); - result.setDimNames(convertToListOfStrings(frame, list)); + result.setDimNames(convertToListOfStrings(list)); controlVisibility(); return result; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateLevels.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateLevels.java index afcae7cb6de479c586046e8682202613d1f78120..1ccefe30ca0d0fb6e321544a97dc63a522063e8e 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateLevels.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateLevels.java @@ -13,7 +13,6 @@ package com.oracle.truffle.r.nodes.builtin.base; import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -29,20 +28,20 @@ public abstract class UpdateLevels extends RInvisibleBuiltinNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - private RAbstractVector castVector(VirtualFrame frame, Object value) { + private RAbstractVector castVector(Object value) { if (castVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVector = insert(CastToVectorNodeGen.create(null, false, false, false, false)); } - return (RAbstractVector) castVector.executeObject(frame, value); + return (RAbstractVector) castVector.executeObject(value); } - private Object castString(VirtualFrame frame, Object operand) { + private Object castString(Object operand) { if (castString == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castString = insert(CastStringNodeGen.create(null, false, true, false, false)); } - return castString.executeCast(frame, operand); + return castString.executeCast(operand); } @Specialization @@ -54,10 +53,10 @@ public abstract class UpdateLevels extends RInvisibleBuiltinNode { } @Specialization(guards = "levelsNotNull(levels)") - protected RAbstractVector updateLevels(VirtualFrame frame, RAbstractVector vector, Object levels) { + protected RAbstractVector updateLevels(RAbstractVector vector, Object levels) { controlVisibility(); RVector v = (RVector) vector.materializeNonShared(); - v.setAttr(RRuntime.LEVELS_ATTR_KEY, castVector(frame, levels)); + v.setAttr(RRuntime.LEVELS_ATTR_KEY, castVector(levels)); return v; } @@ -69,9 +68,9 @@ public abstract class UpdateLevels extends RInvisibleBuiltinNode { } @Specialization(guards = "levelsNotNull(levels)") - protected RFactor updateLevels(VirtualFrame frame, RFactor factor, Object levels) { + protected RFactor updateLevels(RFactor factor, Object levels) { controlVisibility(); - factor.getVector().setAttr(RRuntime.LEVELS_ATTR_KEY, castString(frame, castVector(frame, levels))); + factor.getVector().setAttr(RRuntime.LEVELS_ATTR_KEY, castString(castVector(levels))); return factor; } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateNames.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateNames.java index 46efce87ffb9996f8732aaa26f74b8055f820547..5ba943d5b392684b80b217d74947f3a6c84fd7e5 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateNames.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateNames.java @@ -22,14 +22,13 @@ */ package com.oracle.truffle.r.nodes.builtin.base; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import static com.oracle.truffle.r.runtime.RBuiltinKind.*; import java.util.*; import com.oracle.truffle.api.*; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; @@ -42,15 +41,15 @@ public abstract class UpdateNames extends RInvisibleBuiltinNode { @Child private CastStringNode castStringNode; - private Object castString(VirtualFrame frame, Object o) { + private Object castString(Object o) { if (castStringNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castStringNode = insert(CastStringNodeGen.create(null, false, true, false, false)); } - return castStringNode.executeString(frame, o); + return castStringNode.executeString(o); } - public abstract Object executeStringVector(VirtualFrame frame, RAbstractContainer container, Object o); + public abstract Object executeStringVector(RAbstractContainer container, Object o); @Specialization @TruffleBoundary @@ -88,13 +87,12 @@ public abstract class UpdateNames extends RInvisibleBuiltinNode { } @Specialization - protected RAbstractContainer updateNames(VirtualFrame frame, RAbstractContainer container, Object names) { + protected RAbstractContainer updateNames(RAbstractContainer container, Object names) { controlVisibility(); if (names instanceof RAbstractVector) { - return updateNames(container, (RStringVector) castString(frame, names)); + return updateNames(container, (RStringVector) castString(names)); } else { - return updateNames(container, (String) castString(frame, names)); + return updateNames(container, (String) castString(names)); } } - } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateOldClass.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateOldClass.java index b0934d6801e78d3d80b39bdc6314f8125eb7495d..481ff5fff76f603fbc1f34d1d05bd3c5108bced9 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateOldClass.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateOldClass.java @@ -23,19 +23,16 @@ package com.oracle.truffle.r.nodes.builtin.base; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.r.nodes.builtin.RInvisibleBuiltinNode; -import com.oracle.truffle.r.nodes.unary.CastStringNode; -import com.oracle.truffle.r.nodes.unary.CastStringNodeGen; -import com.oracle.truffle.r.runtime.RBuiltin; -import com.oracle.truffle.r.runtime.data.*; -import com.oracle.truffle.r.runtime.data.model.RAbstractContainer; -import com.oracle.truffle.r.runtime.data.model.RAbstractVector; +import static com.oracle.truffle.r.runtime.RBuiltinKind.*; -import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import static com.oracle.truffle.r.runtime.RBuiltinKind.PRIMITIVE; +import com.oracle.truffle.api.*; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.*; +import com.oracle.truffle.r.nodes.builtin.*; +import com.oracle.truffle.r.nodes.unary.*; +import com.oracle.truffle.r.runtime.*; +import com.oracle.truffle.r.runtime.data.*; +import com.oracle.truffle.r.runtime.data.model.*; // oldClass<- (as opposed to class<-), simply sets the attribute (without handling "implicit" attributes) @RBuiltin(name = "oldClass<-", kind = PRIMITIVE, parameterNames = {"x", ""}) @@ -44,16 +41,14 @@ public abstract class UpdateOldClass extends RInvisibleBuiltinNode { @Child private CastStringNode castStringNode; - public abstract Object execute(VirtualFrame frame, RAbstractContainer vector, Object o); - @Specialization(guards = "!isStringVector(className)") - protected Object setOldClass(VirtualFrame frame, RAbstractContainer arg, RAbstractVector className) { + protected Object setOldClass(RAbstractContainer arg, RAbstractVector className) { controlVisibility(); if (className.getLength() == 0) { return setOldClass(arg, RNull.instance); } initCastStringNode(); - Object result = castStringNode.executeCast(frame, className); + Object result = castStringNode.executeCast(className); return setOldClass(arg, (RStringVector) result); } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateStorageMode.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateStorageMode.java index 1d5699b5c70b79a6ceb929536eb3067bf5b53196..88e6afd432b659446aacf22362634523798bcd8f 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateStorageMode.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/UpdateStorageMode.java @@ -57,7 +57,7 @@ public abstract class UpdateStorageMode extends RBuiltinNode { } initCastTypeNode(); if (mode != null) { - Object result = castTypeNode.execute(frame, x, mode); + Object result = castTypeNode.execute(x, mode); if (result != null) { if (x instanceof RAttributable && result instanceof RAbstractContainer) { RAttributable rx = (RAttributable) x; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/VApply.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/VApply.java index 6c12fc2b46720cfce82ce9381a84875646a1a537..3e14a74a8b5e7d034b9b859330f3fbef12317889 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/VApply.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/VApply.java @@ -88,19 +88,19 @@ public abstract class VApply extends RCastingBuiltinNode { // TODO check funValueLen against length of result if (funValueVec instanceof RAbstractIntVector) { - int[] data = applyResultZeroLength ? new int[0] : convertIntVector(frame, applyResult, funValueVecLen); + int[] data = applyResultZeroLength ? new int[0] : convertIntVector(applyResult, funValueVecLen); result = RDataFactory.createIntVector(data, RDataFactory.COMPLETE_VECTOR); } else if (funValueVec instanceof RAbstractDoubleVector) { - double[] data = applyResultZeroLength ? new double[0] : convertDoubleVector(frame, applyResult, funValueVecLen); + double[] data = applyResultZeroLength ? new double[0] : convertDoubleVector(applyResult, funValueVecLen); result = RDataFactory.createDoubleVector(data, RDataFactory.COMPLETE_VECTOR); } else if (funValueVec instanceof RAbstractLogicalVector) { - byte[] data = applyResultZeroLength ? new byte[0] : convertLogicalVector(frame, applyResult, funValueVecLen); + byte[] data = applyResultZeroLength ? new byte[0] : convertLogicalVector(applyResult, funValueVecLen); result = RDataFactory.createLogicalVector(data, RDataFactory.COMPLETE_VECTOR); } else if (funValueVec instanceof RAbstractStringVector) { - String[] data = applyResultZeroLength ? new String[0] : convertStringVector(frame, applyResult, funValueVecLen); + String[] data = applyResultZeroLength ? new String[0] : convertStringVector(applyResult, funValueVecLen); result = RDataFactory.createStringVector(data, RDataFactory.COMPLETE_VECTOR); } else if (funValueVec instanceof RAbstractComplexVector) { - double[] data = applyResultZeroLength ? new double[1] : convertComplexVector(frame, applyResult, funValueVecLen); + double[] data = applyResultZeroLength ? new double[1] : convertComplexVector(applyResult, funValueVecLen); result = RDataFactory.createComplexVector(data, RDataFactory.COMPLETE_VECTOR); } else { throw RInternalError.shouldNotReachHere(); @@ -126,11 +126,11 @@ public abstract class VApply extends RCastingBuiltinNode { return result; } - private double[] convertDoubleVector(VirtualFrame frame, Object[] values, int len) { + private double[] convertDoubleVector(Object[] values, int len) { double[] newArray = new double[values.length * len]; int ind = 0; for (int i = 0; i < values.length; i++) { - RAbstractDoubleVector v = (RAbstractDoubleVector) RRuntime.asAbstractVector(castDouble(frame, values[i], false)); + RAbstractDoubleVector v = (RAbstractDoubleVector) RRuntime.asAbstractVector(castDouble(values[i], false)); for (int j = 0; j < v.getLength(); j++) { newArray[ind++] = v.getDataAt(j); } @@ -138,11 +138,11 @@ public abstract class VApply extends RCastingBuiltinNode { return newArray; } - private int[] convertIntVector(VirtualFrame frame, Object[] values, int len) { + private int[] convertIntVector(Object[] values, int len) { int[] newArray = new int[values.length * len]; int ind = 0; for (int i = 0; i < values.length; i++) { - RAbstractIntVector v = (RAbstractIntVector) RRuntime.asAbstractVector(castInteger(frame, values[i], false)); + RAbstractIntVector v = (RAbstractIntVector) RRuntime.asAbstractVector(castInteger(values[i], false)); for (int j = 0; j < v.getLength(); j++) { newArray[ind++] = v.getDataAt(j); } @@ -150,11 +150,11 @@ public abstract class VApply extends RCastingBuiltinNode { return newArray; } - private byte[] convertLogicalVector(VirtualFrame frame, Object[] values, int len) { + private byte[] convertLogicalVector(Object[] values, int len) { byte[] newArray = new byte[values.length * len]; int ind = 0; for (int i = 0; i < values.length; i++) { - RAbstractLogicalVector v = (RAbstractLogicalVector) RRuntime.asAbstractVector(castLogical(frame, values[i], false)); + RAbstractLogicalVector v = (RAbstractLogicalVector) RRuntime.asAbstractVector(castLogical(values[i], false)); for (int j = 0; j < v.getLength(); j++) { newArray[ind++] = v.getDataAt(j); } @@ -162,11 +162,11 @@ public abstract class VApply extends RCastingBuiltinNode { return newArray; } - private String[] convertStringVector(VirtualFrame frame, Object[] values, int len) { + private String[] convertStringVector(Object[] values, int len) { String[] newArray = new String[values.length * len]; int ind = 0; for (int i = 0; i < values.length; i++) { - RAbstractStringVector v = (RAbstractStringVector) RRuntime.asAbstractVector(castString(frame, values[i], false)); + RAbstractStringVector v = (RAbstractStringVector) RRuntime.asAbstractVector(castString(values[i], false)); for (int j = 0; j < v.getLength(); j++) { newArray[ind++] = v.getDataAt(j); } @@ -174,11 +174,11 @@ public abstract class VApply extends RCastingBuiltinNode { return newArray; } - private double[] convertComplexVector(VirtualFrame frame, Object[] values, int len) { + private double[] convertComplexVector(Object[] values, int len) { double[] newArray = new double[values.length * len * 2]; int ind = 0; for (int i = 0; i < values.length; i++) { - RAbstractComplexVector v = (RAbstractComplexVector) RRuntime.asAbstractVector(castComplex(frame, values[i], false)); + RAbstractComplexVector v = (RAbstractComplexVector) RRuntime.asAbstractVector(castComplex(values[i], false)); for (int j = 0; j < v.getLength(); j++) { RComplex val = v.getDataAt(j); newArray[ind++] = val.getRealPart(); diff --git a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/TestUtilities.java b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/TestUtilities.java index 0d9efbd162c91ceac8a4adb63e94b5314eb6c68b..7711f80a18ab266b97df70155f790b5f2b49041d 100644 --- a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/TestUtilities.java +++ b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/test/TestUtilities.java @@ -22,8 +22,6 @@ */ package com.oracle.truffle.r.nodes.test; -import java.util.*; - import com.oracle.truffle.api.*; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.nodes.*; @@ -32,7 +30,7 @@ import com.oracle.truffle.r.runtime.*; public class TestUtilities { /** - * Creates a handle that emulates the behavior as if this node would be executed inside of a R + * Creates a handle that emulates the behavior as if this node would be executed inside of an R * call. */ public static <T extends Node> NodeHandle<T> createHandle(T node, NodeAdapter<T> invoke) { @@ -63,12 +61,8 @@ public class TestUtilities { } public Object call(Object... args) { - Object[] rArguments = RArguments.createUnitialized(); - rArguments = Arrays.copyOf(rArguments, RArguments.INDEX_ARGUMENTS + 1); - rArguments[RArguments.INDEX_ARGUMENTS] = args; - return target.call(rArguments); + return target.call(RArguments.createUnitialized((Object) args)); } - } private static class TestRoot<T extends Node> extends RootNode { @@ -84,12 +78,10 @@ public class TestUtilities { @Override public Object execute(VirtualFrame frame) { try { - return invoke.invoke(node, (Object[]) frame.getArguments()[RArguments.INDEX_ARGUMENTS]); + return invoke.invoke(node, (Object[]) RArguments.getArgument(frame, 0)); } catch (ReturnException e) { return e.getResult(); } } - } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RRootNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RRootNode.java index bbbf8fce1381193f126d217ff01a468b7edd35b1..c9a489d5b2cbb3a6fd6a643bd518738d93bb5021 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RRootNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RRootNode.java @@ -40,7 +40,6 @@ import com.oracle.truffle.r.runtime.env.frame.*; public abstract class RRootNode extends RootNode implements HasSignature { @CompilationFinal protected boolean checkSingletonFrame = true; - private final ValueProfile functionProfile = ValueProfile.createIdentityProfile(); private final ValueProfile irregularFrameProfile = ValueProfile.createPrimitiveProfile(); /** @@ -54,7 +53,6 @@ public abstract class RRootNode extends RootNode implements HasSignature { } protected void verifyEnclosingAssumptions(VirtualFrame vf) { - RArguments.setFunction(vf, functionProfile.profile(RArguments.getFunction(vf))); RArguments.setIsIrregular(vf, irregularFrameProfile.profile(RArguments.getIsIrregular(vf))); if (checkSingletonFrame) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessEnclosingFrameNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessEnclosingFrameNode.java index fb49706b03cf4b79a39db769925a1081df604e00..b754e5b3b729e61dc9cb6b00ff46d241404ac675 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessEnclosingFrameNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/AccessEnclosingFrameNode.java @@ -24,27 +24,15 @@ package com.oracle.truffle.r.nodes.access; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.frame.*; -import com.oracle.truffle.api.nodes.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.runtime.*; -@NodeField(name = "level", type = int.class) public abstract class AccessEnclosingFrameNode extends RNode { - @Override - public final Object execute(VirtualFrame frame) { - return executeMaterializedFrame(frame); - } - public abstract MaterializedFrame executeMaterializedFrame(VirtualFrame frame); @Specialization - @ExplodeLoop - protected MaterializedFrame doMaterializedFrame(VirtualFrame frame, int level) { - MaterializedFrame enclosingFrame = RArguments.getFunction(frame).getEnclosingFrame(); - for (int i = 1; i < level; i++) { - enclosingFrame = RArguments.getFunction(enclosingFrame).getEnclosingFrame(); - } - return enclosingFrame; + protected MaterializedFrame doMaterializedFrame(VirtualFrame frame) { + return RArguments.getEnclosingFrame(frame); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/UpdateFieldNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/UpdateFieldNode.java index 8a23b8609167e74dff9171cef045e1cf1049550e..ee91fa1566f0c3dcba3e12168fd2677f9fb939bc 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/UpdateFieldNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/UpdateFieldNode.java @@ -197,16 +197,16 @@ public abstract class UpdateFieldNode extends UpdateNode implements RSyntaxNode } @Specialization - protected Object updateField(VirtualFrame frame, RAbstractVector object, Object value, String field) { + protected Object updateField(RAbstractVector object, Object value, String field) { if (castList == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castList = insert(CastListNodeGen.create(null, true, true, false)); } RError.warning(getEncapsulatingSourceSection(), RError.Message.COERCING_LHS_TO_LIST); if (nullValueProfile.profile(value == RNull.instance)) { - return updateFieldNullValue(castList.executeList(frame, object), value, field); + return updateFieldNullValue(castList.executeList(object), value, field); } else { - return updateField(castList.executeList(frame, object), value, field); + return updateField(castList.executeList(object), value, field); } } @@ -247,5 +247,4 @@ public abstract class UpdateFieldNode extends UpdateNode implements RSyntaxNode protected boolean isObject(RAbstractContainer container) { return container.isObject(attrProfiles) && forObjects; } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/WriteSuperFrameVariableNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/WriteSuperFrameVariableNode.java index 0d0c3bf9a8cf8678d1cb5e1ddb42540cf4418598..8306fc43565e72ff090010fdc96e47ccf5595163 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/WriteSuperFrameVariableNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/WriteSuperFrameVariableNode.java @@ -116,7 +116,7 @@ public abstract class WriteSuperFrameVariableNode extends WriteSuperFrameVariabl * we've reached the global scope, do unconditional write // if this is the first * node in the chain, needs the rhs and enclosingFrame // nodes */ - AccessEnclosingFrameNode enclosingFrameNode = RArguments.getEnclosingFrame(frame) == enclosingFrame ? AccessEnclosingFrameNodeGen.create(1) : null; + AccessEnclosingFrameNode enclosingFrameNode = RArguments.getEnclosingFrame(frame) == enclosingFrame ? AccessEnclosingFrameNodeGen.create() : null; writeNode = WriteSuperFrameVariableNodeGen.create(getRhs(), enclosingFrameNode, FrameSlotNode.create(findOrAddFrameSlot(enclosingFrame.getFrameDescriptor(), symbol)), getName(), mode); } else { WriteSuperFrameVariableNode actualWriteNode = WriteSuperFrameVariableNodeGen.create(null, null, FrameSlotNode.create(symbol), this.getName(), mode); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ArrayPositionCast.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ArrayPositionCast.java index d9186cadfaac4b94f5b48292e059e1cd44251644..34d3b5bac06b308adfaf8c50587c69c993527e9d 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ArrayPositionCast.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ArrayPositionCast.java @@ -27,7 +27,6 @@ import java.util.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.access.array.ArrayPositionCastNodeGen.ContainerDimNamesGetNodeGen; @@ -127,7 +126,7 @@ abstract class ArrayPositionsCastBase extends RNode { @NodeChildren({@NodeChild(value = "vector", type = RNode.class), @NodeChild(value = "operand", type = RNode.class)}) public abstract class ArrayPositionCast extends ArrayPositionsCastBase { - public abstract Object executeArg(VirtualFrame frame, Object container, Object operand); + public abstract Object executeArg(Object container, Object operand); protected abstract RNode getVector(); @@ -154,16 +153,16 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization - protected Object doSymbol(VirtualFrame frame, RAbstractContainer container, RSymbol operand) { + protected Object doSymbol(RAbstractContainer container, RSymbol operand) { if (operand.getName().length() == 0) { - return doMissingVector(frame, container, RMissing.instance); + return doMissingVector(container, RMissing.instance); } else { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_SUBSCRIPT_TYPE, "symbol"); } } @Specialization - protected Object doMissingVector(VirtualFrame frame, RAbstractContainer container, RMissing operand) { + protected Object doMissingVector(RAbstractContainer container, RMissing operand) { return operand; } @@ -217,7 +216,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { @NodeChildren({@NodeChild(value = "vector", type = RNode.class), @NodeChild(value = "operand", type = RNode.class), @NodeChild(value = "exact", type = RNode.class)}) public abstract static class OperatorConverterNode extends ArrayPositionsCastBase { - public abstract Object executeConvert(VirtualFrame frame, Object vector, Object operand, Object exact); + public abstract Object executeConvert(Object vector, Object operand, Object exact); @Child private OperatorConverterNode operatorConvertRecursive; @Child private CastIntegerNode castInteger; @@ -259,32 +258,32 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } } - private RList getContainerDimNames(VirtualFrame frame, RAbstractContainer value) { + private RList getContainerDimNames(RAbstractContainer value) { if (dimNamesGetter == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); dimNamesGetter = insert(ContainerDimNamesGetNodeGen.create(null)); } - return dimNamesGetter.execute(frame, value); + return dimNamesGetter.execute(value); } - private Object convertOperatorRecursive(VirtualFrame frame, RAbstractContainer container, int operand, Object exact) { + private Object convertOperatorRecursive(RAbstractContainer container, int operand, Object exact) { initConvertCast(); - return operatorConvertRecursive.executeConvert(frame, container, operand, exact); + return operatorConvertRecursive.executeConvert(container, operand, exact); } - private Object convertOperatorRecursive(VirtualFrame frame, RAbstractContainer container, double operand, Object exact) { + private Object convertOperatorRecursive(RAbstractContainer container, double operand, Object exact) { initConvertCast(); - return operatorConvertRecursive.executeConvert(frame, container, operand, exact); + return operatorConvertRecursive.executeConvert(container, operand, exact); } - private Object convertOperatorRecursive(VirtualFrame frame, RAbstractContainer container, byte operand, Object exact) { + private Object convertOperatorRecursive(RAbstractContainer container, byte operand, Object exact) { initConvertCast(); - return operatorConvertRecursive.executeConvert(frame, container, operand, exact); + return operatorConvertRecursive.executeConvert(container, operand, exact); } - private Object convertOperatorRecursive(VirtualFrame frame, RAbstractContainer container, Object operand, Object exact) { + private Object convertOperatorRecursive(RAbstractContainer container, Object operand, Object exact) { initConvertCast(); - return operatorConvertRecursive.executeConvert(frame, container, operand, exact); + return operatorConvertRecursive.executeConvert(container, operand, exact); } private void initIntCast() { @@ -294,40 +293,40 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } } - private Object castInteger(VirtualFrame frame, double operand) { + private Object castInteger(double operand) { initIntCast(); - return castInteger.executeCast(frame, operand); + return castInteger.executeCast(operand); } - private Object castInteger(VirtualFrame frame, byte operand) { + private Object castInteger(byte operand) { initIntCast(); - return castInteger.executeCast(frame, operand); + return castInteger.executeCast(operand); } - private Object castInteger(VirtualFrame frame, Object operand) { + private Object castInteger(Object operand) { initIntCast(); - return castInteger.executeCast(frame, operand); + return castInteger.executeCast(operand); } - private Object castLogical(VirtualFrame frame, Object operand) { + private Object castLogical(Object operand) { if (castLogical == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castLogical = insert(CastLogicalNodeGen.create(null, false, false, false)); } - return castLogical.executeCast(frame, operand); + return castLogical.executeCast(operand); } - private Object castVector(VirtualFrame frame, Object operand) { + private Object castVector(Object operand) { if (castVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVector = insert(CastToVectorNodeGen.create(null, false, false, false, false)); } - return castVector.executeCast(frame, operand); + return castVector.executeCast(operand); } @Specialization - protected Object doFactor(VirtualFrame frame, RAbstractContainer container, RFactor factor, Object exact) { - return convertOperatorRecursive(frame, container, factor.getVector(), exact); + protected Object doFactor(RAbstractContainer container, RFactor factor, Object exact) { + return convertOperatorRecursive(container, factor.getVector(), exact); } @Specialization @@ -355,16 +354,16 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization - protected Object doSymbol(VirtualFrame frame, RAbstractContainer container, RSymbol operand, Object exact) { + protected Object doSymbol(RAbstractContainer container, RSymbol operand, Object exact) { if (operand.getName().length() == 0) { - return doMissingDimLengthOne(frame, container, RMissing.instance, exact); + return doMissingDimLengthOne(container, RMissing.instance, exact); } else { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_SUBSCRIPT_TYPE, "symbol"); } } @Specialization - protected Object doMissingDimLengthOne(VirtualFrame frame, RAbstractContainer container, RMissing operand, Object exact) { + protected Object doMissingDimLengthOne(RAbstractContainer container, RMissing operand, Object exact) { if (!assignment && numDimensions == 1) { // need to return original accessed vector (with attributes and such) return RMissing.instance; @@ -376,7 +375,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { throw RError.error(getEncapsulatingSourceSection(), RError.Message.INVALID_SUBSCRIPT_TYPE, "symbol"); } } - if (dimSizeOneProfile.profile(getDimensionSize(frame, container) == 1)) { + if (dimSizeOneProfile.profile(getDimensionSize(container) == 1)) { return 1; } else { return expandMissing(container); @@ -436,8 +435,8 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization(guards = "!opString(operand)") - protected Object doMissingVectorOp(VirtualFrame frame, RNull vector, RAbstractVector operand, Object exact) { - return castInteger(frame, operand); + protected Object doMissingVectorOp(RNull vector, RAbstractVector operand, Object exact) { + return castInteger(operand); } @Specialization(guards = "indNA(operand)") @@ -458,8 +457,8 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization(guards = "!indNA(operand)") - protected Object doInt(VirtualFrame frame, RAbstractContainer container, int operand, Object exact) { - int dimSize = getDimensionSize(frame, container); + protected Object doInt(RAbstractContainer container, int operand, Object exact) { + int dimSize = getDimensionSize(container); if (operand > dimSize) { outOfBoundsPositive.enter(); @@ -490,7 +489,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { // result is no dimensions left return 0; } else { - return doIntNegativeMultiDim(frame, container, operand); + return doIntNegativeMultiDim(container, operand); } } } else { @@ -499,7 +498,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } } - private Object doIntNegativeMultiDim(VirtualFrame frame, RAbstractContainer container, int operand) { + private Object doIntNegativeMultiDim(RAbstractContainer container, int operand) { if (elementsCountProfile.profile(isSubset || container.getLength() <= 2)) { // it's negative, but not out of bounds - pick all indexes apart from the negative // one @@ -519,14 +518,14 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization(guards = "!isNegative(operand)") - protected Object doDouble(VirtualFrame frame, RAbstractContainer container, double operand, Object exact) { - return convertOperatorRecursive(frame, container, castInteger(frame, operand), exact); + protected Object doDouble(RAbstractContainer container, double operand, Object exact) { + return convertOperatorRecursive(container, castInteger(operand), exact); } @Specialization(guards = "isNegative(operand)") - protected Object doDoubleNegative(VirtualFrame frame, RAbstractContainer container, double operand, Object exact) { + protected Object doDoubleNegative(RAbstractContainer container, double operand, Object exact) { // returns object as it may return either int or RIntVector due to conversion - return convertOperatorRecursive(frame, container, castInteger(frame, Math.abs(operand) > container.getLength() ? operand - 1 : operand), exact); + return convertOperatorRecursive(container, castInteger(Math.abs(operand) > container.getLength() ? operand - 1 : operand), exact); // The check for the operand size in relation to the vector length is done to maintain // compatibility with GNU R, which (oddly) does not seem to apply as.integer semantics // to a negative argument here. For instance, { x <- c(1,2,3); x[-3.1] } will give the @@ -545,7 +544,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization(guards = "indNA(operand)") - protected Object doLogicalNA(VirtualFrame frame, RAbstractContainer container, byte operand, Object exact) { + protected Object doLogicalNA(RAbstractContainer container, byte operand, Object exact) { if (isSubset && !assignment) { int dimLength = numDimensions == 1 ? (container.getLength() == 0 ? 1 : container.getLength()) : getDimensions(container)[dimension]; int[] data = new int[dimLength]; @@ -557,7 +556,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization(guards = {"indTrue(operand)", "isSubset"}) - protected RIntVector doLogicalIndTrue(VirtualFrame frame, RAbstractContainer container, byte operand, Object exact) { + protected RIntVector doLogicalIndTrue(RAbstractContainer container, byte operand, Object exact) { int dimLength = numDimensions == 1 ? container.getLength() : getDimensions(container)[dimension]; int[] data = new int[dimLength]; for (int i = 0; i < dimLength; i++) { @@ -660,13 +659,13 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization(guards = "indNA(operand)") - protected Object doStringNA(VirtualFrame frame, RAbstractContainer container, String operand, Object exact) { + protected Object doStringNA(RAbstractContainer container, String operand, Object exact) { if (numDimensions == 1) { if (assignment) { RStringVector resNames = RDataFactory.createStringVector(new String[]{operand}, RDataFactory.INCOMPLETE_VECTOR); return RDataFactory.createIntVector(new int[]{container.getLength() + 1}, RDataFactory.COMPLETE_VECTOR, resNames); } else { - return convertOperatorRecursive(frame, container, RRuntime.INT_NA, exact); + return convertOperatorRecursive(container, RRuntime.INT_NA, exact); } } else { throw RError.error(getEncapsulatingSourceSection(), RError.Message.SUBSCRIPT_BOUNDS); @@ -726,30 +725,30 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization(guards = "!indNA(operand)") - protected Object doString(VirtualFrame frame, RAbstractContainer container, String operand, Object exact) { + protected Object doString(RAbstractContainer container, String operand, Object exact) { boolean findExact = true; - RAbstractLogicalVector exactVec = (RAbstractLogicalVector) castLogical(frame, castVector(frame, exact)); + RAbstractLogicalVector exactVec = (RAbstractLogicalVector) castLogical(castVector(exact)); if (exactVec.getLength() > 0 && exactVec.getDataAt(0) == RRuntime.LOGICAL_FALSE) { findExact = false; } if (numDimensions == 1) { return doStringOneDim(container, operand, findExact); } else { - return doStringMultiDim(container, operand, getContainerDimNames(frame, container), findExact); + return doStringMultiDim(container, operand, getContainerDimNames(container), findExact); } } @Specialization - protected Object doIntVector(VirtualFrame frame, RAbstractContainer container, RAbstractIntVector operand, Object exact) { + protected Object doIntVector(RAbstractContainer container, RAbstractIntVector operand, Object exact) { if (operand.getLength() == 1) { opLengthOne.enter(); - return convertOperatorRecursive(frame, container, operand.getDataAt(0), exact); + return convertOperatorRecursive(container, operand.getDataAt(0), exact); } if (isSubset) { if (emptyOperandProfile.profile(operand.getLength() == 0)) { return 0; } else { - return transformIntoPositive(frame, container, operand); + return transformIntoPositive(container, operand); } } else { if (emptyOperandProfile.profile(operand.getLength() == 0)) { @@ -770,28 +769,28 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization - protected Object doDouble(VirtualFrame frame, RAbstractContainer container, RAbstractDoubleVector operand, Object exact) { - return convertOperatorRecursive(frame, container, castInteger(frame, operand), exact); + protected Object doDouble(RAbstractContainer container, RAbstractDoubleVector operand, Object exact) { + return convertOperatorRecursive(container, castInteger(operand), exact); } @Specialization - protected Object doLogical(VirtualFrame frame, RAbstractContainer container, RAbstractLogicalVector operand, Object exact) { + protected Object doLogical(RAbstractContainer container, RAbstractLogicalVector operand, Object exact) { if (emptyOperandProfile.profile(operand.getLength() == 0)) { - return convertOperatorRecursive(frame, container, castInteger(frame, operand), exact); + return convertOperatorRecursive(container, castInteger(operand), exact); } else if (operand.getLength() == 1) { opLengthOne.enter(); - return convertOperatorRecursive(frame, container, operand.getDataAt(0), exact); + return convertOperatorRecursive(container, operand.getDataAt(0), exact); } else { opLong.enter(); if (isSubset) { - if ((operand.getLength() > getDimensionSize(frame, container)) && numDimensions != 1) { + if ((operand.getLength() > getDimensionSize(container)) && numDimensions != 1) { error.enter(); throw RError.error(getEncapsulatingSourceSection(), RError.Message.LOGICAL_SUBSCRIPT_LONG); } - return doLogicalVectorInternal(frame, container, operand); + return doLogicalVectorInternal(container, operand); } else { - return convertOperatorRecursive(frame, container, castInteger(frame, operand), exact); + return convertOperatorRecursive(container, castInteger(operand), exact); } } } @@ -809,7 +808,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { return data; } - private RIntVector doLogicalVectorInternal(VirtualFrame frame, RAbstractContainer container, RAbstractLogicalVector operand) { + private RIntVector doLogicalVectorInternal(RAbstractContainer container, RAbstractLogicalVector operand) { int dimLength = numDimensions == 1 ? container.getLength() : getDimensions(container)[dimension]; int resultLength = Math.max(operand.getLength(), dimLength); int logicalVectorLength = operand.getLength(); @@ -848,10 +847,10 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } } - private Object handleInvalidVecType(VirtualFrame frame, RAbstractContainer container, RAbstractVector operand, String typeName, Object exact) { + private Object handleInvalidVecType(RAbstractContainer container, RAbstractVector operand, String typeName, Object exact) { if (operand.getLength() == 1) { opLengthOne.enter(); - return convertOperatorRecursive(frame, container, operand.getDataAtAsObject(0), exact); + return convertOperatorRecursive(container, operand.getDataAtAsObject(0), exact); } else { error.enter(); if (operand.getLength() == 0 && !isSubset) { @@ -869,16 +868,16 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization - protected Object doComplex(VirtualFrame frame, RAbstractContainer container, RAbstractComplexVector operand, Object exact) { - return handleInvalidVecType(frame, container, operand, "complex", exact); + protected Object doComplex(RAbstractContainer container, RAbstractComplexVector operand, Object exact) { + return handleInvalidVecType(container, operand, "complex", exact); } @Specialization - protected Object doRawx(VirtualFrame frame, RAbstractContainer container, RAbstractRawVector operand, Object exact) { - return handleInvalidVecType(frame, container, operand, "raw", exact); + protected Object doRawx(RAbstractContainer container, RAbstractRawVector operand, Object exact) { + return handleInvalidVecType(container, operand, "raw", exact); } - private RIntVector findPositions(VirtualFrame frame, RAbstractContainer container, Object namesObj, RAbstractStringVector operand, boolean retainNames) { + private RIntVector findPositions(RAbstractContainer container, Object namesObj, RAbstractStringVector operand, boolean retainNames) { int[] data = new int[operand.getLength()]; boolean hasSeenNA = false; int namesLength = namesObj == RNull.instance ? 0 : ((RStringVector) namesObj).getLength(); @@ -943,7 +942,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { return newInitialPos; } - private static RIntVector findPositionsWithNames(VirtualFrame frame, RAbstractContainer container, RStringVector names, RAbstractStringVector operand, boolean retainNames) { + private static RIntVector findPositionsWithNames(RAbstractContainer container, RStringVector names, RAbstractStringVector operand, boolean retainNames) { RStringVector resNames = operand.materialize(); int initialPos = container.getLength(); int[] data = new int[operand.getLength()]; @@ -958,7 +957,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { return RDataFactory.createIntVector(data, RDataFactory.COMPLETE_VECTOR, resNames); } - private static RIntVector findPositionsWithDimNames(VirtualFrame frame, RAbstractContainer container, Object namesObj, RAbstractStringVector operand, boolean retainNames) { + private static RIntVector findPositionsWithDimNames(RAbstractContainer container, Object namesObj, RAbstractStringVector operand, boolean retainNames) { RStringVector resNames = operand.materialize(); int initialPos = container.getLength(); int[] data = new int[operand.getLength()]; @@ -975,31 +974,31 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization - protected Object doString(VirtualFrame frame, RAbstractContainer container, RAbstractStringVector operand, Object exact) { + protected Object doString(RAbstractContainer container, RAbstractStringVector operand, Object exact) { if (emptyOperandProfile.profile(operand.getLength() == 0)) { - return convertOperatorRecursive(frame, container, castInteger(frame, operand), exact); + return convertOperatorRecursive(container, castInteger(operand), exact); } else if (operand.getLength() == 1) { opLengthOne.enter(); - return convertOperatorRecursive(frame, container, operand.getDataAt(0), exact); + return convertOperatorRecursive(container, operand.getDataAt(0), exact); } else { opLong.enter(); if (isSubset) { if (numDimensions == 1) { if (assignment) { - return findPositionsWithNames(frame, container, container.getNames(attrProfiles), operand, assignment); + return findPositionsWithNames(container, container.getNames(attrProfiles), operand, assignment); } else if (namesProfile.profile(container.getNames(attrProfiles) != null)) { - return findPositions(frame, container, container.getNames(attrProfiles), operand, assignment); + return findPositions(container, container.getNames(attrProfiles), operand, assignment); } else { int[] data = new int[operand.getLength()]; Arrays.fill(data, RRuntime.INT_NA); return RDataFactory.createIntVector(data, RDataFactory.INCOMPLETE_VECTOR); } } else { - if (namesProfile.profile(getContainerDimNames(frame, container) != null)) { + if (namesProfile.profile(getContainerDimNames(container) != null)) { if (assignment) { - return findPositionsWithDimNames(frame, container, getContainerDimNames(frame, container).getDataAt(dimension), operand, assignment); + return findPositionsWithDimNames(container, getContainerDimNames(container).getDataAt(dimension), operand, assignment); } else { - return findPositions(frame, container, getContainerDimNames(frame, container).getDataAt(dimension), operand, assignment); + return findPositions(container, getContainerDimNames(container).getDataAt(dimension), operand, assignment); } } else { error.enter(); @@ -1046,7 +1045,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { private final BranchProfile seenNegative = BranchProfile.create(); private final BranchProfile seenNA = BranchProfile.create(); - private RAbstractIntVector transformIntoPositive(VirtualFrame frame, RAbstractContainer container, RAbstractIntVector positions) { + private RAbstractIntVector transformIntoPositive(RAbstractContainer container, RAbstractIntVector positions) { boolean hasSeenPositive = false; boolean hasSeenZero = false; boolean hasSeenNegative = false; @@ -1146,7 +1145,7 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { return operand.getElementClass() == RString.class; } - private int getDimensionSize(VirtualFrame frame, RAbstractContainer container) { + private int getDimensionSize(RAbstractContainer container) { int[] dimensions = getDimensions(container); verifyDimensions(dimensions); return numDimensions == 1 ? container.getLength() : dimensions[dimension]; @@ -1195,22 +1194,22 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { protected final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - public abstract RList execute(VirtualFrame frame, RAbstractContainer container); + public abstract RList execute(RAbstractContainer container); - private Object getContainerRowNames(VirtualFrame frame, RAbstractContainer value) { + private Object getContainerRowNames(RAbstractContainer value) { if (rowNamesGetter == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); rowNamesGetter = insert(ContainerRowNamesGetNodeGen.create(null)); } - return rowNamesGetter.execute(frame, value); + return rowNamesGetter.execute(value); } - private Object castString(VirtualFrame frame, Object operand) { + private Object castString(Object operand) { if (castString == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castString = insert(CastStringNodeGen.create(null, false, true, false, false)); } - return castString.executeCast(frame, operand); + return castString.executeCast(operand); } @Specialization(guards = "!isDataFrame(container)") @@ -1219,8 +1218,8 @@ public abstract class ArrayPositionCast extends ArrayPositionsCastBase { } @Specialization(guards = "isDataFrame(container)") - RList getDimDataFrame(VirtualFrame frame, RAbstractContainer container) { - return RDataFactory.createList(new Object[]{container.getNames(attrProfiles), castString(frame, getContainerRowNames(frame, container))}); + RList getDimDataFrame(RAbstractContainer container) { + return RDataFactory.createList(new Object[]{container.getNames(attrProfiles), castString(getContainerRowNames(container))}); } protected boolean isDataFrame(RAbstractContainer container) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ContainerRowNamesGet.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ContainerRowNamesGet.java index c555c8058c2474db4f766b86ab63c15a67f37cd5..eb946df68a7d1ffbe9736e68bc2ef17a110df649 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ContainerRowNamesGet.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/ContainerRowNamesGet.java @@ -23,7 +23,6 @@ package com.oracle.truffle.r.nodes.access.array; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.runtime.*; @@ -38,7 +37,7 @@ public abstract class ContainerRowNamesGet extends RNode { private final ConditionProfile nameConditionProfile = ConditionProfile.createBinaryProfile(); protected final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - public abstract Object execute(VirtualFrame frame, RAbstractContainer container); + public abstract Object execute(RAbstractContainer container); // this is copied from Attr.java - can't use it directly due to dependence circularity private Object getFullRowNames(Object a) { @@ -64,5 +63,4 @@ public abstract class ContainerRowNamesGet extends RNode { protected boolean isDataFrame(RAbstractContainer container) { return container.getElementClass() == RDataFrame.class; } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/PositionsArrayConversionNodeAdapter.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/PositionsArrayConversionNodeAdapter.java index 325b8045549f7e9816b4e6937f18e0ae3662ae53..9bf184b90c8b3446633fc34185d202e780dfb770 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/PositionsArrayConversionNodeAdapter.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/PositionsArrayConversionNodeAdapter.java @@ -36,12 +36,12 @@ public abstract class PositionsArrayConversionNodeAdapter extends RNode { private final boolean isSubset; private final int length; - public Object executeArg(VirtualFrame frame, Object container, Object operand, int i) { - return positionCasts[i].executeArg(frame, container, operand); + public Object executeArg(Object container, Object operand, int i) { + return positionCasts[i].executeArg(container, operand); } - public Object executeConvert(VirtualFrame frame, Object vector, Object operand, Object exact, int i) { - return operatorConverters[i].executeConvert(frame, vector, operand, exact); + public Object executeConvert(Object vector, Object operand, Object exact, int i) { + return operatorConverters[i].executeConvert(vector, operand, exact); } public boolean isSubset() { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/AccessArrayNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/AccessArrayNode.java index 42393e20fcaaf7b2dd50e7b31af88724dab6eab8..f48e1ed9705aaeaa466baf66621983989f37d440 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/AccessArrayNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/AccessArrayNode.java @@ -181,20 +181,20 @@ public abstract class AccessArrayNode extends RNode implements RSyntaxNode { return accessRecursive.executeAccess(frame, vector, exact, recLevel, operand, dropDim); } - private Object castVector(VirtualFrame frame, Object value) { + private Object castVector(Object value) { if (castVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castVector = insert(CastToVectorNodeGen.create(null, false, false, false, true)); } - return castVector.executeObject(frame, value); + return castVector.executeObject(value); } - private Object castPosition(VirtualFrame frame, Object vector, Object operand) { + private Object castPosition(Object vector, Object operand) { if (castPosition == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castPosition = insert(ArrayPositionCastNodeGen.create(0, 1, false, false, null, null)); } - return castPosition.executeArg(frame, vector, operand); + return castPosition.executeArg(vector, operand); } private void initOperatorConvert() { @@ -204,14 +204,14 @@ public abstract class AccessArrayNode extends RNode implements RSyntaxNode { } } - private Object convertOperand(VirtualFrame frame, Object vector, int operand, Object exact) { + private Object convertOperand(Object vector, int operand, Object exact) { initOperatorConvert(); - return operatorConverter.executeConvert(frame, vector, operand, exact); + return operatorConverter.executeConvert(vector, operand, exact); } - private Object convertOperand(VirtualFrame frame, Object vector, String operand, Object exact) { + private Object convertOperand(Object vector, String operand, Object exact) { initOperatorConvert(); - return operatorConverter.executeConvert(frame, vector, operand, exact); + return operatorConverter.executeConvert(vector, operand, exact); } private Object getMultiDimData(VirtualFrame frame, Object data, RAbstractVector vector, Object[] positions, int currentDimLevel, int srcArrayBase, int dstArrayBase, int accSrcDimensions, @@ -626,8 +626,8 @@ public abstract class AccessArrayNode extends RNode implements RSyntaxNode { @Specialization(guards = {"!isObject(vector)", "hasNames(vector)", "!isSubset()", "twoPosition(p)"}) protected Object accessStringTwoPosRec(VirtualFrame frame, RList vector, Object exact, int recLevel, RStringVector p, Object dropDim) { int position = getPositionInRecursion(vector, p.getDataAt(0), recLevel, getEncapsulatingSourceSection(), error, attrProfiles); - Object newVector = castVector(frame, vector.getDataAt(position - 1)); - Object newPosition = castPosition(frame, newVector, convertOperand(frame, newVector, p.getDataAt(1), exact)); + Object newVector = castVector(vector.getDataAt(position - 1)); + Object newPosition = castPosition(newVector, convertOperand(newVector, p.getDataAt(1), exact)); return accessRecursive(frame, newVector, exact, newPosition, recLevel + 1, dropDim); } @@ -706,8 +706,8 @@ public abstract class AccessArrayNode extends RNode implements RSyntaxNode { protected Object accessTwoPosRec(VirtualFrame frame, RList vector, Object exact, int recLevel, RIntVector positions, Object dropDim) { int position = positions.getDataAt(0); position = getPositionInRecursion(vector, position, recLevel); - Object newVector = castVector(frame, vector.getDataAt(position - 1)); - Object newPosition = castPosition(frame, newVector, convertOperand(frame, newVector, positions.getDataAt(1), exact)); + Object newVector = castVector(vector.getDataAt(position - 1)); + Object newPosition = castPosition(newVector, convertOperand(newVector, positions.getDataAt(1), exact)); return accessRecursive(frame, newVector, exact, newPosition, recLevel + 1, dropDim); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/MultiDimPosConverterNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/MultiDimPosConverterNode.java index a1f38f7e3368e078fd5e7f5ae41ca3e32cc1a37e..116c4823b18b8a62dfde0a7954977579439c9713 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/MultiDimPosConverterNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/MultiDimPosConverterNode.java @@ -23,7 +23,6 @@ package com.oracle.truffle.r.nodes.access.array.read; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; @@ -32,7 +31,7 @@ import com.oracle.truffle.r.runtime.data.model.*; @NodeChildren({@NodeChild(value = "vector", type = RNode.class), @NodeChild(value = "operand", type = RNode.class)}) public abstract class MultiDimPosConverterNode extends RNode { - public abstract RIntVector executeConvert(VirtualFrame frame, Object vector, Object p); + public abstract RIntVector executeConvert(Object vector, Object p); private final boolean isSubset; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/PositionsArrayConversionNodeMultiDimAdapter.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/PositionsArrayConversionNodeMultiDimAdapter.java index a0521c68d6354848612f6492cdd782e9e3554859..4df1caa7be5f8d06f81c8240709a7742f78dc57b 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/PositionsArrayConversionNodeMultiDimAdapter.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/PositionsArrayConversionNodeMultiDimAdapter.java @@ -22,7 +22,6 @@ */ package com.oracle.truffle.r.nodes.access.array.read; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.access.array.*; import com.oracle.truffle.r.runtime.data.*; @@ -43,8 +42,7 @@ public class PositionsArrayConversionNodeMultiDimAdapter extends PositionsArrayC } } - public RIntVector executeMultiConvert(VirtualFrame frame, Object vector, Object p, int i) { - return this.multiDimOperatorConverters[i].executeConvert(frame, vector, p); + public RIntVector executeMultiConvert(Object vector, Object p, int i) { + return this.multiDimOperatorConverters[i].executeConvert(vector, p); } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/PositionsArrayNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/PositionsArrayNode.java index 05f41b8f71fe1b89008fe78b5c0d51f199047e24..1ca2c94bfe7d47c12355dfadd02940ae61b44ce3 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/PositionsArrayNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/read/PositionsArrayNode.java @@ -94,7 +94,7 @@ public class PositionsArrayNode extends RNode implements RSyntaxNode { int length = conversionAdapter.getLength(); Object[] evaluatedElements = explodeLoopNoVarArg(frame, positionsAdapter, length); length = conversionAdapter.getLength(); // could have changed - doEvalInternal(frame, vector, exact, evaluatedElements, length); + doEvalInternal(vector, exact, evaluatedElements, length); return conversionAdapter.getLength() == 1 ? evaluatedElements[0] : evaluatedElements; } @@ -123,17 +123,17 @@ public class PositionsArrayNode extends RNode implements RSyntaxNode { this.conversionAdapter = insert(new PositionsArrayConversionNodeMultiDimAdapter(this.conversionAdapter.isSubset(), evaluatedElements.length)); } length = conversionAdapter.getLength(); // could have changed - doEvalInternal(frame, vector, exact, evaluatedElements, length); + doEvalInternal(vector, exact, evaluatedElements, length); return conversionAdapter.getLength() == 1 ? evaluatedElements[0] : evaluatedElements; } @ExplodeLoop - private void doEvalInternal(VirtualFrame frame, Object vector, Object exact, Object[] evaluatedElements, int length) { + private void doEvalInternal(Object vector, Object exact, Object[] evaluatedElements, int length) { for (int i = 0; i < length; i++) { - Object convertedOperator = conversionAdapter.executeConvert(frame, vector, evaluatedElements[i], exact, i); - evaluatedElements[i] = conversionAdapter.executeArg(frame, vector, convertedOperator, i); + Object convertedOperator = conversionAdapter.executeConvert(vector, evaluatedElements[i], exact, i); + evaluatedElements[i] = conversionAdapter.executeArg(vector, convertedOperator, i); if (conversionAdapter.multiDimOperatorConverters != null) { - evaluatedElements[i] = conversionAdapter.executeMultiConvert(frame, vector, evaluatedElements[i], i); + evaluatedElements[i] = conversionAdapter.executeMultiConvert(vector, evaluatedElements[i], i); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/CoerceVector.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/CoerceVector.java index 7ca4753b53d363b5aaf86b1cdacdee22332cc4d6..53d0e1d572b820c0263694b717e15a85af53e605 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/CoerceVector.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/CoerceVector.java @@ -36,7 +36,7 @@ import com.oracle.truffle.r.runtime.data.model.*; @NodeChildren({@NodeChild(value = "newValue", type = RNode.class), @NodeChild(value = "vector", type = RNode.class), @NodeChild(value = "operand", type = RNode.class)}) public abstract class CoerceVector extends RNode implements RSyntaxNode/* temp */{ - public abstract Object executeEvaluated(VirtualFrame frame, Object value, Object vector, Object operand); + public abstract Object executeEvaluated(Object value, Object vector, Object operand); @Child private CastComplexNode castComplex; @Child private CastDoubleNode castDouble; @@ -47,88 +47,88 @@ public abstract class CoerceVector extends RNode implements RSyntaxNode/* temp * public abstract RNode getVector(); - private Object coerceRecursive(VirtualFrame frame, Object value, Object vector, Object operand) { + private Object coerceRecursive(Object value, Object vector, Object operand) { if (coerceRecursive == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); coerceRecursive = insert(CoerceVectorNodeGen.create(null, null, null)); } - return coerceRecursive.executeEvaluated(frame, value, vector, operand); + return coerceRecursive.executeEvaluated(value, vector, operand); } - private Object castComplex(VirtualFrame frame, Object vector) { + private Object castComplex(Object vector) { if (castComplex == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castComplex = insert(CastComplexNodeGen.create(null, true, true, true)); } - return castComplex.executeCast(frame, vector); + return castComplex.executeCast(vector); } - private Object castDouble(VirtualFrame frame, Object vector) { + private Object castDouble(Object vector) { if (castDouble == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castDouble = insert(CastDoubleNodeGen.create(null, true, true, true)); } - return castDouble.executeCast(frame, vector); + return castDouble.executeCast(vector); } - private Object castInteger(VirtualFrame frame, Object vector) { + private Object castInteger(Object vector) { if (castInteger == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castInteger = insert(CastIntegerNodeGen.create(null, true, true, true)); } - return castInteger.executeCast(frame, vector); + return castInteger.executeCast(vector); } - private Object castString(VirtualFrame frame, Object vector) { + private Object castString(Object vector) { if (castString == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castString = insert(CastStringNodeGen.create(null, true, true, true, false)); } - return castString.executeCast(frame, vector); + return castString.executeCast(vector); } - private Object castList(VirtualFrame frame, Object vector) { + private Object castList(Object vector) { if (castList == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castList = insert(CastListNodeGen.create(null, true, false, true)); } - return castList.executeCast(frame, vector); + return castList.executeCast(vector); } @Specialization - protected RFunction coerce(VirtualFrame frame, Object value, RFunction vector, Object operand) { + protected RFunction coerce(Object value, RFunction vector, Object operand) { return vector; } @Specialization - protected RFactor coerce(VirtualFrame frame, Object value, RFactor vector, Object operand) { + protected RFactor coerce(Object value, RFactor vector, Object operand) { return vector; } // int vector value @Specialization - protected RAbstractIntVector coerce(VirtualFrame frame, RAbstractIntVector value, RAbstractIntVector vector, Object operand) { + protected RAbstractIntVector coerce(RAbstractIntVector value, RAbstractIntVector vector, Object operand) { return vector; } @Specialization - protected RAbstractDoubleVector coerce(VirtualFrame frame, RAbstractIntVector value, RAbstractDoubleVector vector, Object operand) { + protected RAbstractDoubleVector coerce(RAbstractIntVector value, RAbstractDoubleVector vector, Object operand) { return vector; } @Specialization - protected RAbstractIntVector coerce(VirtualFrame frame, RAbstractIntVector value, RAbstractLogicalVector vector, Object operand) { - return (RIntVector) castInteger(frame, vector); + protected RAbstractIntVector coerce(RAbstractIntVector value, RAbstractLogicalVector vector, Object operand) { + return (RIntVector) castInteger(vector); } @Specialization - protected RAbstractStringVector coerce(VirtualFrame frame, RAbstractIntVector value, RAbstractStringVector vector, Object operand) { + protected RAbstractStringVector coerce(RAbstractIntVector value, RAbstractStringVector vector, Object operand) { return vector; } @Specialization - protected RAbstractComplexVector coerce(VirtualFrame frame, RAbstractIntVector value, RAbstractComplexVector vector, Object operand) { + protected RAbstractComplexVector coerce(RAbstractIntVector value, RAbstractComplexVector vector, Object operand) { return vector; } @@ -138,34 +138,34 @@ public abstract class CoerceVector extends RNode implements RSyntaxNode/* temp * } @Specialization(guards = "isVectorListOrDataFrame(vector)") - protected RAbstractContainer coerce(VirtualFrame frame, RAbstractIntVector value, RAbstractContainer vector, Object operand) { + protected RAbstractContainer coerce(RAbstractIntVector value, RAbstractContainer vector, Object operand) { return vector; } // double vector value @Specialization - protected RDoubleVector coerce(VirtualFrame frame, RAbstractDoubleVector value, RAbstractIntVector vector, Object operand) { - return (RDoubleVector) castDouble(frame, vector); + protected RDoubleVector coerce(RAbstractDoubleVector value, RAbstractIntVector vector, Object operand) { + return (RDoubleVector) castDouble(vector); } @Specialization - protected RAbstractDoubleVector coerce(VirtualFrame frame, RAbstractDoubleVector value, RAbstractDoubleVector vector, Object operand) { + protected RAbstractDoubleVector coerce(RAbstractDoubleVector value, RAbstractDoubleVector vector, Object operand) { return vector; } @Specialization - protected RDoubleVector coerce(VirtualFrame frame, RAbstractDoubleVector value, RAbstractLogicalVector vector, Object operand) { - return (RDoubleVector) castDouble(frame, vector); + protected RDoubleVector coerce(RAbstractDoubleVector value, RAbstractLogicalVector vector, Object operand) { + return (RDoubleVector) castDouble(vector); } @Specialization - protected RAbstractStringVector coerce(VirtualFrame frame, RAbstractDoubleVector value, RAbstractStringVector vector, Object operand) { + protected RAbstractStringVector coerce(RAbstractDoubleVector value, RAbstractStringVector vector, Object operand) { return vector; } @Specialization - protected RAbstractComplexVector coerce(VirtualFrame frame, RAbstractDoubleVector value, RAbstractComplexVector vector, Object operand) { + protected RAbstractComplexVector coerce(RAbstractDoubleVector value, RAbstractComplexVector vector, Object operand) { return vector; } @@ -175,34 +175,34 @@ public abstract class CoerceVector extends RNode implements RSyntaxNode/* temp * } @Specialization - protected RAbstractContainer coerce(VirtualFrame frame, RAbstractDoubleVector value, RAbstractContainer vector, Object operand) { + protected RAbstractContainer coerce(RAbstractDoubleVector value, RAbstractContainer vector, Object operand) { return vector; } // logical vector value @Specialization - protected RAbstractIntVector coerce(VirtualFrame frame, RAbstractLogicalVector value, RAbstractIntVector vector, Object operand) { + protected RAbstractIntVector coerce(RAbstractLogicalVector value, RAbstractIntVector vector, Object operand) { return vector; } @Specialization - protected RAbstractDoubleVector coerce(VirtualFrame frame, RAbstractLogicalVector value, RAbstractDoubleVector vector, Object operand) { + protected RAbstractDoubleVector coerce(RAbstractLogicalVector value, RAbstractDoubleVector vector, Object operand) { return vector; } @Specialization - protected RAbstractLogicalVector coerce(VirtualFrame frame, RAbstractLogicalVector value, RAbstractLogicalVector vector, Object operand) { + protected RAbstractLogicalVector coerce(RAbstractLogicalVector value, RAbstractLogicalVector vector, Object operand) { return vector; } @Specialization - protected RAbstractStringVector coerce(VirtualFrame frame, RAbstractLogicalVector value, RAbstractStringVector vector, Object operand) { + protected RAbstractStringVector coerce(RAbstractLogicalVector value, RAbstractStringVector vector, Object operand) { return vector; } @Specialization - protected RAbstractComplexVector coerce(VirtualFrame frame, RAbstractLogicalVector value, RAbstractComplexVector vector, Object operand) { + protected RAbstractComplexVector coerce(RAbstractLogicalVector value, RAbstractComplexVector vector, Object operand) { return vector; } @@ -212,35 +212,35 @@ public abstract class CoerceVector extends RNode implements RSyntaxNode/* temp * } @Specialization(guards = "isVectorListOrDataFrame(vector)") - protected RAbstractContainer coerce(VirtualFrame frame, RAbstractLogicalVector value, RAbstractContainer vector, Object operand) { + protected RAbstractContainer coerce(RAbstractLogicalVector value, RAbstractContainer vector, Object operand) { return vector; } // string vector value @Specialization - protected RStringVector coerce(VirtualFrame frame, RAbstractStringVector value, RAbstractIntVector vector, Object operand) { - return (RStringVector) castString(frame, vector); + protected RStringVector coerce(RAbstractStringVector value, RAbstractIntVector vector, Object operand) { + return (RStringVector) castString(vector); } @Specialization - protected RStringVector coerce(VirtualFrame frame, RAbstractStringVector value, RAbstractDoubleVector vector, Object operand) { - return (RStringVector) castString(frame, vector); + protected RStringVector coerce(RAbstractStringVector value, RAbstractDoubleVector vector, Object operand) { + return (RStringVector) castString(vector); } @Specialization - protected RStringVector coerce(VirtualFrame frame, RAbstractStringVector value, RAbstractLogicalVector vector, Object operand) { - return (RStringVector) castString(frame, vector); + protected RStringVector coerce(RAbstractStringVector value, RAbstractLogicalVector vector, Object operand) { + return (RStringVector) castString(vector); } @Specialization - protected RAbstractStringVector coerce(VirtualFrame frame, RAbstractStringVector value, RAbstractStringVector vector, Object operand) { + protected RAbstractStringVector coerce(RAbstractStringVector value, RAbstractStringVector vector, Object operand) { return vector; } @Specialization - protected RStringVector coerce(VirtualFrame frame, RAbstractStringVector value, RAbstractComplexVector vector, Object operand) { - return (RStringVector) castString(frame, vector); + protected RStringVector coerce(RAbstractStringVector value, RAbstractComplexVector vector, Object operand) { + return (RStringVector) castString(vector); } @Specialization @@ -249,34 +249,34 @@ public abstract class CoerceVector extends RNode implements RSyntaxNode/* temp * } @Specialization(guards = "isVectorListOrDataFrame(vector)") - protected RAbstractContainer coerce(VirtualFrame frame, RAbstractStringVector value, RAbstractContainer vector, Object operand) { + protected RAbstractContainer coerce(RAbstractStringVector value, RAbstractContainer vector, Object operand) { return vector; } // complex vector value @Specialization - protected RComplexVector coerce(VirtualFrame frame, RAbstractComplexVector value, RAbstractIntVector vector, Object operand) { - return (RComplexVector) castComplex(frame, vector); + protected RComplexVector coerce(RAbstractComplexVector value, RAbstractIntVector vector, Object operand) { + return (RComplexVector) castComplex(vector); } @Specialization - protected RComplexVector coerce(VirtualFrame frame, RAbstractComplexVector value, RAbstractDoubleVector vector, Object operand) { - return (RComplexVector) castComplex(frame, vector); + protected RComplexVector coerce(RAbstractComplexVector value, RAbstractDoubleVector vector, Object operand) { + return (RComplexVector) castComplex(vector); } @Specialization - protected RComplexVector coerce(VirtualFrame frame, RAbstractComplexVector value, RAbstractLogicalVector vector, Object operand) { - return (RComplexVector) castComplex(frame, vector); + protected RComplexVector coerce(RAbstractComplexVector value, RAbstractLogicalVector vector, Object operand) { + return (RComplexVector) castComplex(vector); } @Specialization - protected RAbstractStringVector coerce(VirtualFrame frame, RAbstractComplexVector value, RAbstractStringVector vector, Object operand) { + protected RAbstractStringVector coerce(RAbstractComplexVector value, RAbstractStringVector vector, Object operand) { return vector; } @Specialization - protected RAbstractComplexVector coerce(VirtualFrame frame, RAbstractComplexVector value, RAbstractComplexVector vector, Object operand) { + protected RAbstractComplexVector coerce(RAbstractComplexVector value, RAbstractComplexVector vector, Object operand) { return vector; } @@ -286,14 +286,14 @@ public abstract class CoerceVector extends RNode implements RSyntaxNode/* temp * } @Specialization(guards = "isVectorListOrDataFrame(vector)") - protected RAbstractContainer coerce(VirtualFrame frame, RAbstractComplexVector value, RAbstractContainer vector, Object operand) { + protected RAbstractContainer coerce(RAbstractComplexVector value, RAbstractContainer vector, Object operand) { return vector; } // raw vector value @Specialization - protected RAbstractRawVector coerce(VirtualFrame frame, RAbstractRawVector value, RAbstractRawVector vector, Object operand) { + protected RAbstractRawVector coerce(RAbstractRawVector value, RAbstractRawVector vector, Object operand) { return vector; } @@ -303,34 +303,34 @@ public abstract class CoerceVector extends RNode implements RSyntaxNode/* temp * } @Specialization(guards = "isVectorListOrDataFrame(vector)") - protected RAbstractContainer coerce(VirtualFrame frame, RAbstractRawVector value, RAbstractContainer vector, Object operand) { + protected RAbstractContainer coerce(RAbstractRawVector value, RAbstractContainer vector, Object operand) { return vector; } // list vector value @Specialization(guards = "isVectorListOrDataFrame(vector)") - protected RAbstractContainer coerce(VirtualFrame frame, RList value, RAbstractContainer vector, Object operand) { + protected RAbstractContainer coerce(RList value, RAbstractContainer vector, Object operand) { return vector; } @Specialization(guards = "!isVectorList(vector)") - protected RList coerce(VirtualFrame frame, RList value, RAbstractVector vector, Object operand) { - return (RList) castList(frame, vector); + protected RList coerce(RList value, RAbstractVector vector, Object operand) { + return (RList) castList(vector); } // data frame value @Specialization - protected RList coerce(VirtualFrame frame, RDataFrame value, RAbstractContainer vector, Object operand) { - return (RList) castList(frame, vector); + protected RList coerce(RDataFrame value, RAbstractContainer vector, Object operand) { + return (RList) castList(vector); } // factor value @Specialization - protected Object coerce(VirtualFrame frame, RFactor value, RAbstractContainer vector, Object operand) { - return coerceRecursive(frame, value.getVector(), vector, operand); + protected Object coerce(RFactor value, RAbstractContainer vector, Object operand) { + return coerceRecursive(value.getVector(), vector, operand); } // function vector value @@ -357,8 +357,8 @@ public abstract class CoerceVector extends RNode implements RSyntaxNode/* temp * return vector; } - @Specialization - protected RAbstractVector coerce(RList value, RAbstractVector vector, Object operand) { + @Specialization(guards = "isVectorList(vector)") + protected RAbstractVector coerceList(RList value, RAbstractVector vector, Object operand) { return vector; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/MultiDimPosConverterValueNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/MultiDimPosConverterValueNode.java index 49872b9a17d8bdf08fd7130ffbd7d5664fc356f0..5ac64361b4e2bfc69506d2fdc08ce53a5f0800fb 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/MultiDimPosConverterValueNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/MultiDimPosConverterValueNode.java @@ -23,7 +23,6 @@ package com.oracle.truffle.r.nodes.access.array.write; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.runtime.*; @@ -36,7 +35,7 @@ public abstract class MultiDimPosConverterValueNode extends RNode { private final BranchProfile errorProfile = BranchProfile.create(); - public abstract RIntVector executeConvert(VirtualFrame frame, Object vector, Object value, Object positions); + public abstract RIntVector executeConvert(Object vector, Object value, Object positions); private final boolean isSubset; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/PositionsArrayConversionValueNodeMultiDimAdapter.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/PositionsArrayConversionValueNodeMultiDimAdapter.java index dd62257f46886dceb6eaca68a5efa5b6350def13..12fe3aac08f6e1284010ad99671dd9925a9c4481 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/PositionsArrayConversionValueNodeMultiDimAdapter.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/PositionsArrayConversionValueNodeMultiDimAdapter.java @@ -22,7 +22,6 @@ */ package com.oracle.truffle.r.nodes.access.array.write; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.access.array.*; import com.oracle.truffle.r.runtime.data.*; @@ -42,8 +41,7 @@ public class PositionsArrayConversionValueNodeMultiDimAdapter extends PositionsA } } - public RIntVector executeMultiConvert(VirtualFrame frame, Object vector, Object value, Object p, int i) { - return this.multiDimOperatorConverters[i].executeConvert(frame, vector, value, p); + public RIntVector executeMultiConvert(Object vector, Object value, Object p, int i) { + return this.multiDimOperatorConverters[i].executeConvert(vector, value, p); } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/PositionsArrayNodeValue.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/PositionsArrayNodeValue.java index 820d512aee407513c591b2f3ed2361b5792367be..140130841c27f7774ebb99bbe67921d6d364180d 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/PositionsArrayNodeValue.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/PositionsArrayNodeValue.java @@ -64,7 +64,7 @@ public class PositionsArrayNodeValue extends RNode implements RSyntaxNode { private Object executeEvalNoVarArg(VirtualFrame frame, Object vector, Object value) { int length = conversionAdapter.getLength(); Object[] evaluatedElements = PositionsArrayNode.explodeLoopNoVarArg(frame, positionsAdapter, length); - executeEvalInternal(frame, vector, value, evaluatedElements, length); + executeEvalInternal(vector, value, evaluatedElements, length); return conversionAdapter.getLength() == 1 ? evaluatedElements[0] : evaluatedElements; } @@ -76,17 +76,17 @@ public class PositionsArrayNodeValue extends RNode implements RSyntaxNode { this.conversionAdapter = insert(new PositionsArrayConversionValueNodeMultiDimAdapter(this.conversionAdapter.isSubset(), evaluatedElements.length)); } length = conversionAdapter.getLength(); // could have changed - executeEvalInternal(frame, vector, value, evaluatedElements, length); + executeEvalInternal(vector, value, evaluatedElements, length); return conversionAdapter.getLength() == 1 ? evaluatedElements[0] : evaluatedElements; } @ExplodeLoop - private void executeEvalInternal(VirtualFrame frame, Object vector, Object value, Object[] evaluatedElements, int length) { + private void executeEvalInternal(Object vector, Object value, Object[] evaluatedElements, int length) { for (int i = 0; i < length; i++) { - Object convertedOperator = conversionAdapter.executeConvert(frame, vector, evaluatedElements[i], RRuntime.LOGICAL_TRUE, i); - evaluatedElements[i] = conversionAdapter.executeArg(frame, vector, convertedOperator, i); + Object convertedOperator = conversionAdapter.executeConvert(vector, evaluatedElements[i], RRuntime.LOGICAL_TRUE, i); + evaluatedElements[i] = conversionAdapter.executeArg(vector, convertedOperator, i); if (conversionAdapter.multiDimOperatorConverters != null) { - evaluatedElements[i] = conversionAdapter.executeMultiConvert(frame, vector, value, evaluatedElements[i], i); + evaluatedElements[i] = conversionAdapter.executeMultiConvert(vector, value, evaluatedElements[i], i); } } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/UpdateArrayHelperNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/UpdateArrayHelperNode.java index 15fcf1d5493f7b3239e967b6711f75fb974e473d..1dbf83443dd8a41056741a9bb5db52f8bcf7b126 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/UpdateArrayHelperNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/array/write/UpdateArrayHelperNode.java @@ -68,7 +68,7 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta @Override public Object executeUpdate(VirtualFrame frame, Object lhs, Object rhs) { Object positions = getPositions().executeEval(frame, lhs, rhs); - return executeUpdate(frame, lhs, rhs, positions, getVector().executeEvaluated(frame, rhs, lhs, positions)); + return executeUpdate(frame, lhs, rhs, positions, getVector().executeEvaluated(rhs, lhs, positions)); } public abstract Object executeUpdate(VirtualFrame frame, Object v, Object value, Object positions, Object vector); @@ -161,68 +161,68 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta private final ConditionProfile needsCastProfile = ConditionProfile.createBinaryProfile(); - private RComplexVector castComplex(VirtualFrame frame, Object operand) { + private RComplexVector castComplex(Object operand) { if (needsCastProfile.profile(!(operand instanceof RComplexVector))) { if (castComplex == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castComplex = insert(CastComplexNodeGen.create(null, true, true, false)); } - return (RComplexVector) castComplex.executeCast(frame, operand); + return (RComplexVector) castComplex.executeCast(operand); } else { return (RComplexVector) operand; } } - private RDoubleVector castDouble(VirtualFrame frame, Object operand) { + private RDoubleVector castDouble(Object operand) { if (needsCastProfile.profile(!(operand instanceof RDoubleVector))) { if (castDouble == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castDouble = insert(CastDoubleNodeGen.create(null, true, true, false)); } - return (RDoubleVector) castDouble.executeCast(frame, operand); + return (RDoubleVector) castDouble.executeCast(operand); } else { return (RDoubleVector) operand; } } - private RIntVector castInteger(VirtualFrame frame, Object operand) { + private RIntVector castInteger(Object operand) { if (needsCastProfile.profile(!(operand instanceof RIntVector))) { if (castInteger == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castInteger = insert(CastIntegerNodeGen.create(null, true, true, false)); } - return (RIntVector) castInteger.executeCast(frame, operand); + return (RIntVector) castInteger.executeCast(operand); } else { return (RIntVector) operand; } } - private RStringVector castString(VirtualFrame frame, Object operand) { + private RStringVector castString(Object operand) { if (needsCastProfile.profile(!(operand instanceof RStringVector))) { if (castString == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castString = insert(CastStringNodeGen.create(null, true, true, false, true)); } - return (RStringVector) castString.executeCast(frame, operand); + return (RStringVector) castString.executeCast(operand); } else { return (RStringVector) operand; } } - private Object coerceVector(VirtualFrame frame, Object vector, Object value, Object operand) { + private Object coerceVector(Object vector, Object value, Object operand) { if (coerceVector == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); coerceVector = insert(CoerceVectorNodeGen.create(null, null, null)); } - return coerceVector.executeEvaluated(frame, value, vector, operand); + return coerceVector.executeEvaluated(value, vector, operand); } - private Object castPosition(VirtualFrame frame, Object vector, Object operand) { + private Object castPosition(Object vector, Object operand) { if (castPosition == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castPosition = insert(ArrayPositionCastNodeGen.create(0, 1, true, false, null, null)); } - return castPosition.executeArg(frame, vector, operand); + return castPosition.executeArg(vector, operand); } private void initOperatorConvert() { @@ -232,14 +232,14 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } } - private Object convertOperand(VirtualFrame frame, Object vector, int operand) { + private Object convertOperand(Object vector, int operand) { initOperatorConvert(); - return operatorConverter.executeConvert(frame, vector, operand, RRuntime.LOGICAL_TRUE); + return operatorConverter.executeConvert(vector, operand, RRuntime.LOGICAL_TRUE); } - private Object convertOperand(VirtualFrame frame, Object vector, String operand) { + private Object convertOperand(Object vector, String operand) { initOperatorConvert(); - return operatorConverter.executeConvert(frame, vector, operand, RRuntime.LOGICAL_TRUE); + return operatorConverter.executeConvert(vector, operand, RRuntime.LOGICAL_TRUE); } private Object setMultiDimData(VirtualFrame frame, RAbstractContainer value, RAbstractVector vector, Object[] positions, int currentDimLevel, int srcArrayBase, int dstArrayBase, @@ -800,8 +800,8 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta resultList = (RList) vector.deepCopy(); } if (twoPosProfile.profile(p.getLength() == 2)) { - Object finalVector = coerceVector(frame, resultList.getDataAt(position - 1), value, p); - Object lastPosition = castPosition(frame, finalVector, convertOperand(frame, finalVector, p.getDataAt(1))); + Object finalVector = coerceVector(resultList.getDataAt(position - 1), value, p); + Object lastPosition = castPosition(finalVector, convertOperand(finalVector, p.getDataAt(1))); el = updateRecursive(frame, v, value, finalVector, lastPosition); } else { RStringVector newP = AccessArrayNode.popHead(p, posNACheck); @@ -998,8 +998,8 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } Object el; if (twoPosProfile.profile(p.getLength() == 2)) { - Object finalVector = coerceVector(frame, resultList.getDataAt(position - 1), value, p); - Object lastPosition = castPosition(frame, finalVector, convertOperand(frame, finalVector, p.getDataAt(1))); + Object finalVector = coerceVector(resultList.getDataAt(position - 1), value, p); + Object lastPosition = castPosition(finalVector, convertOperand(finalVector, p.getDataAt(1))); el = updateRecursive(frame, v, value, finalVector, lastPosition); } else { RIntVector newP = AccessArrayNode.popHead(p, posNACheck); @@ -1185,7 +1185,7 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RIntVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, Object[] positions, RAbstractIntVector vector) { - return updateVector(frame, castInteger(frame, value), vector, positions); + return updateVector(frame, castInteger(value), vector, positions); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) @@ -1194,13 +1194,13 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) - protected RAbstractIntVector updateSubset(VirtualFrame frame, Object v, RAbstractLogicalVector value, RIntVector positions, RAbstractIntVector vector) { - return updateSubset(v, castInteger(frame, value), positions, vector); + protected RAbstractIntVector updateSubset(Object v, RAbstractLogicalVector value, RIntVector positions, RAbstractIntVector vector) { + return updateSubset(v, castInteger(value), positions, vector); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) - protected RAbstractIntVector updateSubset(VirtualFrame frame, Object v, RAbstractDoubleVector value, RIntVector positions, RAbstractIntVector vector) { - return updateSubset(v, castInteger(frame, value), positions, vector); + protected RAbstractIntVector updateSubset(Object v, RAbstractDoubleVector value, RIntVector positions, RAbstractIntVector vector) { + return updateSubset(v, castInteger(value), positions, vector); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) @@ -1214,8 +1214,8 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) - protected RAbstractIntVector updateNames(VirtualFrame frame, Object v, RAbstractLogicalVector value, RIntVector positions, RAbstractIntVector vector) { - return updateNames(v, castInteger(frame, value), positions, vector); + protected RAbstractIntVector updateNames(Object v, RAbstractLogicalVector value, RIntVector positions, RAbstractIntVector vector) { + return updateNames(v, castInteger(value), positions, vector); } @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) @@ -1225,8 +1225,8 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) - protected RIntVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractLogicalVector value, int position, RAbstractIntVector vector) { - return updateTooManyValuesSubset(v, castInteger(frame, value), position, vector); + protected RIntVector updateTooManyValuesSubset(Object v, RAbstractLogicalVector value, int position, RAbstractIntVector vector) { + return updateTooManyValuesSubset(v, castInteger(value), position, vector); } @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) @@ -1240,8 +1240,8 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) - protected RIntVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, int position, RAbstractIntVector vector) { - return updateSingleDim(castInteger(frame, value), getResultVector(vector, position), position); + protected RIntVector update(Object v, RAbstractLogicalVector value, int position, RAbstractIntVector vector) { + return updateSingleDim(castInteger(value), getResultVector(vector, position), position); } // double vector @@ -1327,7 +1327,7 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RDoubleVector update(VirtualFrame frame, Object v, RAbstractIntVector value, Object[] positions, RAbstractDoubleVector vector) { - return updateVector(frame, castDouble(frame, value), vector, positions); + return updateVector(frame, castDouble(value), vector, positions); } @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) @@ -1337,12 +1337,12 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RDoubleVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, Object[] positions, RAbstractDoubleVector vector) { - return updateVector(frame, castDouble(frame, value), vector, positions); + return updateVector(frame, castDouble(value), vector, positions); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) - protected RAbstractDoubleVector updateSubset(VirtualFrame frame, Object v, RAbstractIntVector value, RIntVector positions, RAbstractDoubleVector vector) { - return updateSingleDimVector(castDouble(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); + protected RAbstractDoubleVector updateSubset(Object v, RAbstractIntVector value, RIntVector positions, RAbstractDoubleVector vector) { + return updateSingleDimVector(castDouble(value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) @@ -1351,19 +1351,19 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) - protected RAbstractDoubleVector updateNames(VirtualFrame frame, Object v, RAbstractIntVector value, RIntVector positions, RAbstractDoubleVector vector) { - return updateSingleDimVector(castDouble(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); + protected RAbstractDoubleVector updateNames(Object v, RAbstractIntVector value, RIntVector positions, RAbstractDoubleVector vector) { + return updateSingleDimVector(castDouble(value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) - protected RDoubleVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractIntVector value, int position, RAbstractDoubleVector vector) { + protected RDoubleVector updateTooManyValuesSubset(Object v, RAbstractIntVector value, int position, RAbstractDoubleVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); - return updateSingleDim(castDouble(frame, value), getResultVector(vector, position), position); + return updateSingleDim(castDouble(value), getResultVector(vector, position), position); } @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) - protected RDoubleVector update(VirtualFrame frame, Object v, RAbstractIntVector value, int position, RAbstractDoubleVector vector) { - return updateSingleDim(castDouble(frame, value), getResultVector(vector, position), position); + protected RDoubleVector update(Object v, RAbstractIntVector value, int position, RAbstractDoubleVector vector) { + return updateSingleDim(castDouble(value), getResultVector(vector, position), position); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) @@ -1393,8 +1393,8 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) - protected RAbstractDoubleVector updateSubset(VirtualFrame frame, Object v, RAbstractLogicalVector value, RIntVector positions, RAbstractDoubleVector vector) { - return updateSingleDimVector(castDouble(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); + protected RAbstractDoubleVector updateSubset(Object v, RAbstractLogicalVector value, RIntVector positions, RAbstractDoubleVector vector) { + return updateSingleDimVector(castDouble(value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) @@ -1403,19 +1403,19 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) - protected RAbstractDoubleVector updateNames(VirtualFrame frame, Object v, RAbstractLogicalVector value, RIntVector positions, RAbstractDoubleVector vector) { - return updateSingleDimVector(castDouble(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); + protected RAbstractDoubleVector updateNames(Object v, RAbstractLogicalVector value, RIntVector positions, RAbstractDoubleVector vector) { + return updateSingleDimVector(castDouble(value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) - protected RDoubleVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractLogicalVector value, int position, RAbstractDoubleVector vector) { + protected RDoubleVector updateTooManyValuesSubset(Object v, RAbstractLogicalVector value, int position, RAbstractDoubleVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); - return updateSingleDim(castDouble(frame, value), getResultVector(vector, position), position); + return updateSingleDim(castDouble(value), getResultVector(vector, position), position); } @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) - protected RDoubleVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, int position, RAbstractDoubleVector vector) { - return updateSingleDim(castDouble(frame, value), getResultVector(vector, position), position); + protected RDoubleVector update(Object v, RAbstractLogicalVector value, int position, RAbstractDoubleVector vector) { + return updateSingleDim(castDouble(value), getResultVector(vector, position), position); } // logical vector @@ -1612,7 +1612,7 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RStringVector update(VirtualFrame frame, Object v, RAbstractVector value, Object[] positions, RStringVector vector) { - return updateVector(frame, castString(frame, value), vector, positions); + return updateVector(frame, castString(value), vector, positions); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) @@ -1642,8 +1642,8 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) - protected RAbstractStringVector updateSubset(VirtualFrame frame, Object v, RAbstractVector value, RIntVector positions, RStringVector vector) { - return updateSingleDimVector(castString(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); + protected RAbstractStringVector updateSubset(Object v, RAbstractVector value, RIntVector positions, RStringVector vector) { + return updateSingleDimVector(castString(value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) @@ -1652,19 +1652,19 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) - protected RAbstractStringVector updateSubsetNames(VirtualFrame frame, Object v, RAbstractVector value, RIntVector positions, RStringVector vector) { - return updateSingleDimVector(castString(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); + protected RAbstractStringVector updateSubsetNames(Object v, RAbstractVector value, RIntVector positions, RStringVector vector) { + return updateSingleDimVector(castString(value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) - protected RStringVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractVector value, int position, RStringVector vector) { + protected RStringVector updateTooManyValuesSubset(Object v, RAbstractVector value, int position, RStringVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); - return updateSingleDim(castString(frame, value), getResultVector(vector, position), position); + return updateSingleDim(castString(value), getResultVector(vector, position), position); } @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) - protected RStringVector update(VirtualFrame frame, Object v, RAbstractVector value, int position, RStringVector vector) { - return updateSingleDim(castString(frame, value), getResultVector(vector, position), position); + protected RStringVector update(Object v, RAbstractVector value, int position, RStringVector vector) { + return updateSingleDim(castString(value), getResultVector(vector, position), position); } // complex vector @@ -1747,17 +1747,17 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractIntVector value, Object[] positions, RComplexVector vector) { - return updateVector(frame, castComplex(frame, value), vector, positions); + return updateVector(frame, castComplex(value), vector, positions); } @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractDoubleVector value, Object[] positions, RComplexVector vector) { - return updateVector(frame, castComplex(frame, value), vector, positions); + return updateVector(frame, castComplex(value), vector, positions); } @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, Object[] positions, RComplexVector vector) { - return updateVector(frame, castComplex(frame, value), vector, positions); + return updateVector(frame, castComplex(value), vector, positions); } @Specialization(guards = {"!isObject(vector)", "multiDim(vector)", "!wrongDimensionsMatrix(positions, vector)", "!wrongDimensions(positions, vector)"}) @@ -1766,8 +1766,8 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) - protected RAbstractComplexVector updateSubset(VirtualFrame frame, Object v, RAbstractIntVector value, RIntVector positions, RComplexVector vector) { - return updateSingleDimVector(castComplex(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); + protected RAbstractComplexVector updateSubset(Object v, RAbstractIntVector value, RIntVector positions, RComplexVector vector) { + return updateSingleDimVector(castComplex(value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) @@ -1776,24 +1776,24 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) - protected RAbstractComplexVector updateNames(VirtualFrame frame, Object v, RAbstractIntVector value, RIntVector positions, RComplexVector vector) { - return updateSingleDimVector(castComplex(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); + protected RAbstractComplexVector updateNames(Object v, RAbstractIntVector value, RIntVector positions, RComplexVector vector) { + return updateSingleDimVector(castComplex(value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractIntVector value, int position, RComplexVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); - return updateSingleDim(frame, castComplex(frame, value), getResultVector(vector, position), position); + return updateSingleDim(frame, castComplex(value), getResultVector(vector, position), position); } @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractIntVector value, int position, RComplexVector vector) { - return updateSingleDim(frame, castComplex(frame, value), getResultVector(vector, position), position); + return updateSingleDim(frame, castComplex(value), getResultVector(vector, position), position); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) - protected RAbstractComplexVector updateSubset(VirtualFrame frame, Object v, RAbstractDoubleVector value, RIntVector positions, RComplexVector vector) { - return updateSingleDimVector(castComplex(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); + protected RAbstractComplexVector updateSubset(Object v, RAbstractDoubleVector value, RIntVector positions, RComplexVector vector) { + return updateSingleDimVector(castComplex(value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) @@ -1802,24 +1802,24 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) - protected RAbstractComplexVector updateNames(VirtualFrame frame, Object v, RAbstractDoubleVector value, RIntVector positions, RComplexVector vector) { - return updateSingleDimVector(castComplex(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); + protected RAbstractComplexVector updateNames(Object v, RAbstractDoubleVector value, RIntVector positions, RComplexVector vector) { + return updateSingleDimVector(castComplex(value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractDoubleVector value, int position, RComplexVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); - return updateSingleDim(frame, castComplex(frame, value), getResultVector(vector, position), position); + return updateSingleDim(frame, castComplex(value), getResultVector(vector, position), position); } @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractDoubleVector value, int position, RComplexVector vector) { - return updateSingleDim(frame, castComplex(frame, value), getResultVector(vector, position), position); + return updateSingleDim(frame, castComplex(value), getResultVector(vector, position), position); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) - protected RAbstractComplexVector updateSubset(VirtualFrame frame, Object v, RAbstractLogicalVector value, RIntVector positions, RComplexVector vector) { - return updateSingleDimVector(castComplex(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); + protected RAbstractComplexVector updateSubset(Object v, RAbstractLogicalVector value, RIntVector positions, RComplexVector vector) { + return updateSingleDimVector(castComplex(value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "onePosition(positions)"}) @@ -1828,19 +1828,19 @@ public abstract class UpdateArrayHelperNode extends UpdateNode implements RSynta } @Specialization(guards = {"!isObject(vector)", "posNames(positions)"}) - protected RAbstractComplexVector updateNames(VirtualFrame frame, Object v, RAbstractLogicalVector value, RIntVector positions, RComplexVector vector) { - return updateSingleDimVector(castComplex(frame, value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); + protected RAbstractComplexVector updateNames(Object v, RAbstractLogicalVector value, RIntVector positions, RComplexVector vector) { + return updateSingleDimVector(castComplex(value), vector.getLength(), getResultVector(vector, getHighestPos(positions)), positions); } @Specialization(guards = {"!isObject(vector)", "!isValueLengthOne(value)", "isSubset", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector updateTooManyValuesSubset(VirtualFrame frame, Object v, RAbstractLogicalVector value, int position, RComplexVector vector) { RError.warning(RError.Message.NOT_MULTIPLE_REPLACEMENT); - return updateSingleDim(frame, castComplex(frame, value), getResultVector(vector, position), position); + return updateSingleDim(frame, castComplex(value), getResultVector(vector, position), position); } @Specialization(guards = {"!isObject(vector)", "isValueLengthOne(value)", "!isPosNA(position)", "!isPosZero(position)"}) protected RComplexVector update(VirtualFrame frame, Object v, RAbstractLogicalVector value, int position, RComplexVector vector) { - return updateSingleDim(frame, castComplex(frame, value), getResultVector(vector, position), position); + return updateSingleDim(frame, castComplex(value), getResultVector(vector, position), position); } @Specialization(guards = {"!isObject(vector)", "isSubset", "!posNames(positions)", "multiPos(positions)"}) 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 a854d117ee40600b3549584d16dee86be768c680..e6e6ac6c2cdafb4377b9bd1b4282227d754ac557 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 @@ -365,7 +365,6 @@ public class ReadVariableNode extends RNode implements RSyntaxNode, VisibilityCo private final FrameDescriptor nextDescriptor; private final ValueProfile frameProfile = ValueProfile.createClassProfile(); private final ConditionProfile isEvalFrame = ConditionProfile.createBinaryProfile(); - private final ConditionProfile isFunctionFrame = ConditionProfile.createBinaryProfile(); public NextFrameLevel(FrameLevel next, FrameDescriptor nextDescriptor) { this.next = next; @@ -374,14 +373,7 @@ public class ReadVariableNode extends RNode implements RSyntaxNode, VisibilityCo @Override public Object execute(VirtualFrame frame, Frame variableFrame) throws InvalidAssumptionException, LayoutChangedException, FrameSlotTypeException { - Object[] arguments = RArguments.getArgumentsWithEvalCheck(variableFrame, isEvalFrame); - MaterializedFrame nextFrame; - Object function = arguments[RArguments.INDEX_FUNCTION]; - if (isFunctionFrame.profile(function != null)) { - nextFrame = frameProfile.profile(((RFunction) function).getEnclosingFrame()); - } else { - nextFrame = (MaterializedFrame) frameProfile.profile(arguments[RArguments.INDEX_ENCLOSING_FRAME]); - } + MaterializedFrame nextFrame = frameProfile.profile(RArguments.getEnclosingFrame(variableFrame, isEvalFrame)); if (nextDescriptor == null) { if (nextFrame != null) { throw new LayoutChangedException(); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CastTypeNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CastTypeNode.java index 14d0d58f6b0bdfcceb968f280e259cce302f3672..7ba9712d2acffe614c825ba6c0f1e83f94da31e0 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CastTypeNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CastTypeNode.java @@ -13,39 +13,40 @@ package com.oracle.truffle.r.nodes.binary; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; -@SuppressWarnings("unused") public abstract class CastTypeNode extends BinaryNode { protected static final int NUMBER_OF_TYPES = RType.values().length; @Child protected TypeofNode typeof = TypeofNodeGen.create(null); - public abstract Object execute(VirtualFrame frame, Object value, RType type); + public abstract Object execute(Object value, RType type); + @SuppressWarnings("unused") @Specialization(guards = "typeof.execute(value) == type") protected static RAbstractVector doPass(RAbstractVector value, RType type) { return value; } + @SuppressWarnings("unused") @Specialization(guards = {"typeof.execute(value) != type", "type == cachedType", "!isNull(cast)"}, limit = "NUMBER_OF_TYPES") - protected static Object doCast(VirtualFrame frame, RAbstractVector value, RType type, // + protected static Object doCast(RAbstractVector value, RType type, // @Cached("type") RType cachedType, // @Cached("createCast(cachedType)") CastNode cast) { - return cast.executeCast(frame, value); + return cast.executeCast(value); } @Specialization - protected static Object doCastDataFrame(VirtualFrame frame, RDataFrame value, RType type, // + protected static Object doCastDataFrame(RDataFrame value, RType type, // @Cached("create()") CastTypeNode castRecursive) { - return castRecursive.execute(frame, value.getVector(), type); + return castRecursive.execute(value.getVector(), type); } + @SuppressWarnings("unused") @Specialization(guards = "isNull(createCast(type))") @TruffleBoundary protected static Object doCastUnknown(RAbstractVector value, RType type) { @@ -84,5 +85,4 @@ public abstract class CastTypeNode extends BinaryNode { public static CastTypeNode create() { return CastTypeNodeGen.create(null, null); } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RCastingBuiltinNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RCastingBuiltinNode.java index 1e1b28564069b5ca4ceafd7c131201ba717876b1..88fa71b7fcbc7c3034a254775bd2937788a8a285 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RCastingBuiltinNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RCastingBuiltinNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, 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,7 +23,6 @@ package com.oracle.truffle.r.nodes.builtin; import com.oracle.truffle.api.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.nodes.unary.*; import com.oracle.truffle.r.runtime.data.*; @@ -37,60 +36,59 @@ public abstract class RCastingBuiltinNode extends RBuiltinNode { @Child private CastRawNode castRaw; @Child private CastListNode castList; - protected Object castComplex(VirtualFrame frame, Object operand, boolean preserveAllAttr) { + protected Object castComplex(Object operand, boolean preserveAllAttr) { if (castComplex == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castComplex = insert(CastComplexNodeGen.create(null, true, preserveAllAttr, preserveAllAttr)); } - return castComplex.executeCast(frame, operand); + return castComplex.executeCast(operand); } - protected Object castDouble(VirtualFrame frame, Object operand, boolean preserveAllAttr) { + protected Object castDouble(Object operand, boolean preserveAllAttr) { if (castDouble == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castDouble = insert(CastDoubleNodeGen.create(null, true, preserveAllAttr, preserveAllAttr)); } - return castDouble.executeCast(frame, operand); + return castDouble.executeCast(operand); } - protected Object castInteger(VirtualFrame frame, Object operand, boolean preserveAllAttr) { + protected Object castInteger(Object operand, boolean preserveAllAttr) { if (castInteger == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castInteger = insert(CastIntegerNodeGen.create(null, true, preserveAllAttr, preserveAllAttr)); } - return castInteger.executeCast(frame, operand); + return castInteger.executeCast(operand); } - protected Object castLogical(VirtualFrame frame, Object operand, boolean preserveAllAttr) { + protected Object castLogical(Object operand, boolean preserveAllAttr) { if (castLogical == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castLogical = insert(CastLogicalNodeGen.create(null, true, preserveAllAttr, preserveAllAttr)); } - return castLogical.executeCast(frame, operand); + return castLogical.executeCast(operand); } - protected Object castString(VirtualFrame frame, Object operand, boolean preserveAllAttr) { + protected Object castString(Object operand, boolean preserveAllAttr) { if (castString == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castString = insert(CastStringNodeGen.create(null, false, true, preserveAllAttr, preserveAllAttr)); } - return castString.executeCast(frame, operand); + return castString.executeCast(operand); } - protected Object castRaw(VirtualFrame frame, Object operand, boolean preserveAllAttr) { + protected Object castRaw(Object operand, boolean preserveAllAttr) { if (castRaw == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castRaw = insert(CastRawNodeGen.create(null, true, preserveAllAttr, preserveAllAttr)); } - return castRaw.executeCast(frame, operand); + return castRaw.executeCast(operand); } - protected RList castList(VirtualFrame frame, Object operand, boolean preserveAllAttr) { + protected RList castList(Object operand, boolean preserveAllAttr) { if (castList == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castList = insert(CastListNodeGen.create(null, true, preserveAllAttr, preserveAllAttr)); } - return castList.executeList(frame, operand); + return castList.executeList(operand); } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallMatcherNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallMatcherNode.java index 3901f82279d0c3d1c9448bf8417dec66dae953e9..fea4c8cf7b5b5372ca4b40efeb508d67e97bdb44 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallMatcherNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallMatcherNode.java @@ -87,9 +87,7 @@ public abstract class CallMatcherNode extends Node { } protected final Object[] prepareArguments(VirtualFrame frame, Object[] reorderedArgs, ArgumentsSignature reorderedSignature, RFunction function, S3Args s3Args) { - Object[] argObject = RArguments.create(function, getSourceSection(), null, RArguments.getDepth(frame) + 1, reorderedArgs, reorderedSignature); - RArguments.setS3Args(argObject, s3Args); - return argObject; + return RArguments.create(function, getSourceSection(), null, RArguments.getDepth(frame) + 1, reorderedArgs, reorderedSignature, s3Args); } protected final void evaluatePromises(VirtualFrame frame, RFunction function, Object[] args) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionExpressionNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionExpressionNode.java index 491bebe0499f95e88de61f7bfdfd84699809cdf5..1ce42b2dda9433d071b811cae7c729633022c3d5 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionExpressionNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionExpressionNode.java @@ -114,7 +114,7 @@ public final class FunctionExpressionNode extends RNode implements RSyntaxNode { deoptFrameNode.deoptimizeFrame(matFrame); } verifyEnclosingAssumptions(frame, callTarget.getRootNode().getFrameDescriptor()); - RFunction func = RDataFactory.createFunction("", callTarget, matFrame, containsDispatch); + RFunction func = RDataFactory.createFunction("", callTarget, null, matFrame, containsDispatch); if (RInstrument.instrumentingEnabled()) { RInstrument.checkDebugRequested(callTarget.toString(), func); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/GroupDispatchNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/GroupDispatchNode.java index 8b32ed0851ac276a36de3dbdd4e3c0f971c4a139..5d28e61154ee17505539ff17b8d2b43bccd81702 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/GroupDispatchNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/GroupDispatchNode.java @@ -40,7 +40,8 @@ public final class GroupDispatchNode extends RNode implements RSyntaxNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); private final ConditionProfile mismatchProfile = ConditionProfile.createBinaryProfile(); private final ConditionProfile isObjectProfile = ConditionProfile.createBinaryProfile(); - private final ValueProfile argTypeProfile = ValueProfile.createClassProfile(); + private final ValueProfile leftArgTypeProfile = ValueProfile.createClassProfile(); + private final ValueProfile rightArgTypeProfile = ValueProfile.createClassProfile(); @CompilationFinal private boolean dynamicLookup; private final ConditionProfile exactEqualsProfile = ConditionProfile.createBinaryProfile(); @@ -98,7 +99,7 @@ public final class GroupDispatchNode extends RNode implements RSyntaxNode { return RSyntaxNode.cast(RASTUtils.createCall(this, (CallArgumentsNode) callArgsNode.substitute(env).asRNode())); } - protected RStringVector getArgClass(Object arg) { + protected RStringVector getArgClass(Object arg, ValueProfile argTypeProfile) { Object profiledArg = argTypeProfile.profile(arg); if (profiledArg instanceof RAbstractContainer && isObjectProfile.profile(((RAbstractContainer) profiledArg).isObject(attrProfiles))) { return ((RAbstractContainer) profiledArg).getClassHierarchy(); @@ -126,7 +127,7 @@ public final class GroupDispatchNode extends RNode implements RSyntaxNode { private Object executeInternal(VirtualFrame frame, RArgsValuesAndNames argAndNames, String genericName, RGroupGenerics group, RFunction builtinFunction) { Object[] evaluatedArgs = argAndNames.getArguments(); - RStringVector typeL = evaluatedArgs.length == 0 ? null : getArgClass(evaluatedArgs[0]); + RStringVector typeL = evaluatedArgs.length == 0 ? null : getArgClass(evaluatedArgs[0], leftArgTypeProfile); Result resultL = null; if (typeL != null) { @@ -142,7 +143,7 @@ public final class GroupDispatchNode extends RNode implements RSyntaxNode { } Result resultR = null; if (group == RGroupGenerics.Ops && argAndNames.getSignature().getLength() >= 2) { - RStringVector typeR = getArgClass(evaluatedArgs[1]); + RStringVector typeR = getArgClass(evaluatedArgs[1], rightArgTypeProfile); if (typeR != null) { try { if (functionLookupR == null) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/PromiseHelperNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/PromiseHelperNode.java index 975bcd905b49e62609d88f4daa26a3e63b326f2b..d132538cd40e9b733be7a39d2212cb44aa2fbc83 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/PromiseHelperNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/PromiseHelperNode.java @@ -114,9 +114,11 @@ public class PromiseHelperNode extends Node { @Child private PromiseHelperNode nextNode = null; + private final ValueProfile optTypeProfile = ValueProfile.createIdentityProfile(); + private final ValueProfile varArgsOptTypeProfile = ValueProfile.createIdentityProfile(); + private final ValueProfile multiVarArgsOptTypeProfile = ValueProfile.createIdentityProfile(); private final ValueProfile promiseFrameProfile = ValueProfile.createClassProfile(); private final BranchProfile varArgProfile = BranchProfile.create(); - private final BranchProfile multiVarArgProfile = BranchProfile.create(); /** * Guarded by {@link #isInOriginFrame(VirtualFrame,RPromise)}. @@ -136,7 +138,8 @@ public class PromiseHelperNode extends Node { /** * Main entry point for proper evaluation of the given Promise; including * {@link RPromise#isEvaluated()}, propagation of CallSrc and dependency cycles. Actual - * evaluation is delegated to {@link #generateValue(VirtualFrame, RPromise, SourceSection)}. + * evaluation is delegated to + * {@link #generateValue(VirtualFrame, OptType, RPromise, SourceSection)}. * * @return The value the given Promise evaluates to */ @@ -145,12 +148,14 @@ public class PromiseHelperNode extends Node { return promise.getValue(); } RPromise current = promise; - if (current.getOptType() == OptType.VARARG) { + OptType optType = optTypeProfile.profile(current.getOptType()); + if (optType == OptType.VARARG) { varArgProfile.enter(); current = ((VarargPromise) current).getVararg(); - while (current.getOptType() == OptType.VARARG) { - multiVarArgProfile.enter(); + optType = varArgsOptTypeProfile.profile(current.getOptType()); + while (optType == OptType.VARARG) { current = ((VarargPromise) current).getVararg(); + optType = multiVarArgsOptTypeProfile.profile(current.getOptType()); } if (isEvaluated(current)) { return current.getValue(); @@ -163,7 +168,7 @@ public class PromiseHelperNode extends Node { } // Evaluate guarded by underEvaluation - Object obj = generateValue(frame, current, callSrc); + Object obj = generateValue(frame, optType, current, callSrc); setValue(obj, current); return obj; } @@ -175,12 +180,12 @@ public class PromiseHelperNode extends Node { * @param frame The {@link VirtualFrame} of the environment the Promise is forced in * @return The value this Promise represents */ - private Object generateValue(VirtualFrame frame, RPromise promise, SourceSection callSrc) { - if (isOptDefaultProfile.profile(promise.getOptType() == OptType.DEFAULT)) { + private Object generateValue(VirtualFrame frame, OptType optType, RPromise promise, SourceSection callSrc) { + if (optType == OptType.DEFAULT) { return generateValueDefault(frame, promise, callSrc); } else { - assert promise.getOptType() == OptType.EAGER || promise.getOptType() == OptType.PROMISED; - return generateValueEager(frame, (EagerPromise) promise, callSrc); + assert optType == OptType.EAGER || optType == OptType.PROMISED; + return generateValueEager(frame, optType, (EagerPromise) promise, callSrc); } } @@ -216,16 +221,16 @@ public class PromiseHelperNode extends Node { } } - private Object generateValueEager(VirtualFrame frame, EagerPromise promise, SourceSection callSrc) { + private Object generateValueEager(VirtualFrame frame, OptType optType, EagerPromise promise, SourceSection callSrc) { if (isDeoptimized(promise)) { // execFrame already materialized, feedback already given. Now we're a // plain'n'simple RPromise return generateValueDefault(frame, promise, callSrc); } else if (promise.isValid()) { - if (isOptEagerProfile.profile(promise.getOptType() == OptType.EAGER)) { + if (optType == OptType.EAGER) { return getEagerValue(promise); } else { - assert promise.getOptType() == OptType.PROMISED; + assert optType == OptType.PROMISED; return getPromisedEagerValue(frame, promise, callSrc); } } else { @@ -322,7 +327,6 @@ public class PromiseHelperNode extends Node { private final ValueProfile valueProfile = ValueProfile.createClassProfile(); // Eager - private final ConditionProfile isOptDefaultProfile = ConditionProfile.createBinaryProfile(); private final ConditionProfile isOptEagerProfile = ConditionProfile.createBinaryProfile(); private final ConditionProfile isOptPromisedProfile = ConditionProfile.createBinaryProfile(); private final ConditionProfile isDeoptimizedProfile = ConditionProfile.createBinaryProfile(); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/opt/OptVariablePromiseBaseNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/opt/OptVariablePromiseBaseNode.java index 006a62656cf55a909d75a212c0d546efcec72d39..2d707ca78d95239245d0cf6837f81d7f3ece95c6 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/opt/OptVariablePromiseBaseNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/opt/OptVariablePromiseBaseNode.java @@ -24,6 +24,7 @@ package com.oracle.truffle.r.nodes.function.opt; import com.oracle.truffle.api.*; import com.oracle.truffle.api.frame.*; +import com.oracle.truffle.api.nodes.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.access.*; import com.oracle.truffle.r.nodes.access.variables.*; @@ -34,7 +35,6 @@ import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.RPromise.EagerFeedback; import com.oracle.truffle.r.runtime.data.RPromise.RPromiseFactory; import com.oracle.truffle.r.runtime.env.frame.*; -import com.oracle.truffle.r.runtime.env.frame.FrameSlotChangeMonitor.FrameSlotInfo; public abstract class OptVariablePromiseBaseNode extends PromiseNode implements EagerFeedback { protected final ReadVariableNode originalRvn; @@ -61,8 +61,10 @@ public abstract class OptVariablePromiseBaseNode extends PromiseNode implements FrameSlot slot = frameSlotNode.executeFrameSlot(frame); // Check if we may apply eager evaluation on this frame slot - FrameSlotInfo notChangedNonLocally = FrameSlotChangeMonitor.getMonitor(slot); - if (notChangedNonLocally.isNonLocalModified()) { + Assumption notChangedNonLocally = FrameSlotChangeMonitor.getNotChangedNonLocallyAssumption(slot); + try { + notChangedNonLocally.check(); + } catch (InvalidAssumptionException e) { // Cannot apply optimizations, as the value to it got invalidated return rewriteToAndExecuteFallback(frame); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/signature/RArgumentsNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/signature/RArgumentsNode.java index 49591657eaa7d9ee128e1a75b5bed09f91d13395..a38bc9902c20baf1dceb3cf6796922dcdb7c6244 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/signature/RArgumentsNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/signature/RArgumentsNode.java @@ -60,7 +60,7 @@ public abstract class RArgumentsNode extends Node { @Override public Object[] execute(RFunction function, SourceSection callSrc, MaterializedFrame callerFrame, int depth, Object[] evaluatedArgs, ArgumentsSignature signature) { if (function == cachedFunction) { - return RArguments.createInternal(cachedFunction, callSrc, callerFrame, depth, evaluatedArgs, signature, cachedFunction.getEnclosingFrameWithAssumption()); + return RArguments.createInternal(cachedFunction, callSrc, callerFrame, depth, evaluatedArgs, signature, cachedFunction.getEnclosingFrame()); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); return replace(new RArgumentsGenericNode()).execute(function, callSrc, callerFrame, depth, evaluatedArgs, signature); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java index a554d45024a84ff45339ab0103d8873a2c14d74f..27c96610b494c2777f0b8f39d8cbf5f46469a4d0 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastComplexNode.java @@ -26,7 +26,6 @@ import java.util.function.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; @@ -39,13 +38,13 @@ public abstract class CastComplexNode extends CastNode { private final NAProfile naProfile = NAProfile.create(); private final BranchProfile warningBranch = BranchProfile.create(); - public abstract Object executeComplex(VirtualFrame frame, int o); + public abstract Object executeComplex(int o); - public abstract Object executeComplex(VirtualFrame frame, double o); + public abstract Object executeComplex(double o); - public abstract Object executeComplex(VirtualFrame frame, byte o); + public abstract Object executeComplex(byte o); - public abstract Object executeComplex(VirtualFrame frame, Object o); + public abstract Object executeComplex(Object o); @Specialization protected RNull doNull(@SuppressWarnings("unused") RNull operand) { @@ -157,5 +156,4 @@ public abstract class CastComplexNode extends CastNode { public static CastComplexNode create() { return CastComplexNodeGen.create(null, true, true, true); } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java index d61ab6c79059b31070228719ee5a34bee2d214c6..11df521d2b12e98f68f75616600ee6a5480e4588 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java @@ -27,7 +27,6 @@ import java.util.function.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; @@ -40,22 +39,22 @@ public abstract class CastDoubleNode extends CastNode { private final NAProfile naProfile = NAProfile.create(); private final BranchProfile warningBranch = BranchProfile.create(); - public abstract Object executeDouble(VirtualFrame frame, int o); + public abstract Object executeDouble(int o); - public abstract Object executeDouble(VirtualFrame frame, double o); + public abstract Object executeDouble(double o); - public abstract Object executeDouble(VirtualFrame frame, byte o); + public abstract Object executeDouble(byte o); - public abstract Object executeDouble(VirtualFrame frame, Object o); + public abstract Object executeDouble(Object o); @Child private CastDoubleNode recursiveCastDouble; - private Object castDoubleRecursive(VirtualFrame frame, Object o) { + private Object castDoubleRecursive(Object o) { if (recursiveCastDouble == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); recursiveCastDouble = insert(CastDoubleNodeGen.create(null, isPreserveNames(), isDimensionsPreservation(), isAttrPreservation())); } - return recursiveCastDouble.executeDouble(frame, o); + return recursiveCastDouble.executeDouble(o); } @Specialization @@ -202,7 +201,7 @@ public abstract class CastDoubleNode extends CastNode { } @Specialization - protected RDoubleVector doList(VirtualFrame frame, RList list) { + protected RDoubleVector doList(RList list) { int length = list.getLength(); double[] result = new double[length]; boolean seenNA = false; @@ -212,7 +211,7 @@ public abstract class CastDoubleNode extends CastNode { result[i] = RRuntime.DOUBLE_NA; seenNA = true; } else { - Object castEntry = castDoubleRecursive(frame, entry); + Object castEntry = castDoubleRecursive(entry); if (castEntry instanceof Double) { double value = (Double) castEntry; result[i] = value; @@ -250,5 +249,4 @@ public abstract class CastDoubleNode extends CastNode { public static CastDoubleNode create() { return CastDoubleNodeGen.create(null, true, true, true); } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastExpressionNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastExpressionNode.java index 36b2e993ee64d46388a7542e6c3b625db9914c4b..e683a6ec917c90f0ffd45b8c5359e2bb0f63ab70 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastExpressionNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastExpressionNode.java @@ -23,7 +23,6 @@ package com.oracle.truffle.r.nodes.unary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; @@ -32,7 +31,7 @@ public abstract class CastExpressionNode extends CastNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - public abstract Object executeExpression(VirtualFrame frame, Object o); + public abstract Object executeExpression(Object o); @Specialization protected RExpression doNull(@SuppressWarnings("unused") RNull value) { @@ -92,5 +91,4 @@ public abstract class CastExpressionNode extends CastNode { private static RExpression create(Object[] objArray) { return RDataFactory.createExpression(RDataFactory.createList(objArray)); } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java index 164364efb4b101600b7bede10ea473efd8839a16..6b738ac379513343568a78c91bed646b4b074ec2 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java @@ -25,7 +25,6 @@ package com.oracle.truffle.r.nodes.unary; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; @@ -38,22 +37,22 @@ public abstract class CastIntegerNode extends CastNode { private final NAProfile naProfile = NAProfile.create(); private final BranchProfile warningBranch = BranchProfile.create(); - public abstract Object executeInt(VirtualFrame frame, int o); + public abstract Object executeInt(int o); - public abstract Object executeInt(VirtualFrame frame, double o); + public abstract Object executeInt(double o); - public abstract Object executeInt(VirtualFrame frame, byte o); + public abstract Object executeInt(byte o); - public abstract Object executeInt(VirtualFrame frame, Object o); + public abstract Object executeInt(Object o); @Child private CastIntegerNode recursiveCastInteger; - private Object castIntegerRecursive(VirtualFrame frame, Object o) { + private Object castIntegerRecursive(Object o) { if (recursiveCastInteger == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); recursiveCastInteger = insert(CastIntegerNodeGen.create(null, isPreserveNames(), isDimensionsPreservation(), isAttrPreservation())); } - return recursiveCastInteger.executeInt(frame, o); + return recursiveCastInteger.executeInt(o); } @Specialization @@ -185,10 +184,12 @@ public abstract class CastIntegerNode extends CastNode { naCheck.enable(operand); int[] idata = new int[operand.getLength()]; boolean seenNA = false; + boolean seenNANoWarn = false; for (int i = 0; i < operand.getLength(); i++) { String value = operand.getDataAt(i); if (value.length() == 0 || naCheck.check(value)) { idata[i] = RRuntime.INT_NA; + seenNANoWarn = true; } else { idata[i] = naCheck.convertStringToInt(value); if (RRuntime.isNA(idata[i])) { @@ -200,7 +201,7 @@ public abstract class CastIntegerNode extends CastNode { warningBranch.enter(); RError.warning(RError.Message.NA_INTRODUCED_COERCION); } - RIntVector ret = RDataFactory.createIntVector(idata, !seenNA, getPreservedDimensions(operand), getPreservedNames(operand)); + RIntVector ret = RDataFactory.createIntVector(idata, !seenNA && !seenNANoWarn, getPreservedDimensions(operand), getPreservedNames(operand)); preserveDimensionNames(operand, ret); if (isAttrPreservation()) { ret.copyRegAttributesFrom(operand); @@ -225,7 +226,7 @@ public abstract class CastIntegerNode extends CastNode { } @Specialization - protected RIntVector doList(VirtualFrame frame, RList list) { + protected RIntVector doList(RList list) { int length = list.getLength(); int[] result = new int[length]; boolean seenNA = false; @@ -235,7 +236,7 @@ public abstract class CastIntegerNode extends CastNode { result[i] = RRuntime.INT_NA; seenNA = true; } else { - Object castEntry = castIntegerRecursive(frame, entry); + Object castEntry = castIntegerRecursive(entry); if (castEntry instanceof Integer) { int value = (Integer) castEntry; result[i] = value; @@ -278,5 +279,4 @@ public abstract class CastIntegerNode extends CastNode { public static CastIntegerNode create() { return CastIntegerNodeGen.create(null, true, true, true); } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java index 9290d4ec060fd8540fd28f9338cec1042dbe8476..2b31f7d319abb90f52e78a42953c486d6822de57 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastListNode.java @@ -25,7 +25,6 @@ package com.oracle.truffle.r.nodes.unary; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; @@ -36,14 +35,14 @@ public abstract class CastListNode extends CastNode { private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - public abstract RList executeList(VirtualFrame frame, Object o); + public abstract RList executeList(Object o); - private RList castList(VirtualFrame frame, Object operand) { + private RList castList(Object operand) { if (castListRecursive == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); castListRecursive = insert(CastListNodeGen.create(null, false, false, false)); } - return castListRecursive.executeList(frame, operand); + return castListRecursive.executeList(operand); } @Specialization @@ -88,8 +87,8 @@ public abstract class CastListNode extends CastNode { } @Specialization - protected RList doDataFrame(VirtualFrame frame, RDataFrame operand) { - return castList(frame, operand.getVector()); + protected RList doDataFrame(RDataFrame operand) { + return castList(operand.getVector()); } @Specialization diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java index 52889f0cadbfe77991de0dd1013833cd4c2f4cea..3e96cbc3034e3f7d03d274027b1ac6fa81ed991a 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java @@ -27,7 +27,6 @@ import java.util.*; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; @@ -38,18 +37,16 @@ public abstract class CastLogicalNode extends CastNode { private final NACheck naCheck = NACheck.create(); private final NAProfile naProfile = NAProfile.create(); - public abstract Object executeByte(VirtualFrame frame, Object o); - - public abstract Object executeLogical(VirtualFrame frame, Object o); + public abstract Object executeLogical(Object o); @Child private CastLogicalNode recursiveCastLogical; - private Object castLogicalRecursive(VirtualFrame frame, Object o) { + private Object castLogicalRecursive(Object o) { if (recursiveCastLogical == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); recursiveCastLogical = insert(CastLogicalNodeGen.create(null, isPreserveNames(), isDimensionsPreservation(), isAttrPreservation())); } - return recursiveCastLogical.executeLogical(frame, o); + return recursiveCastLogical.executeLogical(o); } @Specialization @@ -144,7 +141,7 @@ public abstract class CastLogicalNode extends CastNode { } @Specialization - protected RLogicalVector doList(VirtualFrame frame, RList list) { + protected RLogicalVector doList(RList list) { int length = list.getLength(); byte[] result = new byte[length]; boolean seenNA = false; @@ -154,7 +151,7 @@ public abstract class CastLogicalNode extends CastNode { result[i] = RRuntime.LOGICAL_NA; seenNA = true; } else { - Object castEntry = castLogicalRecursive(frame, entry); + Object castEntry = castLogicalRecursive(entry); if (castEntry instanceof Byte) { byte value = (Byte) castEntry; result[i] = value; @@ -194,8 +191,8 @@ public abstract class CastLogicalNode extends CastNode { } @Specialization - protected Object asLogical(VirtualFrame frame, RDataFrame dataFrame) { - return castLogicalRecursive(frame, dataFrame.getVector()); + protected Object asLogical(RDataFrame dataFrame) { + return castLogicalRecursive(dataFrame.getVector()); } @Specialization @@ -214,5 +211,4 @@ public abstract class CastLogicalNode extends CastNode { public static CastStringNode create() { return CastStringNodeGen.create(null, false, true, true, true); } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastNode.java index 69a7c023987e6a1a8126d9797156f0dc8c711d09..fe8344dcbcbac2eede8f3a372ba36072b97bb3bd 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastNode.java @@ -23,7 +23,6 @@ package com.oracle.truffle.r.nodes.unary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.access.ConstantNode.ConstantIntegerScalarNode; @@ -40,7 +39,7 @@ public abstract class CastNode extends UnaryNode { private final ConditionProfile hasNamesProfile = ConditionProfile.createBinaryProfile(); private final RAttributeProfiles attrProfiles = RAttributeProfiles.create(); - public abstract Object executeCast(VirtualFrame frame, Object value); + public abstract Object executeCast(Object value); protected abstract boolean isPreserveNames(); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastRawNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastRawNode.java index bebc60d906ea014f7eca197cf57dfb7e8c4beb47..863ad8aead16c209dabbc50e3a4861013bd30d0f 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastRawNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastRawNode.java @@ -24,7 +24,6 @@ package com.oracle.truffle.r.nodes.unary; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; @@ -34,13 +33,13 @@ public abstract class CastRawNode extends CastNode { private final BranchProfile warningBranch = BranchProfile.create(); - public abstract Object executeRaw(VirtualFrame frame, int o); + public abstract Object executeRaw(int o); - public abstract Object executeRaw(VirtualFrame frame, double o); + public abstract Object executeRaw(double o); - public abstract Object executeRaw(VirtualFrame frame, byte o); + public abstract Object executeRaw(byte o); - public abstract Object executeRaw(VirtualFrame frame, Object o); + public abstract Object executeRaw(Object o); @Specialization protected RNull doNull(@SuppressWarnings("unused") RNull operand) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java index 6d222b52cca40c93edf39701ee6ae1b056ff7791..b2152f617231ec464ec082c81b74e1c9d2d9a9d8 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java @@ -23,7 +23,6 @@ package com.oracle.truffle.r.nodes.unary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; @@ -32,13 +31,13 @@ public abstract class CastStringNode extends CastNode { @Child private ToStringNode toString = ToStringNodeGen.create(null, null, null); - public abstract Object executeString(VirtualFrame frame, int o); + public abstract Object executeString(int o); - public abstract Object executeString(VirtualFrame frame, double o); + public abstract Object executeString(double o); - public abstract Object executeString(VirtualFrame frame, byte o); + public abstract Object executeString(byte o); - public abstract Object executeString(VirtualFrame frame, Object o); + public abstract Object executeString(Object o); public abstract boolean isEmptyVectorConvertedToNull(); @@ -52,33 +51,33 @@ public abstract class CastStringNode extends CastNode { return value; } - private String toString(VirtualFrame frame, Object value) { - return toString.executeString(frame, value, false, ToStringNode.DEFAULT_SEPARATOR); + private String toString(Object value) { + return toString.executeString(value, false, ToStringNode.DEFAULT_SEPARATOR); } @Specialization - protected String doInteger(VirtualFrame frame, int value) { - return toString(frame, value); + protected String doInteger(int value) { + return toString(value); } @Specialization - protected String doDouble(VirtualFrame frame, double value) { - return toString(frame, value); + protected String doDouble(double value) { + return toString(value); } @Specialization - protected String doLogical(VirtualFrame frame, byte value) { - return toString(frame, value); + protected String doLogical(byte value) { + return toString(value); } @Specialization - protected String doRaw(VirtualFrame frame, RComplex value) { - return toString(frame, value); + protected String doRaw(RComplex value) { + return toString(value); } @Specialization - protected String doRaw(VirtualFrame frame, RRaw value) { - return toString(frame, value); + protected String doRaw(RRaw value) { + return toString(value); } @Specialization(guards = "vector.getLength() == 0") @@ -92,11 +91,11 @@ public abstract class CastStringNode extends CastNode { } @Specialization(guards = "operand.getLength() != 0") - protected RAbstractContainer doIntVector(VirtualFrame frame, RAbstractContainer operand) { + protected RAbstractContainer doIntVector(RAbstractContainer operand) { String[] sdata = new String[operand.getLength()]; // conversions to character will not introduce new NAs for (int i = 0; i < operand.getLength(); i++) { - sdata[i] = toString(frame, operand.getDataAtAsObject(i)); + sdata[i] = toString(operand.getDataAtAsObject(i)); } RStringVector ret = RDataFactory.createStringVector(sdata, operand.isComplete(), getPreservedDimensions(operand), getPreservedNames(operand)); preserveDimensionNames(operand, ret); @@ -114,5 +113,4 @@ public abstract class CastStringNode extends CastNode { public static CastStringNode create() { return CastStringNodeGen.create(null, false, true, true, true); } - } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastSymbolNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastSymbolNode.java index b8e1b715f41e5c29f2be2ee99cd7f010ff481d13..b536d7ea5a4ba6324ca517c4216f9b5dbf6d9aca 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastSymbolNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastSymbolNode.java @@ -24,7 +24,6 @@ package com.oracle.truffle.r.nodes.unary; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; @@ -32,10 +31,10 @@ public abstract class CastSymbolNode extends CastNode { @Child private ToStringNode toString = ToStringNodeGen.create(null, null, null); - public abstract Object executeSymbol(VirtualFrame frame, Object o); + public abstract Object executeSymbol(Object o); - private String toString(VirtualFrame frame, Object value) { - return toString.executeString(frame, value, true, ToStringNode.DEFAULT_SEPARATOR); + private String toString(Object value) { + return toString.executeString(value, true, ToStringNode.DEFAULT_SEPARATOR); } @Specialization @@ -44,18 +43,18 @@ public abstract class CastSymbolNode extends CastNode { } @Specialization - protected RSymbol doInteger(VirtualFrame frame, int value) { - return backQuote(toString(frame, value)); + protected RSymbol doInteger(int value) { + return backQuote(toString(value)); } @Specialization - protected RSymbol doDouble(VirtualFrame frame, double value) { - return backQuote(toString(frame, value)); + protected RSymbol doDouble(double value) { + return backQuote(toString(value)); } @Specialization - protected RSymbol doLogical(VirtualFrame frame, byte value) { - return backQuote(toString(frame, value)); + protected RSymbol doLogical(byte value) { + return backQuote(toString(value)); } @Specialization @@ -70,18 +69,18 @@ public abstract class CastSymbolNode extends CastNode { } @Specialization - protected RSymbol doIntegerVector(VirtualFrame frame, RIntVector value) { - return doInteger(frame, value.getDataAt(0)); + protected RSymbol doIntegerVector(RIntVector value) { + return doInteger(value.getDataAt(0)); } @Specialization - protected RSymbol doDoubleVector(VirtualFrame frame, RDoubleVector value) { - return doDouble(frame, value.getDataAt(0)); + protected RSymbol doDoubleVector(RDoubleVector value) { + return doDouble(value.getDataAt(0)); } @Specialization - protected RSymbol doLogicalVector(VirtualFrame frame, RLogicalVector value) { - return doLogical(frame, value.getDataAt(0)); + protected RSymbol doLogicalVector(RLogicalVector value) { + return doLogical(value.getDataAt(0)); } @TruffleBoundary diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToContainerNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToContainerNode.java index c5f42b5dd4df4011e72a6697d9a068d26cc4cad7..2d1928b7abd4b3a88df7d627586b7b0048e57fc3 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToContainerNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToContainerNode.java @@ -22,17 +22,16 @@ */ package com.oracle.truffle.r.nodes.unary; +import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; import com.oracle.truffle.r.runtime.env.*; -import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; public abstract class CastToContainerNode extends CastNode implements RSyntaxNode { - public abstract Object executeObject(VirtualFrame frame, Object value); + public abstract Object executeObject(Object value); @Specialization @SuppressWarnings("unused") diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToVectorNode.java index ce0d6ad08bbcdd1925c05f0645e20fce09f7f143..e20a854b463fa5ed8bef78841fe3470c78f3d662 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastToVectorNode.java @@ -22,15 +22,14 @@ */ package com.oracle.truffle.r.nodes.unary; +import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; -import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; @NodeField(name = "nonVectorPreserved", type = boolean.class) public abstract class CastToVectorNode extends CastNode { - public abstract Object executeObject(VirtualFrame frame, Object value); + public abstract Object executeObject(Object value); public abstract boolean isNonVectorPreserved(); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/ToStringNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/ToStringNode.java index f99f5c8e6b04d67d0ae7052b1c2c24fade718c84..aef556ab98cadce20c7893b8ff17c4a91b4f4caa 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/ToStringNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/ToStringNode.java @@ -25,7 +25,6 @@ package com.oracle.truffle.r.nodes.unary; import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; @@ -38,15 +37,15 @@ public abstract class ToStringNode extends UnaryNode { @Child private ToStringNode recursiveToString; - private String toStringRecursive(VirtualFrame frame, Object o, boolean quotes, String separator) { + private String toStringRecursive(Object o, boolean quotes, String separator) { if (recursiveToString == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); recursiveToString = insert(ToStringNodeGen.create(null, null, null)); } - return recursiveToString.executeString(frame, o, quotes, separator); + return recursiveToString.executeString(o, quotes, separator); } - public abstract String executeString(VirtualFrame frame, Object o, boolean quotes, String separator); + public abstract String executeString(Object o, boolean quotes, String separator); @SuppressWarnings("unused") @Specialization @@ -163,7 +162,7 @@ public abstract class ToStringNode extends UnaryNode { } @Specialization - protected String toString(VirtualFrame frame, RList vector, boolean quotes, String separator) { + protected String toString(RList vector, boolean quotes, String separator) { return createResultForVector(vector, quotes, separator, "list()", (index, q, s) -> { Object value = vector.getDataAt(index); if (value instanceof RList) { @@ -171,22 +170,22 @@ public abstract class ToStringNode extends UnaryNode { if (l.getLength() == 0) { return "list()"; } else { - return "list(" + toStringRecursive(frame, l, q, s) + ')'; + return "list(" + toStringRecursive(l, q, s) + ')'; } } else { - return toStringRecursive(frame, value, q, s); + return toStringRecursive(value, q, s); } }); } @Specialization - protected String toString(VirtualFrame frame, RIntSequence vector, boolean quotes, String separator) { - return toStringRecursive(frame, vector.createVector(), quotes, separator); + protected String toString(RIntSequence vector, boolean quotes, String separator) { + return toStringRecursive(vector.createVector(), quotes, separator); } @Specialization - protected String toString(VirtualFrame frame, RDoubleSequence vector, boolean quotes, String separator) { - return toStringRecursive(frame, vector.createVector(), quotes, separator); + protected String toString(RDoubleSequence vector, boolean quotes, String separator) { + return toStringRecursive(vector.createVector(), quotes, separator); } @SuppressWarnings("unused") diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RArguments.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RArguments.java index 87a00ce67110e427e835b81bfd09c8b8bc0019a2..1f669711f48b34da14d1632688f6f8a6ffafe585 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RArguments.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RArguments.java @@ -106,22 +106,22 @@ public final class RArguments { } } - public static final int INDEX_ENVIRONMENT = 0; - public static final int INDEX_FUNCTION = 1; - public static final int INDEX_CALL_SRC = 2; - public static final int INDEX_CALLER_FRAME = 3; - public static final int INDEX_ENCLOSING_FRAME = 4; - public static final int INDEX_S3_ARGS = 5; - public static final int INDEX_DEPTH = 6; - public static final int INDEX_IS_IRREGULAR = 7; - public static final int INDEX_SIGNATURE = 8; - public static final int INDEX_ARGUMENTS = 9; + static final int INDEX_ENVIRONMENT = 0; + static final int INDEX_FUNCTION = 1; + static final int INDEX_CALL_SRC = 2; + static final int INDEX_CALLER_FRAME = 3; + static final int INDEX_ENCLOSING_FRAME = 4; + static final int INDEX_S3_ARGS = 5; + static final int INDEX_DEPTH = 6; + static final int INDEX_IS_IRREGULAR = 7; + static final int INDEX_SIGNATURE = 8; + static final int INDEX_ARGUMENTS = 9; /** * At the least, the array contains the function, enclosing frame, and numbers of arguments and * names. */ - public static final int MINIMAL_ARRAY_LENGTH = INDEX_ARGUMENTS; + static final int MINIMAL_ARRAY_LENGTH = INDEX_ARGUMENTS; private static final ValueProfile materializedFrameProfile = ValueProfile.createClassProfile(); @@ -147,7 +147,7 @@ public final class RArguments { * where {@code arguments.length == 1} and the real {@code arguments} are at * {@code arguments[0]}. See {@code REngine}. */ - public static Object[] getArgumentsWithEvalCheck(Frame frame, ConditionProfile profile) { + public static Object[] getRArgumentsWithEvalCheck(Frame frame, ConditionProfile profile) { CompilerAsserts.compilationConstant(profile); Object[] arguments = frame.getArguments(); if (profile.profile(arguments.length == 1)) { @@ -166,11 +166,16 @@ public final class RArguments { } public static Object[] create(RFunction functionObj, SourceSection callSrc, MaterializedFrame callerFrame, int depth, Object[] evaluatedArgs, ArgumentsSignature signature) { - MaterializedFrame enclosingFrame = functionObj.getEnclosingFrameWithAssumption(); - + MaterializedFrame enclosingFrame = functionObj.getEnclosingFrame(); return createInternal(functionObj, callSrc, callerFrame, depth, evaluatedArgs, signature, enclosingFrame); } + public static Object[] create(RFunction functionObj, SourceSection callSrc, MaterializedFrame callerFrame, int depth, Object[] evaluatedArgs, ArgumentsSignature signature, S3Args s3Args) { + Object[] args = create(functionObj, callSrc, callerFrame, depth, evaluatedArgs, signature); + args[INDEX_S3_ARGS] = s3Args; + return args; + } + public static Object[] createInternal(RFunction functionObj, SourceSection callSrc, MaterializedFrame callerFrame, int depth, Object[] evaluatedArgs, ArgumentsSignature signature, MaterializedFrame enclosingFrame) { assert evaluatedArgs != null && signature != null : evaluatedArgs + " " + signature; @@ -193,18 +198,19 @@ public final class RArguments { @SuppressWarnings("unused") private static boolean envFunctionInvariant(Object[] a) { - return !(a[INDEX_ENVIRONMENT] == null && a[INDEX_FUNCTION] == null); + return a[INDEX_ENVIRONMENT] != null || a[INDEX_FUNCTION] != null; } /** * A method for creating an uninitialized array, used only in very special situations as it * temporarily violates {@link #envFunctionInvariant}. */ - public static Object[] createUnitialized() { - Object[] a = new Object[MINIMAL_ARRAY_LENGTH]; + public static Object[] createUnitialized(Object... args) { + Object[] a = new Object[MINIMAL_ARRAY_LENGTH + args.length]; a[INDEX_DEPTH] = 0; - a[INDEX_SIGNATURE] = ArgumentsSignature.empty(0); + a[INDEX_SIGNATURE] = ArgumentsSignature.empty(args.length); a[INDEX_IS_IRREGULAR] = false; + System.arraycopy(args, 0, a, INDEX_ARGUMENTS, args.length); return a; } @@ -217,10 +223,6 @@ public final class RArguments { return (S3Args) getRArgumentsWithEvalCheck(frame)[INDEX_S3_ARGS]; } - public static void setS3Args(Object[] args, S3Args s3Args) { - args[INDEX_S3_ARGS] = s3Args; - } - public static REnvironment getEnvironment(Frame frame) { return (REnvironment) getRArgumentsWithEvalCheck(frame)[INDEX_ENVIRONMENT]; } @@ -292,13 +294,13 @@ public final class RArguments { } public static MaterializedFrame getEnclosingFrame(Frame frame) { - Object[] arguments = getRArgumentsWithEvalCheck(frame); - if (arguments[INDEX_FUNCTION] != null) { - return ((RFunction) arguments[INDEX_FUNCTION]).getEnclosingFrame(); - } return (MaterializedFrame) getRArgumentsWithEvalCheck(frame)[INDEX_ENCLOSING_FRAME]; } + public static MaterializedFrame getEnclosingFrame(Frame frame, ConditionProfile profile) { + return (MaterializedFrame) getRArgumentsWithEvalCheck(frame, profile)[INDEX_ENCLOSING_FRAME]; + } + public static ArgumentsSignature getSignature(Frame frame) { return (ArgumentsSignature) getRArgumentsWithEvalCheck(frame)[INDEX_SIGNATURE]; } @@ -307,13 +309,6 @@ public final class RArguments { getRArgumentsWithEvalCheck(frame)[INDEX_ENVIRONMENT] = env; } - /** - * Explicitly set the function. Used by {@code REngine.eval}. - */ - public static void setFunction(Frame frame, RFunction function) { - getRArgumentsWithEvalCheck(frame)[INDEX_FUNCTION] = function; - } - /** * Explicitly set the callSrc. Used by {@code REngine.eval}. */ @@ -338,9 +333,6 @@ public final class RArguments { CompilerAsserts.neverPartOfCompilation(); Object[] arguments = getRArgumentsWithEvalCheck(frame); arguments[INDEX_ENCLOSING_FRAME] = encl; - if (arguments[INDEX_FUNCTION] != null) { - ((RFunction) arguments[INDEX_FUNCTION]).setEnclosingFrame(encl); - } FrameSlotChangeMonitor.invalidateEnclosingFrame(frame); } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java index f51f9db6a6f1fbceb40f436b0880d83a9d8abc6a..5dae88adcfed651d1af3b203334b442b05625f9b 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java @@ -428,7 +428,8 @@ public class RSerialize { * on return. */ RFunction func = (RFunction) RContext.getEngine().eval(expr, RDataFactory.createNewEnv(REnvironment.emptyEnv(), null), frameDepth + 1); - func.setEnclosingFrame(((REnvironment) rpl.getTag()).getFrame()); + // copy the function with a different enclosing frame + func = RDataFactory.createFunction(func.getName(), func.getTarget(), func.getRBuiltin(), ((REnvironment) rpl.getTag()).getFrame(), func.containsDispatch()); Source source = func.getRootNode().getSourceSection().getSource(); if (!source.getName().startsWith(UNKNOWN_PACKAGE_SOURCE_PREFIX)) { /* @@ -1219,6 +1220,7 @@ public class RSerialize { writeCHARSXP(((RSymbol) obj).getName()); } else if (type == SEXPTYPE.ENVSXP) { REnvironment env = (REnvironment) obj; + addReadRef(obj); String name = env.getName(); if (name.startsWith("package:")) { RError.warning(RError.Message.PACKAGE_AVAILABLE, name); @@ -1226,7 +1228,8 @@ public class RSerialize { stream.writeString(name); } else if (env.isNamespaceEnv()) { stream.writeInt(SEXPTYPE.NAMESPACESXP.code); - stream.writeString(name); + RStringVector nameSpaceEnvSpec = env.getNamespaceSpec(); + outStringVec(nameSpaceEnvSpec, false); } else { stream.writeInt(SEXPTYPE.ENVSXP.code); stream.writeInt(env.isLocked() ? 1 : 0); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/VirtualEvalFrame.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/VirtualEvalFrame.java index 9e70d08071daad059fef519e8fa22c451961f635..809cab7465e7ff2d9173687c8eb40d422cc9c7ba 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/VirtualEvalFrame.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/VirtualEvalFrame.java @@ -40,10 +40,10 @@ public final class VirtualEvalFrame implements VirtualFrame, MaterializedFrame { private VirtualEvalFrame(MaterializedFrame originalFrame, RFunction function, SourceSection callSrc, int depth) { this.originalFrame = originalFrame; this.arguments = Arrays.copyOf(originalFrame.getArguments(), originalFrame.getArguments().length); - RArguments.setDepth(this, depth); - RArguments.setIsIrregular(this, true); - RArguments.setFunction(this, function); - RArguments.setCallSourceSection(this, callSrc); + this.arguments[RArguments.INDEX_DEPTH] = depth; + this.arguments[RArguments.INDEX_IS_IRREGULAR] = true; + this.arguments[RArguments.INDEX_FUNCTION] = function; + this.arguments[RArguments.INDEX_CALL_SRC] = callSrc; } public static VirtualEvalFrame create(MaterializedFrame originalFrame, RFunction function, SourceSection callSrc, int depth) { diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RDataFactory.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RDataFactory.java index 9e07644c1160e2b19f34203419527fba5cb2964f..b5ef2c4eef58df224c46c82d0994143750019f77 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RDataFactory.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RDataFactory.java @@ -24,9 +24,9 @@ package com.oracle.truffle.r.runtime.data; import java.util.*; +import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.*; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.source.*; import com.oracle.truffle.api.utilities.*; @@ -36,7 +36,6 @@ import com.oracle.truffle.r.runtime.data.RPromise.EagerFeedback; import com.oracle.truffle.r.runtime.data.RPromise.OptType; import com.oracle.truffle.r.runtime.data.RPromise.PromiseType; import com.oracle.truffle.r.runtime.env.*; -import com.oracle.truffle.r.runtime.env.frame.FrameSlotChangeMonitor.FrameSlotInfo; import com.oracle.truffle.r.runtime.gnur.*; public final class RDataFactory { @@ -365,7 +364,7 @@ public final class RDataFactory { return traceDataCreated(new RPromise(type, opt, expr, argumentValue)); } - public static RPromise createEagerPromise(PromiseType type, OptType eager, Closure exprClosure, Object eagerValue, FrameSlotInfo notChangedNonLocally, int nFrameId, EagerFeedback feedback) { + public static RPromise createEagerPromise(PromiseType type, OptType eager, Closure exprClosure, Object eagerValue, Assumption notChangedNonLocally, int nFrameId, EagerFeedback feedback) { return traceDataCreated(new RPromise.EagerPromise(type, eager, exprClosure, eagerValue, notChangedNonLocally, nFrameId, feedback)); } @@ -393,12 +392,8 @@ public final class RDataFactory { return traceDataCreated(new RPairList(car, cdr, tag, type)); } - public static RFunction createFunction(String name, RootCallTarget target, MaterializedFrame enclosingFrame, boolean containsDispatch) { - return traceDataCreated(new RFunction(name, target, null, enclosingFrame, containsDispatch)); - } - - public static RFunction createFunction(String name, RootCallTarget target, RBuiltinDescriptor builtin, MaterializedFrame enclosingFrame) { - return traceDataCreated(new RFunction(name, target, builtin, enclosingFrame, false)); + public static RFunction createFunction(String name, RootCallTarget target, RBuiltinDescriptor builtin, MaterializedFrame enclosingFrame, boolean containsDispatch) { + return traceDataCreated(new RFunction(name, target, builtin, enclosingFrame, containsDispatch)); } public static REnvironment createInternalEnv() { diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RFunction.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RFunction.java index 81c7d791fe322768c2f817afa1e64b500a52048f..fa1ed37a16253a84b2b4b7c33bd7d6a32450ef05 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RFunction.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RFunction.java @@ -22,11 +22,9 @@ */ package com.oracle.truffle.r.runtime.data; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.*; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.nodes.*; -import com.oracle.truffle.api.utilities.*; import com.oracle.truffle.r.runtime.*; /** @@ -49,8 +47,7 @@ public final class RFunction extends RScalar implements RAttributable { private final RBuiltinDescriptor builtin; private final boolean containsDispatch; - private MaterializedFrame enclosingFrame; - @CompilationFinal private StableValue<MaterializedFrame> enclosingFrameAssumption; + private final MaterializedFrame enclosingFrame; private RAttributes attributes; RFunction(String name, RootCallTarget target, RBuiltinDescriptor builtin, MaterializedFrame enclosingFrame, boolean containsDispatch) { @@ -63,7 +60,6 @@ public final class RFunction extends RScalar implements RAttributable { } else { this.enclosingFrame = enclosingFrame; } - this.enclosingFrameAssumption = new StableValue<>(this.enclosingFrame, "RFunction enclosing frame"); } @Override @@ -99,30 +95,6 @@ public final class RFunction extends RScalar implements RAttributable { return enclosingFrame; } - private static final ValueProfile assumptionTypeProfile = ValueProfile.createClassProfile(); - - public MaterializedFrame getEnclosingFrameWithAssumption() { - StableValue<MaterializedFrame> value = assumptionTypeProfile.profile(enclosingFrameAssumption); - try { - value.getAssumption().check(); - } catch (InvalidAssumptionException e) { - return getEnclosingFrame(); - } - return value.getValue(); - } - - public void setEnclosingFrame(MaterializedFrame frame) { - if (enclosingFrame != frame) { - enclosingFrameAssumption.getAssumption().invalidate(); - enclosingFrameAssumption = new StableValue<>(frame, "RFunction enclosing frame"); - enclosingFrame = frame; - } - } - - public RFunction copy() { - return new RFunction(name, target, builtin, enclosingFrame, containsDispatch); - } - public RAttributes initAttributes() { if (attributes == null) { attributes = RAttributes.create(); @@ -156,5 +128,4 @@ public final class RFunction extends RScalar implements RAttributable { this.name = name; RContext.getRRuntimeASTAccess().setFunctionName(getRootNode(), name); } - } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RIntSequence.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RIntSequence.java index 1ac49c6fb7ebde4198a904dc8d8f53f931657c28..cd835fe12f4db9d9a20b1c16c647d10edb9feefe 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RIntSequence.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RIntSequence.java @@ -50,7 +50,7 @@ public final class RIntSequence extends RSequence implements RAbstractIntVector return this; case Double: case Numeric: - return RDataFactory.createDoubleSequence(RRuntime.int2double(getStart()), RRuntime.int2double(getStride()), getLength()); + return RDataFactory.createDoubleSequence(getStart(), getStride(), getLength()); case Complex: return RClosures.createIntToComplexVector(this); case Character: diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RPromise.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RPromise.java index da35a2643676cea776d2d78e2dc51b309c22f32b..792489a1035c27661040d18c993cc6a78b73cf91 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RPromise.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RPromise.java @@ -28,7 +28,6 @@ import com.oracle.truffle.api.CompilerDirectives.ValueType; import com.oracle.truffle.api.frame.FrameInstance.FrameAccess; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.runtime.*; -import com.oracle.truffle.r.runtime.env.frame.FrameSlotChangeMonitor.FrameSlotInfo; /** * Denotes an R {@code promise}. Its child classes - namely {@link EagerPromise} and @@ -283,7 +282,7 @@ public class RPromise extends RLanguageRep implements RTypedValue { public static final class EagerPromise extends RPromise { protected final Object eagerValue; - private final FrameSlotInfo notChangedNonLocally; + private final Assumption notChangedNonLocally; private final int frameId; private final EagerFeedback feedback; @@ -293,7 +292,7 @@ public class RPromise extends RLanguageRep implements RTypedValue { */ private boolean deoptimized = false; - EagerPromise(PromiseType type, OptType optType, Closure closure, Object eagerValue, FrameSlotInfo notChangedNonLocally, int nFrameId, EagerFeedback feedback) { + EagerPromise(PromiseType type, OptType optType, Closure closure, Object eagerValue, Assumption notChangedNonLocally, int nFrameId, EagerFeedback feedback) { super(type, optType, (MaterializedFrame) null, closure); assert type != PromiseType.NO_ARG; this.eagerValue = eagerValue; @@ -331,7 +330,7 @@ public class RPromise extends RLanguageRep implements RTypedValue { } public boolean isValid() { - return !notChangedNonLocally.isNonLocalModified(); + return notChangedNonLocally.isValid(); } public void notifySuccess() { @@ -415,11 +414,11 @@ public class RPromise extends RLanguageRep implements RTypedValue { * until evaluation * @return An {@link EagerPromise} */ - public RPromise createEagerSuppliedPromise(Object eagerValue, FrameSlotInfo notChangedNonLocally, int nFrameId, EagerFeedback feedback) { + public RPromise createEagerSuppliedPromise(Object eagerValue, Assumption notChangedNonLocally, int nFrameId, EagerFeedback feedback) { return RDataFactory.createEagerPromise(type, OptType.EAGER, exprClosure, eagerValue, notChangedNonLocally, nFrameId, feedback); } - public RPromise createPromisedPromise(RPromise promisedPromise, FrameSlotInfo notChangedNonLocally, int nFrameId, EagerFeedback feedback) { + public RPromise createPromisedPromise(RPromise promisedPromise, Assumption notChangedNonLocally, int nFrameId, EagerFeedback feedback) { return RDataFactory.createEagerPromise(type, OptType.PROMISED, exprClosure, promisedPromise, notChangedNonLocally, nFrameId, feedback); } 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 0013d8dfa6bc8365fff479bea6a4003d7d4c1dff..38403b79bccb7d1a538d5d2b97f04cf5fd635aea 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 @@ -683,7 +683,7 @@ public abstract class REnvironment extends RAttributeStorage implements RAttribu /** * Return the "spec" attribute of the "info" env in a namespace or {@code null} if not found. */ - private RStringVector getNamespaceSpec() { + public RStringVector getNamespaceSpec() { Object value = frameAccess.get(NAMESPACE_KEY); if (value instanceof REnvironment) { REnvironment info = (REnvironment) value; diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/FrameSlotChangeMonitor.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/FrameSlotChangeMonitor.java index 9a89c3540ee5d45cc184a5452756102cc06e5794..80f8f769e421a468962e91ab21e82fea9eb0352a 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/FrameSlotChangeMonitor.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/env/frame/FrameSlotChangeMonitor.java @@ -39,10 +39,6 @@ import com.oracle.truffle.r.runtime.data.*; * track of thanks to R powerful language features. To keep the maintenance for the assumption as * cheap as possible, it checks only local reads - which is fast - and does a more costly check on * "<<-" but invalidates the assumption as soon as "eval" and the like comes into play.<br/> - * - * - * @see #checkAndInvalidate(Frame, FrameSlot, boolean, BranchProfile) - * @see #getMonitor(FrameSlot) */ public final class FrameSlotChangeMonitor { @@ -56,20 +52,9 @@ public final class FrameSlotChangeMonitor { // System.out.println(String.format(format, args)); } - public abstract static class FrameSlotInfo { - private boolean nonLocalModified = false; - - public final boolean isNonLocalModified() { - return nonLocalModified; - } - - public final void setNonLocalModified() { - nonLocalModified = true; - } - } - - private static final class FrameSlotInfoImpl extends FrameSlotInfo { + private static final class FrameSlotInfoImpl { @CompilationFinal private StableValue<Object> stableValue; + private final Assumption nonLocalModifiedAssumption = Truffle.getRuntime().createAssumption(); private final Object identifier; private int invalidationCount; @@ -115,16 +100,12 @@ public final class FrameSlotChangeMonitor { } /** - * Retrieves the not-changed-locally {@link Assumption} in the {@link FrameSlot#getInfo()} - * field. + * Retrieves the not-changed-locally {@link Assumption} for the given frame slot. * - * @param slot * @return The "not changed locally" assumption of the given {@link FrameSlot} - * - * @see FrameSlotChangeMonitor */ - public static FrameSlotInfo getMonitor(FrameSlot slot) { - return getFrameSlotInfo(slot); + public static Assumption getNotChangedNonLocallyAssumption(FrameSlot slot) { + return getFrameSlotInfo(slot).nonLocalModifiedAssumption; } public static FrameSlotInfoImpl getFrameSlotInfo(FrameSlot slot) { @@ -173,7 +154,7 @@ public final class FrameSlotChangeMonitor { if (invalidateProfile != null) { invalidateProfile.enter(); } - getMonitor(slot).setNonLocalModified(); + getNotChangedNonLocallyAssumption(slot).invalidate(); } } diff --git a/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/Makefile b/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/Makefile deleted file mode 100644 index 4419b3fcf6ca589a9fce7750a9e473ddb0d5cfe8..0000000000000000000000000000000000000000 --- a/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/src/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright (c) 2014, 2015, 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 -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -.PHONY: all clean - -C_SOURCES := $(wildcard *.c) -# R uses the .so extension on Mac OS X -C_OBJECTS := $(C_SOURCES:.c=.o) -C_LIB := testrffi.so - -NATIVE_PROJECT=$(FASTR_HOME)/com.oracle.truffle.r.native -ifneq ($(MAKECMDGOALS),clean) -include $(NATIVE_PROJECT)/platform.mk -endif - -ifeq ($(FASTR_INSTALL), GNUR) - INCLUDES := -I $(R_HOME)/include - ifeq ($(OS_NAME), Darwin) - FRAMEWORKFLAGS := -F${R_HOME}/../.. -framework R - else - FRAMEWORKFLAGS := - endif - LDFLAGS := $(LDFLAGS) $(FRAMEWORKFLAGS) -else - INCLUDES := -I $(NATIVE_PROJECT)/include/jni/include -I $(FASTR_JAVA_HOME)/include -I $(FASTR_JAVA_HOME)/include/$(OS_DIR) -endif - - -all: $(C_LIB) - -$(C_LIB): $(C_OBJECTS) - $(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(C_LIB) $(C_OBJECTS) - -%.o: %.c - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ - -clean: - rm $(C_LIB) $(C_OBJECTS) - 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 1b9be6fea63a2dd89017445e813cec94581a0ca1..0a58cb06bf6353a199a63c950ab5dbb8b5f36f9c 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 @@ -5239,6 +5239,10 @@ Error in as.vector(x, "expression") : #{ as.integer("1") } [1] 1 +##com.oracle.truffle.r.test.library.base.TestSimpleBuiltins.testAsInteger +#{ as.integer("1", as.character(NA)) } +[1] 1 + ##com.oracle.truffle.r.test.library.base.TestSimpleBuiltins.testAsInteger #{ as.integer("TRUE") } [1] NA diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleBuiltins.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleBuiltins.java index 66577306592386eb7de2954a1fa9e56162c74533..e928e3469e10e443b20d68e189d88739ce74b5ae 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleBuiltins.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleBuiltins.java @@ -723,6 +723,7 @@ public class TestSimpleBuiltins extends TestBase { assertEval("{ as.integer(NULL) }"); assertEval("{ as.integer(\"\") }"); assertEval("{ as.integer(as.character(NA)) }"); + assertEval("{ as.integer(\"1\", as.character(NA)) }"); } @Test diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java index cc81c98a2803dc1e522a2d2293ae73a5226d4baa..67b6c651ae858311d125aa54ab9fdf59adb04791 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java @@ -43,9 +43,6 @@ public class TestRPackages extends TestBase { * expected output with GnuR, and running FastR, to keep the {@code lib_loc} argument the same * in the test string. So the install is destructive, but ok as there is never a clash. * - * Currently we are using GnuR to do the install of the FastR-compiled package. The install - * environment for packageds with nativge code is handled in the Makefile using environment - * variables set in {@link #installPackage(String)}. */ private static final class PackagePaths { /** @@ -69,16 +66,27 @@ public class TestRPackages extends TestBase { private boolean installPackage(String packageName) { Path packagePath = rpackagesDists.resolve(packageName).resolve("lib").resolve(packageName + ".tar"); - // install the package (using GnuR for now) - ProcessBuilder pb = new ProcessBuilder("R", "CMD", "INSTALL", packagePath.toString()); + String[] cmds; + if (generatingExpected()) { + // use GnuR + cmds = new String[4]; + cmds[0] = "R"; + } else { + // use FastR + cmds = new String[5]; + cmds[0] = FileSystems.getDefault().getPath(REnvVars.rHome(), "bin", "R").toString(); + // TODO remove --no-help limitation when markdown parser functioning + cmds[3] = "--no-help"; + } + cmds[1] = "CMD"; + cmds[2] = "INSTALL"; + cmds[cmds.length - 1] = packagePath.toString(); + ProcessBuilder pb = new ProcessBuilder(cmds); Map<String, String> env = pb.environment(); env.put("R_LIBS_USER", rpackagesLibs.toString()); - String installKind = generatingExpected() ? "GNUR" : "FASTR"; - env.put("FASTR_INSTALL", installKind); - env.put("FASTR_HOME", REnvVars.rHome()); - String javaHome = System.getenv("JAVA_HOME"); - // GnuR INSTALL sets JAVA_HOME to a 1.6 JRE - env.put("FASTR_JAVA_HOME", javaHome); + if (!generatingExpected()) { + env.put("R_INSTALL_TAR", REnvVars.get("TAR")); + } try { if (FastROptions.debugMatches("TestRPackages")) { pb.inheritIO(); diff --git a/mx.fastr/imports b/mx.fastr/imports index 9300daca30b763cc663c7a5f0acfda8820a781d1..7c7fa2ad3c518fd95efb673f028b759d9c274394 100644 --- a/mx.fastr/imports +++ b/mx.fastr/imports @@ -1 +1 @@ -graal,6d5a198d23e67bb4b850ce1d74f5c338840cfe04,http://hg.openjdk.java.net/graal/graal +graal,40336f3ef7cb91e7c73741d34c110d2f50f76afe,http://hg.openjdk.java.net/graal/graal diff --git a/mx.fastr/mx_fastr.py b/mx.fastr/mx_fastr.py index f7ba6ce7423039428c1788ca83a420d1627b12c4..c6b2cfd8fcb04eba669a32fbb47956b47424f0f0 100644 --- a/mx.fastr/mx_fastr.py +++ b/mx.fastr/mx_fastr.py @@ -30,10 +30,10 @@ import os _fastr_suite = None _apptests_suite = None -def runR(args, className, nonZeroIsFatal=True, extraVmArgs=None, runBench=False): +def runR(args, className, nonZeroIsFatal=True, extraVmArgs=None, runBench=False, graalVM='server'): # extraVmArgs is not normally necessary as the global --J option can be used running R/RScript # However, the bench command invokes other Java VMs along the way, so it must use extraVmArgs - setREnvironment() + setREnvironment(graalVM) project = className.rpartition(".")[0] vmArgs = ['-cp', mx.classpath(project)] vmArgs = vmArgs + ["-Drhome.path=" + _fastr_suite.dir] @@ -42,17 +42,9 @@ def runR(args, className, nonZeroIsFatal=True, extraVmArgs=None, runBench=False) vmArgs = vmArgs + ['-ea', '-esa'] if extraVmArgs: vmArgs = vmArgs + extraVmArgs - return mx_graal.vm(vmArgs + [className] + args, nonZeroIsFatal=nonZeroIsFatal) + return mx_graal.vm(vmArgs + [className] + args, vm=graalVM, nonZeroIsFatal=nonZeroIsFatal) -def runRCommand(args, nonZeroIsFatal=True, extraVmArgs=None, runBench=False): - '''run R shell''' - return runR(args, "com.oracle.truffle.r.shell.RCommand", nonZeroIsFatal=nonZeroIsFatal, extraVmArgs=extraVmArgs, runBench=runBench) - -def runRscriptCommand(args, nonZeroIsFatal=True, extraVmArgs=None, runBench=False): - '''run Rscript file''' - return runR(args, "com.oracle.truffle.r.shell.RscriptCommand", nonZeroIsFatal=nonZeroIsFatal, extraVmArgs=extraVmArgs, runBench=runBench) - -def setREnvironment(): +def setREnvironment(graalVM): osname = platform.system() lib_base = join(_fastr_suite.dir, 'com.oracle.truffle.r.native', 'builtinlibs', 'lib') lib_value = lib_base @@ -62,9 +54,41 @@ def setREnvironment(): else: lib_env = 'LD_LIBRARY_PATH' os.environ[lib_env] = lib_value + # For R sub-processes we need to set the DEFAULT_VM environment variable + os.environ['DEFAULT_VM'] = graalVM + +def _add_vm_arg(parser): + parser.add_argument('--graal-vm', action='store', dest='graalVM', metavar='<arg>', help='Graal VM', default='server') + +def _process_graalVM_arg(args): + ''' + Check for the --graal-vm argument and if it exists return it as fiust result else None. + Unfortunately we can't use ArgumentParser as that doesn't like other args with a leading '-' unless + a '--' separator is provide and we can't do that. + ''' + graalVM = "server" + try: + vmIndex = args.index('--graal-vm') + graalVM = args[vmIndex + 1] + del args[vmIndex:vmIndex + 2] + except ValueError: + pass + return graalVM, args + +def rshell(args, nonZeroIsFatal=True, extraVmArgs=None, runBench=False): + '''run R shell''' + # Optional args for external use by benchmarks + graalVM, args = _process_graalVM_arg(args) + runR(args, "com.oracle.truffle.r.shell.RCommand", nonZeroIsFatal=nonZeroIsFatal, extraVmArgs=extraVmArgs, runBench=False, graalVM=graalVM) + +def rscript(args): + '''run Rscript''' + graalVM, args = _process_graalVM_arg(args) + runR(args, "com.oracle.truffle.r.shell.RscriptCommand", graalVM=graalVM) def build(args): '''FastR build''' + graalVM, args = _process_graalVM_arg(args) # Overridden in case we ever want to do anything non-standard # workaround for Hotspot Mac OS X build problem osname = platform.system() @@ -72,7 +96,7 @@ def build(args): os.environ['COMPILER_WARNINGS_FATAL'] = 'false' os.environ['USE_CLANG'] = 'true' os.environ['LFLAGS'] = '-Xlinker -lstdc++' - mx_graal.build(args, vm='server') # this calls mx.build + mx_graal.build(args, vm=graalVM) # this calls mx.build def findbugs(args): '''run FindBugs against non-test Java projects''' @@ -213,13 +237,14 @@ def _junit_r_harness(args, vmArgs, junitArgs): # suppress Truffle compilation by using a high threshold vmArgs += ['-G:TruffleCompilationThreshold=100000'] - setREnvironment() + setREnvironment(args.graalVM) - return mx_graal.vm(vmArgs + junitArgs, vm="server", nonZeroIsFatal=False) + return mx_graal.vm(vmArgs + junitArgs, vm=args.graalVM, nonZeroIsFatal=False) def junit(args): '''run R Junit tests''' parser = ArgumentParser(prog='r junit') + _add_vm_arg(parser) parser.add_argument('--gen-expected-output', action='store_true', help='generate/update expected test output file') parser.add_argument('--gen-expected-quiet', action='store_true', help='suppress output on new tests being added') parser.add_argument('--keep-trailing-whitespace', action='store_true', help='keep trailing whitespace in expected test output file') @@ -384,6 +409,13 @@ def rcmplib(args): def bench(args): mx.abort("no benchmarks available") +def _rREPLClass(): + return "com.oracle.truffle.r.repl.RREPLServer" + +def runRREPL(args, nonZeroIsFatal=True, extraVmArgs=None): + '''run R repl''' + return runR(args, _rREPLClass(), nonZeroIsFatal=nonZeroIsFatal, extraVmArgs=['-DR:+Instrument']) + def load_optional_suite(name): hg_base = mx.get_env('MX_HG_BASE') alternate = None if hg_base is None else join(hg_base, name) @@ -405,16 +437,17 @@ def mx_post_parse_cmd_line(opts): os.environ['MX_SUITEMODEL'] = suiteModel load_optional_suite('r_benchmarks') + load_optional_suite('repl') def mx_init(suite): global _fastr_suite _fastr_suite = suite commands = { # new commands - 'r' : [runRCommand, '[options]'], - 'R' : [runRCommand, '[options]'], - 'rscript' : [runRscriptCommand, '[options]'], - 'Rscript' : [runRscriptCommand, '[options]'], + 'r' : [rshell, '[options]'], + 'R' : [rshell, '[options]'], + 'rscript' : [rscript, '[options]'], + 'Rscript' : [rscript, '[options]'], 'rtestgen' : [testgen, ''], # core overrides 'bench' : [bench, ''], @@ -429,5 +462,6 @@ def mx_init(suite): 'rcmplib' : [rcmplib, ['options']], 'findbugs' : [findbugs, ''], 'test' : [test, ['options']], + 'rrepl' : [runRREPL, '[options]'], } mx.update_commands(suite, commands) diff --git a/mx.fastr/suite.py b/mx.fastr/suite.py index e34fe3172db6f7f7ff98b1f57c2ea6253ffaee9d..7c221ef2260339ba01cd956ef4260b39f302c072 100644 --- a/mx.fastr/suite.py +++ b/mx.fastr/suite.py @@ -21,7 +21,7 @@ # questions. # suite = { - "mxversion" : "3.1.1", + "mxversion" : "3.2.0", "name" : "fastr", "libraries" : { "GNUR" : {