From 2bc503b28f622133bdf90611641b4d91df309c23 Mon Sep 17 00:00:00 2001 From: Tomas Stupka <tomas.stupka@oracle.com> Date: Fri, 13 Jul 2018 17:10:13 +0200 Subject: [PATCH] always encapsulate arguments when creating internalDispatchCall in RCallNode --- .../truffle/r/nodes/function/RCallNode.java | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java index 576694287c..1e7f8797ab 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallNode.java @@ -306,17 +306,7 @@ public abstract class RCallNode extends RCallBaseNode implements RSyntaxNode, RS try { boolean isFieldAccess = builtin.isFieldAccess(); if (internalDispatchCall == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - AlteredArguments alteredArguments = null; - if (isFieldAccess) { - RSyntaxNode[] newArgs = Arrays.copyOf(arguments, arguments.length); - newArgs[1] = RContext.getASTBuilder().constant(newArgs[1].getSourceSection(), CallUtils.unevaluatedArgAsFieldName(this, newArgs[1])); - // we know that there are no varargs in the signature, but this RCallNode - // instance could have been confused by lookup of "..." as the field, in which - // case it would think it should lookup varargs. - alteredArguments = new AlteredArguments(newArgs, new int[0]); - } - internalDispatchCall = insert(FunctionDispatchNodeGen.create(this, alteredArguments, false, slot)); + createInternDispatchCall(isFieldAccess, slot); } if (isAttributableProfile.profile(dispatchObject instanceof RAttributeStorage) && isS4Profile.profile(((RAttributeStorage) dispatchObject).isS4())) { @@ -348,8 +338,7 @@ public abstract class RCallNode extends RCallBaseNode implements RSyntaxNode, RS resultFunction = function; } if (internalDispatchCall == null || internalDispatchCall.tempFrameSlot != slot) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - internalDispatchCall = insert(FunctionDispatchNodeGen.create(this, false, slot)); + createInternDispatchCall(isFieldAccess, slot); } return internalDispatchCall.execute(frame, resultFunction, lookupVarArgs(frame, isFieldAccess), s3Args, null); } finally { @@ -357,6 +346,20 @@ public abstract class RCallNode extends RCallBaseNode implements RSyntaxNode, RS } } + private void createInternDispatchCall(boolean isFieldAccess, FrameSlot slot) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + AlteredArguments alteredArguments = null; + if (isFieldAccess) { + RSyntaxNode[] newArgs = Arrays.copyOf(arguments, arguments.length); + newArgs[1] = RContext.getASTBuilder().constant(newArgs[1].getSourceSection(), CallUtils.unevaluatedArgAsFieldName(this, newArgs[1])); + // we know that there are no varargs in the signature, but this RCallNode + // instance could have been confused by lookup of "..." as the field, in which + // case it would think it should lookup varargs. + alteredArguments = new AlteredArguments(newArgs, new int[0]); + } + internalDispatchCall = insert(FunctionDispatchNodeGen.create(this, alteredArguments, false, slot)); + } + @Specialization(guards = {"explicitArgs != null", "isInternalGenericDispatch(function)"}) public Object callInternalGenericExplicit(VirtualFrame frame, RFunction function, @Cached("create()") ClassHierarchyNode classHierarchyNode, -- GitLab