Commit 4c64573d authored by machenbach's avatar machenbach Committed by Commit bot

Revert of [heap] Move large object space selection into AllocateRaw. (patchset...

Revert of [heap] Move large object space selection into AllocateRaw. (patchset #2 id:20001 of https://codereview.chromium.org/1373523002/ )

Reason for revert:
Breaks mac asan:
http://build.chromium.org/p/client.v8/builders/V8%20Mac64%20ASAN/builds/2895

According to auto bisect

Original issue's description:
> [heap] Move large object space selection into AllocateRaw.
>
> BUG=
>
> Committed: https://crrev.com/e4f7ebb000432cc2011ecaaa71a69e2e60f416f0
> Cr-Commit-Position: refs/heads/master@{#30938}

TBR=mlippautz@chromium.org,hpayer@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=

Review URL: https://codereview.chromium.org/1368833004

Cr-Commit-Position: refs/heads/master@{#30948}
parent 26f36f10
...@@ -123,11 +123,12 @@ AllocationResult Heap::AllocateOneByteInternalizedString( ...@@ -123,11 +123,12 @@ AllocationResult Heap::AllocateOneByteInternalizedString(
// Compute map and object size. // Compute map and object size.
Map* map = one_byte_internalized_string_map(); Map* map = one_byte_internalized_string_map();
int size = SeqOneByteString::SizeFor(str.length()); int size = SeqOneByteString::SizeFor(str.length());
AllocationSpace space = SelectSpace(size, TENURED);
// Allocate string. // Allocate string.
HeapObject* result = nullptr; HeapObject* result = nullptr;
{ {
AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE);
if (!allocation.To(&result)) return allocation; if (!allocation.To(&result)) return allocation;
} }
...@@ -154,11 +155,12 @@ AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, ...@@ -154,11 +155,12 @@ AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str,
// Compute map and object size. // Compute map and object size.
Map* map = internalized_string_map(); Map* map = internalized_string_map();
int size = SeqTwoByteString::SizeFor(str.length()); int size = SeqTwoByteString::SizeFor(str.length());
AllocationSpace space = SelectSpace(size, TENURED);
// Allocate string. // Allocate string.
HeapObject* result = nullptr; HeapObject* result = nullptr;
{ {
AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE);
if (!allocation.To(&result)) return allocation; if (!allocation.To(&result)) return allocation;
} }
...@@ -204,14 +206,11 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationSpace space, ...@@ -204,14 +206,11 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationSpace space,
isolate_->counters()->objs_since_last_young()->Increment(); isolate_->counters()->objs_since_last_young()->Increment();
#endif #endif
bool large_object = size_in_bytes > Page::kMaxRegularHeapObjectSize;
HeapObject* object = nullptr; HeapObject* object = nullptr;
AllocationResult allocation; AllocationResult allocation;
if (NEW_SPACE == space) { if (NEW_SPACE == space) {
if (!large_object) {
allocation = new_space_.AllocateRaw(size_in_bytes, alignment); allocation = new_space_.AllocateRaw(size_in_bytes, alignment);
if (always_allocate() && allocation.IsRetry() && if (always_allocate() && allocation.IsRetry() && retry_space != NEW_SPACE) {
retry_space != NEW_SPACE) {
space = retry_space; space = retry_space;
} else { } else {
if (allocation.To(&object)) { if (allocation.To(&object)) {
...@@ -219,27 +218,21 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationSpace space, ...@@ -219,27 +218,21 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationSpace space,
} }
return allocation; return allocation;
} }
} else {
space = LO_SPACE;
}
} }
if (OLD_SPACE == space) { if (OLD_SPACE == space) {
if (!large_object) {
allocation = old_space_->AllocateRaw(size_in_bytes, alignment); allocation = old_space_->AllocateRaw(size_in_bytes, alignment);
} else {
allocation = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE);
}
} else if (CODE_SPACE == space) { } else if (CODE_SPACE == space) {
if (!large_object) { if (size_in_bytes <= code_space()->AreaSize()) {
allocation = code_space_->AllocateRawUnaligned(size_in_bytes); allocation = code_space_->AllocateRawUnaligned(size_in_bytes);
} else { } else {
// Large code objects are allocated in large object space.
allocation = lo_space_->AllocateRaw(size_in_bytes, EXECUTABLE); allocation = lo_space_->AllocateRaw(size_in_bytes, EXECUTABLE);
} }
} else if (LO_SPACE == space) { } else if (LO_SPACE == space) {
DCHECK(large_object);
allocation = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE); 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); allocation = map_space_->AllocateRawUnaligned(size_in_bytes);
} }
if (allocation.To(&object)) { if (allocation.To(&object)) {
......
...@@ -2372,7 +2372,7 @@ AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode, ...@@ -2372,7 +2372,7 @@ AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode,
int size = HeapNumber::kSize; int size = HeapNumber::kSize;
STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxRegularHeapObjectSize); STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxRegularHeapObjectSize);
AllocationSpace space = SelectSpace(pretenure); AllocationSpace space = SelectSpace(size, pretenure);
HeapObject* result = nullptr; HeapObject* result = nullptr;
{ {
...@@ -2393,7 +2393,7 @@ AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode, ...@@ -2393,7 +2393,7 @@ AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode,
int size = Type::kSize; \ int size = Type::kSize; \
STATIC_ASSERT(Type::kSize <= Page::kMaxRegularHeapObjectSize); \ STATIC_ASSERT(Type::kSize <= Page::kMaxRegularHeapObjectSize); \
\ \
AllocationSpace space = SelectSpace(pretenure); \ AllocationSpace space = SelectSpace(size, pretenure); \
\ \
HeapObject* result = nullptr; \ HeapObject* result = nullptr; \
{ \ { \
...@@ -2931,7 +2931,7 @@ AllocationResult Heap::AllocateByteArray(int length, PretenureFlag pretenure) { ...@@ -2931,7 +2931,7 @@ AllocationResult Heap::AllocateByteArray(int length, PretenureFlag pretenure) {
v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true);
} }
int size = ByteArray::SizeFor(length); int size = ByteArray::SizeFor(length);
AllocationSpace space = SelectSpace(pretenure); AllocationSpace space = SelectSpace(size, pretenure);
HeapObject* result = nullptr; HeapObject* result = nullptr;
{ {
AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE);
...@@ -3142,7 +3142,7 @@ AllocationResult Heap::AllocateFixedTypedArrayWithExternalPointer( ...@@ -3142,7 +3142,7 @@ AllocationResult Heap::AllocateFixedTypedArrayWithExternalPointer(
int length, ExternalArrayType array_type, void* external_pointer, int length, ExternalArrayType array_type, void* external_pointer,
PretenureFlag pretenure) { PretenureFlag pretenure) {
int size = FixedTypedArrayBase::kHeaderSize; int size = FixedTypedArrayBase::kHeaderSize;
AllocationSpace space = SelectSpace(pretenure); AllocationSpace space = SelectSpace(size, pretenure);
HeapObject* result = nullptr; HeapObject* result = nullptr;
{ {
AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE);
...@@ -3186,7 +3186,7 @@ AllocationResult Heap::AllocateFixedTypedArray(int length, ...@@ -3186,7 +3186,7 @@ AllocationResult Heap::AllocateFixedTypedArray(int length,
ForFixedTypedArray(array_type, &element_size, &elements_kind); ForFixedTypedArray(array_type, &element_size, &elements_kind);
int size = OBJECT_POINTER_ALIGN(length * element_size + int size = OBJECT_POINTER_ALIGN(length * element_size +
FixedTypedArrayBase::kDataOffset); FixedTypedArrayBase::kDataOffset);
AllocationSpace space = SelectSpace(pretenure); AllocationSpace space = SelectSpace(size, pretenure);
HeapObject* object = nullptr; HeapObject* object = nullptr;
AllocationResult allocation = AllocateRaw( AllocationResult allocation = AllocateRaw(
...@@ -3401,7 +3401,8 @@ AllocationResult Heap::AllocateJSObjectFromMap( ...@@ -3401,7 +3401,8 @@ AllocationResult Heap::AllocateJSObjectFromMap(
FixedArray* properties = empty_fixed_array(); FixedArray* properties = empty_fixed_array();
// Allocate the JSObject. // Allocate the JSObject.
AllocationSpace space = SelectSpace(pretenure); int size = map->instance_size();
AllocationSpace space = SelectSpace(size, pretenure);
JSObject* js_obj = nullptr; JSObject* js_obj = nullptr;
AllocationResult allocation = Allocate(map, space, allocation_site); AllocationResult allocation = Allocate(map, space, allocation_site);
if (!allocation.To(&js_obj)) return allocation; if (!allocation.To(&js_obj)) return allocation;
...@@ -3602,11 +3603,12 @@ AllocationResult Heap::AllocateInternalizedStringImpl(T t, int chars, ...@@ -3602,11 +3603,12 @@ AllocationResult Heap::AllocateInternalizedStringImpl(T t, int chars,
map = internalized_string_map(); map = internalized_string_map();
size = SeqTwoByteString::SizeFor(chars); size = SeqTwoByteString::SizeFor(chars);
} }
AllocationSpace space = SelectSpace(size, TENURED);
// Allocate string. // Allocate string.
HeapObject* result = nullptr; HeapObject* result = nullptr;
{ {
AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE);
if (!allocation.To(&result)) return allocation; if (!allocation.To(&result)) return allocation;
} }
...@@ -3644,7 +3646,7 @@ AllocationResult Heap::AllocateRawOneByteString(int length, ...@@ -3644,7 +3646,7 @@ AllocationResult Heap::AllocateRawOneByteString(int length,
DCHECK_GE(String::kMaxLength, length); DCHECK_GE(String::kMaxLength, length);
int size = SeqOneByteString::SizeFor(length); int size = SeqOneByteString::SizeFor(length);
DCHECK(size <= SeqOneByteString::kMaxSize); DCHECK(size <= SeqOneByteString::kMaxSize);
AllocationSpace space = SelectSpace(pretenure); AllocationSpace space = SelectSpace(size, pretenure);
HeapObject* result = nullptr; HeapObject* result = nullptr;
{ {
...@@ -3668,7 +3670,7 @@ AllocationResult Heap::AllocateRawTwoByteString(int length, ...@@ -3668,7 +3670,7 @@ AllocationResult Heap::AllocateRawTwoByteString(int length,
DCHECK_GE(String::kMaxLength, length); DCHECK_GE(String::kMaxLength, length);
int size = SeqTwoByteString::SizeFor(length); int size = SeqTwoByteString::SizeFor(length);
DCHECK(size <= SeqTwoByteString::kMaxSize); DCHECK(size <= SeqTwoByteString::kMaxSize);
AllocationSpace space = SelectSpace(pretenure); AllocationSpace space = SelectSpace(size, pretenure);
HeapObject* result = nullptr; HeapObject* result = nullptr;
{ {
...@@ -3803,7 +3805,7 @@ AllocationResult Heap::AllocateRawFixedArray(int length, ...@@ -3803,7 +3805,7 @@ AllocationResult Heap::AllocateRawFixedArray(int length,
v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true);
} }
int size = FixedArray::SizeFor(length); int size = FixedArray::SizeFor(length);
AllocationSpace space = SelectSpace(pretenure); AllocationSpace space = SelectSpace(size, pretenure);
return AllocateRaw(size, space, OLD_SPACE); return AllocateRaw(size, space, OLD_SPACE);
} }
...@@ -3872,7 +3874,7 @@ AllocationResult Heap::AllocateRawFixedDoubleArray(int length, ...@@ -3872,7 +3874,7 @@ AllocationResult Heap::AllocateRawFixedDoubleArray(int length,
kDoubleAligned); kDoubleAligned);
} }
int size = FixedDoubleArray::SizeFor(length); int size = FixedDoubleArray::SizeFor(length);
AllocationSpace space = SelectSpace(pretenure); AllocationSpace space = SelectSpace(size, pretenure);
HeapObject* object = nullptr; HeapObject* object = nullptr;
{ {
...@@ -3929,9 +3931,10 @@ AllocationResult Heap::AllocateStruct(InstanceType type) { ...@@ -3929,9 +3931,10 @@ AllocationResult Heap::AllocateStruct(InstanceType type) {
return exception(); return exception();
} }
int size = map->instance_size(); int size = map->instance_size();
AllocationSpace space = SelectSpace(size, TENURED);
Struct* result = nullptr; Struct* result = nullptr;
{ {
AllocationResult allocation = Allocate(map, OLD_SPACE); AllocationResult allocation = Allocate(map, space);
if (!allocation.To(&result)) return allocation; if (!allocation.To(&result)) return allocation;
} }
result->InitializeBody(size); result->InitializeBody(size);
......
...@@ -1644,8 +1644,10 @@ class Heap { ...@@ -1644,8 +1644,10 @@ class Heap {
static void ScavengeStoreBufferCallback(Heap* heap, MemoryChunk* page, static void ScavengeStoreBufferCallback(Heap* heap, MemoryChunk* page,
StoreBufferEvent event); StoreBufferEvent event);
// Selects the proper allocation space based on the pretenuring decision. // Selects the proper allocation space depending on the given object
static AllocationSpace SelectSpace(PretenureFlag pretenure) { // 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; return (pretenure == TENURED) ? OLD_SPACE : NEW_SPACE;
} }
......
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