| Index: src/heap/spaces.cc
|
| diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
|
| index 988da6bc99e6440f2b6e873aee94887c70a38620..23b1cfd3ad6e937fd7152a613f243adaa51a0354 100644
|
| --- a/src/heap/spaces.cc
|
| +++ b/src/heap/spaces.cc
|
| @@ -958,8 +958,7 @@ PagedSpace::PagedSpace(Heap* heap, AllocationSpace space,
|
| area_size_ = MemoryAllocator::PageAreaSize(space);
|
| accounting_stats_.Clear();
|
|
|
| - allocation_info_.set_top(NULL);
|
| - allocation_info_.set_limit(NULL);
|
| + allocation_info_.Reset(nullptr, nullptr);
|
|
|
| anchor_.InitializeAsAnchor(this);
|
| }
|
| @@ -1248,8 +1247,7 @@ void PagedSpace::ReleasePage(Page* page) {
|
| DCHECK(!free_list_.ContainsPageFreeListItems(page));
|
|
|
| if (Page::FromAllocationTop(allocation_info_.top()) == page) {
|
| - allocation_info_.set_top(NULL);
|
| - allocation_info_.set_limit(NULL);
|
| + allocation_info_.Reset(nullptr, nullptr);
|
| }
|
|
|
| // If page is still in a list, unlink it from that list.
|
| @@ -1390,8 +1388,8 @@ void NewSpace::TearDown() {
|
| }
|
|
|
| start_ = NULL;
|
| - allocation_info_.set_top(NULL);
|
| - allocation_info_.set_limit(NULL);
|
| + allocation_info_.Reset(nullptr, nullptr);
|
| +
|
|
|
| to_space_.TearDown();
|
| from_space_.TearDown();
|
| @@ -1480,10 +1478,50 @@ void NewSpace::Shrink() {
|
| }
|
|
|
|
|
| +void LocalAllocationBuffer::Close() {
|
| + if (IsValid()) {
|
| + heap_->CreateFillerObjectAt(
|
| + allocation_info_.top(),
|
| + static_cast<int>(allocation_info_.limit() - allocation_info_.top()));
|
| + }
|
| +}
|
| +
|
| +
|
| +LocalAllocationBuffer::LocalAllocationBuffer(Heap* heap,
|
| + AllocationInfo allocation_info)
|
| + : heap_(heap), allocation_info_(allocation_info) {
|
| + if (IsValid()) {
|
| + heap_->CreateFillerObjectAt(
|
| + allocation_info_.top(),
|
| + static_cast<int>(allocation_info_.limit() - allocation_info_.top()));
|
| + }
|
| +}
|
| +
|
| +
|
| +LocalAllocationBuffer::LocalAllocationBuffer(
|
| + const LocalAllocationBuffer& other) {
|
| + *this = other;
|
| +}
|
| +
|
| +
|
| +LocalAllocationBuffer& LocalAllocationBuffer::operator=(
|
| + const LocalAllocationBuffer& other) {
|
| + Close();
|
| + heap_ = other.heap_;
|
| + allocation_info_ = other.allocation_info_;
|
| +
|
| + // This is needed since we (a) cannot yet use move-semantics, and (b) want
|
| + // to make the use of the class easy by it as value and (c) implicitly call
|
| + // {Close} upon copy.
|
| + const_cast<LocalAllocationBuffer&>(other)
|
| + .allocation_info_.Reset(nullptr, nullptr);
|
| + return *this;
|
| +}
|
| +
|
| +
|
| void NewSpace::UpdateAllocationInfo() {
|
| MemoryChunk::UpdateHighWaterMark(allocation_info_.top());
|
| - allocation_info_.set_top(to_space_.page_low());
|
| - allocation_info_.set_limit(to_space_.page_high());
|
| + allocation_info_.Reset(to_space_.page_low(), to_space_.page_high());
|
| UpdateInlineAllocationLimit(0);
|
| DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_);
|
| }
|
| @@ -1566,6 +1604,12 @@ bool NewSpace::AddFreshPage() {
|
| }
|
|
|
|
|
| +bool NewSpace::AddFreshPageSynchronized() {
|
| + base::LockGuard<base::Mutex> guard(&mutex_);
|
| + return AddFreshPage();
|
| +}
|
| +
|
| +
|
| bool NewSpace::EnsureAllocation(int size_in_bytes,
|
| AllocationAlignment alignment) {
|
| Address old_top = allocation_info_.top();
|
| @@ -2764,9 +2808,7 @@ void PagedSpace::EvictEvacuationCandidatesFromLinearAllocationArea() {
|
| int remaining =
|
| static_cast<int>(allocation_info_.limit() - allocation_info_.top());
|
| heap()->CreateFillerObjectAt(allocation_info_.top(), remaining);
|
| -
|
| - allocation_info_.set_top(nullptr);
|
| - allocation_info_.set_limit(nullptr);
|
| + allocation_info_.Reset(nullptr, nullptr);
|
| }
|
| }
|
|
|
|
|