Compilers

Which describes a runtime that uses JIT compilation?

  1. AThe entire program is translated to machine code before execution and then distributed
  2. BHot code is compiled during execution, using run-time information
  3. 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.
Practice this topic Back to topic

More Compilers questions

  1. Which describes the basic structure of LLVM?
  2. When is the no-optimization setting of a compiler (such as -O0) commonly used?
  3. Which describes profile-guided optimization (PGO)?
  4. Which optimization does link-time optimization (LTO) make possible?
  5. In C, signed integer overflow is undefined behavior. Under this rule, which code might an optimizing compiler generate for the function above?