Reputation: 9
As i know JIT compiles the bytecode into native machine code which can be run faster.So according to my belief the answer of my question should be 1.Translate into machine code 2.Interpret the bytecode. As Interpreting the code means executing the code. But i found the answer opposite! Could anyone please explain... Thanks in Advance
Upvotes: 0
Views: 229
Reputation:
Once you have machine code for a bytecode sequence (which, as you note, should be faster than interpretation), it makes no sense to keep interpreting that bytecode sequence (*). It's more useful to interpret while compilation is running in the background, or not yet kicked off (for whatever reason -- a common case is: The code hasn't been executed frequently enough to be considered worth compiling).
(*) Actually, some JIT compilers do specialize the machine code so much that it's invalid for some code paths or inputs, and have to fall back to interpretation/re-compiling when those happen. And even other JIT compilers sometimes compile code anew, which may or may not lead to temporarily going back to interpretation. But by and large, if the code applies and is faster (it always should be), there's no point in not using it.
Upvotes: 2