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

Side by Side Diff: test/cctest/heap/test-compaction.cc

Issue 2310143002: [heap] Introduce enum of garbage collection reasons. (Closed)
Patch Set: rebase Created 4 years, 3 months 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
« no previous file with comments | « test/cctest/heap/test-array-buffer-tracker.cc ('k') | test/cctest/heap/test-heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/factory.h" 5 #include "src/factory.h"
6 #include "src/heap/mark-compact.h" 6 #include "src/heap/mark-compact.h"
7 #include "src/isolate.h" 7 #include "src/isolate.h"
8 // FIXME(mstarzinger, marja): This is weird, but required because of the missing 8 // FIXME(mstarzinger, marja): This is weird, but required because of the missing
9 // (disallowed) include: src/factory.h -> src/objects-inl.h 9 // (disallowed) include: src/factory.h -> src/objects-inl.h
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 CHECK(heap->old_space()->Expand()); 61 CHECK(heap->old_space()->Expand());
62 auto compaction_page_handles = 62 auto compaction_page_handles =
63 heap::CreatePadding(heap, Page::kAllocatableMemory, TENURED); 63 heap::CreatePadding(heap, Page::kAllocatableMemory, TENURED);
64 Page* to_be_aborted_page = 64 Page* to_be_aborted_page =
65 Page::FromAddress(compaction_page_handles.front()->address()); 65 Page::FromAddress(compaction_page_handles.front()->address());
66 to_be_aborted_page->SetFlag( 66 to_be_aborted_page->SetFlag(
67 MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); 67 MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING);
68 CheckAllObjectsOnPage(compaction_page_handles, to_be_aborted_page); 68 CheckAllObjectsOnPage(compaction_page_handles, to_be_aborted_page);
69 69
70 heap->set_force_oom(true); 70 heap->set_force_oom(true);
71 heap->CollectAllGarbage(); 71 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
72 heap->mark_compact_collector()->EnsureSweepingCompleted(); 72 heap->mark_compact_collector()->EnsureSweepingCompleted();
73 73
74 // Check that all handles still point to the same page, i.e., compaction 74 // Check that all handles still point to the same page, i.e., compaction
75 // has been aborted on the page. 75 // has been aborted on the page.
76 for (Handle<FixedArray> object : compaction_page_handles) { 76 for (Handle<FixedArray> object : compaction_page_handles) {
77 CHECK_EQ(to_be_aborted_page, Page::FromAddress(object->address())); 77 CHECK_EQ(to_be_aborted_page, Page::FromAddress(object->address()));
78 } 78 }
79 CheckInvariantsOfAbortedPage(to_be_aborted_page); 79 CheckInvariantsOfAbortedPage(to_be_aborted_page);
80 } 80 }
81 } 81 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 HandleScope scope3(isolate); 121 HandleScope scope3(isolate);
122 CHECK(heap->old_space()->Expand()); 122 CHECK(heap->old_space()->Expand());
123 const int num_objects = 3; 123 const int num_objects = 3;
124 std::vector<Handle<FixedArray>> page_to_fill_handles = 124 std::vector<Handle<FixedArray>> page_to_fill_handles =
125 heap::CreatePadding(heap, object_size * num_objects, TENURED, 125 heap::CreatePadding(heap, object_size * num_objects, TENURED,
126 object_size); 126 object_size);
127 Page* page_to_fill = 127 Page* page_to_fill =
128 Page::FromAddress(page_to_fill_handles.front()->address()); 128 Page::FromAddress(page_to_fill_handles.front()->address());
129 129
130 heap->set_force_oom(true); 130 heap->set_force_oom(true);
131 heap->CollectAllGarbage(); 131 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
132 heap->mark_compact_collector()->EnsureSweepingCompleted(); 132 heap->mark_compact_collector()->EnsureSweepingCompleted();
133 133
134 bool migration_aborted = false; 134 bool migration_aborted = false;
135 for (Handle<FixedArray> object : compaction_page_handles) { 135 for (Handle<FixedArray> object : compaction_page_handles) {
136 // Once compaction has been aborted, all following objects still have 136 // Once compaction has been aborted, all following objects still have
137 // to be on the initial page. 137 // to be on the initial page.
138 CHECK(!migration_aborted || 138 CHECK(!migration_aborted ||
139 (Page::FromAddress(object->address()) == to_be_aborted_page)); 139 (Page::FromAddress(object->address()) == to_be_aborted_page));
140 if (Page::FromAddress(object->address()) == to_be_aborted_page) { 140 if (Page::FromAddress(object->address()) == to_be_aborted_page) {
141 // This object has not been migrated. 141 // This object has not been migrated.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 HandleScope scope3(isolate); 203 HandleScope scope3(isolate);
204 CHECK(heap->old_space()->Expand()); 204 CHECK(heap->old_space()->Expand());
205 const int num_objects = 2; 205 const int num_objects = 2;
206 int used_memory = object_size * num_objects; 206 int used_memory = object_size * num_objects;
207 std::vector<Handle<FixedArray>> page_to_fill_handles = 207 std::vector<Handle<FixedArray>> page_to_fill_handles =
208 heap::CreatePadding(heap, used_memory, TENURED, object_size); 208 heap::CreatePadding(heap, used_memory, TENURED, object_size);
209 Page* page_to_fill = 209 Page* page_to_fill =
210 Page::FromAddress(page_to_fill_handles.front()->address()); 210 Page::FromAddress(page_to_fill_handles.front()->address());
211 211
212 heap->set_force_oom(true); 212 heap->set_force_oom(true);
213 heap->CollectAllGarbage(); 213 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
214 heap->mark_compact_collector()->EnsureSweepingCompleted(); 214 heap->mark_compact_collector()->EnsureSweepingCompleted();
215 215
216 // The following check makes sure that we compacted "some" objects, while 216 // The following check makes sure that we compacted "some" objects, while
217 // leaving others in place. 217 // leaving others in place.
218 bool in_place = true; 218 bool in_place = true;
219 Handle<FixedArray> current = root_array; 219 Handle<FixedArray> current = root_array;
220 while (current->get(0) != heap->undefined_value()) { 220 while (current->get(0) != heap->undefined_value()) {
221 current = Handle<FixedArray>(FixedArray::cast(current->get(0))); 221 current = Handle<FixedArray>(FixedArray::cast(current->get(0)));
222 CHECK(current->IsFixedArray()); 222 CHECK(current->IsFixedArray());
223 if (Page::FromAddress(current->address()) != to_be_aborted_page) { 223 if (Page::FromAddress(current->address()) != to_be_aborted_page) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 HandleScope scope3(isolate); 296 HandleScope scope3(isolate);
297 CHECK(heap->old_space()->Expand()); 297 CHECK(heap->old_space()->Expand());
298 const int num_objects = 2; 298 const int num_objects = 2;
299 int used_memory = object_size * num_objects; 299 int used_memory = object_size * num_objects;
300 std::vector<Handle<FixedArray>> page_to_fill_handles = 300 std::vector<Handle<FixedArray>> page_to_fill_handles =
301 heap::CreatePadding(heap, used_memory, TENURED, object_size); 301 heap::CreatePadding(heap, used_memory, TENURED, object_size);
302 Page* page_to_fill = 302 Page* page_to_fill =
303 Page::FromAddress(page_to_fill_handles.front()->address()); 303 Page::FromAddress(page_to_fill_handles.front()->address());
304 304
305 heap->set_force_oom(true); 305 heap->set_force_oom(true);
306 heap->CollectAllGarbage(); 306 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask);
307 heap->mark_compact_collector()->EnsureSweepingCompleted(); 307 heap->mark_compact_collector()->EnsureSweepingCompleted();
308 308
309 // The following check makes sure that we compacted "some" objects, while 309 // The following check makes sure that we compacted "some" objects, while
310 // leaving others in place. 310 // leaving others in place.
311 bool in_place = true; 311 bool in_place = true;
312 Handle<FixedArray> current = root_array; 312 Handle<FixedArray> current = root_array;
313 while (current->get(0) != heap->undefined_value()) { 313 while (current->get(0) != heap->undefined_value()) {
314 current = Handle<FixedArray>(FixedArray::cast(current->get(0))); 314 current = Handle<FixedArray>(FixedArray::cast(current->get(0)));
315 CHECK(!heap->InNewSpace(*current)); 315 CHECK(!heap->InNewSpace(*current));
316 CHECK(current->IsFixedArray()); 316 CHECK(current->IsFixedArray());
(...skipping 29 matching lines...) Expand all
346 // the first word in the string. Since the first object definitely 346 // the first word in the string. Since the first object definitely
347 // migrated we can just allocate until we hit the aborted page. 347 // migrated we can just allocate until we hit the aborted page.
348 string = isolate->factory() 348 string = isolate->factory()
349 ->NewStringFromOneByte(string_to_broken_addresss, TENURED) 349 ->NewStringFromOneByte(string_to_broken_addresss, TENURED)
350 .ToHandleChecked(); 350 .ToHandleChecked();
351 } while (Page::FromAddress(string->address()) != to_be_aborted_page); 351 } while (Page::FromAddress(string->address()) != to_be_aborted_page);
352 352
353 // If store buffer entries are not properly filtered/reset for aborted 353 // If store buffer entries are not properly filtered/reset for aborted
354 // pages we have now a broken address at an object slot in old space and 354 // pages we have now a broken address at an object slot in old space and
355 // the following scavenge will crash. 355 // the following scavenge will crash.
356 heap->CollectGarbage(NEW_SPACE); 356 CcTest::CollectGarbage(NEW_SPACE);
357 } 357 }
358 } 358 }
359 } 359 }
360 360
361 } // namespace internal 361 } // namespace internal
362 } // namespace v8 362 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/heap/test-array-buffer-tracker.cc ('k') | test/cctest/heap/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698