When does JIT compilation occur and at what level?

  • Thread starter Thread starter Chromium
  • Start date Start date
AI Thread Summary
Just-in-time (JIT) compilation primarily occurs when translating an intermediate representation of a program into native code, rather than compiling line-by-line as suggested. Compiling each line individually would be inefficient due to the constant overhead of compilation and execution. Instead, JIT compilation typically processes entire modules or classes, allowing for better performance as these components remain loaded in memory for subsequent executions. This approach enables programs to "warm up," achieving speeds comparable to fully pre-compiled native executables. JIT compilation often operates at the subroutine level or higher, utilizing intermediate forms like syntax trees that encompass entire subroutines, facilitating efficient compilation and execution. In languages like .NET or Java, JIT involves converting intermediate language (IL) or bytecode into machine code, eliminating the original source code during this process.
Chromium
Messages
56
Reaction score
0
Does "JIT" only occur when translating some intermediate form of the program into native code? Or can it also occur in other ways? For example, say you have a compiler that kind of acts like an interpreter in that for each line it compiles that source code into native code and immediately after compiling that line it executes it.

So for each line, you go through these steps:
1) Compile
2) Execute

To me it seems that something like this would be slow because constantly compiling & executing seems like a pretty inefficient way of computing. But, it was the only example I could think of.

Thanks,

--Jonathan
 
Technology news on Phys.org
Chromium,

It would be very inefficient to "compile" one line of code at a time. Instead, entire modules or classes are just-in-time compiled before being used.

- Warren
 
Also, already-compiled classes and modules are kept loaded (in executable form) in memory (as long as enough memory is available) so that if they are called again, no compilation is needed. This causes programs to "warm up"--once most parts of a program have been JIT-compiled, it runs about as fast as a native executable that is entirely pre-compiled.
 
JITing usually occurs at the subroutine level or higher. Compilation (or interpretation) produces an intermediate form (a tree usually) that represents the source statements. It is common for these syntax trees to span entire subroutines, that way they can refer to each other. For example an 'if' statement will refer to the 'else' part. Therefore when compiling the whole tree is done at once. JITing (in the .NET or Java sense) refers to taking an intermediate form (IL or byte codes) and compiling them into machine code. At this level there is no source code as it has already been compiled away.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top