Usage:
This flag allows you to specify a command to perform on a method.-XX:CompileCommand=command,method[,option] where is command is one of the following commands: break, compileonly, dontinline, exclude, help, inline, log, option, print, quietmethod is the name of the method which the command will be performed on it
Since:
Starting from JDK 6.
Examples:
This will specify a exclude “add” method of the class “List” from being compiler:
-XX:CompileCommand=exclude,java/util/List.add
Description:
Just In Time Compiler (JIT), generally translated as a real-time compiler, this is for interpreted languages, and is not necessary for virtual machines, it is an optimization method, The Java virtual machine standard does not make any specification for the existence of JIT, so this is a custom optimization technique implemented by the virtual machine.
JVM can execute Java code in two ways: [interpretation and execution] and [compile and execute]. If the execution method is compiled and executed, JIT will be used, but interpretation and execution will not be used. JIT, therefore, in the early days, there is no problem to say that Java is an interpreted language, but in the Java virtual machine environment with JIT, it is strictly incorrect to say that Java is an interpreted language.
The compiler in JVM is javac, and his job is to compile the source code into bytecode. This part of the work is completely independent and does not require runtime participation at all, so the compilation of Java programs is a semi-independent implementation. With the bytecode, there is an interpreter for interpretation and execution. This is the workflow of the early virtual machine. Later, the virtual machine will compile the method or statement block with high execution frequency into local machine code through JIT, which improves the execution time of the code.
This parameter is used to customize compilation requirements. For example, you can specify that a method is not to be JIT compiled, or you can only compile the specified method, and so on.
The command has the following options:
- Exclude: skip compiling the specified method
- compileonly: only compile the specified method
- inline/dontinline: set whether to inline the specified method
- print: print the generated assembly code
- break: when the JVM is running in debug mode, set a breakpoint at the beginning of the method compilation
- quiet: do not print compile options specified by -XX:CompileCommand after this command
- log: record the compilation log of the specified method, if not specified, record the compilation log of all methods
- option: This command can be used to pass JIT compilation options to the specified method
- help: Print the help message for the -XX:CompileCommand option.
Set the compiler to skip compiling in 4 different ways of writing the “contains” method of the java.util.List class:
- -XX:CompileCommand=exclude,java/util/List.contains
- -XX:CompileCommand=exclude,java/util/List::contains
- -XX:CompileCommand=exclude,java.util.List::contains
- -XX:CompileCommand="exclude java/util/List contains"
Set the compiler to only skip compiling the int equalsIgnoreCase(String) method of the java.lang.String class
-XX:CompileCommand="exclude,java/lang/String.equalsIgnoreCase,(Ljava/lang/String;)I"
Set the compiler to skip compiling the equals method of all classes
-XX:CompileCommand=exclude,*.equals
Default Value:
By default, this flag is disabled.
Arguments related:
CompileCommandFile, CompileOnly, CompileThreshold, CompileThresholdScaling
Related Posts:
Edit your Comment