How do I control JIT behavior in the JVM?

Source: Internet
Author: User

First, let me explain my own test environment:

Ubuntu 12.04 x86-64,openjdk 7 64-bit Server VM (mixed mode)

MacOS 10.11,hotspot 7 64-bit Server VM (mixed mode)

1. How do I turn off JIT?

In general, JIT is turned on by default, so there is only one problem with how to turn it off.

When starting the JVM, simply increase the-xint or-Djava.compiler=NONE选项即可:

Java-xint Your_main_class_file_name

Java-Djava. Compiler Your_main_class_file_name

If you are booting from eclipse, you need to specify the above parameters in run configurations.

2. How do I view the JIT-generated assembly code?

Sometimes, we need to look at the JIT-generated assembly code to see how the JIT affects the execution of the code.

To complete this task, you need to install a support library, Hsdis, steps below.

Linux systems:

Download linux-hsdis-amd64.so or linux-hsdis-i386.so

Rename to hsdis-amd64.so or hsdis-i386.so

Copy to $java_home/jre/lib/amd64/directory

It's/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/on my machine.

OS x System:

Download Gnu-bsd-libhsdis-amd64.dylib or Gnu-bsd-libhsdis-i386.dylib

Rename to Hsdis-amd64.dylib or Hsdis-i386.dylib

Copy to $java_home/jre/lib/directory

It's/library/java/javavirtualmachines/jdk1.7.0_79.jdk/contents/home/jre/lib/hsdis-amd64.dylib on my machine.

After installing the support library, you only need to add the following two options when starting the JVM:

java-xx:+unlockdiagnosticvmoptions-xx:+printassembly Your_main_class_file_name

Here is a link to the detailed description, you can refer to:

https://wiki.openjdk.java.net/display/HotSpot/PrintAssembly

In addition, if you do not install a support library, you will get the following error when you specify the options above and start the JVM:

Java HotSpot (TM) 64-bit Server VM warning:printassembly is enabled; Turning on debugnonsafepoints to gain additional output

Could not load hsdis-amd64.dylib; Library not loadable; Printassembly is disabled

How do I control JIT behavior in the JVM?

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.