简体   繁体   中英

jvm - About code cache area

Here is some question about cache area in JVM: ( for hotspot Java8 )

  • Does all machine code that jvm could run stored in this area, or only some hot code is stored here?
  • From some book, it says client compiler (C1) is more likely to run out of memory in cache area, while server compiler (C2) don't. I am a little confused about that. Is that because the server compiler only compile the hot part, and interrupt the other part? In that case, shouldn't the server compiler be slow?
  • How many times the code is run before C1 & C2 would compile & cache them respectively?

Note that the answer to this could vary from implementation to implementation :

Does all machine code that jvm could run stored in this area, or only some hot code is stored here?

Code cache will almost always be used to cache hot methods (or methods that were once considered hot by C1 + C2 ( tiered compilation )

From some book, it says client compiler (C1) is more likely to run out of memory in cache area, while server compiler (C2) don't. I am a little confused about that. Is that because the server compiler only compile the hot part, and interrupt the other part? In that case, shouldn't the server compiler be slow?

C1 compiler compiles everything. C2 waits until it finds some optimizations that could be applied and then applies those optimizations and compiles the methods (not always true, but mostly).

Note that C1 can compile the same method multiple times.

How many times the code is run before C1 & C2 would compile them respectively?

A method can be compiled even if it is called only once if C1 / C2 find out that it is taking a long time to run.

You can use JITWatch to see C1 and C2 in action.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM