Skip to content

Commit 39e2597

Browse files
author
Christian Wimmer
committed
Make forcedCompilation registration thread safe
1 parent ae676fa commit 39e2597

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CompilationInfoSupport.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@
2424
*/
2525
package com.oracle.svm.hosted.code;
2626

27-
import java.util.HashMap;
28-
import java.util.HashSet;
2927
import java.util.List;
3028
import java.util.Map;
3129
import java.util.Set;
30+
import java.util.concurrent.ConcurrentHashMap;
3231
import java.util.stream.Collectors;
3332

3433
import org.graalvm.compiler.nodeinfo.Verbosity;
@@ -122,10 +121,10 @@ public DeoptSourceFrameInfo mergeStateInfo(FrameState state) {
122121

123122
protected boolean sealed;
124123

125-
private final Set<AnalysisMethod> forcedCompilations = new HashSet<>();
126-
private final Set<AnalysisMethod> frameInformationRequired = new HashSet<>();
127-
private final Map<AnalysisMethod, Map<Long, DeoptSourceFrameInfo>> deoptEntries = new HashMap<>();
128-
private final Set<AnalysisMethod> deoptInliningExcludes = new HashSet<>();
124+
private final Set<AnalysisMethod> forcedCompilations = ConcurrentHashMap.newKeySet();
125+
private final Set<AnalysisMethod> frameInformationRequired = ConcurrentHashMap.newKeySet();
126+
private final Map<AnalysisMethod, Map<Long, DeoptSourceFrameInfo>> deoptEntries = new ConcurrentHashMap<>();
127+
private final Set<AnalysisMethod> deoptInliningExcludes = ConcurrentHashMap.newKeySet();
129128

130129
public static CompilationInfoSupport singleton() {
131130
return ImageSingletons.lookup(CompilationInfoSupport.class);
@@ -150,7 +149,7 @@ public void registerFrameInformationRequired(AnalysisMethod method) {
150149
* deoptimization target. No bci needs to be registered, it is enough to have a non-null
151150
* value in the map.
152151
*/
153-
deoptEntries.computeIfAbsent(method, m -> new HashMap<>());
152+
deoptEntries.computeIfAbsent(method, m -> new ConcurrentHashMap<>());
154153
}
155154

156155
public boolean isFrameInformationRequired(ResolvedJavaMethod method) {
@@ -163,7 +162,7 @@ public void registerDeoptEntry(FrameState state) {
163162
assert state.bci >= 0;
164163
long encodedBci = FrameInfoEncoder.encodeBci(state.bci, state.duringCall(), state.rethrowException());
165164

166-
Map<Long, DeoptSourceFrameInfo> sourceFrameInfoMap = deoptEntries.computeIfAbsent(toAnalysisMethod(state.getMethod()), m -> new HashMap<>());
165+
Map<Long, DeoptSourceFrameInfo> sourceFrameInfoMap = deoptEntries.computeIfAbsent(toAnalysisMethod(state.getMethod()), m -> new ConcurrentHashMap<>());
167166
sourceFrameInfoMap.compute(encodedBci, (k, v) -> v == null ? DeoptSourceFrameInfo.create(state) : v.mergeStateInfo(state));
168167
}
169168

0 commit comments

Comments
 (0)