• Michael Lippautz's avatar
    Reland "cppgc-js: Add snapshot for C++ objects" · 063d56e7
    Michael Lippautz authored
    This reverts commit fba14bde.
    
    Reland fixes:
    - const vector<const string> -> const vector<string>
    
    Original message:
    The following implements a snapshotting algorithm for C++ objects that
    also filters strongly-connected components (SCCs) of only "hidden"
    objects that are not (transitively) referencing any non-hidden
    objects.
    
    C++ objects come in two versions.
    a. Named objects that have been assigned a name through NameProvider.
    b. Unnamed objects, that are potentially hidden if the build
       configuration requires Oilpan to hide such names. Hidden objects have
       their name set to NameProvider::kHiddenName.
    
    The main challenge for the algorithm is to avoid blowing up the final
    object graph with hidden nodes that do not carry information. For that
    reason, the algorithm filters SCCs of only hidden objects, e.g.:
      ...  -> (object) -> (object) -> (hidden) -> (hidden)
    In this case the (hidden) objects are filtered from the graph. The
    trickiest part is maintaining visibility state for objects referencing
    other objects that are currently being processed.
    
    Main algorithm idea (two passes):
    1. First pass marks all non-hidden objects and those that transitively
       reach non-hidden objects as visible. Details:
       - Iterate over all objects.
       - If object is non-hidden mark it as visible and also mark parent
         as visible if needed.
       - If object is hidden, traverse children as DFS to find non-hidden
         objects. Post-order process the objects and mark those objects as
         visible that have child nodes that are visible themselves.
       - Maintain an epoch counter (StateStorage::state_count_) to allow
         deferring the visibility decision to other objects in the same
         SCC. This is similar to the "lowlink" value in Tarjan's algorithm
         for SCC.
       - After the first pass it is guaranteed that all deferred
         visibility decisions can be resolved.
    2. Second pass adds nodes and edges for all visible objects.
       - Upon first checking the visibility state of an object, all deferred
         visibility states are resolved.
    
    For practical reasons, the recursion is transformed into an iteration.
    We do not use plain Tarjan's algorithm to avoid another pass over
    all nodes to create SCCs.
    
    Follow ups:
    1. Adding wrapper nodes for cpp objects that are wrappables for V8
       wrappers.
    2. Adding detachedness information.
    
    Bug: chromium:1056170
    Change-Id: Ib47df5c912c57d644d052f209276e9d926cece0f
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2480362
    Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
    Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
    Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
    Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#70577}
    063d56e7
Name
Last commit
Last update
..
base Loading commit data...
cppgc Loading commit data...
allocation-observer-unittest.cc Loading commit data...
barrier-unittest.cc Loading commit data...
bitmap-test-utils.h Loading commit data...
bitmap-unittest.cc Loading commit data...
code-object-registry-unittest.cc Loading commit data...
embedder-tracing-unittest.cc Loading commit data...
gc-idle-time-handler-unittest.cc Loading commit data...
gc-tracer-unittest.cc Loading commit data...
heap-controller-unittest.cc Loading commit data...
heap-unittest.cc Loading commit data...
heap-utils.h Loading commit data...
index-generator-unittest.cc Loading commit data...
item-parallel-job-unittest.cc Loading commit data...
js-member-unittest.cc Loading commit data...
list-unittest.cc Loading commit data...
local-factory-unittest.cc Loading commit data...
local-heap-unittest.cc Loading commit data...
marking-unittest.cc Loading commit data...
marking-worklist-unittest.cc Loading commit data...
memory-reducer-unittest.cc Loading commit data...
object-start-bitmap-unittest.cc Loading commit data...
object-stats-unittest.cc Loading commit data...
persistent-handles-unittest.cc Loading commit data...
safepoint-unittest.cc Loading commit data...
slot-set-unittest.cc Loading commit data...
spaces-unittest.cc Loading commit data...
unified-heap-snapshot-unittest.cc Loading commit data...
unified-heap-unittest.cc Loading commit data...
unmapper-unittest.cc Loading commit data...
worklist-unittest.cc Loading commit data...