PrintAssembly

Version 5 by jrose
on Feb 22, 2009 00:16.

compared with
Current by UlfZibis
on Nov 18, 2009 04:45.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (10)

View page history
h3. Plugin Implementations
The plugin is defined in the OpenJDK sources here:
http://hg.openjdk.java.net/jdk7/hotspot/hotspot/file/tip/src/share/tools/hsdis/
There are 2 implementations around:
 
h5. OpenJDK [sources|http://hg.openjdk.java.net/jdk7/hotspot/hotspot/file/tip/src/share/tools/hsdis/] (defines the plugin API)
This version of the plugin requires the Gnu disassembler, which is available separately as part of the [binutils|http://directory.fsf.org/project/binutils] project.

Look at the [README|http://hg.openjdk.java.net/jdk7/hotspot/hotspot/file/tip/src/share/tools/hsdis/README] for instructions on building. Pre-built binaries do not seem to be available _(help... anyone?)_.
Independently of the OpenJDK sources, there is an implementation of the plugin in the [base-hsdis project|http://kenai.com/projects/base-hsdis] at Kenai. This is a from-scratch implementation which uses code from the [Bastard project|http://sourceforge.net/projects/bastard] at SourceForge. The copyrights on this code are non-restrictive.
h5. Kenai project [base-hsdis|http://kenai.com/projects/base-hsdis]
 
This is a from-scratch implementation which uses code from the [Bastard project|http://sourceforge.net/projects/bastard] at SourceForge. The copyrights on this code are non-restrictive.
The Kenai project offers [binary downloads|http://kenai.com/projects/base-hsdis/downloads].
h3. Installing the Plugin

Once you succeed in building or downloading the {{hsdis}} binary library (in the following named DLL), you have to install it next to your libjvm.so (jvm.dll on Windows), in the same folder. (Alternatively, you can put it anywhere on your {{LD_LIBRARY_PATH}}.) The DLL must be given the name that the JVM will be looking for. The core of the name will be {{hsdis-i386}} for 32-bit Intel JVMs. Other names in use are {{hsdis-amd64}}, {{hsdis-sparc}}, and {{hsdis-sparcv9}}. A prefix and/or suffix will be required, according to system-dependent rules for naming DLLs.

{noformat:title=installing the plugin on Solaris}
$ JDK7=my/copy/of/jre1.7.0
$ cp -p hsdis/.libs/hsdis.so $JDK7/lib/i386/client/libhsdis-i386.so
$ cp -p hsdis/.libs/hsdis.so $JDK7/lib/i386/server/libhsdis-i386.so
$ XJAVA="$JDK7/bin/java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly"
$ $XJAVA -Xcomp -cp ~/Classes hello
$ $XJAVA -Xcomp -cp ~/Classes -XX:PrintAssemblyOptions=hsdis-print-bytes hello
$ $XJAVA -XX:-PrintAssembly -XX:+PrintStubCode
$ $XJAVA -XX:-PrintAssembly -XX:+PrintInterpreter
$ $XJAVA -XX:-PrintAssembly -XX:+PrintSignatureHandlers
$ $XJAVA -Xbatch -cp ~/Classes -XX:+PrintCompilation myloopingbenchmark
{noformat}

The last line (with {{myloopingbenchmark}}) is most typical, since it uses the batch execution mode common with benchmarks. The {{-XX:+PrintCompilation}} flag will let you know which (if any) methods are being compiled.
h3. Filtering Output
The {{-XX:+PrintAssembly}} option prints everything. If that's too much, drop it and use one of the following options.
Individual methods may be printed:
* {{CompileCommand=print,*MyClass.myMethod}} prints assembly for just one method
* {{CompileCommand=option,*MyClass.myMethod,PrintNMethods}} produces method dumps
These options accumulate.
 
If you get no output, use {{-XX:+PrintCompilation}} to verify that your method is getting compiled at all.
h3. Reading the compiler's mind

The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact