Skip to content

Commit

Permalink
Collect information about call edges and print it with other analysis…
Browse files Browse the repository at this point in the history
… results statistics.
  • Loading branch information
Marjana Solajic committed Oct 13, 2021
1 parent 7bc06f8 commit 83e3186
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
*/
package com.oracle.graal.pointsto.reports;

import org.graalvm.collections.EconomicMap;
import org.graalvm.compiler.options.Option;
import org.graalvm.compiler.options.OptionKey;

import static com.oracle.graal.pointsto.api.PointstoOptions.TrackAccessChain;

public class AnalysisReportsOptions {

@Option(help = "Print analysis results statistics.")//
Expand All @@ -38,6 +41,17 @@ public class AnalysisReportsOptions {
@Option(help = "Print analysis call tree, a breadth-first tree reduction of the call graph.")//
public static final OptionKey<Boolean> PrintAnalysisCallTree = new OptionKey<>(false);

@Option(help = "Print call edges with other analysis results statistics.")//
public static final OptionKey<Boolean> PrintCallEdges = new OptionKey<Boolean>(false) {
@Override
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean oldValue, Boolean newValue) {
if (newValue) {
PrintAnalysisStatistics.update(values, true);
TrackAccessChain.update(values, true);
}
}
};

@Option(help = "Print image object hierarchy.")//
public static final OptionKey<Boolean> PrintImageObjectTree = new OptionKey<>(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ private void printStats(PrintWriter out) {

beginObject(out);

if (AnalysisReportsOptions.PrintCallEdges.getValue(bb.getOptions())) {
int[] callEdges = getNumCallEdges(bb);
print(out, "total_call_edges", callEdges[0]);
print(out, "app_call_edges", callEdges[1]);
}
print(out, "total_reachable_types", reachableTypes[0]);
print(out, "app_reachable_types", reachableTypes[1]);
print(out, "total_reachable_methods", reachableMethods[0]);
Expand Down Expand Up @@ -108,6 +113,21 @@ public static void printLast(PrintWriter out, String key, long value) {
out.format("%s\"%s\": %d%n", INDENT, key, value);
}

private static int[] getNumCallEdges(BigBang bb) {
int callEdges = 0;
int appCallEdges = 0;
for (AnalysisMethod method : bb.getUniverse().getMethods()) {
if (method.isImplementationInvoked()) {
int callers = method.getCallers().size();
callEdges += callers;
if (!isRuntimeLibraryType(method.getDeclaringClass())) {
appCallEdges += callers;
}
}
}
return new int[]{callEdges, appCallEdges};
}

private static int[] getNumReachableTypes(BigBang bb) {
int reachable = 0;
int appReachable = 0;
Expand Down
12 changes: 12 additions & 0 deletions vm/mx.vm/mx_vm_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def __init__(self, vm, bm_suite, args):
self.base_image_build_args += ['-H:Path=' + self.output_dir]
self.base_image_build_args += ['-H:ConfigurationFileDirectories=' + self.config_dir]
self.base_image_build_args += ['-H:+PrintAnalysisStatistics', '-H:AnalysisStatisticsFile=' + self.analysis_report_path]
self.base_image_build_args += ['-H:+PrintCallEdges']
self.base_image_build_args += ['-H:+CollectImageBuildStatistics', '-H:ImageBuildStatisticsFile=' + self.image_build_report_path]
self.base_image_build_args += ['-H:+ConfigureReflectionMetadata']
if vm.is_llvm:
Expand Down Expand Up @@ -581,6 +582,17 @@ def __call__(self, *args, **kwargs):
"metric.iteration": 0,
"metric.object": ("<section>", str),
}),
mx_benchmark.JsonStdOutFileRule(r'^# Printing analysis results stats to: (?P<path>\S+?)$', 'path', {
"benchmark": benchmarks[0],
"metric.name": "analysis-stats",
"metric.type": "numeric",
"metric.unit": "#",
"metric.value": ("<total_call_edges>", int),
"metric.score-function": "id",
"metric.better": "lower",
"metric.iteration": 0,
"metric.object": "call-edges",
}, ['total_call_edges']),
mx_benchmark.JsonStdOutFileRule(r'^# Printing analysis results stats to: (?P<path>\S+?)$', 'path', {
"benchmark": benchmarks[0],
"metric.name": "analysis-stats",
Expand Down

0 comments on commit 83e3186

Please sign in to comment.