Search code examples
compiler-constructionintermediate-languagevm-implementation

Is it misleading to say that intermediate code runs in a virtual machine


If I am correct in understanding what I've read a virtual machine is essentially a compiler for intermediate code. But it is never said that Delphi (as an example of unmanaged code) runs in its compiler. Would it be less confusing to just describe a virtual machine as a compiler?


Solution

  • There's a compiler that translates source code to VM code (bytecode), and a JIT compiler for VM code -> machine code. The VM is the standard that the source code -> VM compiler targets, not necessarily the specific implementation. It could be implemented with a real machine, in which case it wouldn't need to do JIT compilation.

    A VM is closer to an emulator (or if your JIT is really stupid, an interpreter :))