On Wed, Apr 5, 2017 at 5:50 PM, 阿炳 <[email protected]> wrote:

> Thanks to all of you for answering my question so quickly.
> Firstly in the document "V8 Code Caching, v2" , the author was considering
> what and when to cache.
> But as Yang figured out, we are already caching ignition's byte code after
> we turn ignition + turbofan on, so I think the key point is when to cache
> the byte code.
> Only changing the timing to save code cache may not be very difficult?
>

Well, it's not as easy as it looks.

The code cache is serializing the result of a top-level compile. That
includes Ignition byte code, but also all the referenced literals, function
objects, etc. Those may be modified as the program executes, and may
contain or reference objects that depend on the current context. However,
since that context would no longer be there when the code cache is read,
reading it back won't work. The solution in the original (current) code
caching implementation is to serialize the code cache immediately after
compiling, before any of its code has been executed in a given context (and
thus before it could have picked up any context dependencies). That's what
forces the serialization to be done at the time of compile. If we just wait
(but don't adapt the code), we'll just get a code cache entry that won't
work.

Now... as you correctly observe, that could (and should) be implemented
differently. It's just that it's not a simple operation, since it requires
to re-think the serialization strategy and touches quite a bit of code. The
'v2' doc is my best guess at how to do that... :)

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to