Reviewers: Michael Starzinger,
Description:
Simplified large object allocation strategy.
BUG=
Please review this at https://codereview.chromium.org/19934006/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/arm/macro-assembler-arm.cc
M src/heap.h
M src/heap.cc
M src/ia32/macro-assembler-ia32.cc
M src/mips/macro-assembler-mips.cc
M src/x64/macro-assembler-x64.cc
M test/cctest/test-heap.cc
M test/cctest/test-mark-compact.cc
Index: src/arm/macro-assembler-arm.cc
diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc
index
4266d4186133c8c50dbf3675cca3282c1db5b1e5..306584f34839a4b383ba23c00313fe3e6b3b4ec6
100644
--- a/src/arm/macro-assembler-arm.cc
+++ b/src/arm/macro-assembler-arm.cc
@@ -1625,6 +1625,7 @@ void MacroAssembler::Allocate(int object_size,
Register scratch2,
Label* gc_required,
AllocationFlags flags) {
+ ASSERT(object_size < Page::kMaxNonCodeHeapObjectSize);
if (!FLAG_inline_new) {
if (emit_debug_code()) {
// Trash the registers to simulate an allocation failure.
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);
}
+ 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,
AllocationSpace space =
(pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE;
+ AllocationSpace retry_space = OLD_DATA_SPACE;
+
int size = FixedDoubleArray::SizeFor(length);
#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;
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
6b0236330f9c96185fa8d3cf8c61d379b8f081a2..4babcce0afd4b8188dcf50fa53a3260c41d92578
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -1716,8 +1716,6 @@ class Heap {
// we try to promote this object.
inline bool ShouldBePromoted(Address old_address, int object_size);
- int MaxObjectSizeInNewSpace() { return kMaxObjectSizeInNewSpace; }
-
void ClearJSFunctionResultCaches();
void ClearNormalizedMapCaches();
@@ -1966,12 +1964,6 @@ class Heap {
int scan_on_scavenge_pages_;
-#if V8_TARGET_ARCH_X64
- static const int kMaxObjectSizeInNewSpace = 1024*KB;
-#else
- static const int kMaxObjectSizeInNewSpace = 512*KB;
-#endif
-
NewSpace new_space_;
OldSpace* old_pointer_space_;
OldSpace* old_data_space_;
Index: src/ia32/macro-assembler-ia32.cc
diff --git a/src/ia32/macro-assembler-ia32.cc
b/src/ia32/macro-assembler-ia32.cc
index
b08ee92b1bf556a6a4d6d295f2443ab5d6d1ff3e..f6b92692cc56754df88090ee8d126d6faaedcbb2
100644
--- a/src/ia32/macro-assembler-ia32.cc
+++ b/src/ia32/macro-assembler-ia32.cc
@@ -1248,6 +1248,7 @@ void MacroAssembler::Allocate(int object_size,
Label* gc_required,
AllocationFlags flags) {
ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0);
+ ASSERT(object_size < Page::kMaxNonCodeHeapObjectSize);
if (!FLAG_inline_new) {
if (emit_debug_code()) {
// Trash the registers to simulate an allocation failure.
Index: src/mips/macro-assembler-mips.cc
diff --git a/src/mips/macro-assembler-mips.cc
b/src/mips/macro-assembler-mips.cc
index
26e8f2110986a2c98d3ab7dc7ff0b687e732efc7..ba5f353e144f6840fa22922c36fced736ecb7b35
100644
--- a/src/mips/macro-assembler-mips.cc
+++ b/src/mips/macro-assembler-mips.cc
@@ -2882,6 +2882,7 @@ void MacroAssembler::Allocate(int object_size,
Register scratch2,
Label* gc_required,
AllocationFlags flags) {
+ ASSERT(object_size < Page::kMaxNonCodeHeapObjectSize);
if (!FLAG_inline_new) {
if (emit_debug_code()) {
// Trash the registers to simulate an allocation failure.
Index: src/x64/macro-assembler-x64.cc
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index
53dedda7ac7212ea282d8e731107e82db1870804..127c64d2ec5d040dc4ab3b76375f7d4968682e80
100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -3838,6 +3838,7 @@ void MacroAssembler::Allocate(int object_size,
Label* gc_required,
AllocationFlags flags) {
ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0);
+ ASSERT(object_size < Page::kMaxNonCodeHeapObjectSize);
if (!FLAG_inline_new) {
if (emit_debug_code()) {
// Trash the registers to simulate an allocation failure.
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index
d2b915690e2bb03e1c5b0ee4af0fc5271eb0371a..a55238b8204c97d56b9e950abfa282bf7acfe052
100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -984,7 +984,7 @@ TEST(Regression39128) {
// just enough room to allocate JSObject and thus fill the newspace.
int allocation_amount = Min(FixedArray::kMaxSize,
- HEAP->MaxObjectSizeInNewSpace());
+ Page::kMaxNonCodeHeapObjectSize);
int allocation_len = LenFromSize(allocation_amount);
NewSpace* new_space = HEAP->new_space();
Address* top_addr = new_space->allocation_top_address();
Index: test/cctest/test-mark-compact.cc
diff --git a/test/cctest/test-mark-compact.cc
b/test/cctest/test-mark-compact.cc
index
626df16617128ca371283b4657d97e2fe4a407d3..ba487d50c6d03b9d368141b91e88bf5ef091bf65
100644
--- a/test/cctest/test-mark-compact.cc
+++ b/test/cctest/test-mark-compact.cc
@@ -120,7 +120,7 @@ TEST(NoPromotion) {
// Allocate a big Fixed array in the new space.
int max_size =
- Min(Page::kMaxNonCodeHeapObjectSize,
HEAP->MaxObjectSizeInNewSpace());
+ Min(Page::kMaxNonCodeHeapObjectSize,
Page::kMaxNonCodeHeapObjectSize);
int length = (max_size - FixedArray::kHeaderSize) / (2*kPointerSize);
Object* obj = i::Isolate::Current()->heap()->AllocateFixedArray(length)->
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.