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