Index: test/cctest/test-heap.cc |
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc |
index add16ad9c45bcb852656bcf5a9a3a35aed1446bb..8204b0fb5ab1fd334beebf9dbfca9bd6a6bb1122 100644 |
--- a/test/cctest/test-heap.cc |
+++ b/test/cctest/test-heap.cc |
@@ -5529,8 +5529,8 @@ TEST(ArrayShiftSweeping) { |
Heap* heap = isolate->heap(); |
v8::Local<v8::Value> result = CompileRun( |
- "var array = new Array(40000);" |
- "var tmp = new Array(100000);" |
+ "var array = new Array(400);" |
+ "var tmp = new Array(1000);" |
"array[0] = 10;" |
"gc();" |
"gc();" |
@@ -5609,26 +5609,46 @@ UNINITIALIZED_TEST(PromotionQueue) { |
} |
heap->CollectGarbage(NEW_SPACE); |
- // Create the first huge object which will exactly fit the first semi-space |
- // page. |
- int new_linear_size = |
+ // Create many big objects to fill up the first semi-space page. |
Michael Lippautz
2015/09/30 14:14:24
Can't you use your CreatePadding() function here?
Hannes Payer (out of office)
2015/10/05 13:13:10
Done.
|
+ int free_memory = |
static_cast<int>(*heap->new_space()->allocation_limit_address() - |
*heap->new_space()->allocation_top_address()); |
- int length = new_linear_size / kPointerSize - FixedArray::kHeaderSize; |
- Handle<FixedArray> first = |
- i_isolate->factory()->NewFixedArray(length, NOT_TENURED); |
- CHECK(heap->InNewSpace(*first)); |
- |
- // Create the second huge object of maximum allocatable second semi-space |
- // page size. |
- new_linear_size = |
+ const int max_number_of_objects = 20; |
+ Handle<FixedArray> big_objects_1[max_number_of_objects]; |
+ int allocate_memory; |
+ int length; |
+ for (int i = 0; i < max_number_of_objects && free_memory > 0; i++) { |
+ if (free_memory > Page::kMaxRegularHeapObjectSize) { |
+ allocate_memory = Page::kMaxRegularHeapObjectSize; |
+ } else { |
+ allocate_memory = free_memory; |
+ } |
+ length = (allocate_memory - FixedArray::kHeaderSize) / kPointerSize; |
+ DCHECK(length > 0); |
+ big_objects_1[i] = |
+ i_isolate->factory()->NewFixedArray(length, NOT_TENURED); |
+ CHECK(heap->InNewSpace(*big_objects_1[i])); |
+ free_memory -= allocate_memory; |
+ } |
+ |
+ // Create again big objects to fill up the next semi-space page. |
+ free_memory = |
static_cast<int>(*heap->new_space()->allocation_limit_address() - |
*heap->new_space()->allocation_top_address()); |
- length = Page::kMaxRegularHeapObjectSize / kPointerSize - |
- FixedArray::kHeaderSize; |
- Handle<FixedArray> second = |
- i_isolate->factory()->NewFixedArray(length, NOT_TENURED); |
- CHECK(heap->InNewSpace(*second)); |
+ Handle<FixedArray> big_objects_2[max_number_of_objects]; |
+ for (int i = 0; i < max_number_of_objects && free_memory > 0; i++) { |
+ if (free_memory > Page::kMaxRegularHeapObjectSize) { |
+ allocate_memory = Page::kMaxRegularHeapObjectSize; |
+ } else { |
+ allocate_memory = free_memory; |
+ } |
+ length = (allocate_memory - FixedArray::kHeaderSize) / kPointerSize; |
+ DCHECK(length > 0); |
+ big_objects_2[i] = |
+ i_isolate->factory()->NewFixedArray(length, NOT_TENURED); |
+ CHECK(heap->InNewSpace(*big_objects_2[i])); |
+ free_memory -= allocate_memory; |
+ } |
// This scavenge will corrupt memory if the promotion queue is not |
// evacuated. |
@@ -5654,19 +5674,11 @@ TEST(Regress388880) { |
int desired_offset = Page::kPageSize - map1->instance_size(); |
- // Allocate fixed array in old pointer space so, that object allocated |
+ // Allocate padding objects in old pointer space so, that object allocated |
// afterwards would end at the end of the page. |
- { |
- SimulateFullSpace(heap->old_space()); |
- int padding_size = desired_offset - Page::kObjectStartOffset; |
- int padding_array_length = |
- (padding_size - FixedArray::kHeaderSize) / kPointerSize; |
- |
- Handle<FixedArray> temp2 = |
- factory->NewFixedArray(padding_array_length, TENURED); |
- Page* page = Page::FromAddress(temp2->address()); |
- CHECK_EQ(Page::kObjectStartOffset, page->Offset(temp2->address())); |
- } |
+ SimulateFullSpace(heap->old_space()); |
+ int padding_size = desired_offset - Page::kObjectStartOffset; |
+ CreatePadding(heap, padding_size, TENURED); |
Handle<JSObject> o = factory->NewJSObjectFromMap(map1, TENURED); |
o->set_properties(*factory->empty_fixed_array()); |