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 9454d1b46b985707c8c836d1c714a9b1b86936e3..e034cfa67da52aab6d8a18ab88da0b95344e6a95 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 @@ -60,7 +60,7 @@ public abstract class CallMatcherNode extends RBaseNode { private static final int MAX_CACHE_DEPTH = 3; public static CallMatcherNode create(boolean argsAreEvaluated) { - return new CallMatcherUninitializedNode(argsAreEvaluated); + return new CallMatcherUninitializedNode(argsAreEvaluated, 0); } public abstract Object execute(VirtualFrame frame, ArgumentsSignature suppliedSignature, Object[] suppliedArguments, RFunction function, String functionName, DispatchArgs dispatchArgs); @@ -151,19 +151,20 @@ public abstract class CallMatcherNode extends RBaseNode { @NodeInfo(cost = NodeCost.UNINITIALIZED) private static final class CallMatcherUninitializedNode extends CallMatcherNode { - CallMatcherUninitializedNode(boolean argsAreEvaluated) { + CallMatcherUninitializedNode(boolean argsAreEvaluated, int depth) { super(argsAreEvaluated); + this.depth = depth; } - private int depth; + private final int depth; @Override public Object execute(VirtualFrame frame, ArgumentsSignature suppliedSignature, Object[] suppliedArguments, RFunction function, String functionName, DispatchArgs dispatchArgs) { CompilerDirectives.transferToInterpreterAndInvalidate(); - if (++depth > MAX_CACHE_DEPTH) { + if (depth > MAX_CACHE_DEPTH) { return replace(new CallMatcherGenericNode(argsAreEvaluated)).execute(frame, suppliedSignature, suppliedArguments, function, functionName, dispatchArgs); } else { - CallMatcherCachedNode cachedNode = replace(specialize(suppliedSignature, suppliedArguments, function, this)); + CallMatcherCachedNode cachedNode = replace(specialize(suppliedSignature, suppliedArguments, function, new CallMatcherUninitializedNode(argsAreEvaluated, depth + 1))); // for splitting if necessary if (cachedNode.call != null && RCallNode.needsSplitting(function.getTarget())) { cachedNode.call.getCallNode().cloneCallTarget();