Commit 82f41638 authored by Hannes Payer's avatar Hannes Payer Committed by Commit Bot

[heap] Cleanup: Remove various from/to space helpers.

Change-Id: I4cb2e72fdc008ee855014d703af33d2e937bada3
Reviewed-on: https://chromium-review.googlesource.com/1070148
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53392}
parent 2b5f7205
......@@ -80,8 +80,8 @@ void LocalArrayBufferTracker::Process(Callback callback) {
void ArrayBufferTracker::PrepareToFreeDeadInNewSpace(Heap* heap) {
DCHECK_EQ(heap->gc_state(), Heap::HeapState::SCAVENGE);
for (Page* page : PageRange(heap->new_space()->FromSpaceStart(),
heap->new_space()->FromSpaceEnd())) {
for (Page* page :
PageRange(heap->new_space()->from_space().first_page(), nullptr)) {
bool empty = ProcessBuffers(page, kUpdateForwardedRemoveOthers);
CHECK(empty);
}
......
......@@ -1979,7 +1979,7 @@ void Heap::EvacuateYoungGeneration() {
LOG(isolate_, ResourceEvent("scavenge", "begin"));
// Move pages from new->old generation.
PageRange range(new_space()->bottom(), new_space()->top());
PageRange range(new_space()->first_allocatable_address(), new_space()->top());
for (auto it = range.begin(); it != range.end();) {
Page* p = (*++it)->prev_page();
new_space()->from_space().RemovePage(p);
......@@ -2202,8 +2202,7 @@ void Heap::Scavenge() {
if (FLAG_concurrent_marking) {
// Ensure that concurrent marker does not track pages that are
// going to be unmapped.
for (Page* p : PageRange(new_space()->FromSpaceStart(),
new_space()->FromSpaceEnd())) {
for (Page* p : PageRange(new_space()->from_space().first_page(), nullptr)) {
concurrent_marking()->ClearLiveness(p);
}
}
......@@ -3848,8 +3847,7 @@ void Heap::VerifyCountersBeforeConcurrentSweeping() {
void Heap::ZapFromSpace() {
if (!new_space_->IsFromSpaceCommitted()) return;
for (Page* page :
PageRange(new_space_->FromSpaceStart(), new_space_->FromSpaceEnd())) {
for (Page* page : PageRange(new_space_->from_space().first_page(), nullptr)) {
for (Address cursor = page->area_start(), limit = page->area_end();
cursor < limit; cursor += kPointerSize) {
Memory::Address_at(cursor) = static_cast<Address>(kFromSpaceZapValue);
......
......@@ -128,9 +128,10 @@ void MarkingVerifier::VerifyMarking(NewSpace* space) {
Address end = space->top();
// The bottom position is at the start of its page. Allows us to use
// page->area_start() as start of range on all pages.
CHECK_EQ(space->bottom(), Page::FromAddress(space->bottom())->area_start());
CHECK_EQ(space->first_allocatable_address(),
space->first_page()->area_start());
PageRange range(space->bottom(), end);
PageRange range(space->first_allocatable_address(), end);
for (auto it = range.begin(); it != range.end();) {
Page* page = *(it++);
Address limit = it != range.end() ? page->area_end() : end;
......@@ -258,7 +259,7 @@ void EvacuationVerifier::VerifyEvacuationOnPage(Address start, Address end) {
}
void EvacuationVerifier::VerifyEvacuation(NewSpace* space) {
PageRange range(space->bottom(), space->top());
PageRange range(space->first_allocatable_address(), space->top());
for (auto it = range.begin(); it != range.end();) {
Page* page = *(it++);
Address current = page->area_start();
......@@ -488,7 +489,7 @@ void MarkCompactCollector::VerifyMarkbitsAreClean(PagedSpace* space) {
void MarkCompactCollector::VerifyMarkbitsAreClean(NewSpace* space) {
for (Page* p : PageRange(space->bottom(), space->top())) {
for (Page* p : PageRange(space->first_allocatable_address(), space->top())) {
CHECK(non_atomic_marking_state()->bitmap(p)->IsClean());
CHECK_EQ(0, non_atomic_marking_state()->live_bytes(p));
}
......@@ -2142,7 +2143,8 @@ void MarkCompactCollector::EvacuatePrologue() {
// New space.
NewSpace* new_space = heap()->new_space();
// Append the list of new space pages to be processed.
for (Page* p : PageRange(new_space->bottom(), new_space->top())) {
for (Page* p :
PageRange(new_space->first_allocatable_address(), new_space->top())) {
new_space_evacuation_pages_.push_back(p);
}
new_space->Flip();
......@@ -2954,7 +2956,7 @@ class ArrayBufferTrackerUpdatingItem : public UpdatingItem {
int MarkCompactCollectorBase::CollectToSpaceUpdatingItems(
ItemParallelJob* job) {
// Seed to space pages.
const Address space_start = heap()->new_space()->bottom();
const Address space_start = heap()->new_space()->first_allocatable_address();
const Address space_end = heap()->new_space()->top();
int pages = 0;
for (Page* page : PageRange(space_start, space_end)) {
......@@ -3677,8 +3679,8 @@ void MinorMarkCompactCollector::CollectGarbage() {
{
TRACE_GC(heap()->tracer(), GCTracer::Scope::MINOR_MC_RESET_LIVENESS);
for (Page* p : PageRange(heap()->new_space()->FromSpaceStart(),
heap()->new_space()->FromSpaceEnd())) {
for (Page* p :
PageRange(heap()->new_space()->from_space().first_page(), nullptr)) {
DCHECK(!p->IsFlagSet(Page::SWEEP_TO_ITERATE));
non_atomic_marking_state()->ClearLiveness(p);
if (FLAG_concurrent_marking) {
......@@ -3840,7 +3842,8 @@ void MinorMarkCompactCollector::ClearNonLiveReferences() {
void MinorMarkCompactCollector::EvacuatePrologue() {
NewSpace* new_space = heap()->new_space();
// Append the list of new space pages to be processed.
for (Page* p : PageRange(new_space->bottom(), new_space->top())) {
for (Page* p :
PageRange(new_space->first_allocatable_address(), new_space->top())) {
new_space_evacuation_pages_.push_back(p);
}
new_space->Flip();
......
......@@ -2644,7 +2644,7 @@ void SemiSpace::AssertValidRange(Address start, Address end) {
// SemiSpaceIterator implementation.
SemiSpaceIterator::SemiSpaceIterator(NewSpace* space) {
Initialize(space->bottom(), space->top());
Initialize(space->first_allocatable_address(), space->top());
}
......
......@@ -2383,6 +2383,8 @@ class SemiSpace : public Space {
bool EnsureCurrentCapacity();
Address space_end() { return memory_chunk_list_.back()->area_end(); }
// Returns the start address of the first page of the space.
Address space_start() {
DCHECK_NE(memory_chunk_list_.front(), nullptr);
......@@ -2392,9 +2394,6 @@ class SemiSpace : public Space {
Page* current_page() { return current_page_; }
int pages_used() { return pages_used_; }
// Returns one past the end address of the space.
Address space_end() { return memory_chunk_list_.back()->area_end(); }
// Returns the start address of the current page of the space.
Address page_low() { return current_page_->area_start(); }
......@@ -2455,6 +2454,7 @@ class SemiSpace : public Space {
}
Page* first_page() { return reinterpret_cast<Page*>(Space::first_page()); }
Page* last_page() { return reinterpret_cast<Page*>(Space::last_page()); }
iterator begin() { return iterator(first_page()); }
iterator end() { return iterator(nullptr); }
......@@ -2680,8 +2680,9 @@ class NewSpace : public SpaceWithLinearArea {
Address original_top() { return original_top_.Value(); }
Address original_limit() { return original_limit_.Value(); }
// Return the address of the first object in the active semispace.
Address bottom() { return to_space_.space_start(); }
// Return the address of the first allocatable address in the active
// semispace. This may be the address where the first object resides.
Address first_allocatable_address() { return to_space_.space_start(); }
// Get the age mark of the inactive semispace.
Address age_mark() { return from_space_.age_mark(); }
......@@ -2710,18 +2711,6 @@ class NewSpace : public SpaceWithLinearArea {
// it in steps to guarantee that the observers are notified periodically.
void UpdateInlineAllocationLimit(size_t size_in_bytes) override;
// Get the extent of the inactive semispace (for use as a marking stack,
// or to zap it). Notice: space-addresses are not necessarily on the
// same page, so FromSpaceStart() might be above FromSpaceEnd().
Address FromSpacePageLow() { return from_space_.page_low(); }
Address FromSpacePageHigh() { return from_space_.page_high(); }
Address FromSpaceStart() { return from_space_.space_start(); }
Address FromSpaceEnd() { return from_space_.space_end(); }
// Get the extent of the active semispace's pages' memory.
Address ToSpaceStart() { return to_space_.space_start(); }
Address ToSpaceEnd() { return to_space_.space_end(); }
inline bool ToSpaceContainsSlow(Address a);
inline bool FromSpaceContainsSlow(Address a);
inline bool ToSpaceContains(Object* o);
......@@ -2759,6 +2748,9 @@ class NewSpace : public SpaceWithLinearArea {
SemiSpace* active_space() { return &to_space_; }
Page* first_page() { return to_space_.first_page(); }
Page* last_page() { return to_space_.last_page(); }
iterator begin() { return to_space_.begin(); }
iterator end() { return to_space_.end(); }
......
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