You have heard many times the mantra “code in because the JVM that makes it free.”
Think again, Buster!
Dynamic dead code elimination is not performed by the client VM! Consider this bit of code, like I was the other day:
if (Sys.DEBUG) {
checkGLError();
}
Sys.DEBUG is a static final boolean but it’s not known what value it will take until classloading; therefore the java compiler can’t simply remove the code during the build.
A few experiments with commenting out the code:
//if (Sys.DEBUG) {
//checkGLError();
//}
and timing it using our hires timer show us that the Hotspot Server VM eliminates it immediately and completely - the commented out code runs at exactly the same speed as the uncommented out code when Sys.DEBUG is false.
The lamentable client VM, on the other hand, retains the check, and executes slower, even though it will always be false. Bah.
Where’s my two-stage-compile converged JVM eh??? The client VM is definitely a performance hobbler when you start to do clever stuff that’s not actually rendering - like shadow volume calculations and such…
Cas