wood burning stoves 2.0*
The moose likes Java in General and the fly likes waht role of JIT in JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "waht role of JIT in JVM" Watch "waht role of JIT in JVM" New topic
Author

waht role of JIT in JVM

amit bhadre
Ranch Hand

Joined: Jan 23, 2006
Posts: 124
What is JIT and what is its work in JVM?


Thanks advance who ever answers this question.


regards
amit bhadre
Vinny Menon
Ranch Hand

Joined: Jan 10, 2006
Posts: 62

Hi Amit
In the Java programming language and environment, a just-in-time (JIT) compiler is a program that turns Java bytecode (a program that contains instructions that must be interpreted) into instructions that can be sent directly to the processor. After you've written a Java program, the source language statements are compiled by the Java compiler into bytecode rather than into code that contains instructions that match a particular hardware platform's processor (for example, an Intel Pentium microprocessor). The bytecode is platform-independent code that can be sent to any platform and run on that platform.
One of the biggest advantages of Java is that you only have to write and compile a program once. The Java on any platform will interpret the compiled bytecode into instructions understandable by the particular processor. However, the virtual machine handles one bytecode instruction at a time. Using the Java just-in-time compiler (really a second compiler) at the particular system platform compiles the bytecode into the particular system code (as though the program had been compiled initially on that platform). Once the code has been (re-)compiled by the JIT compiler, it will usually run more quickly in the computer.

The just-in-time compiler comes with the virtual machine and is used optionally. It compiles the bytecode into platform-specific executable code that is immediately executed. Sun Microsystems suggests that it's usually faster to select the JIT compiler option, especially if the method executable is repeatedly reused.

hth,
cheers
vinny m


Regards,Vinny M.
proud Fan of European Champion CHELSEA FC
"If you don't see the bug where you're looking, perhaps you're looking in the wrong place" -James Gosling
amit bhadre
Ranch Hand

Joined: Jan 23, 2006
Posts: 124
Ok I agree but whats role of interpretor then? its also checks line by line... but whats its role for JIT? i will show the diagram here...



*.class
|
Security Manager
|
|
classLoader
|
|
ByteVerifyer
| |
| |
JIT Interpretor
| |
-----|-------
|
Security Manager
|
OS
Zip Ped
Ranch Hand

Joined: Jul 26, 2005
Posts: 336
Hi Amit,

The following information might help:

How to use the JIT to your advantage

The first thing to remember is that the JIT compiler achieves most of its speed improvements the second time it calls a method. The JIT compiler does compile the whole method instead of interpreting it line by line which can also be a performance gain for when running an application with the JIT enabled. This means that if code is only called once you will not see a significant performance gain. The JIT compiler also ignores class constructors so if possible keep constructor code to a minimum.

The JIT compiler also achieves a minor performance gain by not pre-checking certain Java boundary conditions such as Null pointer or array out of bounds exceptions. The only way the JIT compiler knows it has a null pointer exception is by a signal raised by the operating system. Because the signal comes from the operating system and not the Java VM, your program takes a performance hit. To ensure the best performance when running an application with the JIT, make sure your code is very clean with no errors like Null pointer or array out of bounds exceptions.

The interpreter is more space efficient as it performs optimization and in some cases the JIT compiler might be slower than the interpreter.

more info here : google JIT compiler Vs Interpreter and look into the search results under Google groups.
amit bhadre
Ranch Hand

Joined: Jan 23, 2006
Posts: 124
THNX
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: waht role of JIT in JVM