How can I see the code that HotSpot generates after optimizing? [duplicate]
Asked Answered
J

2

8

I'd like to have a better understanding of what optimizations HotSpot might generate for my Java code at run time.

Is there a way to see the optimized code that HotSpot is using after it's been running for a while?

Jocose answered 11/10, 2009 at 21:8 Comment(0)
R
10

You will need to start the JVM with the options -XX:+PrintAssembly and -XX:UnlockDiagnosticVMOptions, but PrintAssembly requires the JVM to have the hsdis binary (HotSpot disassembler). The hsdis binary is not distributed with the JVM due to license incompatibility, so you will need to compile hsdis yourself or find a prebuilt hsdis binary from an unofficial web site.

To make sense of the output, a tool like JITWatch is useful. Follow its instructions to write the debug information to a log file which can be analyzed in JITWatch.

Reliquiae answered 11/10, 2009 at 21:32 Comment(2)
Yep, -XX:+PrintOptoAssembly is the key.Gandhiism
Note: PrintAssembly is the new flag. PrintOptoAssembly is the old flag, which I believe requires a debug build of the JVM.Guilt

© 2022 - 2024 — McMap. All rights reserved.