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