4 ms·
https://developers.google.com/v8/design https://developers.google.com/v8/design C-f for "Dynamic Machine Code Generation" V8 compiles it to native machine cod
by Jtsummers 10y ago
https://developers.google.com/v8/design https://developers.google.com/v8/design
C-f for "Dynamic Machine Code Generation"
V8 compiles it to native machine code for execution. It's not an interpreter or a VM with its own bytecode.
- marcosdumay 10y agoCool. There is no VM, just a runtime not much different from the ones from other compiled languages. It compiles your code piece by piece, and optimizes during that compilation. This is a very interesting solution for JavaScript, but I think it's constrained by the language and could become better if it were fully compiled.
- Jtsummers 10y agoPerhaps for the use-case of node, being fully compiled could be a bit better. But I'm not convinced. Java has demonstrated (over two decades now) that initial compilation to machine code isn't essential for performant software (ok, less than two decades for hotspot JITs in Java). The cost for node is in startup time, but this is, like with Java, amortized over the life of the program. For a single-run executable, it's perhaps too costly (but we use truly interpreted languages for this as well, so depends on the task), but for a server, it's potentially pretty good.
- marcosdumay 10y agoYes, that was for the specific case of Node. For web use, full compilation is a clear loss. Java can make great use of JIT exactly because it's interpreted. When you make partial compilations, you lose a lot of JIT opportunities, and a lot of static optimization opportunities too. Yet, it looks like V8 attenuated this somehow, and got good performance anyway. Must have been a feat.