The TL;DR: is that non-hot code will run slower (it looks like about 1.5 to 2 times slower) with the benefit of reducing the code-space to about 25% of it's current size. (saving any memory usage that would have been used by that)
"Hot" or optimizable code will still be optimized and run just as fast.
It's not disk size that we care about, it's memory size. Reducing the space that the "parsed" code takes up in memory will reduce the amount of memory used by the engine.
> It's not disk size that we care about, it's memory size.
Yeah, I get it. We have a lot of memory these days. Gigabytes. Not always enough for images and videos, but for code? for client-side browser code that is downloaded & run on the fly? Makes you wonder how we got there.
Using an interpreter instead of a compiler for the lowest JIT tier can reduce startup time. When it's done in a good way it could actually even lead to speedups in common cases.
This might be about RAM-constrained phones; the design doc refers to '--optimize-for-size devices', suggesting it won't (initially?) be on for everyone. Android and Chrome OS already enable Linux zram to get more out of low-memory gadgets. Incidentally, Google announced a (to me very ambitious-sounding) push for $50 Android phones today (http://www.engadget.com/2015/08/10/google-revamps-android-on...) that better low-RAM support could mesh nicely with, though of course it's just a coincidence the dates lined up.
"The interpreter itself consists of a set of bytecode handler code snippets, each of which handles a specific bytecode and dispatches to the handler for the next bytecode. These bytecode handlers are written in a high level, machine architecture agnostic form of assembly code, as implemented by the RawMachineAssembler class and compiled by Turbofan"
It also seems as if all calls are mediated by code generated by the compiler, which has the advantage of avoiding the awkwardness of different calling conventions between native and bytecode functions (possibly at some cost to performance?).
Fascinating reading. Thanks V8 people for allowing such documents to be public!
When written in C, is typically done using GCC's computed goto and the && label address-of operator extension.
Writing the handlers in machine-agnostic assembly is interesting; I'm guessing they want to tune the output more than writing the handlers in C would let them, or they can't rely on something like GCC's computed gotos.
Worth noting that IIRC, for a while LuaJIT in interpreted mode was able to beat V8 in optimized mode not all that infrequently (although it depended on the use case, they are different languages, and I do not know if this is still the case).
Common register allocation across different bytecode interpretation sequences was one of the things specifically on my mind that could be tuned using a high-level assembler.
Very suboptimal might be a slight overstatement. I can see a way, given known register calling conventions, that you could write an interpreter written as tail calls and post-process the machine code to effectively JMP instead of CALL. Guaranteed tail calls would save you a bunch of effort, and register calling convention would give you some guarantees about consistent allocation.
Not that unusual. In fact the planned architecture sounds exactly like HotSpot: a fast assembly based interpreter that profiles the code, with tiered fast/slow compilers producing machine code for hot spots, with deoptimization support to allow more speculative optimisations.
It actually seems a bit of a shame that V8 and Nashorn are competing despite heading towards very similar architectures.
I got the same impression from a cursory read. Profiling in the interpreter has its downsides, chief among them is lack of inlining causing profiles sometimes to be less useful. Tiered compilation can help here, but requires more careful code cache management.
I like the way Google projects seem to use Google Docs for this sort of thing. I've noticed in the past docs come up for projects like Angular and Go. I'd like to hear more about some of these documentation policies if anyone knows anything.
I no longer work at Google, things could have changed, but there was a strong culture to use Google Docs for project requirements gathering and design documents. There were some internal templates you could copy if you didn't want to think of the headers yourself.
While it's great this is part of the culture, discoverability/versioning were still problems, i.e. had to be done yourself.
There's no official "policy" that I know of. It's just that most Googlers tend to prefer Docs. It works anywhere you have a browser, is easy to share on the web, has nice collaboration features, and built-in comments.
AFAIK, V8 already has 3 tiers: full-codegen (the basic non-optimizing JIT), crankshaft and turbofan. With ignition, they're replacing full-codegen with an interpreter.
It's strange that there's only one mention of crankshaft in the entire document, but turbofan is all over the place. Are they also planning to get rid of the former?
The link to optimizing an ANSI C interpreter is broken, it's missing a colon after the protocol. I dunno if there's anyone here that can fix that, just thought I'd say it anyway.
Actually it's not the colon, there are two protocols: