Commit da831e96 authored by Rodrigo Bruno's avatar Rodrigo Bruno Committed by Commit Bot

[heap] Added NewToOld page promotion test using JSArrayBuffers.

Bug: chromium:845409
Change-Id: I7a4e19529193f7e8369b7db02c7bcf01ae302ee3
Reviewed-on: https://chromium-review.googlesource.com/1113439
Commit-Queue: Rodrigo Bruno <rfbpb@google.com>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54002}
parent fd151f32
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment