From f746d35775f429c0e2d86c605c250d75048e6020 Mon Sep 17 00:00:00 2001 From: machenbach Date: Fri, 25 Sep 2015 04:27:43 -0700 Subject: [PATCH] Revert of [heap] Move large object space selection into AllocateRaw. (patchset #1 id:1 of https://codereview.chromium.org/1360903004/ ) Reason for revert: [Sheriff] Breaks: http://build.chromium.org/p/client.v8/builders/V8%20Linux%20-%20nosnap%20-%20debug%20-%202/builds/2080 And maybe (not sure): http://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Linux%2064%20%28dbg%29/builds/1529 Original issue's description: > [heap] Move large object space selection into AllocateRaw. > > BUG= > > Committed: https://crrev.com/1403815bdbcbd3336b2d85291704640fada30ffe > Cr-Commit-Position: refs/heads/master@{#30930} TBR=mlippautz@chromium.org,hpayer@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG= Review URL: https://codereview.chromium.org/1368103002 Cr-Commit-Position: refs/heads/master@{#30931} --- src/heap/heap-inl.h | 32 +++++++++++++++----------------- src/heap/heap.cc | 27 +++++++++++++++------------ src/heap/heap.h | 6 ++++-- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/heap/heap-inl.h b/src/heap/heap-inl.h index e121db1..6f7c060 100644 --- a/src/heap/heap-inl.h +++ b/src/heap/heap-inl.h @@ -123,11 +123,12 @@ AllocationResult Heap::AllocateOneByteInternalizedString( // Compute map and object size. Map* map = one_byte_internalized_string_map(); int size = SeqOneByteString::SizeFor(str.length()); + AllocationSpace space = SelectSpace(size, TENURED); // Allocate string. HeapObject* result = nullptr; { - AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); + AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); if (!allocation.To(&result)) return allocation; } @@ -154,11 +155,12 @@ AllocationResult Heap::AllocateTwoByteInternalizedString(Vector str, // Compute map and object size. Map* map = internalized_string_map(); int size = SeqTwoByteString::SizeFor(str.length()); + AllocationSpace space = SelectSpace(size, TENURED); // Allocate string. HeapObject* result = nullptr; { - AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); + AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); if (!allocation.To(&result)) return allocation; } @@ -204,37 +206,33 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationSpace space, isolate_->counters()->objs_since_last_young()->Increment(); #endif - bool large_object = size_in_bytes > Page::kMaxRegularHeapObjectSize; HeapObject* object = nullptr; AllocationResult allocation; if (NEW_SPACE == space) { - if (!large_object) { - allocation = new_space_.AllocateRaw(size_in_bytes, alignment); - if (always_allocate() && allocation.IsRetry() && - retry_space != NEW_SPACE) { - space = retry_space; - } + allocation = new_space_.AllocateRaw(size_in_bytes, alignment); + if (always_allocate() && allocation.IsRetry() && retry_space != NEW_SPACE) { + space = retry_space; } else { - space = LO_SPACE; + if (allocation.To(&object)) { + OnAllocationEvent(object, size_in_bytes); + } + return allocation; } } if (OLD_SPACE == space) { - if (!large_object) { - allocation = old_space_->AllocateRaw(size_in_bytes, alignment); - } else { - allocation = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE); - } + allocation = old_space_->AllocateRaw(size_in_bytes, alignment); } else if (CODE_SPACE == space) { if (size_in_bytes <= code_space()->AreaSize()) { allocation = code_space_->AllocateRawUnaligned(size_in_bytes); } else { + // Large code objects are allocated in large object space. allocation = lo_space_->AllocateRaw(size_in_bytes, EXECUTABLE); } } else if (LO_SPACE == space) { - DCHECK(large_object); allocation = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE); - } else if (MAP_SPACE == space) { + } else { + DCHECK(MAP_SPACE == space); allocation = map_space_->AllocateRawUnaligned(size_in_bytes); } if (allocation.To(&object)) { diff --git a/src/heap/heap.cc b/src/heap/heap.cc index bafce6f..31b93e7 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -2364,7 +2364,7 @@ AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode, int size = HeapNumber::kSize; STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxRegularHeapObjectSize); - AllocationSpace space = SelectSpace(pretenure); + AllocationSpace space = SelectSpace(size, pretenure); HeapObject* result = nullptr; { @@ -2385,7 +2385,7 @@ AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode, int size = Type::kSize; \ STATIC_ASSERT(Type::kSize <= Page::kMaxRegularHeapObjectSize); \ \ - AllocationSpace space = SelectSpace(pretenure); \ + AllocationSpace space = SelectSpace(size, pretenure); \ \ HeapObject* result = nullptr; \ { \ @@ -2923,7 +2923,7 @@ AllocationResult Heap::AllocateByteArray(int length, PretenureFlag pretenure) { v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); } int size = ByteArray::SizeFor(length); - AllocationSpace space = SelectSpace(pretenure); + AllocationSpace space = SelectSpace(size, pretenure); HeapObject* result = nullptr; { AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); @@ -3134,7 +3134,7 @@ AllocationResult Heap::AllocateFixedTypedArrayWithExternalPointer( int length, ExternalArrayType array_type, void* external_pointer, PretenureFlag pretenure) { int size = FixedTypedArrayBase::kHeaderSize; - AllocationSpace space = SelectSpace(pretenure); + AllocationSpace space = SelectSpace(size, pretenure); HeapObject* result = nullptr; { AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); @@ -3178,7 +3178,7 @@ AllocationResult Heap::AllocateFixedTypedArray(int length, ForFixedTypedArray(array_type, &element_size, &elements_kind); int size = OBJECT_POINTER_ALIGN(length * element_size + FixedTypedArrayBase::kDataOffset); - AllocationSpace space = SelectSpace(pretenure); + AllocationSpace space = SelectSpace(size, pretenure); HeapObject* object = nullptr; AllocationResult allocation = AllocateRaw( @@ -3393,7 +3393,8 @@ AllocationResult Heap::AllocateJSObjectFromMap( FixedArray* properties = empty_fixed_array(); // Allocate the JSObject. - AllocationSpace space = SelectSpace(pretenure); + int size = map->instance_size(); + AllocationSpace space = SelectSpace(size, pretenure); JSObject* js_obj = nullptr; AllocationResult allocation = Allocate(map, space, allocation_site); if (!allocation.To(&js_obj)) return allocation; @@ -3594,11 +3595,12 @@ AllocationResult Heap::AllocateInternalizedStringImpl(T t, int chars, map = internalized_string_map(); size = SeqTwoByteString::SizeFor(chars); } + AllocationSpace space = SelectSpace(size, TENURED); // Allocate string. HeapObject* result = nullptr; { - AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); + AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); if (!allocation.To(&result)) return allocation; } @@ -3636,7 +3638,7 @@ AllocationResult Heap::AllocateRawOneByteString(int length, DCHECK_GE(String::kMaxLength, length); int size = SeqOneByteString::SizeFor(length); DCHECK(size <= SeqOneByteString::kMaxSize); - AllocationSpace space = SelectSpace(pretenure); + AllocationSpace space = SelectSpace(size, pretenure); HeapObject* result = nullptr; { @@ -3660,7 +3662,7 @@ AllocationResult Heap::AllocateRawTwoByteString(int length, DCHECK_GE(String::kMaxLength, length); int size = SeqTwoByteString::SizeFor(length); DCHECK(size <= SeqTwoByteString::kMaxSize); - AllocationSpace space = SelectSpace(pretenure); + AllocationSpace space = SelectSpace(size, pretenure); HeapObject* result = nullptr; { @@ -3795,7 +3797,7 @@ AllocationResult Heap::AllocateRawFixedArray(int length, v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); } int size = FixedArray::SizeFor(length); - AllocationSpace space = SelectSpace(pretenure); + AllocationSpace space = SelectSpace(size, pretenure); return AllocateRaw(size, space, OLD_SPACE); } @@ -3864,7 +3866,7 @@ AllocationResult Heap::AllocateRawFixedDoubleArray(int length, kDoubleAligned); } int size = FixedDoubleArray::SizeFor(length); - AllocationSpace space = SelectSpace(pretenure); + AllocationSpace space = SelectSpace(size, pretenure); HeapObject* object = nullptr; { @@ -3921,9 +3923,10 @@ AllocationResult Heap::AllocateStruct(InstanceType type) { return exception(); } int size = map->instance_size(); + AllocationSpace space = SelectSpace(size, TENURED); Struct* result = nullptr; { - AllocationResult allocation = Allocate(map, OLD_SPACE); + AllocationResult allocation = Allocate(map, space); if (!allocation.To(&result)) return allocation; } result->InitializeBody(size); diff --git a/src/heap/heap.h b/src/heap/heap.h index 442d4de..3b6fd98 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -1640,8 +1640,10 @@ class Heap { static void ScavengeStoreBufferCallback(Heap* heap, MemoryChunk* page, StoreBufferEvent event); - // Selects the proper allocation space based on the pretenuring decision. - static AllocationSpace SelectSpace(PretenureFlag pretenure) { + // Selects the proper allocation space depending on the given object + // size and pretenuring decision. + static AllocationSpace SelectSpace(int object_size, PretenureFlag pretenure) { + if (object_size > Page::kMaxRegularHeapObjectSize) return LO_SPACE; return (pretenure == TENURED) ? OLD_SPACE : NEW_SPACE; } -- 2.7.4