Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: test/cctest/test-mark-compact.cc

Issue 42543008: Simplify test-mark-compact/NoPromotion test. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Minor fix. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 current_address -= kPointerSize; 66 current_address -= kPointerSize;
67 CHECK_EQ(current_address, value); 67 CHECK_EQ(current_address, value);
68 } 68 }
69 69
70 CHECK_EQ(original_address, current_address); 70 CHECK_EQ(original_address, current_address);
71 DeleteArray(mem); 71 DeleteArray(mem);
72 } 72 }
73 73
74 74
75 TEST(Promotion) { 75 TEST(Promotion) {
76 // This test requires compaction. If compaction is turned off, we
77 // skip the entire test.
78 if (FLAG_never_compact) return;
79
80 CcTest::InitializeVM(); 76 CcTest::InitializeVM();
81
82 // Ensure that we get a compacting collection so that objects are promoted
83 // from new space.
84 FLAG_gc_global = true;
85 FLAG_always_compact = true;
86 Heap* heap = CcTest::heap(); 77 Heap* heap = CcTest::heap();
87 heap->ConfigureHeap(2*256*KB, 8*MB, 8*MB); 78 heap->ConfigureHeap(2*256*KB, 1*MB, 1*MB);
88 79
89 v8::HandleScope sc(CcTest::isolate()); 80 v8::HandleScope sc(CcTest::isolate());
90 81
91 // Allocate a fixed array in the new space. 82 // Allocate a fixed array in the new space.
92 int array_size = 83 int array_length =
93 (Page::kMaxNonCodeHeapObjectSize - FixedArray::kHeaderSize) / 84 (Page::kMaxNonCodeHeapObjectSize - FixedArray::kHeaderSize) /
94 (kPointerSize * 4); 85 (4 * kPointerSize);
95 Object* obj = heap->AllocateFixedArray(array_size)->ToObjectChecked(); 86 Object* obj = heap->AllocateFixedArray(array_length)->ToObjectChecked();
96
97 Handle<FixedArray> array(FixedArray::cast(obj)); 87 Handle<FixedArray> array(FixedArray::cast(obj));
98 88
99 // Array should be in the new space. 89 // Array should be in the new space.
100 CHECK(heap->InSpace(*array, NEW_SPACE)); 90 CHECK(heap->InSpace(*array, NEW_SPACE));
101 91
102 // Call the m-c collector, so array becomes an old object. 92 // Call mark compact GC, so array becomes an old object.
103 heap->CollectGarbage(OLD_POINTER_SPACE); 93 heap->CollectGarbage(OLD_POINTER_SPACE);
104 94
105 // Array now sits in the old space 95 // Array now sits in the old space
106 CHECK(heap->InSpace(*array, OLD_POINTER_SPACE)); 96 CHECK(heap->InSpace(*array, OLD_POINTER_SPACE));
107 } 97 }
108 98
109 99
110 TEST(NoPromotion) { 100 TEST(NoPromotion) {
111 // Test the situation that some objects in new space are promoted to
112 // the old space
113 CcTest::InitializeVM(); 101 CcTest::InitializeVM();
114 102 Heap* heap = CcTest::heap();
115 CcTest::heap()->ConfigureHeap(2*256*KB, 8*MB, 8*MB); 103 heap->ConfigureHeap(2*256*KB, 1*MB, 1*MB);
116 104
117 v8::HandleScope sc(CcTest::isolate()); 105 v8::HandleScope sc(CcTest::isolate());
118 106
119 // Do a mark compact GC to shrink the heap. 107 // Allocate a big fixed array in the new space.
120 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); 108 int array_length =
121 109 (Page::kMaxNonCodeHeapObjectSize - FixedArray::kHeaderSize) /
122 // Allocate a big Fixed array in the new space. 110 (2 * kPointerSize);
123 int length = (Page::kMaxNonCodeHeapObjectSize - 111 Object* obj = heap->AllocateFixedArray(array_length)->ToObjectChecked();
124 FixedArray::kHeaderSize) / (2 * kPointerSize);
125 Object* obj = CcTest::heap()->AllocateFixedArray(length)->
126 ToObjectChecked();
127
128 Handle<FixedArray> array(FixedArray::cast(obj)); 112 Handle<FixedArray> array(FixedArray::cast(obj));
129 113
130 // Array still stays in the new space. 114 // Array should be in the new space.
131 CHECK(CcTest::heap()->InSpace(*array, NEW_SPACE)); 115 CHECK(heap->InSpace(*array, NEW_SPACE));
132 116
133 // Allocate objects in the old space until out of memory. 117 // Simulate a full old space to make promotion fail.
134 FixedArray* host = *array; 118 SimulateFullSpace(heap->old_pointer_space());
135 while (true) {
136 Object* obj;
137 { MaybeObject* maybe_obj = CcTest::heap()->AllocateFixedArray(100, TENURED);
138 if (!maybe_obj->ToObject(&obj)) break;
139 }
140
141 host->set(0, obj);
142 host = FixedArray::cast(obj);
143 }
144 119
145 // Call mark compact GC, and it should pass. 120 // Call mark compact GC, and it should pass.
146 CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); 121 heap->CollectGarbage(OLD_POINTER_SPACE);
147 } 122 }
148 123
149 124
150 TEST(MarkCompactCollector) { 125 TEST(MarkCompactCollector) {
151 FLAG_incremental_marking = false; 126 FLAG_incremental_marking = false;
152 CcTest::InitializeVM(); 127 CcTest::InitializeVM();
153 Isolate* isolate = CcTest::i_isolate(); 128 Isolate* isolate = CcTest::i_isolate();
154 Heap* heap = isolate->heap(); 129 Heap* heap = isolate->heap();
155 130
156 v8::HandleScope sc(CcTest::isolate()); 131 v8::HandleScope sc(CcTest::isolate());
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 525
551 526
552 TEST(RegressJoinThreadsOnIsolateDeinit) { 527 TEST(RegressJoinThreadsOnIsolateDeinit) {
553 intptr_t size_limit = ShortLivingIsolate() * 2; 528 intptr_t size_limit = ShortLivingIsolate() * 2;
554 for (int i = 0; i < 10; i++) { 529 for (int i = 0; i < 10; i++) {
555 CHECK_GT(size_limit, ShortLivingIsolate()); 530 CHECK_GT(size_limit, ShortLivingIsolate());
556 } 531 }
557 } 532 }
558 533
559 #endif // __linux__ and !USE_SIMULATOR 534 #endif // __linux__ and !USE_SIMULATOR
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698