-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Extend PrintAnalysisCallTree option #3227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hi @mcraj017, could you please assign this to someone for a review? |
@zakkak thanks for the PR, I have assigned reviwers for this |
d03afb1
to
4f44eed
Compare
@christianwimmer @vjovanov are there any updates on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document the new option format in /docs/reference-manual/native-image/Reports.md
. Is this supposed to work only for entry points, or any method can be selected?
boolean isNative = invoke.targetMethod.wrapped.getClass().getName().equals("com.oracle.svm.jni.hosted.JNINativeCallWrapperMethod"); | ||
if (print) { | ||
if (calleeNode instanceof MethodNodeReference && printedID.add(((MethodNodeReference) calleeNode).methodNode.id)) { | ||
calleeNode = ((MethodNodeReference) calleeNode).methodNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why expand the method reference only for the direct invokes but not for the virtual invokes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
if (calleeNode instanceof MethodNode) { | ||
printCallTreeNode(out, prefix + (lastInvoke ? EMPTY_INDENT : CONNECTING_INDENT) + (lastCallee ? EMPTY_INDENT : CONNECTING_INDENT), (MethodNode) calleeNode); | ||
printCallTreeNode(out, prefix + (lastInvoke ? EMPTY_INDENT : CONNECTING_INDENT) + (lastCallee ? EMPTY_INDENT : CONNECTING_INDENT), (MethodNode) calleeNode, print, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing null
for the beginning
parameter seems wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example testing this naively with mx helloworld -H:PrintAnalysisCallTree='java.lang.String.hashCode(),java.lang.String.toString()
results in:
VM Entry Points
nullentry java.lang.String.hashCode():int id=1277
nullentry java.lang.String.toString():java.lang.String id=1351
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
d986983
to
c73cd5a
Compare
Updated the reference file. It should report for any method selected.@cstancu please have a review. Thanks. |
d1f9510
to
7b21f5c
Compare
Please consider my comment #3843 (comment) before integrating this. I'd rather |
@@ -17,7 +17,10 @@ the image heap, respectively. | |||
The call tree is a a breadth-first tree reduction of the call graph as seen by the points-to analysis. | |||
The points-to analysis eliminates calls to methods that it determines cannot be reachable at runtime, based on the analysed receiver types. | |||
It also completely eliminates invocations in unreachable code blocks, e.g., blocks guarded by a type check that always fails. | |||
The call tree report is enabled using the `-H:+PrintAnalysisCallTree` option. | |||
The call tree report is enabled using the `-H:PrintAnalysisCallTree=<comma-separated method list>` option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ziyilin , as discussed in #3843 (comment) this option would better be left as is and a new option -H:PrintAnalysisCallTreeFilter=<comma-separated method list>
should be introduced instead. To avoid the need of passing both PrintAnalysisCallTreeFilter
and PrintAnalysisCallTree
, the former can implicitly set the latter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have modified as suggested.
7b21f5c
to
f8f93ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update @ziyilin .
I have added a couple of suggestion could you please have a look?
There seems to be a styling issue as well https://github.com/oracle/graal/pull/3227/checks?check_run_id=3834984765#step:9:1000
@@ -17,7 +17,11 @@ the image heap, respectively. | |||
The call tree is a a breadth-first tree reduction of the call graph as seen by the points-to analysis. | |||
The points-to analysis eliminates calls to methods that it determines cannot be reachable at runtime, based on the analysed receiver types. | |||
It also completely eliminates invocations in unreachable code blocks, e.g., blocks guarded by a type check that always fails. | |||
The call tree report is enabled using the `-H:+PrintAnalysisCallTree` option. | |||
The call tree report is enabled using the `-H:PrintAnalysisCallTree` option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call tree report is enabled using the `-H:PrintAnalysisCallTree` option. | |
The call tree report is enabled using the `-H:+PrintAnalysisCallTree` option. |
The call tree report is enabled using the `-H:+PrintAnalysisCallTree` option. | ||
The call tree report is enabled using the `-H:PrintAnalysisCallTree` option. | ||
Option `-H:PrintAnalysisCallTreeFilter=<comma-separated method list>` can be used to only print out the specified methods' | ||
call tree, and it implicitly enables the `-H:PrintAnalysisCallTree`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call tree, and it implicitly enables the `-H:PrintAnalysisCallTree`. | |
call tree, and it implicitly sets `-H:+PrintAnalysisCallTree`. |
@@ -45,8 +45,12 @@ public static void printAnalysisReports(String imageName, OptionValues options, | |||
StatisticsPrinter.print(bb, reportsPath, ReportUtils.extractImageName(imageName)); | |||
} | |||
|
|||
if (AnalysisReportsOptions.PrintAnalysisCallTree.getValue(options)) { | |||
CallTreePrinter.print(bb, reportsPath, ReportUtils.extractImageName(imageName)); | |||
if (AnalysisReportsOptions.PrintAnalysisCallTree.hasBeenSet(options)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (AnalysisReportsOptions.PrintAnalysisCallTree.hasBeenSet(options)) { | |
if (AnalysisReportsOptions.PrintAnalysisCallTree.getValue(options)) { |
This condition should check whether PrintAnalysisCallTree
is true, right? Not if it's just been set (possibly to false).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, I didn't change it when PrintAnalysisCallTree
is changed from String
to Boolean
.
-H:PrintAnalysisCallTreeFilter= option accept a list of methods to print the call tree of them, the default value is an empty string to print all call trees.
f8f93ae
to
c64d8e6
Compare
Hello @cstancu, are there any updates on this? |
This PR fell between cracks. If it's still relevant for you I have a few suggestions:
|
Current
-H:+PrintAnalysisCallTree
option prints call trees for all entries. However, the resulting file is too large to look for the method that user is interested in.This PR extends the option to
-H:PrintAnalysisCallTree=<comma-separated method list>
. Only the specified entry methods' call tree will be printed out. And-H:PrintAnalysisCallTree=
prints call tree for all entry methods, just like previous-H:+PrintAnalysisCallTree
does.The method name is the qualified name including parameter types, such as
sun.nio.fs.UnixNativeDispatcher.<clinit>()
.