When does JIT compilation occur and at what level?

  • Thread starter Thread starter Chromium
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around Just-In-Time (JIT) compilation, specifically addressing when it occurs and at what level within the compilation process. Participants explore various aspects of JIT compilation, including its efficiency, the levels at which it operates, and the implications of compiling code on-the-fly versus pre-compiling it.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant questions whether JIT compilation is limited to translating intermediate forms of programs into native code or if it can occur in other ways, such as compiling and executing code line by line.
  • Another participant argues that compiling one line at a time would be inefficient, suggesting that entire modules or classes are typically JIT-compiled before use.
  • It is noted that already-compiled classes and modules remain in memory to avoid recompilation, which contributes to the performance improvement of programs as they "warm up."
  • One participant explains that JIT compilation usually occurs at the subroutine level or higher, and that it involves compiling an intermediate form, such as syntax trees, into machine code, with no source code present at that stage.

Areas of Agreement / Disagreement

Participants express differing views on the efficiency of JIT compilation methods, particularly regarding the line-by-line compilation approach. While some agree on the inefficiency of this method, there is no consensus on the broader implications or definitions of JIT compilation.

Contextual Notes

Participants discuss various levels of JIT compilation and its relationship to intermediate forms, but there are unresolved assumptions regarding the definitions and efficiency of different compilation strategies.

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.
 

Similar threads

Replies
6
Views
3K
  • · Replies 29 ·
Replies
29
Views
4K
Replies
59
Views
9K
Replies
6
Views
2K
Replies
65
Views
5K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 39 ·
2
Replies
39
Views
5K