Reland "[heap] Skip weak heap objects when sharedness doesn't match"

This is a reland of commit 387674761f

Changes since revert: None, original failure was caused by another CL

Original change's description:
> [heap] Skip weak heap objects when sharedness doesn't match
>
> During marking, shared objects should not be marked when not
> marking the shared heap (i.e. when not doing a shared GC).
> Doing so is unsafe, as marking can race with sweeper threads
> sweeping the shared heap. This CL adds the missing check on
> weak object marking.
>
> Bug: v8:12687
> Change-Id: I1e0b8ba6b09bbcf665e5ff0f6242ed88f543c1fa
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3583610
> Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
> Commit-Queue: Shu-yu Guo <syg@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#79964}

Bug: v8:12687
Change-Id: Ia24ff5daa4d37daf73391c0e577b086611c5e496
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3584600
Owners-Override: Shu-yu Guo <syg@chromium.org>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79971}
This commit is contained in:
Shu-yu Guo 2022-04-12 12:16:22 -07:00 committed by V8 LUCI CQ
parent 9b79b2d740
commit 4a3997198d

View File

@ -55,6 +55,7 @@ template <typename THeapObjectSlot>
void MarkingVisitorBase<ConcreteVisitor, MarkingState>::ProcessWeakHeapObject(
HeapObject host, THeapObjectSlot slot, HeapObject heap_object) {
concrete_visitor()->SynchronizePageAccess(heap_object);
if (!is_shared_heap_ && heap_object.InSharedHeap()) return;
if (concrete_visitor()->marking_state()->IsBlackOrGrey(heap_object)) {
// Weak references with live values are directly processed here to
// reduce the processing time of weak cells during the main GC