Skip to content

HotSpot Disassembler

July 14, 2013

HotSpot treats bytecode as input to one or both of it’s JIT compilers: C1 – client (faster startup) or C2 – server (long running process optimized).

Sometimes it’s useful to see what code is actually being run by the JVM, because it’s usually not what the bytecode says.

hsdisHotSpot Disassembler Plugin can be found here in the Open JDK source code.

http://hg.openjdk.java.net/jdk8/jdk8/hotspot/tip/src/share/tools/hsdis

Building and Installing the plugin

The README file present in that directory describes the procedure, but for completeness I’ll describe what worked for me on Mac OSX 10.8.4. Download the latest GNU binutils from here: http://ftp.gnu.org/gnu/binutils/

export BINUTILS=/somdirectory/binutils-2.23.2
make all64

Now you should have a build/macosx-amd64 subdirectory with all that you need to run. Now you can either install this in your JRE/JDK OR you can just set LD_LIBRARY_PATH to this directory.

To install permanently in your JDK/JRE

cp jdk8/hotspot/src/share/tools/hsdis/build/macosx-amd64/hsdis-amd64.dylib /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/

Running the disassembler

java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly SomeCompiledClass

Example code and output can be found here …

Advertisements

From → Java

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: