Skip to content

Commit

Permalink
Introduce PrintAnalysisCallTreeType option
Browse files Browse the repository at this point in the history
This option enables users to choose the structure of the call tree
report. Currently supported formats are txt and csv.

The use of this flag implicitly enables PrintAnalysisCallTree option.

Closes: oracle#3843
  • Loading branch information
zakkak committed Nov 26, 2021
1 parent dbeff85 commit 89428dd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/
package com.oracle.graal.pointsto.reports;

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

Expand All @@ -38,6 +40,15 @@ 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 = "Change the output format of the analysis call tree. See: Reports.md.")//
public static final EnumOptionKey<CallTreeType> PrintAnalysisCallTreeType = new EnumOptionKey<CallTreeType>(CallTreeType.TXT) {
@Override
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, CallTreeType oldValue, CallTreeType newValue) {
super.onValueUpdate(values, oldValue, newValue);
PrintAnalysisCallTree.update(values, true);
}
};

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

Expand All @@ -52,4 +63,9 @@ public class AnalysisReportsOptions {

@Option(help = "Suppress the expansion of specified types. See: Reports.md.")//
public static final OptionKey<String> ImageObjectTreeSuppressTypes = new OptionKey<>("");

enum CallTreeType {
TXT,
CSV;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import com.oracle.graal.pointsto.flow.InvokeTypeFlow;
import com.oracle.graal.pointsto.meta.AnalysisMethod;

import com.oracle.graal.pointsto.util.AnalysisError;
import jdk.vm.ci.code.BytecodePosition;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.ResolvedJavaMethod;
Expand All @@ -75,16 +76,24 @@ public static void print(BigBang bb, String reportsPath, String reportName) {
CallTreePrinter printer = new CallTreePrinter(bb);
printer.buildCallTree();

ReportUtils.report("call tree", reportsPath, "call_tree_" + reportName, "txt",
printer::printMethods);
AnalysisReportsOptions.CallTreeType optionValue = AnalysisReportsOptions.PrintAnalysisCallTreeType.getValue(bb.getOptions());
switch (optionValue) {
case TXT:
ReportUtils.report("call tree", reportsPath, "call_tree_" + reportName, "txt",
printer::printMethods);
break;
case CSV:
printCsvFiles(printer.methodToNode, reportsPath, reportName);
break;
default:
throw AnalysisError.shouldNotReachHere("Unsupported CallTreeType " + optionValue + " used with PrintAnalysisCallTreeType option");
}
ReportUtils.report("list of used methods", reportsPath, "used_methods_" + reportName, "txt",
printer::printUsedMethods);
ReportUtils.report("list of used classes", reportsPath, "used_classes_" + reportName, "txt",
writer -> printer.printClasses(writer, false));
ReportUtils.report("list of used packages", reportsPath, "used_packages_" + reportName, "txt",
writer -> printer.printClasses(writer, true));

printCsvFiles(printer.methodToNode, reportsPath, reportName);
}

interface Node {
Expand Down

0 comments on commit 89428dd

Please sign in to comment.