Use printassembly to print the assembly in the Java runtime __JVM

Source: Internet
Author: User

Printassembly is a diagnostic flag for the hotspot JVM that allows us to obtain the JIT compiler/or assembly instructions generated during the interpretation process, which can often be used to help us find problems by analyzing the execution of assembly instructions, or to help us analyze and understand the JVM How it is interpreted and compiled.
How to install these are not directly provided by the JVM, the way in which plug-ins are needed in the JVM, and the Kenai Project provides this plug-in
Download: https://kenai.com/projects/base-hsdis/downloads
Find the corresponding instruction set, the operating system corresponding to the so file download, does not seem to support windows

Installation directory: Your libjvm.so the same directory
$JAVA _PATH/JRE/LIB/CPU Instruction Set/server/
For example:
$JAVA _path/jre/lib/amd64/server/
File name naming rules
1. Different instruction sets use the hsdis-instruction set
Hsdis-amd64, Hsdis-sparc, hsdis-sparcv9
2. So file renamed as Lib prefix file name, which seems to be the JVM bug (http://mail.openjdk.java.net/pipermail/hotspot-dev/2011-July/004284.html)
such as libhdis-amd64.so


Common usage Parameters

+printassembly Print assembly code for bytecoded and native methods +printnmethods
print Nmethods as they are generate D
+printnativenmethods Print native method wrappers as they are generated +printsignaturehandlers
print native Me Thod signature Handlers
+printadapterhandlers print adapters (I2C, c2i) as they are generated +printstubcode prin
T stubs:deopt, uncommon Trap, exception, SafePoint, runtime support +printinterpreter
print interpreter code

Using these parameters requires opening the parameters first
-xx:+unlockdiagnosticvmoptions


Common usage

-xx:+unlockdiagnosticvmoptions-xx:+printassembly


printassembly Print JIT-compiled assembly
Compilation of Printinterpreter print interpretations


How to filter output

-xx:compilecommand=print,*myclass.mymethod prints assembly for just one method
-xx:compilecommand=option,* myclass.mymethod,printoptoassembly (Debug build only) produces the old Print command output
-xx:compilecommand= Option,*myclass.mymethod,printnmethods produces method dumps

You can set the filter and output the assembly of the method you want.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.