Compilers
Which describes a runtime that uses JIT compilation?
- AThe entire program is translated to machine code before execution and then distributed
- BHot code is compiled during execution, using run-time information
- CBytecode is interpreted one instruction at a time forever, never using machine code
Show answer and explanation
Answer: B. Hot code is compiled during execution, using run-time information
With JIT compilation, bytecode is first interpreted, and when frequently executed parts (hot spots) are found, they are compiled to machine code while the program runs. Run-time information, such as which branches are taken and which types are passed, enables aggressive optimizations hard to achieve ahead of time, with a fallback to interpretation if assumptions fail. Translating everything beforehand is ahead-of-time (AOT) compilation, and only interpreting is a pure interpreter.
- A. Translating everything beforehand is ahead-of-time compilation.
- B. Correct. It compiles at run time and can use run-time information.
- C. Only interpreting is a pure interpreter.