• Clemens Hammacher's avatar
    Implement managed objects with phantom handles · f244f0c5
    Clemens Hammacher authored
    For each Managed<T> (which is a Foreign), we create a weak global handle
    with a finalizer which deletes the referenced C++ object once the
    Foreign is dead.
    Before calling this finalizer, the garbage collector needs to mark the
    referenced object black (i.e. live), because the finalizer might
    resurrect it.
    Since this is never done for managed objects, we can use the more
    lightweight phantom handle semantics, which allows the referenced
    object to be garbage collected right away.
    
    However, we can't access the global handle via the WeakCallbackInfo,
    because the global handle will already be garbage collected. So we need
    to store it explicitly. This is solved by storing the global handle
    together with the finalizer.
    In order to implement this, ownership of the ManagedObjectFinalizer
    is moved from the isolate to the managed object.
    
    R=ulan@chromium.org, mtrofin@chromium.org
    BUG=v8:6505, chromium:734345
    
    Change-Id: I94a245df601f70e19355d82439d30099e159231b
    Reviewed-on: https://chromium-review.googlesource.com/539578
    Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
    Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#46036}
    f244f0c5
isolate.cc 131 KB