• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

21. Java > JITs

JITs

Just-in-time compilers (JITs) compile stretches of bytecode (from a single instruction up to an entire method) into efficient native code as the bytecode is being executed. The next time the same stretch of bytecode is to be run, the compiled native code is run instead. For example, loops will run far faster under a JIT compiler because the bytecode does not have to be interpreted on every cycle of the loop. On the first cycle, there is a delay while native code for the loop is generated, and on the second and subsequent cycles, this native code is called and is presumably faster than interpreting the bytecode.

Just-in-time compilers usually help performance substantially, but be aware that they help the most for repetitive code, but are not useful for GUI code. In fact, it’s possible that your code will run more slowly with a JIT. One problem is that you really don’t want to JIT-compile code that will be used only once, but JITs are not very smart about what they compile (namely, everything). JavaSoft’s HotSpot compiler is different. HotSpot collects runtime execution data and uses that data to compile only the portions of the code that are repeatedly executed — that is, the “hot spots.” This gives some boost to GUI applications.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint