| OLD | NEW |
| 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 Loading... |
| 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(); | |
| 54 | 53 |
| 55 // Check that all handles still point to the same page, i.e., compaction | 54 // Check that all handles still point to the same page, i.e., compaction |
| 56 // has been aborted on the page. | 55 // has been aborted on the page. |
| 57 for (Handle<FixedArray> object : compaction_page_handles) { | 56 for (Handle<FixedArray> object : compaction_page_handles) { |
| 58 CHECK_EQ(to_be_aborted_page, Page::FromAddress(object->address())); | 57 CHECK_EQ(to_be_aborted_page, Page::FromAddress(object->address())); |
| 59 } | 58 } |
| 60 CheckInvariantsOfAbortedPage(to_be_aborted_page); | 59 CheckInvariantsOfAbortedPage(to_be_aborted_page); |
| 61 } | 60 } |
| 62 } | 61 } |
| 63 } | 62 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 HandleScope scope3(isolate); | 101 HandleScope scope3(isolate); |
| 103 CHECK(heap->old_space()->Expand()); | 102 CHECK(heap->old_space()->Expand()); |
| 104 const int num_objects = 3; | 103 const int num_objects = 3; |
| 105 std::vector<Handle<FixedArray>> page_to_fill_handles = CreatePadding( | 104 std::vector<Handle<FixedArray>> page_to_fill_handles = CreatePadding( |
| 106 heap, object_size * num_objects, TENURED, object_size); | 105 heap, object_size * num_objects, TENURED, object_size); |
| 107 Page* page_to_fill = | 106 Page* page_to_fill = |
| 108 Page::FromAddress(page_to_fill_handles.front()->address()); | 107 Page::FromAddress(page_to_fill_handles.front()->address()); |
| 109 | 108 |
| 110 heap->set_force_oom(true); | 109 heap->set_force_oom(true); |
| 111 heap->CollectAllGarbage(); | 110 heap->CollectAllGarbage(); |
| 112 heap->mark_compact_collector()->EnsureSweepingCompleted(); | |
| 113 | 111 |
| 114 bool migration_aborted = false; | 112 bool migration_aborted = false; |
| 115 for (Handle<FixedArray> object : compaction_page_handles) { | 113 for (Handle<FixedArray> object : compaction_page_handles) { |
| 116 // Once compaction has been aborted, all following objects still have | 114 // Once compaction has been aborted, all following objects still have |
| 117 // to be on the initial page. | 115 // to be on the initial page. |
| 118 CHECK(!migration_aborted || | 116 CHECK(!migration_aborted || |
| 119 (Page::FromAddress(object->address()) == to_be_aborted_page)); | 117 (Page::FromAddress(object->address()) == to_be_aborted_page)); |
| 120 if (Page::FromAddress(object->address()) == to_be_aborted_page) { | 118 if (Page::FromAddress(object->address()) == to_be_aborted_page) { |
| 121 // This object has not been migrated. | 119 // This object has not been migrated. |
| 122 migration_aborted = true; | 120 migration_aborted = true; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 CHECK(heap->old_space()->Expand()); | 183 CHECK(heap->old_space()->Expand()); |
| 186 const int num_objects = 2; | 184 const int num_objects = 2; |
| 187 int used_memory = object_size * num_objects; | 185 int used_memory = object_size * num_objects; |
| 188 std::vector<Handle<FixedArray>> page_to_fill_handles = | 186 std::vector<Handle<FixedArray>> page_to_fill_handles = |
| 189 CreatePadding(heap, used_memory, TENURED, object_size); | 187 CreatePadding(heap, used_memory, TENURED, object_size); |
| 190 Page* page_to_fill = | 188 Page* page_to_fill = |
| 191 Page::FromAddress(page_to_fill_handles.front()->address()); | 189 Page::FromAddress(page_to_fill_handles.front()->address()); |
| 192 | 190 |
| 193 heap->set_force_oom(true); | 191 heap->set_force_oom(true); |
| 194 heap->CollectAllGarbage(); | 192 heap->CollectAllGarbage(); |
| 195 heap->mark_compact_collector()->EnsureSweepingCompleted(); | |
| 196 | 193 |
| 197 // The following check makes sure that we compacted "some" objects, while | 194 // The following check makes sure that we compacted "some" objects, while |
| 198 // leaving others in place. | 195 // leaving others in place. |
| 199 bool in_place = true; | 196 bool in_place = true; |
| 200 Handle<FixedArray> current = root_array; | 197 Handle<FixedArray> current = root_array; |
| 201 while (current->get(0) != heap->undefined_value()) { | 198 while (current->get(0) != heap->undefined_value()) { |
| 202 current = Handle<FixedArray>(FixedArray::cast(current->get(0))); | 199 current = Handle<FixedArray>(FixedArray::cast(current->get(0))); |
| 203 CHECK(current->IsFixedArray()); | 200 CHECK(current->IsFixedArray()); |
| 204 if (Page::FromAddress(current->address()) != to_be_aborted_page) { | 201 if (Page::FromAddress(current->address()) != to_be_aborted_page) { |
| 205 in_place = false; | 202 in_place = false; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 CHECK(heap->old_space()->Expand()); | 276 CHECK(heap->old_space()->Expand()); |
| 280 const int num_objects = 2; | 277 const int num_objects = 2; |
| 281 int used_memory = object_size * num_objects; | 278 int used_memory = object_size * num_objects; |
| 282 std::vector<Handle<FixedArray>> page_to_fill_handles = | 279 std::vector<Handle<FixedArray>> page_to_fill_handles = |
| 283 CreatePadding(heap, used_memory, TENURED, object_size); | 280 CreatePadding(heap, used_memory, TENURED, object_size); |
| 284 Page* page_to_fill = | 281 Page* page_to_fill = |
| 285 Page::FromAddress(page_to_fill_handles.front()->address()); | 282 Page::FromAddress(page_to_fill_handles.front()->address()); |
| 286 | 283 |
| 287 heap->set_force_oom(true); | 284 heap->set_force_oom(true); |
| 288 heap->CollectAllGarbage(); | 285 heap->CollectAllGarbage(); |
| 289 heap->mark_compact_collector()->EnsureSweepingCompleted(); | |
| 290 | 286 |
| 291 // The following check makes sure that we compacted "some" objects, while | 287 // The following check makes sure that we compacted "some" objects, while |
| 292 // leaving others in place. | 288 // leaving others in place. |
| 293 bool in_place = true; | 289 bool in_place = true; |
| 294 Handle<FixedArray> current = root_array; | 290 Handle<FixedArray> current = root_array; |
| 295 while (current->get(0) != heap->undefined_value()) { | 291 while (current->get(0) != heap->undefined_value()) { |
| 296 current = Handle<FixedArray>(FixedArray::cast(current->get(0))); | 292 current = Handle<FixedArray>(FixedArray::cast(current->get(0))); |
| 297 CHECK(!heap->InNewSpace(*current)); | 293 CHECK(!heap->InNewSpace(*current)); |
| 298 CHECK(current->IsFixedArray()); | 294 CHECK(current->IsFixedArray()); |
| 299 if (Page::FromAddress(current->address()) != to_be_aborted_page) { | 295 if (Page::FromAddress(current->address()) != to_be_aborted_page) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 // If store buffer entries are not properly filtered/reset for aborted | 331 // If store buffer entries are not properly filtered/reset for aborted |
| 336 // pages we have now a broken address at an object slot in old space and | 332 // pages we have now a broken address at an object slot in old space and |
| 337 // the following scavenge will crash. | 333 // the following scavenge will crash. |
| 338 heap->CollectGarbage(NEW_SPACE); | 334 heap->CollectGarbage(NEW_SPACE); |
| 339 } | 335 } |
| 340 } | 336 } |
| 341 } | 337 } |
| 342 | 338 |
| 343 } // namespace internal | 339 } // namespace internal |
| 344 } // namespace v8 | 340 } // namespace v8 |
| OLD | NEW |