diff options
Diffstat (limited to 'deps/v8/test/cctest/heap/test-page-promotion.cc')
-rw-r--r-- | deps/v8/test/cctest/heap/test-page-promotion.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/deps/v8/test/cctest/heap/test-page-promotion.cc b/deps/v8/test/cctest/heap/test-page-promotion.cc index 7572718d9e..97f50203f7 100644 --- a/deps/v8/test/cctest/heap/test-page-promotion.cc +++ b/deps/v8/test/cctest/heap/test-page-promotion.cc @@ -160,6 +160,49 @@ UNINITIALIZED_TEST(PagePromotion_NewToNewJSArrayBuffer) { isolate->Dispose(); } +UNINITIALIZED_TEST(PagePromotion_NewToOldJSArrayBuffer) { + if (!i::FLAG_page_promotion) return; + + // Test makes sure JSArrayBuffer backing stores are still tracked after + // new-to-old promotion. + v8::Isolate* isolate = NewIsolateForPagePromotion(); + 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(); + + // Fill the current page which potentially contains the age mark. + heap::FillCurrentPage(heap->new_space()); + // Allocate a buffer we would like to check against. + Handle<JSArrayBuffer> buffer = + i_isolate->factory()->NewJSArrayBuffer(SharedFlag::kNotShared); + CHECK(JSArrayBuffer::SetupAllocatingData(buffer, i_isolate, 100)); + std::vector<Handle<FixedArray>> handles; + // Simulate a full space, filling the interesting page with live objects. + heap::SimulateFullSpace(heap->new_space(), &handles); + CHECK_GT(handles.size(), 0u); + // First object in handles should be on the same page as the allocated + // JSArrayBuffer. + Handle<FixedArray> first_object = handles.front(); + Page* to_be_promoted_page = Page::FromAddress(first_object->address()); + CHECK(!to_be_promoted_page->Contains(heap->new_space()->age_mark())); + CHECK(to_be_promoted_page->Contains(first_object->address())); + CHECK(to_be_promoted_page->Contains(buffer->address())); + CHECK(heap->new_space()->ToSpaceContainsSlow(first_object->address())); + CHECK(heap->new_space()->ToSpaceContainsSlow(buffer->address())); + heap::GcAndSweep(heap, OLD_SPACE); + heap::GcAndSweep(heap, OLD_SPACE); + CHECK(heap->old_space()->ContainsSlow(first_object->address())); + CHECK(heap->old_space()->ContainsSlow(buffer->address())); + CHECK(to_be_promoted_page->Contains(first_object->address())); + CHECK(to_be_promoted_page->Contains(buffer->address())); + CHECK(ArrayBufferTracker::IsTracked(*buffer)); + } + isolate->Dispose(); +} + UNINITIALIZED_HEAP_TEST(Regress658718) { if (!i::FLAG_page_promotion) return; |