How to Control JIT behavior in JVM ?, Control jvmjit Behavior

Source: Internet
Author: User

How to Control JIT behavior in JVM ?, Control jvmjit Behavior

First, let me explain my testing 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 to disable JIT?

In general, JIT is enabled by default, so there is only a problem of how to disable it.

When starting JVM, you only need to add-Xint or-Djava. compiler = NONE:

Java-XintYour_main_class_file_name

Java-Djava. compilerYour_main_class_file_name

If it is started from Eclipse, You need to specify the above parameters in Run Configurations.

 

2. How to view the compiled code generated by JIT?

Sometimes, we need to check the compiled code generated by JIT to see how JIT affects code execution.

To complete this task, you need to install a support library, hsdis, as follows.

Linux:

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

My machine is/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/

 

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 the $ JAVA_HOME/jre/lib/directory

My machine is/Library/Java/JavaVirtualMachines/jdk1.7.0 _ 79.jdk/ Contents/Home/jre/lib/hsdis-amd64.dylib

 

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

Java-XX: + UnlockDiagnosticVMOptions-XX: + PrintAssemblyYour_main_class_file_name

The following link provides a detailed description. For more information, see:

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

 

In addition, if the supported libraries are not installed, the following error occurs when you specify the above options and start JVM:

Java HotSpot (TM) 64-Bit Server VM warning: PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output

Cowould not load hsdis-amd64.dylib; library not loadable; PrintAssembly is disabled

 

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.