Commit 600db596 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[heap] Add object iterator for OffThreadSpace

Adds an paged space object iterator for OffThreadSpace, and removes
the Heap pointer from the iterator so that it can be used off-thread.

Bug: chromium:1011762
Change-Id: I025edf144f393e61d89cce2485c0ff1fe8c80c56
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1991488
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65658}
parent c8ab41eb
......@@ -5,6 +5,7 @@
#ifndef V8_HEAP_SPACES_INL_H_
#define V8_HEAP_SPACES_INL_H_
#include "src/common/globals.h"
#include "src/heap/spaces.h"
#include "src/base/atomic-utils.h"
......@@ -86,8 +87,8 @@ HeapObject PagedSpaceObjectIterator::FromCurrentPage() {
if (!obj.IsFreeSpaceOrFiller()) {
if (obj.IsCode()) {
DCHECK_IMPLIES(
space_ != heap_->code_space(),
space_ == heap_->read_only_space() && Code::cast(obj).is_builtin());
space_->identity() != CODE_SPACE,
space_->identity() == RO_SPACE && Code::cast(obj).is_builtin());
DCHECK_CODEOBJECT_SIZE(obj_size, space_);
} else {
DCHECK_OBJECT_SIZE(obj_size);
......
......@@ -53,11 +53,10 @@ PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap,
PagedSpace* space)
: cur_addr_(kNullAddress),
cur_end_(kNullAddress),
heap_(heap),
space_(space),
page_range_(space->first_page(), nullptr),
current_page_(page_range_.begin()) {
heap_->mark_compact_collector()->EnsureSweepingCompleted();
heap->mark_compact_collector()->EnsureSweepingCompleted();
}
PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap,
......@@ -65,11 +64,10 @@ PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap,
Page* page)
: cur_addr_(kNullAddress),
cur_end_(kNullAddress),
heap_(heap),
space_(space),
page_range_(page),
current_page_(page_range_.begin()) {
heap_->mark_compact_collector()->EnsureSweepingCompleted();
heap->mark_compact_collector()->EnsureSweepingCompleted();
#ifdef DEBUG
AllocationSpace owner = page->owner_identity();
DCHECK(owner == RO_SPACE || owner == OLD_SPACE || owner == MAP_SPACE ||
......@@ -77,6 +75,13 @@ PagedSpaceObjectIterator::PagedSpaceObjectIterator(Heap* heap,
#endif // DEBUG
}
PagedSpaceObjectIterator::PagedSpaceObjectIterator(OffThreadSpace* space)
: cur_addr_(kNullAddress),
cur_end_(kNullAddress),
space_(space),
page_range_(space->first_page(), nullptr),
current_page_(page_range_.begin()) {}
// We have hit the end of the page and should advance to the next block of
// objects. This happens at the end of the page.
bool PagedSpaceObjectIterator::AdvanceToNextPage() {
......
......@@ -54,6 +54,7 @@ class LocalSpace;
class MemoryAllocator;
class MemoryChunk;
class MemoryChunkLayout;
class OffThreadSpace;
class Page;
class PagedSpace;
class SemiSpace;
......@@ -1619,6 +1620,9 @@ class V8_EXPORT_PRIVATE PagedSpaceObjectIterator : public ObjectIterator {
PagedSpaceObjectIterator(Heap* heap, PagedSpace* space);
PagedSpaceObjectIterator(Heap* heap, PagedSpace* space, Page* page);
// Creates a new object iterator in a given off-thread space.
explicit PagedSpaceObjectIterator(OffThreadSpace* space);
// Advance to the next object, skipping free spaces and other fillers and
// skipping the special garbage section of which there is one per space.
// Returns nullptr when the iteration has ended.
......@@ -1634,7 +1638,6 @@ class V8_EXPORT_PRIVATE PagedSpaceObjectIterator : public ObjectIterator {
Address cur_addr_; // Current iteration point.
Address cur_end_; // End iteration point.
Heap* heap_;
PagedSpace* space_;
PageRange page_range_;
PageRange::iterator current_page_;
......
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