diff options
Diffstat (limited to 'deps/v8/src/heap/local-allocator-inl.h')
-rw-r--r-- | deps/v8/src/heap/local-allocator-inl.h | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/deps/v8/src/heap/local-allocator-inl.h b/deps/v8/src/heap/local-allocator-inl.h index 10d6ce7370f..0f6f7e54539 100644 --- a/deps/v8/src/heap/local-allocator-inl.h +++ b/deps/v8/src/heap/local-allocator-inl.h @@ -12,10 +12,10 @@ namespace v8 { namespace internal { -AllocationResult LocalAllocator::Allocate(AllocationSpace space, - int object_size, - AllocationOrigin origin, - AllocationAlignment alignment) { +AllocationResult EvacuationAllocator::Allocate(AllocationSpace space, + int object_size, + AllocationOrigin origin, + AllocationAlignment alignment) { switch (space) { case NEW_SPACE: return AllocateInNewSpace(object_size, origin, alignment); @@ -30,8 +30,8 @@ AllocationResult LocalAllocator::Allocate(AllocationSpace space, } } -void LocalAllocator::FreeLast(AllocationSpace space, HeapObject object, - int object_size) { +void EvacuationAllocator::FreeLast(AllocationSpace space, HeapObject object, + int object_size) { switch (space) { case NEW_SPACE: FreeLastInNewSpace(object, object_size); @@ -45,7 +45,8 @@ void LocalAllocator::FreeLast(AllocationSpace space, HeapObject object, } } -void LocalAllocator::FreeLastInNewSpace(HeapObject object, int object_size) { +void EvacuationAllocator::FreeLastInNewSpace(HeapObject object, + int object_size) { if (!new_space_lab_.TryFreeLast(object, object_size)) { // We couldn't free the last object so we have to write a proper filler. heap_->CreateFillerObjectAt(object.address(), object_size, @@ -53,7 +54,8 @@ void LocalAllocator::FreeLastInNewSpace(HeapObject object, int object_size) { } } -void LocalAllocator::FreeLastInOldSpace(HeapObject object, int object_size) { +void EvacuationAllocator::FreeLastInOldSpace(HeapObject object, + int object_size) { if (!compaction_spaces_.Get(OLD_SPACE)->TryFreeLast(object, object_size)) { // We couldn't free the last object so we have to write a proper filler. heap_->CreateFillerObjectAt(object.address(), object_size, @@ -61,8 +63,8 @@ void LocalAllocator::FreeLastInOldSpace(HeapObject object, int object_size) { } } -AllocationResult LocalAllocator::AllocateInLAB(int object_size, - AllocationAlignment alignment) { +AllocationResult EvacuationAllocator::AllocateInLAB( + int object_size, AllocationAlignment alignment) { AllocationResult allocation; if (!new_space_lab_.IsValid() && !NewLocalAllocationBuffer()) { return AllocationResult::Retry(OLD_SPACE); @@ -79,22 +81,24 @@ AllocationResult LocalAllocator::AllocateInLAB(int object_size, return allocation; } -bool LocalAllocator::NewLocalAllocationBuffer() { +bool EvacuationAllocator::NewLocalAllocationBuffer() { if (lab_allocation_will_fail_) return false; - LocalAllocationBuffer saved_lab_ = new_space_lab_; AllocationResult result = new_space_->AllocateRawSynchronized(kLabSize, kWordAligned); + if (result.IsRetry()) { + lab_allocation_will_fail_ = true; + return false; + } + LocalAllocationBuffer saved_lab = std::move(new_space_lab_); new_space_lab_ = LocalAllocationBuffer::FromResult(heap_, result, kLabSize); - if (new_space_lab_.IsValid()) { - new_space_lab_.TryMerge(&saved_lab_); - return true; + DCHECK(new_space_lab_.IsValid()); + if (!new_space_lab_.TryMerge(&saved_lab)) { + saved_lab.CloseAndMakeIterable(); } - new_space_lab_ = saved_lab_; - lab_allocation_will_fail_ = true; - return false; + return true; } -AllocationResult LocalAllocator::AllocateInNewSpace( +AllocationResult EvacuationAllocator::AllocateInNewSpace( int object_size, AllocationOrigin origin, AllocationAlignment alignment) { if (object_size > kMaxLabObjectSize) { return new_space_->AllocateRawSynchronized(object_size, alignment, origin); |