I'll CC the V8 list on the answer for posterity and in case they have input. It's been a while since I worked on this.
Cache is perhaps not the right name. When we start up the Blink process we run the deserializer and it quickly creates all the V8 objects that a new V8 instance needs to find on its heap, and connects them up in the correct way. When we create a context (an iframe), we need some more V8 objects to be created. These are the builtins, like the Array prototype object. Each context has its own copy of these JS objects so that monkey patching is iframe local and not global. These context objects are in the second (partial) snapshot, which can be deserialized several times to create several contexts. The objects in the partial snapshot need to point to some of the objects that were created when the original snapshot was deserialized. This is things like code objects, and string objects which are conceptually immutable and can be shared between contexts. The cache is a map that tells us the memory location of these immutable objects, so that we can quickly create pointers to them when deserializing the context snapshot. At serialization time we create both snapshots simultaneously. We have to do this, because the serialization is a graph-walking reachability algorithm, and we have to serialize (in the startup snapshot) objects that are reachable through a context. At deserialization time we build up the cache so that it matches the one that was built at serialization time. Hope this helps. On Thu, Aug 7, 2014 at 4:51 AM, Weiliang Lin <[email protected]> wrote: > Hi Erik, > > Recently, I am studying the code of V8 snapshot. I have a question about > the partial snapshot cache. What is it? And I see it goes to serialize the > context object. So I think it may be go to dump the objects referred by > context. > > Could you please share somethings about it? Why we need such a > partial serializer. Thanks a lot. > > -- > Thanks > -Weiliang > -- -- 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.
