| Index: test/cctest/heap/test-page-promotion.cc | 
| diff --git a/test/cctest/heap/test-page-promotion.cc b/test/cctest/heap/test-page-promotion.cc | 
| index b3ac4960a54b69db9dbc51cb6595e7b929aa0fbc..4673f2edcf25422ec04282821e45a59b5609a333 100644 | 
| --- a/test/cctest/heap/test-page-promotion.cc | 
| +++ b/test/cctest/heap/test-page-promotion.cc | 
| @@ -14,20 +14,22 @@ | 
| // src/type-feedback-vector-inl.h | 
| #include "src/type-feedback-vector-inl.h" | 
| #include "test/cctest/cctest.h" | 
| +#include "test/cctest/heap/heap-tester.h" | 
| #include "test/cctest/heap/heap-utils.h" | 
|  | 
| namespace { | 
|  | 
| -v8::Isolate* NewIsolateForPagePromotion() { | 
| +v8::Isolate* NewIsolateForPagePromotion(int min_semi_space_size = 8, | 
| +                                        int max_semi_space_size = 8) { | 
| i::FLAG_page_promotion = true; | 
| i::FLAG_page_promotion_threshold = 0;  // % | 
| -  i::FLAG_min_semi_space_size = 8; | 
| +  i::FLAG_min_semi_space_size = min_semi_space_size; | 
| // We cannot optimize for size as we require a new space with more than one | 
| // page. | 
| i::FLAG_optimize_for_size = false; | 
| // Set max_semi_space_size because it could've been initialized by an | 
| // implication of optimize_for_size. | 
| -  i::FLAG_max_semi_space_size = i::FLAG_min_semi_space_size; | 
| +  i::FLAG_max_semi_space_size = max_semi_space_size; | 
| v8::Isolate::CreateParams create_params; | 
| create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 
| v8::Isolate* isolate = v8::Isolate::New(create_params); | 
| @@ -134,5 +136,38 @@ UNINITIALIZED_TEST(PagePromotion_NewToNewJSArrayBuffer) { | 
| } | 
| } | 
|  | 
| +UNINITIALIZED_HEAP_TEST(Regress658718) { | 
| +  v8::Isolate* isolate = NewIsolateForPagePromotion(4, 8); | 
| +  Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); | 
| +  { | 
| +    v8::Isolate::Scope isolate_scope(isolate); | 
| +    v8::HandleScope handle_scope(isolate); | 
| +    v8::Context::New(isolate)->Enter(); | 
| +    Heap* heap = i_isolate->heap(); | 
| +    heap->delay_sweeper_tasks_for_testing_ = true; | 
| +    heap->new_space()->Grow(); | 
| +    { | 
| +      v8::HandleScope inner_handle_scope(isolate); | 
| +      std::vector<Handle<FixedArray>> handles; | 
| +      heap::SimulateFullSpace(heap->new_space(), &handles); | 
| +      CHECK_GT(handles.size(), 0u); | 
| +      // Last object in handles should definitely be on the last page which does | 
| +      // not contain the age mark. | 
| +      Handle<FixedArray> last_object = handles.back(); | 
| +      Page* to_be_promoted_page = Page::FromAddress(last_object->address()); | 
| +      CHECK(to_be_promoted_page->Contains(last_object->address())); | 
| +      CHECK(heap->new_space()->ToSpaceContainsSlow(last_object->address())); | 
| +      heap->CollectGarbage(OLD_SPACE, i::GarbageCollectionReason::kTesting); | 
| +      CHECK(heap->new_space()->ToSpaceContainsSlow(last_object->address())); | 
| +      CHECK(to_be_promoted_page->Contains(last_object->address())); | 
| +    } | 
| +    heap->CollectGarbage(NEW_SPACE, i::GarbageCollectionReason::kTesting); | 
| +    heap->new_space()->Shrink(); | 
| +    heap->memory_allocator()->unmapper()->WaitUntilCompleted(); | 
| +    heap->mark_compact_collector()->sweeper().StartSweeperTasks(); | 
| +    heap->mark_compact_collector()->EnsureSweepingCompleted(); | 
| +  } | 
| +} | 
| + | 
| }  // namespace internal | 
| }  // namespace v8 | 
|  |