Home > Java > javaTutorial > How Can I Inspect JIT-Compiled Java Code?

How Can I Inspect JIT-Compiled Java Code?

Patricia Arquette
Release: 2024-12-10 17:40:10
Original
252 people have browsed it

How Can I Inspect JIT-Compiled Java Code?

Inspecting JIT-Compiled Code in the JVM

Accessing JIT Output

To view the native code generated by the JIT compiler in a Java Virtual Machine (JVM), employ the following JVM options:

-XX:+UnlockDiagnosticVMOptions
-XX:+PrintAssembly
Copy after login

Filtering on Specific Methods

Alternatively, you can filter on a particular method using the syntax:

-XX:+UnlockDiagnosticVMOptions
-XX:CompileCommand=print,*MyClass.myMethod
Copy after login

Windows Considerations

For Windows users, you must first install hsdis-amd64.dll and hsdis-i386.dll from the fcml project.

Step-by-Step Installation Guide for 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 (from the Utils category)
  2. Download and extract the GNU binutils source package to your Cygwin home directory (e.g., C:cygwinhome).
  3. Download and extract the OpenJDK hsdis directory to your Cygwin home directory.
  4. Navigate to the hsdis directory in the Cygwin Terminal (cd ~/hsdis).
  5. Compile hsdis-amd64.dll:

    • make OS=Linux MINGW=x86_64-w64-mingw32 'AR=$(MINGW)-ar' BINUTILS=~/binutils-2.25
  6. Compile hsdis-i386.dll:

    • make OS=Linux MINGW=i686-w64-mingw32 'AR=$(MINGW)-ar' BINUTILS=~/binutils-2.25
  7. Edit ~/hsdis/build/Linux-amd64/bfd/Makefile and change SUBDIRS = doc po to SUBDIRS = po.
  8. Re-run the compilation command.
  9. Copy the DLL to your JRE's bin directory:

    • Copy from hsdisbuildLinux-amd64 or hsdisbuildLinux-i586 to JREbinserver or JREbinclient.

The above is the detailed content of How Can I Inspect JIT-Compiled Java Code?. 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