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

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

Issue 1891683002: Reland of "[heap] Better integrate handling of aborted compaction pages" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixed Created 4 years, 8 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
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 "test/cctest/cctest.h" 5 #include "test/cctest/cctest.h"
6 #include "test/cctest/heap/heap-tester.h" 6 #include "test/cctest/heap/heap-tester.h"
7 #include "test/cctest/heap/utils-inl.h" 7 #include "test/cctest/heap/utils-inl.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 CHECK(heap->old_space()->Expand()); 43 CHECK(heap->old_space()->Expand());
44 auto compaction_page_handles = 44 auto compaction_page_handles =
45 CreatePadding(heap, Page::kAllocatableMemory, TENURED); 45 CreatePadding(heap, Page::kAllocatableMemory, TENURED);
46 Page* to_be_aborted_page = 46 Page* to_be_aborted_page =
47 Page::FromAddress(compaction_page_handles.front()->address()); 47 Page::FromAddress(compaction_page_handles.front()->address());
48 to_be_aborted_page->SetFlag( 48 to_be_aborted_page->SetFlag(
49 MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); 49 MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING);
50 50
51 heap->set_force_oom(true); 51 heap->set_force_oom(true);
52 heap->CollectAllGarbage(); 52 heap->CollectAllGarbage();
53 heap->mark_compact_collector()->EnsureSweepingCompleted();
53 54
54 // Check that all handles still point to the same page, i.e., compaction 55 // Check that all handles still point to the same page, i.e., compaction
55 // has been aborted on the page. 56 // has been aborted on the page.
56 for (Handle<FixedArray> object : compaction_page_handles) { 57 for (Handle<FixedArray> object : compaction_page_handles) {
57 CHECK_EQ(to_be_aborted_page, Page::FromAddress(object->address())); 58 CHECK_EQ(to_be_aborted_page, Page::FromAddress(object->address()));
58 } 59 }
59 CheckInvariantsOfAbortedPage(to_be_aborted_page); 60 CheckInvariantsOfAbortedPage(to_be_aborted_page);
60 } 61 }
61 } 62 }
62 } 63 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 HandleScope scope3(isolate); 102 HandleScope scope3(isolate);
102 CHECK(heap->old_space()->Expand()); 103 CHECK(heap->old_space()->Expand());
103 const int num_objects = 3; 104 const int num_objects = 3;
104 std::vector<Handle<FixedArray>> page_to_fill_handles = CreatePadding( 105 std::vector<Handle<FixedArray>> page_to_fill_handles = CreatePadding(
105 heap, object_size * num_objects, TENURED, object_size); 106 heap, object_size * num_objects, TENURED, object_size);
106 Page* page_to_fill = 107 Page* page_to_fill =
107 Page::FromAddress(page_to_fill_handles.front()->address()); 108 Page::FromAddress(page_to_fill_handles.front()->address());
108 109
109 heap->set_force_oom(true); 110 heap->set_force_oom(true);
110 heap->CollectAllGarbage(); 111 heap->CollectAllGarbage();
112 heap->mark_compact_collector()->EnsureSweepingCompleted();
111 113
112 bool migration_aborted = false; 114 bool migration_aborted = false;
113 for (Handle<FixedArray> object : compaction_page_handles) { 115 for (Handle<FixedArray> object : compaction_page_handles) {
114 // Once compaction has been aborted, all following objects still have 116 // Once compaction has been aborted, all following objects still have
115 // to be on the initial page. 117 // to be on the initial page.
116 CHECK(!migration_aborted || 118 CHECK(!migration_aborted ||
117 (Page::FromAddress(object->address()) == to_be_aborted_page)); 119 (Page::FromAddress(object->address()) == to_be_aborted_page));
118 if (Page::FromAddress(object->address()) == to_be_aborted_page) { 120 if (Page::FromAddress(object->address()) == to_be_aborted_page) {
119 // This object has not been migrated. 121 // This object has not been migrated.
120 migration_aborted = true; 122 migration_aborted = true;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 CHECK(heap->old_space()->Expand()); 185 CHECK(heap->old_space()->Expand());
184 const int num_objects = 2; 186 const int num_objects = 2;
185 int used_memory = object_size * num_objects; 187 int used_memory = object_size * num_objects;
186 std::vector<Handle<FixedArray>> page_to_fill_handles = 188 std::vector<Handle<FixedArray>> page_to_fill_handles =
187 CreatePadding(heap, used_memory, TENURED, object_size); 189 CreatePadding(heap, used_memory, TENURED, object_size);
188 Page* page_to_fill = 190 Page* page_to_fill =
189 Page::FromAddress(page_to_fill_handles.front()->address()); 191 Page::FromAddress(page_to_fill_handles.front()->address());
190 192
191 heap->set_force_oom(true); 193 heap->set_force_oom(true);
192 heap->CollectAllGarbage(); 194 heap->CollectAllGarbage();
195 heap->mark_compact_collector()->EnsureSweepingCompleted();
193 196
194 // The following check makes sure that we compacted "some" objects, while 197 // The following check makes sure that we compacted "some" objects, while
195 // leaving others in place. 198 // leaving others in place.
196 bool in_place = true; 199 bool in_place = true;
197 Handle<FixedArray> current = root_array; 200 Handle<FixedArray> current = root_array;
198 while (current->get(0) != heap->undefined_value()) { 201 while (current->get(0) != heap->undefined_value()) {
199 current = Handle<FixedArray>(FixedArray::cast(current->get(0))); 202 current = Handle<FixedArray>(FixedArray::cast(current->get(0)));
200 CHECK(current->IsFixedArray()); 203 CHECK(current->IsFixedArray());
201 if (Page::FromAddress(current->address()) != to_be_aborted_page) { 204 if (Page::FromAddress(current->address()) != to_be_aborted_page) {
202 in_place = false; 205 in_place = false;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 CHECK(heap->old_space()->Expand()); 279 CHECK(heap->old_space()->Expand());
277 const int num_objects = 2; 280 const int num_objects = 2;
278 int used_memory = object_size * num_objects; 281 int used_memory = object_size * num_objects;
279 std::vector<Handle<FixedArray>> page_to_fill_handles = 282 std::vector<Handle<FixedArray>> page_to_fill_handles =
280 CreatePadding(heap, used_memory, TENURED, object_size); 283 CreatePadding(heap, used_memory, TENURED, object_size);
281 Page* page_to_fill = 284 Page* page_to_fill =
282 Page::FromAddress(page_to_fill_handles.front()->address()); 285 Page::FromAddress(page_to_fill_handles.front()->address());
283 286
284 heap->set_force_oom(true); 287 heap->set_force_oom(true);
285 heap->CollectAllGarbage(); 288 heap->CollectAllGarbage();
289 heap->mark_compact_collector()->EnsureSweepingCompleted();
286 290
287 // The following check makes sure that we compacted "some" objects, while 291 // The following check makes sure that we compacted "some" objects, while
288 // leaving others in place. 292 // leaving others in place.
289 bool in_place = true; 293 bool in_place = true;
290 Handle<FixedArray> current = root_array; 294 Handle<FixedArray> current = root_array;
291 while (current->get(0) != heap->undefined_value()) { 295 while (current->get(0) != heap->undefined_value()) {
292 current = Handle<FixedArray>(FixedArray::cast(current->get(0))); 296 current = Handle<FixedArray>(FixedArray::cast(current->get(0)));
293 CHECK(!heap->InNewSpace(*current)); 297 CHECK(!heap->InNewSpace(*current));
294 CHECK(current->IsFixedArray()); 298 CHECK(current->IsFixedArray());
295 if (Page::FromAddress(current->address()) != to_be_aborted_page) { 299 if (Page::FromAddress(current->address()) != to_be_aborted_page) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // If store buffer entries are not properly filtered/reset for aborted 335 // If store buffer entries are not properly filtered/reset for aborted
332 // pages we have now a broken address at an object slot in old space and 336 // pages we have now a broken address at an object slot in old space and
333 // the following scavenge will crash. 337 // the following scavenge will crash.
334 heap->CollectGarbage(NEW_SPACE); 338 heap->CollectGarbage(NEW_SPACE);
335 } 339 }
336 } 340 }
337 } 341 }
338 342
339 } // namespace internal 343 } // namespace internal
340 } // namespace v8 344 } // namespace v8
OLDNEW
« src/heap/mark-compact.cc ('K') | « src/heap/spaces-inl.h ('k') | tools/eval_gc_time.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698