Commit 195f6e11 authored by Dominik Inführ's avatar Dominik Inführ Committed by V8 LUCI CQ

[heap] Handle paged spaces in Heap::MakeHeapIterable

Complete implementation of Heap::MakeHeapIterable() by also making the
LABs of paged spaces iterable. This method is the one to use when
the heap and/or a particular space shall be iterable.

Bug: v8:12338
Change-Id: Id859cf1a05df21a54939c504c59d7b1ccd659c9b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3277888Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77891}
parent 0e6eb3e2
......@@ -3522,13 +3522,18 @@ void Heap::CreateFillerForArray(T object, int elements_to_trim,
void Heap::MakeHeapIterable() {
mark_compact_collector()->EnsureSweepingCompleted();
MakeLocalHeapLabsIterable();
}
void Heap::MakeLocalHeapLabsIterable() {
safepoint()->IterateLocalHeaps([](LocalHeap* local_heap) {
local_heap->MakeLinearAllocationAreaIterable();
});
PagedSpaceIterator spaces(this);
for (PagedSpace* space = spaces.Next(); space != nullptr;
space = spaces.Next()) {
space->MakeLinearAllocationAreaIterable();
}
// New space is bump-pointer allocation only and therefore guaranteed to be
// iterable up to top().
}
namespace {
......@@ -4598,8 +4603,6 @@ void Heap::VerifyRememberedSetFor(HeapObject object) {
#ifdef DEBUG
void Heap::VerifyCountersAfterSweeping() {
MakeLocalHeapLabsIterable();
PagedSpaceIterator spaces(this);
for (PagedSpace* space = spaces.Next(); space != nullptr;
space = spaces.Next()) {
......
......@@ -1652,6 +1652,10 @@ class Heap {
void UpdateEpochFull();
// Ensure that we have swept all spaces in such a way that we can iterate
// over all objects.
void MakeHeapIterable();
private:
using ExternalStringTableUpdaterCallback = String (*)(Heap* heap,
FullObjectSlot pointer);
......@@ -1781,13 +1785,6 @@ class Heap {
// with the allocation memento of the object at the top
void EnsureFillerObjectAtTop();
// Ensure that we have swept all spaces in such a way that we can iterate
// over all objects. May cause a GC.
void MakeHeapIterable();
// Ensure that LABs of local heaps are iterable.
void MakeLocalHeapLabsIterable();
// Performs garbage collection in a safepoint.
// Returns the number of freed global handles.
size_t PerformGarbageCollection(
......
......@@ -37,8 +37,8 @@ PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap,
cage_base_(heap->isolate())
#endif // V8_COMPRESS_POINTERS
{
space_->MakeLinearAllocationAreaIterable();
heap->mark_compact_collector()->EnsureSweepingCompleted();
heap->MakeHeapIterable();
USE(space_);
}
PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap,
......@@ -54,8 +54,7 @@ PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap,
cage_base_(heap->isolate())
#endif // V8_COMPRESS_POINTERS
{
space_->MakeLinearAllocationAreaIterable();
heap->mark_compact_collector()->EnsureSweepingCompleted();
heap->MakeHeapIterable();
#ifdef DEBUG
AllocationSpace owner = page->owner_identity();
DCHECK(owner == OLD_SPACE || owner == MAP_SPACE || owner == CODE_SPACE);
......
......@@ -12,6 +12,7 @@
#include "src/heap/heap-inl.h"
#include "src/heap/paged-spaces-inl.h"
#include "src/heap/read-only-heap.h"
#include "src/heap/safepoint.h"
#include "src/heap/spaces.h"
#include "src/objects/objects-inl.h"
......@@ -128,6 +129,7 @@ static int DumpHeapConstants(FILE* out, const char* argv0) {
{
Isolate::Scope scope(isolate);
i::Heap* heap = reinterpret_cast<i::Isolate*>(isolate)->heap();
i::SafepointScope safepoint_scope(heap);
i::ReadOnlyHeap* read_only_heap =
reinterpret_cast<i::Isolate*>(isolate)->read_only_heap();
i::PrintF(out, "%s", kHeader);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment