Excerpt |
---|
Puzzled by a performance glitch? You might have to look at the generated code. |
Examining generated code
The following HotSpot options (with an -XX: prefix on the command line) require OpenJDK 7 and an externally loadable disassembler plugin:
...
The disassembly output is annotated with various kinds of debugging information, such as field names and source locations. The quality of this information improved markedly in January 2010 (bug fix 6912062).
Examples
Code Block |
---|
0x0188272f: mov ecx, [ecx+0x1A8B8B30] ; {oop(cache [42] for constant pool [234]/invokedynamic for 'SumWithIndy' cache=0x1a8b8b30)}
0x01882735: mov edx, [ecx+0x10]
0x01882738: cmp edx, a 'sun/dyn/ToGeneric$A2'
; {oop(a 'sun/dyn/ToGeneric$A2')}
0x0188273e: jnz 0x018827c1 ;*invokedynamic
; - SumWithIndy::test@17 (line 90)
0x01882744: mov edi, 0x00000150
0x01882749: mov edx, [edi+0x1A8B9110] ;*getstatic cache
; - java.lang.Integer::valueOf@35 (line 651)
; - sun.dyn.ToGeneric$A2::targetA2@3 (line 663)
; - sun.dyn.ToGeneric$A2::invoke_L@4 (line 672)
; - java.dyn.InvokeDynamic::invokeExact@4
; - SumWithIndy::test@17 (line 90)
; {oop('java/lang/Integer$IntegerCache')}
|
...
Look at the README for instructions on building.
With recent binutils version (i.e. binutils-2.23.2) you may get the following build error:
WARNING: `makeinfo' is missing on your system. You should only need it if
you modified a `.texi' or `.texinfo' file, or any other file
...
This is because of "Bug 15345 - [2.23.2 regression] binutils-2.23.2 tarball doesn't build without makeinfo". The simplest workaround is to touch 'bfd/doc/bfd.info
' in the biuntils source directory.
Pre-built binaries do not seem to be available (help... anyone?). Prebuilt binaries for Windows-x86: hsdis-i386.dll
...
No Format | ||
---|---|---|
| ||
$ JDK7=my/copy/of/jre1.7.0
$ cp -p hsdis/.libs/hsdis.so $JDK7/lib/i386/client/hsdis-i386.so
$ cp -p hsdis/.libs/hsdis.so $JDK7/lib/i386/server/hsdis-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
|
...