• Leszek Swirski's avatar
    [serializer] Serialize map before object · 7c912ffa
    Leszek Swirski authored
    Change the serialization protocol to ensure that maps are serialized
    before objects using them. This ensures that as soon as we allocate
    space for an object, we can immediately write the object's map into that
    allocation. In the future, this will allow us to make deserialized
    object visible to the GC.
    
    Specifically, this forces map serialization to happen after emitting
    a kNewObject for an object, but before allocating the space for it. We
    have to serialize the map after kNewObject because otherwise the map
    itself would be written into the "current" slot, into which the object
    is supposed to be deserialized.
    
    Objects whose maps are currently being deserialized are considered
    "pending" -- started, but not yet allocated. The map might point to a
    pending object (e.g. if an object's constructor points to the object).
    This is solved by introducing a new concept of forward references, where
    the field referring to the pending object is serialized as a "pending
    forward reference" which is "resolved" once the object is allocated.
    
    It might also point to itself, in the case of the meta map -- this is
    simply solved by introducing a new bytecode for the meta map; this
    cannot be a pending forward reference because the meta map is not yet
    allocated, so its map slot cannot be registered as pending.
    
    Finally, we may need to go to a new chunk after serializing the map; so
    after the map serialization, we peek to see if there's a next chunk
    bytecode before the object allocation.
    
    Bug: v8:10815
    Change-Id: Ifa8f25bdaf3b15b5d990a1d2e7be677c2fa80013
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2362953
    Commit-Queue: Leszek Swirski <leszeks@chromium.org>
    Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#69636}
    7c912ffa
deserializer.h 8.36 KB