 Chromium Code Reviews
 Chromium Code Reviews Issue 19934006:
  Simplified large object allocation strategy.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 19934006:
  Simplified large object allocation strategy.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| Index: src/heap.cc | 
| diff --git a/src/heap.cc b/src/heap.cc | 
| index dff217a99118fdc4c47497d10450d18fa60ae746..3103fe14e39f7702d6b2ebfef631ceb893267a3d 100644 | 
| --- a/src/heap.cc | 
| +++ b/src/heap.cc | 
| @@ -5360,18 +5360,11 @@ MaybeObject* Heap::AllocateRawOneByteString(int length, | 
| AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | 
| AllocationSpace retry_space = OLD_DATA_SPACE; | 
| - if (space == NEW_SPACE) { | 
| - if (size > kMaxObjectSizeInNewSpace) { | 
| - // Allocate in large object space, retry space will be ignored. | 
| - space = LO_SPACE; | 
| - } else if (size > Page::kMaxNonCodeHeapObjectSize) { | 
| - // Allocate in new space, retry in large object space. | 
| - retry_space = LO_SPACE; | 
| - } | 
| - } else if (space == OLD_DATA_SPACE && | 
| - size > Page::kMaxNonCodeHeapObjectSize) { | 
| + if (size > Page::kMaxNonCodeHeapObjectSize) { | 
| + // Allocate in large object space, retry space will be ignored. | 
| space = LO_SPACE; | 
| } | 
| + | 
| Object* result; | 
| { MaybeObject* maybe_result = AllocateRaw(size, space, retry_space); | 
| if (!maybe_result->ToObject(&result)) return maybe_result; | 
| @@ -5397,18 +5390,11 @@ MaybeObject* Heap::AllocateRawTwoByteString(int length, | 
| AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | 
| AllocationSpace retry_space = OLD_DATA_SPACE; | 
| - if (space == NEW_SPACE) { | 
| - if (size > kMaxObjectSizeInNewSpace) { | 
| - // Allocate in large object space, retry space will be ignored. | 
| - space = LO_SPACE; | 
| - } else if (size > Page::kMaxNonCodeHeapObjectSize) { | 
| - // Allocate in new space, retry in large object space. | 
| - retry_space = LO_SPACE; | 
| - } | 
| - } else if (space == OLD_DATA_SPACE && | 
| - size > Page::kMaxNonCodeHeapObjectSize) { | 
| + if (size > Page::kMaxNonCodeHeapObjectSize) { | 
| + // Allocate in large object space, retry space will be ignored. | 
| space = LO_SPACE; | 
| } | 
| + | 
| Object* result; | 
| { MaybeObject* maybe_result = AllocateRaw(size, space, retry_space); | 
| if (!maybe_result->ToObject(&result)) return maybe_result; | 
| @@ -5482,7 +5468,7 @@ MaybeObject* Heap::AllocateRawFixedArray(int length) { | 
| if (always_allocate()) return AllocateFixedArray(length, TENURED); | 
| // Allocate the raw data for a fixed array. | 
| int size = FixedArray::SizeFor(length); | 
| - return size <= kMaxObjectSizeInNewSpace | 
| + return size <= Page::kMaxNonCodeHeapObjectSize | 
| ? new_space_.AllocateRaw(size) | 
| : lo_space_->AllocateRaw(size, NOT_EXECUTABLE); | 
| } | 
| @@ -5554,21 +5540,16 @@ MaybeObject* Heap::AllocateRawFixedArray(int length, PretenureFlag pretenure) { | 
| return Failure::OutOfMemoryException(0xe); | 
| } | 
| 
Michael Starzinger
2013/07/22 19:27:50
nit: Let's drop this empty new-line for consistenc
 
Hannes Payer (out of office)
2013/07/23 20:00:51
Done.
 | 
| + int size = FixedArray::SizeFor(length); | 
| AllocationSpace space = | 
| (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE; | 
| - int size = FixedArray::SizeFor(length); | 
| - if (space == NEW_SPACE && size > kMaxObjectSizeInNewSpace) { | 
| - // Too big for new space. | 
| - space = LO_SPACE; | 
| - } else if (space == OLD_POINTER_SPACE && | 
| - size > Page::kMaxNonCodeHeapObjectSize) { | 
| - // Too big for old pointer space. | 
| + AllocationSpace retry_space = OLD_POINTER_SPACE; | 
| + | 
| + if (size > Page::kMaxNonCodeHeapObjectSize) { | 
| + // Allocate in large object space, retry space will be ignored. | 
| space = LO_SPACE; | 
| } | 
| - AllocationSpace retry_space = | 
| - (size <= Page::kMaxNonCodeHeapObjectSize) ? OLD_POINTER_SPACE : LO_SPACE; | 
| - | 
| return AllocateRaw(size, space, retry_space); | 
| } | 
| @@ -5689,24 +5670,19 @@ MaybeObject* Heap::AllocateRawFixedDoubleArray(int length, | 
| 
Michael Starzinger
2013/07/22 19:27:50
nit: Let's drop this empty new-line for consistenc
 
Hannes Payer (out of office)
2013/07/23 20:00:51
Done.
 | 
| AllocationSpace space = | 
| (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | 
| 
Michael Starzinger
2013/07/22 19:27:50
nit: Should fit into one line.
 
Hannes Payer (out of office)
2013/07/23 20:00:51
Done.
 | 
| + AllocationSpace retry_space = OLD_DATA_SPACE; | 
| + | 
| int size = FixedDoubleArray::SizeFor(length); | 
| 
Michael Starzinger
2013/07/22 19:27:50
nit: Let's move this line (i.e. the size calculati
 
Hannes Payer (out of office)
2013/07/23 20:00:51
Done.
 | 
| #ifndef V8_HOST_ARCH_64_BIT | 
| size += kPointerSize; | 
| #endif | 
| - if (space == NEW_SPACE && size > kMaxObjectSizeInNewSpace) { | 
| - // Too big for new space. | 
| - space = LO_SPACE; | 
| - } else if (space == OLD_DATA_SPACE && | 
| - size > Page::kMaxNonCodeHeapObjectSize) { | 
| - // Too big for old data space. | 
| + if (size > Page::kMaxNonCodeHeapObjectSize) { | 
| + // Allocate in large object space, retry space will be ignored. | 
| space = LO_SPACE; | 
| } | 
| - AllocationSpace retry_space = | 
| - (size <= Page::kMaxNonCodeHeapObjectSize) ? OLD_DATA_SPACE : LO_SPACE; | 
| - | 
| HeapObject* object; | 
| { MaybeObject* maybe_object = AllocateRaw(size, space, retry_space); | 
| if (!maybe_object->To<HeapObject>(&object)) return maybe_object; |