当前位置:网站首页>Interpretation and compilation of JVM
Interpretation and compilation of JVM
2022-04-23 18:14:00 【The hunter is eating meat】
1、 principle
Bytecode cannot be directly handed over to hardware for execution. Virtual machine is required translate become Machine code To perform ,“ translate ” There are two strategies : Explain to perform
and Compile implementation
, also called Just in time compilation (JIT).
-
Explain to perform
,- Run bytecode in interpreted mode ,
- Explanation execution means Read a sentence , Execute a sentence .
Advantage is Fast start-up efficiency ,
The disadvantage is that The overall execution speed is slow . -
Compile implementation
,- Compile bytecode into machine code
- Execute machine code directly
- Compile at run time
- After compiling , There's an order of magnitude improvement in performance .
Its characteristics are opposite to interpretation and execution , Slow start , Fast execution .
stay jvm In the virtual machine, the two are mixed , There are both interpretation execution and compilation execution . First of all Explain to perform , Execute all bytecodes one by one , If JVM If a method is found to be called frequently, it will be compiled with the strategy of compilation and execution , Call the machine code directly the next time , This method is called Hot methods , thus it can be seen , Compile implementation Is in terms of method .
From a business perspective , The server and the client have different requirements for the execution speed and startup speed of the code .
such as , Mobile applications , Users want the program to start faster .
The server program , There may be higher requirements for the execution speed of the program .
So , from java7 Start , HotSpot Layered compilation is adopted , That is, two compilers are introduced :C1、C2.
C1 compiler , be called client compiler , For clients that require startup performance , Compilation period , The optimization strategy is simple ;
C2, be called Serve compiler , Server side with peak performance requirements , Long compilation time , The optimization strategy is complex .
Specifically, when compiling hotspot methods , First use C1 compiler , The hotspot method in the hotspot will be C2 The compiler compiles again .
2、JVM Related parameters
-Xint : Explain the pattern , Do not activate JIT compiler ( namely CompileThreshold=0).
-Xcomp : Compile mode , Appoint JVM Compile all bytecodes into local code when used for the first time .( namely CompileThreshold=1).
explain :comp:Compile
-Xmixed : Mixed mode execution ,-Xint
、-Xcomp
Two mixed use , That is, the interpretation mode and Compile mode A mixture of .
-Xbatch : Compile methods in the foreground , The method cannot execute until the compilation is complete .
-XX:CICompilerCount=n : Appoint JIT The number of threads the compiler uses to compile methods .
-XX:CompileThreshold=n : Specifies the number of calls to a method , In order to make HotSpot and JIT The compiler can compile it .
3、JVM Three models of
int Pattern : use -Xint
Turn on , namely Explain the pattern , In this mode, all take the interpretation mode to run .
comp Pattern : use -Xcomp
Turn on , In this mode, notify JVM close Explain the pattern , use Compile mode function . But it often leads to poor automatic optimization .
mixed Pattern : use -Xmixed
Turn on , Namely, mixed operation mode , It's also Hotspot Default mode .
版权声明
本文为[The hunter is eating meat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210611118516.html
边栏推荐
- 解决允许在postman中写入注释请求接口方法
- NVIDIA Jetson: GStreamer and openmax (GST OMX) plug-ins
- Gst-launch-1.0 usage notes
- Solution to Chinese garbled code after reg file is imported into the registry
- Stanford machine learning course summary
- Pointers in rust: box, RC, cell, refcell
- Rust: shared variable in thread pool
- Software test summary
- How to install jsonpath package
- Resolves the interface method that allows annotation requests to be written in postman
猜你喜欢
Visualization of residential house prices
Dock installation redis
【ACM】376. 摆动序列
C language loop structure program
Differences between SSD hard disk SATA interface and m.2 interface (detailed summary)
【ACM】70. climb stairs
STM32学习记录0008——GPIO那些事1
解决报错max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
Re expression régulière
Qt读写XML文件(含源码+注释)
随机推荐
How to ensure the security of futures accounts online?
From introduction to mastery of MATLAB (2)
Docker 安装 Redis
硬核解析Promise对象(这七个必会的常用API和七个关键问题你都了解吗?)
Re expression régulière
[UDS unified diagnostic service] IV. typical diagnostic service (6) - input / output control unit (0x2F)
Rust: how to match a string?
RC smart pointer in rust
Installation du docker redis
MATLAB小技巧(6)七种滤波方法比较
powerdesigner各种字体设置;preview字体设置;sql字体设置
Feign requests the log to be printed uniformly
Selenium + phantom JS crack sliding verification 2
WIN1 remote "this may be due to credssp encryption Oracle correction" solution
The vivado project corresponding to the board is generated by TCL script
C language to achieve 2048 small game direction merging logic
Using files to save data (C language)
【ACM】455. 分发饼干(1. 大饼干优先喂给大胃口;2. 遍历两个数组可以只用一个for循环(用下标索引--来遍历另一个数组))
【ACM】455. Distribute Biscuits (1. Give priority to big biscuits to big appetite; 2. Traverse two arrays with only one for loop (use subscript index -- to traverse another array))
Queue solving Joseph problem