4 ms·
Maybe my knowledge isn't up to date, but I always understood (since Hotspot anyway) that not all bytecode is necessarily JIT'd to native code. From the Hotspot
by nineteen999 6y ago
Maybe my knowledge isn't up to date, but I always understood (since Hotspot anyway) that not all bytecode is necessarily JIT'd to native code.
From the Hotspot Wikipedia page:
"Both VMs compile only often-run methods, using a configurable invocation-count threshold to decide which methods to compile."[1]
Also see very old discussions at StackOverflow[2][3].
Then of course there are compilers (eg. gcj) which compile to native up-front.
[1] https://en.wikipedia.org/wiki/HotSpot#Features https://en.wikipedia.org/wiki/HotSpot#Features
[2] https://stackoverflow.com/questions/7100365/why-doesnt-javas-jit-compiler-translate-everything-to-native-code https://stackoverflow.com/questions/7100365/why-doesnt-javas...
[3] https://stackoverflow.com/questions/16568253/difference-between-jvm-and-hotspot https://stackoverflow.com/questions/16568253/difference-betw...
- chrisseaton 6y ago> I always understood (since Hotspot anyway) that not all bytecode is necessarily JIT'd to native code Who are you disagreeing with? I didn’t say that’s the only way they execute bytecode, did I? The question was how it’s executed ‘after they warm up’. > Then of course there are compilers (eg. gcj) which compile to native up-front. But I was replying to someone who asked specifically about how ‘production JVMs’ do it, not how discontinued compilers do it.
- nineteen999 6y ago> Who are you disagreeing with? I didn’t say that’s the only way they execute bytecode, did I? Nope, my bad. Thanks for clarifying.
- bitcharmer 6y agoOnly hot code paths get compiled. That's after 10000 executions on "server" JVM and 1000 executions on a "client" JVM by default. This is by design, and if you need everything compiled right away you can set the compilation threshold to 1. I don't see any value in compiling parts of code that only gets executed during bootstrap.
- nineteen999 6y ago> I don't see any value in compiling parts of code that only gets executed during bootstrap. Not disagreeing with you there, since stopping to compile code/optimize at runtime contributes to sluggish interactive performance.
- bitcharmer 6y agoCompilation is performed concurrently to the application in specialised compilation threads. Only OSR (on-stack-replacement) requires stopping execution.
- chrisseaton 6y ago> Not disagreeing with you there, since stopping to compile code/optimize at runtime contributes to sluggish interactive performance. No JVM I am aware of stops to compile - the compiler runs on a background thread while the application continues to run as normal.
- MaxBarraclough 6y agoNitpick: the HotSpot 'client' JVM's default JIT threshold is 1500, not 1000. https://www.oracle.com/java/technologies/javase/vmoptions-jsp.html https://www.oracle.com/java/technologies/javase/vmoptions-js...
- bitcharmer 6y agoYou're right, thank you for correcting me. For more popular archs (x86, arm, aarch64) it's 1500. It's only 1000 by default for ppc, s390 and sparc. https://chriswhocodes.com/hotspot_options_jdk14.html https://chriswhocodes.com/hotspot_options_jdk14.html
- MaxBarraclough 6y agoSo we're both right! Didn't know it varied between architectures.