Skip to content

Commit b609631

Browse files
committed
[GR-30013] Make PrintPointsToStatistics thread safe.
PullRequest: graal/8519
2 parents 0534b44 + 0c7383a commit b609631

File tree

1 file changed

+7
-7
lines changed
  • substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/typestate

1 file changed

+7
-7
lines changed

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/typestate/PointsToStats.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
import java.nio.file.Path;
3333
import java.time.LocalDateTime;
3434
import java.time.format.DateTimeFormatter;
35-
import java.util.ArrayList;
3635
import java.util.Comparator;
3736
import java.util.List;
3837
import java.util.Map.Entry;
3938
import java.util.Objects;
4039
import java.util.concurrent.ConcurrentHashMap;
40+
import java.util.concurrent.CopyOnWriteArrayList;
4141
import java.util.concurrent.atomic.AtomicInteger;
4242
import java.util.function.Consumer;
4343
import java.util.function.Function;
@@ -139,7 +139,7 @@ private static void doReport(Path dir, String reportNameRoot, String whatIsRepor
139139

140140
}
141141

142-
private static List<TypeFlowBuilder<?>> typeFlowBuilders = new ArrayList<>();
142+
private static List<TypeFlowBuilder<?>> typeFlowBuilders = new CopyOnWriteArrayList<>();
143143

144144
public static void registerTypeFlowBuilder(BigBang bb, TypeFlowBuilder<?> builder) {
145145
if (!bb.reportAnalysisStatistics()) {
@@ -190,15 +190,15 @@ static class TypeFlowStats {
190190

191191
final TypeFlow<?> flow;
192192

193-
final ArrayList<TypeState> allUpdates;
194-
final ArrayList<TypeState> successfulUpdates;
193+
final List<TypeState> allUpdates;
194+
final List<TypeState> successfulUpdates;
195195
final AtomicInteger queuedUpdates;
196196

197197
TypeFlowStats(TypeFlow<?> flow) {
198198
this.retainReason = "";
199199
this.flow = flow;
200-
this.allUpdates = new ArrayList<>();
201-
this.successfulUpdates = new ArrayList<>();
200+
this.allUpdates = new CopyOnWriteArrayList<>();
201+
this.successfulUpdates = new CopyOnWriteArrayList<>();
202202
this.queuedUpdates = new AtomicInteger(0);
203203
}
204204

@@ -586,7 +586,7 @@ private static String asString(TypeFlow<?> flow) {
586586
} else if (flow instanceof ActualReturnTypeFlow) {
587587
ActualReturnTypeFlow ret = (ActualReturnTypeFlow) flow;
588588
InvokeTypeFlow invoke = ret.invokeFlow();
589-
return "ActualReturn(" + formatMethod(invoke.getTargetMethod()) + ")@ " + formatSource(flow);
589+
return "ActualReturn(" + (invoke == null ? "null" : formatMethod(invoke.getTargetMethod())) + ")@ " + formatSource(flow);
590590
} else if (flow instanceof MergeTypeFlow) {
591591
return "Merge @ " + formatSource(flow);
592592
} else if (flow instanceof SourceTypeFlow) {

0 commit comments

Comments
 (0)