[heap] Fix old-to-shared recording with large pages

HandleSlot was only checking whether the target object is in the
shared heap but that flag is only set after the GC for large pages.

This CL fixes this by also checking for SHARED_HEAP_PROMOTION.

Bug: v8:13267, chromium:1401069
Change-Id: Ie2d8b1b1557175d45cff6b27b7291b3d2c4560df
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4110739
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84880}
This commit is contained in:
Dominik Inführ 2022-12-15 16:03:08 +01:00 committed by V8 LUCI CQ
parent bc078aed99
commit cc86fab53f

View File

@ -34,6 +34,14 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace {
bool RecordOldToSharedSlot(HeapObject heap_object) {
BasicMemoryChunk* chunk = BasicMemoryChunk::FromHeapObject(heap_object);
return chunk->InSharedHeap() ||
chunk->IsFlagSet(MemoryChunk::SHARED_HEAP_PROMOTION);
}
} // anonymous namespace
class IterateAndScavengePromotedObjectsVisitor final : public ObjectVisitor { class IterateAndScavengePromotedObjectsVisitor final : public ObjectVisitor {
public: public:
IterateAndScavengePromotedObjectsVisitor(Scavenger* scavenger, IterateAndScavengePromotedObjectsVisitor(Scavenger* scavenger,
@ -154,7 +162,7 @@ class IterateAndScavengePromotedObjectsVisitor final : public ObjectVisitor {
MemoryChunk::FromHeapObject(host), slot.address()); MemoryChunk::FromHeapObject(host), slot.address());
} }
if (target.InSharedWritableHeap()) { if (RecordOldToSharedSlot(target)) {
DCHECK(!scavenger_->heap()->IsShared()); DCHECK(!scavenger_->heap()->IsShared());
MemoryChunk* chunk = MemoryChunk::FromHeapObject(host); MemoryChunk* chunk = MemoryChunk::FromHeapObject(host);
RememberedSet<OLD_TO_SHARED>::Insert<AccessMode::ATOMIC>(chunk, RememberedSet<OLD_TO_SHARED>::Insert<AccessMode::ATOMIC>(chunk,
@ -864,14 +872,6 @@ void Scavenger::AddEphemeronHashTable(EphemeronHashTable table) {
ephemeron_table_list_local_.Push(table); ephemeron_table_list_local_.Push(table);
} }
namespace {
bool RecordOldToSharedSlot(HeapObject heap_object) {
BasicMemoryChunk* chunk = BasicMemoryChunk::FromHeapObject(heap_object);
return chunk->InSharedHeap() ||
chunk->IsFlagSet(MemoryChunk::SHARED_HEAP_PROMOTION);
}
} // anonymous namespace
template <typename TSlot> template <typename TSlot>
void Scavenger::CheckOldToNewSlotForSharedUntyped(MemoryChunk* chunk, void Scavenger::CheckOldToNewSlotForSharedUntyped(MemoryChunk* chunk,
TSlot slot) { TSlot slot) {