• 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
..
OWNERS Loading commit data...
allocation-tracker.cc Loading commit data...
allocation-tracker.h Loading commit data...
circular-queue-inl.h Loading commit data...
circular-queue.h Loading commit data...
cpu-profiler-inl.h Loading commit data...
cpu-profiler.cc Loading commit data...
cpu-profiler.h Loading commit data...
heap-profiler.cc Loading commit data...
heap-profiler.h Loading commit data...
heap-snapshot-generator-inl.h Loading commit data...
heap-snapshot-generator.cc Loading commit data...
heap-snapshot-generator.h Loading commit data...
profile-generator-inl.h Loading commit data...
profile-generator.cc Loading commit data...
profile-generator.h Loading commit data...
profiler-listener.cc Loading commit data...
profiler-listener.h Loading commit data...
profiler-stats.cc Loading commit data...
profiler-stats.h Loading commit data...
sampling-heap-profiler.cc Loading commit data...
sampling-heap-profiler.h Loading commit data...
strings-storage.cc Loading commit data...
strings-storage.h Loading commit data...
symbolizer.cc Loading commit data...
symbolizer.h Loading commit data...
tick-sample.cc Loading commit data...
tick-sample.h Loading commit data...
tracing-cpu-profiler.cc Loading commit data...
tracing-cpu-profiler.h Loading commit data...