Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1733)

Unified Diff: test/cctest/heap/test-heap.cc

Issue 2063013005: Revert of [heap] Add page evacuation mode for new->new (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/heap/test-page-promotion.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/heap/test-heap.cc
diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc
index b491381ae55d111e39e1d2d32a74f85364d99cb2..f3782273598bf45ff00da41754f64bbf90096d94 100644
--- a/test/cctest/heap/test-heap.cc
+++ b/test/cctest/heap/test-heap.cc
@@ -6560,6 +6560,56 @@
heap->CollectGarbage(OLD_SPACE);
}
+UNINITIALIZED_TEST(PagePromotion) {
+ FLAG_page_promotion = true;
+ FLAG_page_promotion_threshold = 0; // %
+ i::FLAG_min_semi_space_size = 8 * (Page::kPageSize / MB);
+ // 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;
+ v8::Isolate::CreateParams create_params;
+ create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
+ v8::Isolate* isolate = v8::Isolate::New(create_params);
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ {
+ v8::Isolate::Scope isolate_scope(isolate);
+ v8::HandleScope handle_scope(isolate);
+ v8::Context::New(isolate)->Enter();
+ Heap* heap = i_isolate->heap();
+
+ // Clean up any left over objects from cctest initialization.
+ heap->CollectAllGarbage();
+ heap->CollectAllGarbage();
+
+ std::vector<Handle<FixedArray>> handles;
+ heap::SimulateFullSpace(heap->new_space(), &handles);
+ heap->CollectGarbage(NEW_SPACE);
+ CHECK_GT(handles.size(), 0u);
+ // First object in handle should be on the first page.
+ Handle<FixedArray> first_object = handles.front();
+ Page* first_page = Page::FromAddress(first_object->address());
+ // The age mark should not be on the first page.
+ CHECK(!first_page->ContainsLimit(heap->new_space()->age_mark()));
+ // To perform a sanity check on live bytes we need to mark the heap.
+ heap::SimulateIncrementalMarking(heap, true);
+ // Sanity check that the page meets the requirements for promotion.
+ const int threshold_bytes =
+ FLAG_page_promotion_threshold * Page::kAllocatableMemory / 100;
+ CHECK_GE(first_page->LiveBytes(), threshold_bytes);
+
+ // Actual checks: The page is in new space first, but is moved to old space
+ // during a full GC.
+ CHECK(heap->new_space()->ContainsSlow(first_page->address()));
+ CHECK(!heap->old_space()->ContainsSlow(first_page->address()));
+ heap->CollectGarbage(OLD_SPACE);
+ CHECK(!heap->new_space()->ContainsSlow(first_page->address()));
+ CHECK(heap->old_space()->ContainsSlow(first_page->address()));
+ }
+}
+
TEST(Regress598319) {
// This test ensures that no white objects can cross the progress bar of large
// objects during incremental marking. It checks this by using Shift() during
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/heap/test-page-promotion.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698