| Index: test/cctest/heap/test-compaction.cc | 
| diff --git a/test/cctest/heap/test-compaction.cc b/test/cctest/heap/test-compaction.cc | 
| index b787780d25dd7bb8c7a3840d238a35b307882c31..f61f7e1c41b8cba310f0aa610402017b6df50630 100644 | 
| --- a/test/cctest/heap/test-compaction.cc | 
| +++ b/test/cctest/heap/test-compaction.cc | 
| @@ -4,12 +4,14 @@ | 
|  | 
| #include "test/cctest/cctest.h" | 
| #include "test/cctest/heap/heap-tester.h" | 
| -#include "test/cctest/heap/utils-inl.h" | 
| +#include "test/cctest/heap/heap-utils.h" | 
|  | 
| namespace v8 { | 
| namespace internal { | 
|  | 
| -static void CheckInvariantsOfAbortedPage(Page* page) { | 
| +namespace { | 
| + | 
| +void CheckInvariantsOfAbortedPage(Page* page) { | 
| // Check invariants: | 
| // 1) Markbits are cleared | 
| // 2) The page is not marked as evacuation candidate anymore | 
| @@ -19,6 +21,14 @@ static void CheckInvariantsOfAbortedPage(Page* page) { | 
| CHECK(!page->IsFlagSet(Page::COMPACTION_WAS_ABORTED)); | 
| } | 
|  | 
| +void CheckAllObjectsOnPage(std::vector<Handle<FixedArray>>& handles, | 
| +                           Page* page) { | 
| +  for (auto& fixed_array : handles) { | 
| +    CHECK(Page::FromAddress(fixed_array->address()) == page); | 
| +  } | 
| +} | 
| + | 
| +}  // namespace | 
|  | 
| HEAP_TEST(CompactionFullAbortedPage) { | 
| // Test the scenario where we reach OOM during compaction and the whole page | 
| @@ -33,20 +43,19 @@ HEAP_TEST(CompactionFullAbortedPage) { | 
| Heap* heap = isolate->heap(); | 
| { | 
| HandleScope scope1(isolate); | 
| -    PageIterator it(heap->old_space()); | 
| -    while (it.has_next()) { | 
| -      it.next()->MarkNeverAllocateForTesting(); | 
| -    } | 
| + | 
| +    heap::SealCurrentObjects(heap); | 
|  | 
| { | 
| HandleScope scope2(isolate); | 
| CHECK(heap->old_space()->Expand()); | 
| auto compaction_page_handles = | 
| -          CreatePadding(heap, Page::kAllocatableMemory, TENURED); | 
| +          heap::CreatePadding(heap, Page::kAllocatableMemory, TENURED); | 
| Page* to_be_aborted_page = | 
| Page::FromAddress(compaction_page_handles.front()->address()); | 
| to_be_aborted_page->SetFlag( | 
| MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); | 
| +      CheckAllObjectsOnPage(compaction_page_handles, to_be_aborted_page); | 
|  | 
| heap->set_force_oom(true); | 
| heap->CollectAllGarbage(); | 
| @@ -72,29 +81,29 @@ HEAP_TEST(CompactionPartiallyAbortedPage) { | 
| FLAG_concurrent_sweeping = false; | 
| FLAG_manual_evacuation_candidates_selection = true; | 
|  | 
| -  const int object_size = 128 * KB; | 
| +  const int objects_per_page = 10; | 
| +  const int object_size = Page::kAllocatableMemory / objects_per_page; | 
|  | 
| CcTest::InitializeVM(); | 
| Isolate* isolate = CcTest::i_isolate(); | 
| Heap* heap = isolate->heap(); | 
| { | 
| HandleScope scope1(isolate); | 
| -    PageIterator it(heap->old_space()); | 
| -    while (it.has_next()) { | 
| -      it.next()->MarkNeverAllocateForTesting(); | 
| -    } | 
| + | 
| +    heap::SealCurrentObjects(heap); | 
|  | 
| { | 
| HandleScope scope2(isolate); | 
| // Fill another page with objects of size {object_size} (last one is | 
| // properly adjusted). | 
| CHECK(heap->old_space()->Expand()); | 
| -      auto compaction_page_handles = | 
| -          CreatePadding(heap, Page::kAllocatableMemory, TENURED, object_size); | 
| +      auto compaction_page_handles = heap::CreatePadding( | 
| +          heap, Page::kAllocatableMemory, TENURED, object_size); | 
| Page* to_be_aborted_page = | 
| Page::FromAddress(compaction_page_handles.front()->address()); | 
| to_be_aborted_page->SetFlag( | 
| MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); | 
| +      CheckAllObjectsOnPage(compaction_page_handles, to_be_aborted_page); | 
|  | 
| { | 
| // Add another page that is filled with {num_objects} objects of size | 
| @@ -102,8 +111,9 @@ HEAP_TEST(CompactionPartiallyAbortedPage) { | 
| HandleScope scope3(isolate); | 
| CHECK(heap->old_space()->Expand()); | 
| const int num_objects = 3; | 
| -        std::vector<Handle<FixedArray>> page_to_fill_handles = CreatePadding( | 
| -            heap, object_size * num_objects, TENURED, object_size); | 
| +        std::vector<Handle<FixedArray>> page_to_fill_handles = | 
| +            heap::CreatePadding(heap, object_size * num_objects, TENURED, | 
| +                                object_size); | 
| Page* page_to_fill = | 
| Page::FromAddress(page_to_fill_handles.front()->address()); | 
|  | 
| @@ -145,7 +155,8 @@ HEAP_TEST(CompactionPartiallyAbortedPageIntraAbortedPointers) { | 
| FLAG_concurrent_sweeping = false; | 
| FLAG_manual_evacuation_candidates_selection = true; | 
|  | 
| -  const int object_size = 128 * KB; | 
| +  const int objects_per_page = 10; | 
| +  const int object_size = Page::kAllocatableMemory / objects_per_page; | 
|  | 
| CcTest::InitializeVM(); | 
| Isolate* isolate = CcTest::i_isolate(); | 
| @@ -155,10 +166,7 @@ HEAP_TEST(CompactionPartiallyAbortedPageIntraAbortedPointers) { | 
| Handle<FixedArray> root_array = | 
| isolate->factory()->NewFixedArray(10, TENURED); | 
|  | 
| -    PageIterator it(heap->old_space()); | 
| -    while (it.has_next()) { | 
| -      it.next()->MarkNeverAllocateForTesting(); | 
| -    } | 
| +    heap::SealCurrentObjects(heap); | 
|  | 
| Page* to_be_aborted_page = nullptr; | 
| { | 
| @@ -167,7 +175,8 @@ HEAP_TEST(CompactionPartiallyAbortedPageIntraAbortedPointers) { | 
| // properly adjusted). | 
| CHECK(heap->old_space()->Expand()); | 
| std::vector<Handle<FixedArray>> compaction_page_handles = | 
| -          CreatePadding(heap, Page::kAllocatableMemory, TENURED, object_size); | 
| +          heap::CreatePadding(heap, Page::kAllocatableMemory, TENURED, | 
| +                              object_size); | 
| to_be_aborted_page = | 
| Page::FromAddress(compaction_page_handles.front()->address()); | 
| to_be_aborted_page->SetFlag( | 
| @@ -176,8 +185,8 @@ HEAP_TEST(CompactionPartiallyAbortedPageIntraAbortedPointers) { | 
| compaction_page_handles[i]->set(0, *compaction_page_handles[i - 1]); | 
| } | 
| root_array->set(0, *compaction_page_handles.back()); | 
| +      CheckAllObjectsOnPage(compaction_page_handles, to_be_aborted_page); | 
| } | 
| - | 
| { | 
| // Add another page that is filled with {num_objects} objects of size | 
| // {object_size}. | 
| @@ -186,7 +195,7 @@ HEAP_TEST(CompactionPartiallyAbortedPageIntraAbortedPointers) { | 
| const int num_objects = 2; | 
| int used_memory = object_size * num_objects; | 
| std::vector<Handle<FixedArray>> page_to_fill_handles = | 
| -          CreatePadding(heap, used_memory, TENURED, object_size); | 
| +          heap::CreatePadding(heap, used_memory, TENURED, object_size); | 
| Page* page_to_fill = | 
| Page::FromAddress(page_to_fill_handles.front()->address()); | 
|  | 
| @@ -233,7 +242,8 @@ HEAP_TEST(CompactionPartiallyAbortedPageWithStoreBufferEntries) { | 
| FLAG_concurrent_sweeping = false; | 
| FLAG_manual_evacuation_candidates_selection = true; | 
|  | 
| -  const int object_size = 128 * KB; | 
| +  const int objects_per_page = 10; | 
| +  const int object_size = Page::kAllocatableMemory / objects_per_page; | 
|  | 
| CcTest::InitializeVM(); | 
| Isolate* isolate = CcTest::i_isolate(); | 
| @@ -242,10 +252,7 @@ HEAP_TEST(CompactionPartiallyAbortedPageWithStoreBufferEntries) { | 
| HandleScope scope1(isolate); | 
| Handle<FixedArray> root_array = | 
| isolate->factory()->NewFixedArray(10, TENURED); | 
| -    PageIterator it(heap->old_space()); | 
| -    while (it.has_next()) { | 
| -      it.next()->MarkNeverAllocateForTesting(); | 
| -    } | 
| +    heap::SealCurrentObjects(heap); | 
|  | 
| Page* to_be_aborted_page = nullptr; | 
| { | 
| @@ -253,8 +260,8 @@ HEAP_TEST(CompactionPartiallyAbortedPageWithStoreBufferEntries) { | 
| // Fill another page with objects of size {object_size} (last one is | 
| // properly adjusted). | 
| CHECK(heap->old_space()->Expand()); | 
| -      auto compaction_page_handles = | 
| -          CreatePadding(heap, Page::kAllocatableMemory, TENURED, object_size); | 
| +      auto compaction_page_handles = heap::CreatePadding( | 
| +          heap, Page::kAllocatableMemory, TENURED, object_size); | 
| // Sanity check that we have enough space for linking up arrays. | 
| CHECK_GE(compaction_page_handles.front()->length(), 2); | 
| to_be_aborted_page = | 
| @@ -270,6 +277,7 @@ HEAP_TEST(CompactionPartiallyAbortedPageWithStoreBufferEntries) { | 
| isolate->factory()->NewFixedArray(1, NOT_TENURED); | 
| CHECK(heap->InNewSpace(*new_space_array)); | 
| compaction_page_handles.front()->set(1, *new_space_array); | 
| +      CheckAllObjectsOnPage(compaction_page_handles, to_be_aborted_page); | 
| } | 
|  | 
| { | 
| @@ -280,7 +288,7 @@ HEAP_TEST(CompactionPartiallyAbortedPageWithStoreBufferEntries) { | 
| const int num_objects = 2; | 
| int used_memory = object_size * num_objects; | 
| std::vector<Handle<FixedArray>> page_to_fill_handles = | 
| -          CreatePadding(heap, used_memory, TENURED, object_size); | 
| +          heap::CreatePadding(heap, used_memory, TENURED, object_size); | 
| Page* page_to_fill = | 
| Page::FromAddress(page_to_fill_handles.front()->address()); | 
|  | 
|  |