diff --git a/src/heap/scavenger-inl.h b/src/heap/scavenger-inl.h index bc3b97f667..96a192f076 100644 --- a/src/heap/scavenger-inl.h +++ b/src/heap/scavenger-inl.h @@ -298,7 +298,7 @@ SlotCallbackResult Scavenger::EvacuateThinString(Map map, THeapObjectSlot slot, static_assert(std::is_same::value || std::is_same::value, "Only FullHeapObjectSlot and HeapObjectSlot are expected here"); - if (!is_incremental_marking_ && shortcut_strings_) { + if (shortcut_strings_) { // The ThinString should die after Scavenge, so avoid writing the proper // forwarding pointer and instead just signal the actual object as forwarded // reference. @@ -326,7 +326,7 @@ SlotCallbackResult Scavenger::EvacuateShortcutCandidate(Map map, "Only FullHeapObjectSlot and HeapObjectSlot are expected here"); DCHECK(IsShortcutCandidate(map.instance_type())); - if (!is_incremental_marking_ && shortcut_strings_ && + if (shortcut_strings_ && object.unchecked_second() == ReadOnlyRoots(heap()).empty_string()) { HeapObject first = HeapObject::cast(object.unchecked_first()); diff --git a/src/heap/scavenger.cc b/src/heap/scavenger.cc index ec4ea57576..d7689171b4 100644 --- a/src/heap/scavenger.cc +++ b/src/heap/scavenger.cc @@ -610,6 +610,18 @@ ConcurrentAllocator* CreateSharedOldAllocator(Heap* heap) { } return nullptr; } + +// This returns true if the scavenger runs in a client isolate and incremental +// marking is enabled in the shared space isolate. +bool IsSharedIncrementalMarking(Isolate* isolate) { + return isolate->has_shared_heap() && v8_flags.shared_space && + !isolate->is_shared_space_isolate() && + isolate->shared_space_isolate() + ->heap() + ->incremental_marking() + ->IsMarking(); +} + } // namespace Scavenger::Scavenger(ScavengerCollector* collector, Heap* heap, bool is_logging, @@ -633,8 +645,10 @@ Scavenger::Scavenger(ScavengerCollector* collector, Heap* heap, bool is_logging, is_compacting_(heap->incremental_marking()->IsCompacting()), shared_string_table_(shared_old_allocator_.get() != nullptr), mark_shared_heap_(heap->isolate()->is_shared_space_isolate()), - shortcut_strings_(!heap->IsGCWithStack() || - v8_flags.shortcut_strings_with_stack) {} + shortcut_strings_( + (!heap->IsGCWithStack() || v8_flags.shortcut_strings_with_stack) && + !is_incremental_marking_ && + !IsSharedIncrementalMarking(heap->isolate())) {} void Scavenger::IterateAndScavengePromotedObject(HeapObject target, Map map, int size) {