From bb0f74d3364a0e7205affb991ad4f5c4846d13a3 Mon Sep 17 00:00:00 2001 From: Shu-yu Guo Date: Tue, 16 Nov 2021 08:44:07 -0800 Subject: [PATCH] [heap] Support AllocationType::kSharedOld in LocalHeap and LocalFactory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is in anticipation for sharing internalized and in-place-internalizable strings across Isolates. When such strings are shared, background compilation threads need to be able to allocate strings in the shared old space. Bug: v8:12007 Change-Id: I93179c9674cc16e5a6125049d20e61495bc1f3a9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3283615 Reviewed-by: Dominik Inführ Commit-Queue: Shu-yu Guo Cr-Commit-Position: refs/heads/main@{#77959} --- src/heap/heap.cc | 3 +++ src/heap/heap.h | 1 + src/heap/local-factory.cc | 3 ++- src/heap/local-heap-inl.h | 16 +++++++++++----- src/heap/local-heap.cc | 10 ++++++++++ src/heap/local-heap.h | 7 +++++++ 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/heap/heap.cc b/src/heap/heap.cc index e1173b7651..2b40c0f132 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -3534,6 +3534,9 @@ void Heap::FreeLinearAllocationAreas() { void Heap::FreeSharedLinearAllocationAreas() { if (!isolate()->shared_isolate()) return; + safepoint()->IterateLocalHeaps([](LocalHeap* local_heap) { + local_heap->FreeSharedLinearAllocationArea(); + }); shared_old_allocator_->FreeLinearAllocationArea(); shared_map_allocator_->FreeLinearAllocationArea(); } diff --git a/src/heap/heap.h b/src/heap/heap.h index 82bafc4cbb..a16a7a5739 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -870,6 +870,7 @@ class Heap { NewSpace* new_space() { return new_space_; } OldSpace* old_space() { return old_space_; } + OldSpace* shared_old_space() { return shared_old_space_; } CodeSpace* code_space() { return code_space_; } MapSpace* map_space() { return map_space_; } OldLargeObjectSpace* lo_space() { return lo_space_; } diff --git a/src/heap/local-factory.cc b/src/heap/local-factory.cc index a581cfee60..d8c2ce898a 100644 --- a/src/heap/local-factory.cc +++ b/src/heap/local-factory.cc @@ -40,7 +40,8 @@ void LocalFactory::AddToScriptList(Handle