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

thread safety in CallArgumentsNode

parent 95d95181
No related branches found
No related tags found
No related merge requests found
...@@ -161,8 +161,18 @@ public final class CallArgumentsNode extends RBaseNode implements UnmatchedArgum ...@@ -161,8 +161,18 @@ public final class CallArgumentsNode extends RBaseNode implements UnmatchedArgum
return Arguments.create(values, ArgumentsSignature.get(newNames)); return Arguments.create(values, ArgumentsSignature.get(newNames));
} }
private ArgumentsSignature cachedVarArgsSignature; private static final class CachedSignature {
private ArgumentsSignature cachedResultSignature; private final ArgumentsSignature signature;
private final ArgumentsSignature resultSignature;
protected CachedSignature(ArgumentsSignature signature, ArgumentsSignature resultSignature) {
this.signature = signature;
this.resultSignature = resultSignature;
}
}
private CachedSignature cachedVarArgsSignature;
private final BranchProfile regenerateSignatureProfile = BranchProfile.create(); private final BranchProfile regenerateSignatureProfile = BranchProfile.create();
public ArgumentsSignature flattenNames(RArgsValuesAndNames varArgs) { public ArgumentsSignature flattenNames(RArgsValuesAndNames varArgs) {
...@@ -170,15 +180,15 @@ public final class CallArgumentsNode extends RBaseNode implements UnmatchedArgum ...@@ -170,15 +180,15 @@ public final class CallArgumentsNode extends RBaseNode implements UnmatchedArgum
return signature; return signature;
} }
ArgumentsSignature varArgsSignature = varArgs.getSignature(); ArgumentsSignature varArgsSignature = varArgs.getSignature();
if (cachedVarArgsSignature == null) { CachedSignature cached = cachedVarArgsSignature;
if (cached == null) {
CompilerDirectives.transferToInterpreter(); CompilerDirectives.transferToInterpreter();
} }
if (varArgsSignature == cachedVarArgsSignature) { if (cached == null || varArgsSignature != cached.signature) {
return cachedResultSignature; regenerateSignatureProfile.enter();
cachedVarArgsSignature = cached = new CachedSignature(varArgsSignature, flattenNamesInternal(varArgsSignature));
} }
regenerateSignatureProfile.enter(); return cached.resultSignature;
cachedVarArgsSignature = varArgsSignature;
return cachedResultSignature = flattenNamesInternal(varArgsSignature);
} }
@TruffleBoundary @TruffleBoundary
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment