Revert "[heap] Committed SemiSpace state depends on pages being present in the memory_chunk_list_."

This reverts commit 28f0b62a8c.

Reason for revert: Speculative revert for broken arm64 sim GC stress bot - https://ci.chromium.org/p/v8/builders/ci/V8%20Linux%20-%20arm64%20-%20sim%20-%20gc%20stress/20100

Also appears as a flake later - https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64%20-%20arm64%20-%20sim%20-%20pointer%20compression/7419

Original change's description:
> [heap] Committed SemiSpace state depends on pages being present in the memory_chunk_list_.
>
> Bug: chromium:1054771
> Change-Id: Idad2d6464ed29c8aa6d7d0665b84525c0f954df8
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2562245
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Commit-Queue: Hannes Payer <hpayer@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#71429}

TBR=ulan@chromium.org,hpayer@chromium.org

Change-Id: Ib7f9666abe059126004de6a81e5f1fa93e36e932
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1054771
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2563258
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71441}
This commit is contained in:
Maya Lekova 2020-11-27 06:54:13 +00:00 committed by Commit Bot
parent 72732e5109
commit f2316c8748
2 changed files with 19 additions and 13 deletions

View File

@ -37,7 +37,7 @@ Page* SemiSpace::InitializePage(MemoryChunk* chunk) {
}
bool SemiSpace::EnsureCurrentCapacity() {
if (IsCommitted()) {
if (is_committed()) {
const int expected_pages =
static_cast<int>(target_capacity_ / Page::kPageSize);
MemoryChunk* current_page = first_page();
@ -93,18 +93,19 @@ void SemiSpace::SetUp(size_t initial_capacity, size_t maximum_capacity) {
minimum_capacity_ = RoundDown(initial_capacity, Page::kPageSize);
target_capacity_ = minimum_capacity_;
maximum_capacity_ = RoundDown(maximum_capacity, Page::kPageSize);
committed_ = false;
}
void SemiSpace::TearDown() {
// Properly uncommit memory to keep the allocator counters in sync.
if (IsCommitted()) {
if (is_committed()) {
Uncommit();
}
target_capacity_ = maximum_capacity_ = 0;
}
bool SemiSpace::Commit() {
DCHECK(!IsCommitted());
DCHECK(!is_committed());
const int num_pages = static_cast<int>(target_capacity_ / Page::kPageSize);
for (int pages_added = 0; pages_added < num_pages; pages_added++) {
// Pages in the new spaces can be moved to the old space by the full
@ -125,11 +126,12 @@ bool SemiSpace::Commit() {
if (age_mark_ == kNullAddress) {
age_mark_ = first_page()->area_start();
}
committed_ = true;
return true;
}
bool SemiSpace::Uncommit() {
DCHECK(IsCommitted());
DCHECK(is_committed());
while (!memory_chunk_list_.Empty()) {
MemoryChunk* chunk = memory_chunk_list_.front();
memory_chunk_list_.Remove(chunk);
@ -138,12 +140,13 @@ bool SemiSpace::Uncommit() {
current_page_ = nullptr;
current_capacity_ = 0;
AccountUncommitted(target_capacity_);
committed_ = false;
heap()->memory_allocator()->unmapper()->FreeQueuedChunks();
return true;
}
size_t SemiSpace::CommittedPhysicalMemory() {
if (!IsCommitted()) return 0;
if (!is_committed()) return 0;
size_t size = 0;
for (Page* p : *this) {
size += p->CommittedPhysicalMemory();
@ -152,7 +155,7 @@ size_t SemiSpace::CommittedPhysicalMemory() {
}
bool SemiSpace::GrowTo(size_t new_capacity) {
if (!IsCommitted()) {
if (!is_committed()) {
if (!Commit()) return false;
}
DCHECK_EQ(new_capacity & kPageAlignmentMask, 0u);
@ -198,7 +201,7 @@ bool SemiSpace::ShrinkTo(size_t new_capacity) {
DCHECK_EQ(new_capacity & kPageAlignmentMask, 0u);
DCHECK_GE(new_capacity, minimum_capacity_);
DCHECK_LT(new_capacity, target_capacity_);
if (IsCommitted()) {
if (is_committed()) {
const size_t delta = target_capacity_ - new_capacity;
DCHECK(IsAligned(delta, Page::kPageSize));
int delta_pages = static_cast<int>(delta / Page::kPageSize);
@ -279,6 +282,7 @@ void SemiSpace::Swap(SemiSpace* from, SemiSpace* to) {
std::swap(from->maximum_capacity_, to->maximum_capacity_);
std::swap(from->minimum_capacity_, to->minimum_capacity_);
std::swap(from->age_mark_, to->age_mark_);
std::swap(from->committed_, to->committed_);
std::swap(from->memory_chunk_list_, to->memory_chunk_list_);
std::swap(from->current_page_, to->current_page_);
std::swap(from->external_backing_store_bytes_,
@ -386,7 +390,7 @@ size_t NewSpace::CommittedPhysicalMemory() {
if (!base::OS::HasLazyCommits()) return CommittedMemory();
BasicMemoryChunk::UpdateHighWaterMark(allocation_info_.top());
size_t size = to_space_.CommittedPhysicalMemory();
if (from_space_.IsCommitted()) {
if (from_space_.is_committed()) {
size += from_space_.CommittedPhysicalMemory();
}
return size;
@ -408,7 +412,7 @@ NewSpace::NewSpace(Heap* heap, v8::PageAllocator* page_allocator,
if (!to_space_.Commit()) {
V8::FatalProcessOutOfMemory(heap->isolate(), "New space setup");
}
DCHECK(!from_space_.IsCommitted()); // No need to use memory yet.
DCHECK(!from_space_.is_committed()); // No need to use memory yet.
ResetLinearAllocationArea();
}

View File

@ -48,6 +48,7 @@ class SemiSpace : public Space {
maximum_capacity_(0),
minimum_capacity_(0),
age_mark_(kNullAddress),
committed_(false),
id_(semispace),
current_page_(nullptr) {}
@ -60,7 +61,7 @@ class SemiSpace : public Space {
bool Commit();
bool Uncommit();
bool IsCommitted() { return !memory_chunk_list_.Empty(); }
bool is_committed() { return committed_; }
// Grow the semispace to the new capacity. The new capacity requested must
// be larger than the current capacity and less than the maximum capacity.
@ -191,6 +192,7 @@ class SemiSpace : public Space {
// Used to govern object promotion during mark-compact collection.
Address age_mark_;
bool committed_;
SemiSpaceId id_;
Page* current_page_;
@ -429,16 +431,16 @@ class V8_EXPORT_PRIVATE NewSpace
// Return whether the operation succeeded.
bool CommitFromSpaceIfNeeded() {
if (from_space_.IsCommitted()) return true;
if (from_space_.is_committed()) return true;
return from_space_.Commit();
}
bool UncommitFromSpace() {
if (!from_space_.IsCommitted()) return true;
if (!from_space_.is_committed()) return true;
return from_space_.Uncommit();
}
bool IsFromSpaceCommitted() { return from_space_.IsCommitted(); }
bool IsFromSpaceCommitted() { return from_space_.is_committed(); }
SemiSpace* active_space() { return &to_space_; }