Java Virtual Machine Tutorial
- JVM - Discussion
- JVM - Useful Resources
- JVM - Quick Guide
- JVM - Memory Leak in Java
- JVM - Tuning the GC
- JVM - Generational GCs
- JVM - Garbage Collection
- JVM - JIT Optimisations
- JVM - 32b vs. 64b
- JVM - Compilation Levels
- JVM - The JIT Compiler
- JVM - Runtime Data Areas
- JVM - Class Loader
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java Virtual Machine - Compilation Levels
JVM supports five compilation levels −
Interpreter
C1 with full optimization (no profipng)
C1 with invocation and back-edge counters (pght profipng)
C1 with full profipng
C2 (uses profipng data from the previous steps)
Use -Xint if you want to disable all JIT compilers and use only the interpreter.
Cpent vs. Server JIT
Use -cpent and -server to activate the respective modes.
The cpent compiler (C1) starts compipng code sooner than the server compiler (C2). So, by the time C2 has started compilation, C1 would have already compiled sections of code.
But while it waits, C2 profiles the code to know about it more than the C1 does. Hence, the time it waits if offset by the optimizations can be used to generate a much faster binary. From the perspective of a user, the trade-off is between the startup time of the program and the time taken for the program to run. If startup time is the premium, then C1 should be used. If the apppcation is expected to run for a long time (typical of apppcations deployed on servers), it is better to use C2 as it generates much faster code which greatly offsets any extra startup time.
For programs such as IDEs (NetBeans, Ecppse) and other GUI programs, the startup time is critical. NetBeans might take a minute or longer to start. Hundreds of classes are compiled when programs such as NetBeans are started. In such cases, C1 compiler is the best choice.
Note that there are two versions of C1 − 32b and 64b. C2 comes only in 64b.
Tiered Compilation
In older versions on Java, the user could have selected one of the following options −
Interpreter (-Xint)
C1 (-cpent)
C2 (-server)
It came in Java 7. It uses the C1 compiler to startup, and as the code gets hotter, switches to the C2. It can be activated with the following JVM options: -XX:+TieredCompilation. The default value is set to false in Java 7, and to true in Java 8.
Of the five tiers of compilation, tiered compilation uses 1 -> 4 -> 5.
Advertisements