From 5c62e987140b5e76859222cf4627b862cabd8980 Mon Sep 17 00:00:00 2001 From: Lukas Stadler <lukas.stadler@oracle.com> Date: Mon, 12 Dec 2016 12:58:05 +0100 Subject: [PATCH] thread safety in CallMatcherNode --- .../truffle/r/nodes/function/CallMatcherNode.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 9454d1b46b..e034cfa67d 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(); -- GitLab