Search code examples
optimizationcompiler-constructiontheoryinterpreterjit

Theory: Can JIT Compiler be used to parse the whole program first, then execute later?


Normally, JIT Compiler works by reads the byte code, translate it into machine code, and execute it. This is what I understand, but in theory, is it possible to make the JIT Compiler parses the whole program first, then execute the program later as machine code? I do not know how JIT Compiler works technically and exactly, so I don't know any feasibility in this case. But theoretically, is it possible? Or am I doing it wrong?


Solution

  • No, this is not possible, for the simple reason that "JIT" means "Just-In-Time" and if you don't do it "Just-In-Time", then it's not a "Just-In-Time" compiler.

    That's like asking whether it would be possible to buy a red car, but in blue.

    What you are asking for, is an Ahead-Of-Time compiler, which is usually just called a compiler.