Skip to content
Snippets Groups Projects
Commit 5c62e987 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

thread safety in CallMatcherNode

parent 52743262
Branches
No related tags found
No related merge requests found
...@@ -60,7 +60,7 @@ public abstract class CallMatcherNode extends RBaseNode { ...@@ -60,7 +60,7 @@ public abstract class CallMatcherNode extends RBaseNode {
private static final int MAX_CACHE_DEPTH = 3; private static final int MAX_CACHE_DEPTH = 3;
public static CallMatcherNode create(boolean argsAreEvaluated) { 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); 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 { ...@@ -151,19 +151,20 @@ public abstract class CallMatcherNode extends RBaseNode {
@NodeInfo(cost = NodeCost.UNINITIALIZED) @NodeInfo(cost = NodeCost.UNINITIALIZED)
private static final class CallMatcherUninitializedNode extends CallMatcherNode { private static final class CallMatcherUninitializedNode extends CallMatcherNode {
CallMatcherUninitializedNode(boolean argsAreEvaluated) { CallMatcherUninitializedNode(boolean argsAreEvaluated, int depth) {
super(argsAreEvaluated); super(argsAreEvaluated);
this.depth = depth;
} }
private int depth; private final int depth;
@Override @Override
public Object execute(VirtualFrame frame, ArgumentsSignature suppliedSignature, Object[] suppliedArguments, RFunction function, String functionName, DispatchArgs dispatchArgs) { public Object execute(VirtualFrame frame, ArgumentsSignature suppliedSignature, Object[] suppliedArguments, RFunction function, String functionName, DispatchArgs dispatchArgs) {
CompilerDirectives.transferToInterpreterAndInvalidate(); CompilerDirectives.transferToInterpreterAndInvalidate();
if (++depth > MAX_CACHE_DEPTH) { if (depth > MAX_CACHE_DEPTH) {
return replace(new CallMatcherGenericNode(argsAreEvaluated)).execute(frame, suppliedSignature, suppliedArguments, function, functionName, dispatchArgs); return replace(new CallMatcherGenericNode(argsAreEvaluated)).execute(frame, suppliedSignature, suppliedArguments, function, functionName, dispatchArgs);
} else { } 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 // for splitting if necessary
if (cachedNode.call != null && RCallNode.needsSplitting(function.getTarget())) { if (cachedNode.call != null && RCallNode.needsSplitting(function.getTarget())) {
cachedNode.call.getCallNode().cloneCallTarget(); cachedNode.call.getCallNode().cloneCallTarget();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment