File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes What does JIT compiler do ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "What does JIT compiler do ?" Watch "What does JIT compiler do ?" New topic
Author

What does JIT compiler do ?

tanu dua
Ranch Hand

Joined: Apr 05, 2004
Posts: 145
I have learnt that JustInTime Compiler compiles the code "on the fly".So does that mean that u can make the exe of the java code and hence does not need Java Virtual Machine( JVM ).

Thanx
Bhushan Damle
Greenhorn

Joined: Nov 28, 2004
Posts: 21
The JIT compiler compiles code "on the fly". I don't know What r u getting from the phrase "on the fly". The JIT compiler never facilitate u to make the exe of java code rather it itself generates a byte code that is always interpreted by a JVM only.
So, according to me "on the fly" does not mean that u can make the exe of the java code and hence does not need Java Virtual Machine( JVM ), but it means that the code is generated for use on any machine as it is a byte code.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

sry u r wrng .. cough, cough Excuse me, I had something stuck in my throat. As I was saying, sorry, but that's wrong. A JIT compiler compiles (some) Java bytecodes into hardware-specific native code at runtime. The resulting native code snippets still need the context of the JVM in which to run, but the process eliminates the overhead of interpreting the bytecodes.

Sun's JVMs use a sort of "smart" JIT called HotSpot that works hard to translate only performance-critical sections of your code into native code, and optimize those bits heavily using runtime profiling data as a guide. The traditional sort of JIT that translates all the bytecode has fallen out of favor, largely because JVMs are so fast now that the overhead of JIT compilation outweighs the overhead of bytecode interpretation.

In contrast to a JIT ("just-in-time") compiler, there also exist AOT ("ahead-of-time") compilers, which translate an entire program into native code and turn it into a self-contained EXE file. None of these compilers produce results which are significantly better than what HotSpot does.

Well-written Java code is generally within a factor of two in performance of equivalent C++ code. Note that I say "within a factor of two" and not "half as fast"; sometimes, it's the C++ code that's slower (particularly with certain C++ compilers.)


[Jess in Action][AskingGoodQuestions]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I think Bhushan was trying to explain that a JIT compiler does not create an executable file, as you described, Ernest. However, as you said, it doesn't create byte code either, it takes the byte code that was previously compiled (with javac, for instance), and compiles it to native machine code. (Basically that's repeating what Ernest said. I just like to summarize some times.)

Keep coding!

Layne
[ November 30, 2004: Message edited by: Layne Lund ]

Java API Documentation
The Java Tutorial
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Originally posted by Layne Lund:
I just like to sumarize some times.


And sometimes (often?) I need summarizing. Thanks.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Ernest Friedman-Hill:


And sometimes (often?) I need summarizing. Thanks.


Heh. Well, I'm also trying to get my post count up to 1000. Almost there!
tanu dua
Ranch Hand

Joined: Apr 05, 2004
Posts: 145
Thanx for the explanation !! But,please tell me this also there are other compilers too like IBM Symantec. Does it performs the same thing.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What does JIT compiler do ?
 
Similar Threads
Unreachable code
compiling using ant from within Vim
Why Byte boxing doesn't work here
How to deprecate?
char literals