logoalt Hacker News

CalChristoday at 2:39 PM2 repliesview on HN

Why is this known bits optimization being done by the JIT rather than the Java compiler?


Replies

cogman10today at 2:49 PM

Because you might want to put a breakpoint on that line of code and debug the variables going in and coming out.

But further, optimizing in the compiler can preclude future optimizations by the JIT. Giving the JIT more information can make it make better decisions.

Also, the JIT needs to do that optimization anyways. If a class was compiled with Java 1.0, it might miss some optimizations introduced in the Java 27 compiler. To cover for that, the JVM 27 will need in it's jit the optimizations which were missing from the 1.0 javac if it wants to keep making the code go faster.

That's why the JVM developers have ultimately pushed to make javac pretty dumb and the JIT pretty smart. They can make much better optimizations in the JIT which are retroactive.

show 1 reply
re-thctoday at 5:37 PM

The Java compiler almost does ZERO optimizations.

So you really want to you should ask why the JIT rather than compiler does optimizations in Java?