Home > Java > javaTutorial > How Can I View JIT-Compiled Code Generated by the JVM?

How Can I View JIT-Compiled Code Generated by the JVM?

Linda Hamilton
Release: 2024-12-15 17:33:22
Original
276 people have browsed it

How Can I View JIT-Compiled Code Generated by the JVM?

How to See JIT-Compiled Code in JVM

Despite just-in-time (JIT) compilation being a crucial aspect of optimizing Java Virtual Machine (JVM) performance, directly viewing its output code can be challenging. However, there are specific JVM options that allow for examining the native code generated by the JIT.

General Usage

The following JVM options can be added to command lines:

  • -XX: UnlockDiagnosticVMOptions
  • -XX: PrintAssembly

These options provide verbose output and include generated assembly instructions.

Filtering on a Specific Method

To limit the output to a particular method, use the syntax:

  • -XX: UnlockDiagnosticVMOptions -XX:CompileCommand=print,*MyClass.myMethod

Installing Required Libraries on Windows

For Windows systems, installing hsdis-amd64.dll and hsdis-i386.dll is necessary to access the PrintAssembly functionality. Prebuilt binaries are available from the fcml project, or they can be built manually using Cygwin and binutils.

Building hsdis-amd64.dll and hsdis-i386.dll on Windows

  1. Install Cygwin and select the following packages:

    • make
    • mingw64-x86_64-gcc-core (for hsdis-amd64.dll)
    • mingw64-i686-gcc-core (for hsdis-i386.dll)
    • diffutils
    1. Run the Cygwin Terminal and create a Cygwin home directory.
    2. Download and extract the GNU binutils and hsdis source packages to the Cygwin home directory.
    3. In the Cygwin Terminal, navigate to the hsdis directory and build hsdis-amd64.dll or hsdis-i386.dll using the appropriate commands.
  2. Modify the buildLinux-amd64bfdMakefile to change SUBDIRS = doc po to SUBDIRS = po.
  3. Re-run the build command.
  4. Copy the built DLLs to the JRE's bin directories.

Bonus Tip

To display assembly instructions using Intel rather than AT&T syntax, add -XX:PrintAssemblyOptions=intel to the JVM options.

The above is the detailed content of How Can I View JIT-Compiled Code Generated by the JVM?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template