I understands that most of the recent browsers use JIT compilation to execute javascript. What I do not understand is: which part of javascript is JIT'ed - the script, or the bytecode?

Let me explain. From what I understand, V8 takes your JS and compiles it into machine language (not bytecode) with output being placed in the RAM instead of being written into a separate file on the drive. Optimizations follow as per future requirements.

About the Chakra engine: this link says that the source code is converted into bytecode and then passed to a bytecode execution unit where it is executed via an interpreter or a JIT compiler. What it does not tell is: How does the javascript get converted into bytecode in the first place? Is it JIT compiled itself - (effectively giving us two jitters working end to end) - or is it compiled more traditionally? Where is the output placed? RAM or some temporary place at the drive?

And how does SpiderMonkey work? Seems it's quite like Chakra/ChakraCore.

While we are at it, would you kindly explain HHVM and php 7 in the same context? Is the bytecode JITed or is the source code JITed? Or is it both?

  • Have you read about JIT at Wikipedia? "JIT" just means dynamic compilation; it is a very broad and unspecific term, so don't try to nail it down. Ok, the standard interchange format for Javascript is text files; there is no standard bytecode format. We know that javascript is shared as text and thus has to be parsed to be executed, right? So, is that parsing part of JIT'ing? The answer is that it doesn't really matter; parsing must be done regardless.
    – Erik Eidt
    Commented Aug 31, 2016 at 21:21
  • 2
    Making sense of interpreters which are capable of Just In Time compiling can get difficult if you are not familiar with how interpreted languages are handled traditionally. It may help for us to understand why these distinctions you are interested in matter to you. While there are certainly answers to these questions, it may be that the best answer is to explain why they may not be important for use of the Javascript language and its interpreters.
    – Cort Ammon
    Commented Sep 1, 2016 at 3:37
  • @Cort Ammon No, I get the interpreters capable of JIT compiling. As of today, I also have a better understanding of what I asked in my question. All I mainly wanna know now is: Does the compiler making bytecode after parsing put it in the RAM directly or in some temporary location of the main memory? Should I edit my question for this or let it be to help the future visitors?
    – Kraken
    Commented Sep 1, 2016 at 14:44
  • 1
    I do think it would help to edit the question to foucs it more. You've got 4-5 questions right now, so you may be able to get a better answer if you narrowed it down. However, the answer may not be simple. I don't know my Javascript interpreter implementations, but I do know Python. In python, the compiled code is both stored in RAM and on a temporary place in the HD. Python compiles it into RAM and uses it all in RAM, but it also writes it out to disk so that, if python gets run again, it can skip the compiling step and just load the pre-compiled file.
    – Cort Ammon
    Commented Sep 1, 2016 at 17:40

1 Answer 1


A JavaScript file (or <script>-element) has to be parsed and compiled into bytecode as a whole before execution. This is because an expression can refer to declarations occurring later in the file, so the whole file has to be parsed before execution can begin. JIT is not really possible at the parsing stage.

  • Ah, thanks. So where does the bytecode reside? Main memory right?
    – Kraken
    Commented Aug 31, 2016 at 21:41
  • I am right about the V8 though, right? No bytecode, just plain native.
    – Kraken
    Commented Aug 31, 2016 at 21:43
  • @Kraken: See jayconrod.com/posts/51/a-tour-of-v8-full-compiler for some details about V8. It states there is no bytecode stage.
    – JacquesB
    Commented Sep 1, 2016 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.