Skip to content

Commit c477751

Browse files
committed
add timer for getting method summaries
1 parent 290429e commit c477751

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

substratevm/src/com.oracle.graal.reachability/src/com/oracle/graal/reachability/ReachabilityAnalysis.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ public abstract class ReachabilityAnalysis extends AbstractReachabilityAnalysis
6363

6464
private final MethodSummaryProvider methodSummaryProvider;
6565
private final AnalysisType objectType;
66+
private final Timer summaryTimer;
6667

6768
public ReachabilityAnalysis(OptionValues options, AnalysisUniverse universe, HostedProviders providers, HostVM hostVM, ForkJoinPool executorService, Runnable heartbeatCallback,
6869
UnsupportedFeatures unsupportedFeatures, MethodSummaryProvider methodSummaryProvider) {
6970
super(options, universe, providers, hostVM, executorService, heartbeatCallback, unsupportedFeatures);
7071
this.methodSummaryProvider = methodSummaryProvider;
7172
this.objectType = metaAccess.lookupJavaType(Object.class);
73+
this.summaryTimer = new Timer(hostVM.getImageName(), "((summaries))", false);
7274
}
7375

7476
@Override
@@ -137,7 +139,10 @@ public void markMethodImplementationInvoked(AnalysisMethod method, Object reason
137139

138140
private void onMethodImplementationInvoked(AnalysisMethod method) {
139141
try {
140-
MethodSummary summary = methodSummaryProvider.getSummary(this, method);
142+
MethodSummary summary;
143+
try (Timer.StopTimer t = summaryTimer.start()) {
144+
summary = methodSummaryProvider.getSummary(this, method);
145+
}
141146
processSummary(method, summary);
142147
summaries.put(method, summary);
143148
} catch (Throwable ex) {
@@ -229,7 +234,7 @@ public void markTypeInstantiated(AnalysisType type) {
229234
}
230235
AnalysisMethod implementationInvokedMethod = type.resolveConcreteMethod(method, current);
231236
if (implementationInvokedMethod == null) {
232-
System.out.println("onMethodInvoked: method " + method + " on type " + current + " is null");
237+
// System.out.println("onMethodInvoked: method " + method + " on type " + current + " is null");
233238
continue;
234239
}
235240
markMethodImplementationInvoked(implementationInvokedMethod, type); // todo better
@@ -256,7 +261,7 @@ private void onMethodInvoked(AnalysisMethod method) {
256261
for (AnalysisType subtype : instantiatedSubtypes) {
257262
AnalysisMethod resolvedMethod = subtype.resolveConcreteMethod(method, clazz);
258263
if (resolvedMethod == null) {
259-
System.out.println("onMethodInvoked: method " + method + " on type " + subtype + " is null");
264+
// System.out.println("onMethodInvoked: method " + method + " on type " + subtype + " is null");
260265
continue;
261266
}
262267
markMethodImplementationInvoked(resolvedMethod, method); // todo better reason
@@ -340,7 +345,10 @@ public TypeState getAllSynchronizedTypeState() {
340345
}
341346

342347
public void processGraph(StructuredGraph graph) {
343-
MethodSummary summary = methodSummaryProvider.getSummary(this, graph);
348+
MethodSummary summary;
349+
try (Timer.StopTimer t = summaryTimer.start()) {
350+
summary = methodSummaryProvider.getSummary(this, graph);
351+
}
344352
AnalysisMethod method = analysisMethod(graph.method());
345353
method.registerAsInvoked(null);
346354
method.registerAsImplementationInvoked(null);
@@ -351,7 +359,6 @@ public void processGraph(StructuredGraph graph) {
351359

352360
private void registerForeignCalls(StructuredGraph graph) {
353361
for (Node n : graph.getNodes()) {
354-
// todo handle foreign calls even in the summary provider?
355362
if (n instanceof ForeignCall) {
356363
ForeignCall node = (ForeignCall) n;
357364
registerForeignCall(node.getDescriptor());
@@ -379,4 +386,10 @@ private void registerForeignCall(ForeignCallDescriptor descriptor) {
379386
private AnalysisMethod analysisMethod(ResolvedJavaMethod method) {
380387
return method instanceof AnalysisMethod ? ((AnalysisMethod) method) : universe.lookup(method);
381388
}
389+
390+
@Override
391+
public void printTimers() {
392+
summaryTimer.print();
393+
super.printTimers();
394+
}
382395
}

0 commit comments

Comments
 (0)