RFR 8233389: Add PrintIdeal to compiler directives

Jorn Vernee jorn.vernee at oracle.com
Fri Nov 1 23:03:16 UTC 2019


Hi Nikola,

Thanks for the suggestion, and welcome to OpenJDK!

The PrintIdeal option is slightly different from PrintIdealGraph + 
IGVPrintLevel. The latter outputs the graph in XML format (or directly 
to the visualizer tool), while the former calls Node::dump on the root 
node of the graph, which outputs a plain text representation of the 
graph to the console instead. IGVPrintLevel is already supported as a 
compiler directive, but I'd like to add PrintIdeal as well, since that 
doesn't require using the visualizer tool :)

In case you were unaware of the feature; I'm using the compiler 
directives JSON file support which was added by JEP 165: 
https://openjdk.java.net/jeps/165 in Java 9. This allows me to use 
"-XX:CompilerDirectivesFile=compile.txt" and then have a compile.txt 
file with something like:

```
[
     {
         match: "main.Main::invoke",
         c2: {
             inline: "-main.Main::invoke",
             Log: true,
             PrintAssembly: true,
             PrintInlining: true,
             PrintIdeal: true
         }
     }
]
```

As a more structured way of defining the compile commands I need.

Cheers,
Jorn

On 01/11/2019 19:26, Nikola Grcevski wrote:
> Hi Jorn and hotspot-compiler-dev!
>
> I'm a VM engineer at Microsoft and we recently signed the OCA agreement so we can properly contribute to OpenJDK. I was recently also in need of this option, as I have been educating myself on Ideal Graph and how the C2 optimizations work. I initially went ahead and added a very similar change in my local build to be able to log only certain methods in larger applications, however I later on discovered that a similar effect can be achieved by using the following combination of options:
>
> 1. On the main java command line you would need to add: -XX:+PrintIdealGraph -XX:PrintIdealGraphLevel=0
>
> 2. With the compile command (or through the .hotspot_compiler file) you can then use IGVPrintLevel to increase the level to greater than 0 on the methods you'd like, e.g:
> option path.class_name::method_name,intx,IGVPrintLevel,2
>
> The idea is to enable the Ideal Graph printing globally, set the global level to 0, and then control which methods would get logged by setting their level through the compiler directive.
>
> This is not as good as having a direct option properly documented as suggested by Jorn, but it works.
>
> Thank you and please let me know if you think this is valid approach and if I should add this comment in the bug report.
> Nikola
>
> -----Original Message-----
> From: hotspot-compiler-dev <hotspot-compiler-dev-bounces at openjdk.java.net> On Behalf Of Jorn Vernee
> Sent: November 1, 2019 11:10 AM
> To: hotspot-compiler-dev at openjdk.java.net
> Subject: RFR 8233389: Add PrintIdeal to compiler directives
>
> Hi,
>
> I'd like to add PrintIdeal as a compiler directive in order to enable PrintIdeal for only a single method when combining it with the 'match'
> directive.
>
> Please review the following:
>
> Bug: https://urldefense.proofpoint.com/v2/url?u=https-3A__nam06.safelinks.protection.outlook.com_-3Furl-3Dhttps-253A-252F-252Fbugs.openjdk.java.net-252Fbrowse-252FJDK-2D8233389-26amp-3Bdata-3D02-257C01-257CNikola.Grcevski-2540microsoft.com-257Cda3a597a49d94f4c541008d75ede29b2-257C72f988bf86f141af91ab2d7cd011db47-257C1-257C0-257C637082181241665037-26amp-3Bsdata-3D24uDd9T1ncKsAPzcvxYI70XUZ1WvXdJ8eX5jHrNHNhk-253D-26amp-3Breserved-3D0&d=DwIGaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=z6hqmB9KSaIU-Otko9bPiG2fp55VDaBvROsDkQobkYI&m=k9YvYehfSfTknl9EFUZMcbiqTaW26xrJPPQUd5KnPTs&s=mObyYrV_E5da2eJQdvqpKJI_tJ5te1qGcSXVSOHqz0M&e=
> Webrev: https://urldefense.proofpoint.com/v2/url?u=https-3A__nam06.safelinks.protection.outlook.com_-3Furl-3Dhttp-3A-252F-252Fcr.openjdk.java.net-252F-7Ejvernee-252Fprint-5Fideal-252Fwebrev.00-252F-26amp-3Bdata-3D02-257C01-257CNikola.Grcevski-2540microsoft.com-257Cda3a597a49d94f4c541008d75ede29b2-257C72f988bf86f141af91ab2d7cd011db47-257C1-257C0-257C637082181241665037-26amp-3Bsdata-3DGD8GvzGdJljn4gDWsLTGxbtbvVl5KCv0RgmMPNH3UKU-253D-26amp-3Breserved-3D0&d=DwIGaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=z6hqmB9KSaIU-Otko9bPiG2fp55VDaBvROsDkQobkYI&m=k9YvYehfSfTknl9EFUZMcbiqTaW26xrJPPQUd5KnPTs&s=3HriLu-X9seR3J_Z7VsBJyyWVginzlyEMhTEBTzkfBs&e=
> (Testing = tier1, manual)
>
> As a heads-up; I'm not a committer on the jdk project, so if this sounds like a good idea, I would require a sponsor to push the changes.
>
> Thanks,
> Jorn
>


More information about the hotspot-compiler-dev mailing list