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

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

Issue 1863983002: 🏄 [heap] Add page evacuation mode for new->old (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable optimize_for_size for the feature test as we require >1 page new space Created 4 years, 8 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 | « src/heap/spaces-inl.h ('k') | test/cctest/heap/utils-inl.h » ('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 b3cdd2a6052352ae1a053790bb83e345fe881059..0d2482a68384d593f32a42e80ab2dc3a13c03001 100644
--- a/test/cctest/heap/test-heap.cc
+++ b/test/cctest/heap/test-heap.cc
@@ -3524,6 +3524,8 @@ TEST(ReleaseOverReservedPages) {
// Concurrent sweeping adds non determinism, depending on when memory is
// available for further reuse.
i::FLAG_concurrent_sweeping = false;
+ // Fast evacuation of pages may result in a different page count in old space.
+ i::FLAG_page_promotion = false;
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
@@ -6573,5 +6575,51 @@ HEAP_TEST(Regress589413) {
heap->CollectGarbage(OLD_SPACE);
}
+UNINITIALIZED_TEST(PagePromotion) {
+ FLAG_page_promotion = true;
+ FLAG_page_promotion_threshold = 50; // %
+ 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();
+ std::vector<Handle<FixedArray>> handles;
+ 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();
+ NewSpacePage* first_page =
+ NewSpacePage::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.
+ SimulateIncrementalMarking(heap, true);
+ // Sanity check that the page meets the requirements for promotion.
+ const int threshold_bytes =
+ FLAG_page_promotion_threshold * NewSpacePage::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()));
+ }
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/heap/spaces-inl.h ('k') | test/cctest/heap/utils-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698