

Ignition: V8 Interpreter - hittaruki
https://docs.google.com/document/d/11T2CRex9hXxoJwbYqVQ32yIPMh0uouUZLdyrtmMoL44/edit?pli=1#heading=h.6jz9dj3bnr8t

======
hittaruki
[https://twitter.com/andywingo/status/630705153922838528](https://twitter.com/andywingo/status/630705153922838528)

~~~
abrowne
The tweet says "V8 is replacing its baseline JIT with an interpreter, not
unlike JSC and SpiderMonkey".

~~~
hittaruki
There is an 80 char limit on subject!!! so had to cut short.

------
pwg
See this: [http://i.stanford.edu/pub/cstr/reports/cs/tr/94/1520/CS-
TR-9...](http://i.stanford.edu/pub/cstr/reports/cs/tr/94/1520/CS-
TR-94-1520.pdf) (ADAPTIVE OPTIMIZATION FOR SELF: RECONCILING HIGH PERFORMANCE
WITH EXPLORATORY PROGRAMING)

Esp. section 5.3+ starting on physical pdf page 56.

~~~
acqq
For others who consider if it's worth clicking: the paper is by
[https://en.wikipedia.org/wiki/Urs_H%C3%B6lzle](https://en.wikipedia.org/wiki/Urs_H%C3%B6lzle)
and it's written in 1994.

------
s_kilk
Can anyone summarize what this move will mean for performance on the average
web app?

Will they be giving up some speed to claw back some memory?

~~~
Klathmon
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.

~~~
rakoo
What portion of a "standard" web site (say, Google search) is hot vs non-hot ?

~~~
Klathmon
The specifics of this are a bit outside my knowledge area, so take this with a
few major grains of salt.

But basically V8 has tools built in that will decide when the cost of
compiling is worth the possible benefit.

So the AJAX submission javascript will probably never hit the optimizing
compiler, but your function inside 3 nested loops will probably be hit ASAP.

------
twotwotwo
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...](http://www.engadget.com/2015/08/10/google-revamps-android-one-india/))
that better low-RAM support could mesh nicely with, though of course it's just
a coincidence the dates lined up.

------
gsg
Interesting decision.

The architecture sounds a little unusual:

"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!

~~~
mike_hearn
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.

~~~
gsg
Having TurboFan compile the interpreter from machine-independent templates is
what struck me as unusual.

The rest is familiar enough, true.

~~~
mike_hearn
The HotSpot interpreter is done the same way, I believe. It's also a template
based interpreter.

------
themckman
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.

~~~
tuckerman
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.

------
pietaalpha
Would it be useful a <hot-code> tag for the purpose of indicating that
optimizations are required for the code?

in Lisp we have compiler options (declare (optimize ...))

------
ilyaigpetrov
Does this make implementation of other language compiled for V8 easier?

------
ndesaulniers
So V8 will be moving from a two tier to a three tier architecture.

Spidermonkey is three tier and JSC is four.

~~~
yoklov
Are they adding an extra tier, or replacing the lowest? I thought they were
replacing the lowest.

------
felixangell
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:

    
    
        http://http://dl.acm.org/citation.cfm?id=199526
        ^^^^^^^
    

My bad.

------
rancur
by my deeds I will honor him, V8

~~~
rancur
source for the uninitiated:
[https://www.youtube.com/watch?v=egSwfPKOX1c](https://www.youtube.com/watch?v=egSwfPKOX1c)

