aspose file tools*
The moose likes Java in General and the fly likes JIT compiler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "JIT compiler" Watch "JIT compiler" New topic
Author

JIT compiler

satish varma
Greenhorn

Joined: Feb 11, 2010
Posts: 27
how JIT compiler work in JVM?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39869
    
  28
Welcome to the Ranch

If you Google you will find lots of links.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's a pretty broad question--have you read any of the white papers that talk about it?

Nutshell version: by profiling the actual execution of bytecode the JIT can optimize for actual execution paths and generate corresponding native machine code.
satish varma
Greenhorn

Joined: Feb 11, 2010
Posts: 27
okay thank u..
i read in some book- in JVM architecture execution engine contains Interpreter and JIT compiler. why both interpreter and JIT compiler to convert Byte code into Mechine code? what are the tasks of interpreter and JIT ?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14350
    
  22

The interpreter basically does this:

1. Read the next bytecode to be executed
2. Look at what the bytecode is and find the native machine instruction(s) that correspond to it
3. Execute the native machine instruction(s)
4. Go to step 1

That is simple, it works well, and it will run your Java program. But it's also inefficient, because looking up the native instruction(s) for every single bytecode to be executed costs processing time. So the JVM contains a second mechanism, the Just-In-Time compiler, which basically does this:

1. Read all the bytecodes for the method that needs to be executed
2. Convert all those bytecodes to native machine instructions
3. Execute the generated native machine instructions

After it has converted the bytecodes for a method to native machine instructions, the JVM remembers that native code, so that the next time the method has to be run, it can simply run the native instructions - it doesn't need to convert the bytecodes every time the method is run. This makes the program run much faster.

Also, the JIT performs lots of optimizations to generate native code that runs as fast as possible.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JIT compiler