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

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

Issue 2185383002: [heap] Add more left and right trimming test cases for black areas. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | no next file » | 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 1e2ad3aa8bbbe062428ca2e4bd6b4ce73abbb14d..4782471a320218dad9b6d297af29e07d02d4e261 100644
--- a/test/cctest/heap/test-heap.cc
+++ b/test/cctest/heap/test-heap.cc
@@ -6824,6 +6824,127 @@ TEST(LeftTrimFixedArrayInBlackArea) {
heap::GcAndSweep(heap, OLD_SPACE);
}
+TEST(ContinuousLeftTrimFixedArrayInBlackArea) {
+ FLAG_black_allocation = true;
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Heap* heap = CcTest::heap();
+ Isolate* isolate = heap->isolate();
+ heap->CollectAllGarbage();
+
+ i::MarkCompactCollector* collector = heap->mark_compact_collector();
+ i::IncrementalMarking* marking = heap->incremental_marking();
+ if (collector->sweeping_in_progress()) {
+ collector->EnsureSweepingCompleted();
+ }
+ CHECK(marking->IsMarking() || marking->IsStopped());
+ if (marking->IsStopped()) {
+ heap->StartIncrementalMarking();
+ }
+ CHECK(marking->IsMarking());
+ marking->StartBlackAllocationForTesting();
+
+ // Ensure that we allocate a new page, set up a bump pointer area, and
+ // perform the allocation in a black area.
+ heap::SimulateFullSpace(heap->old_space());
+ isolate->factory()->NewFixedArray(10, TENURED);
+
+ // Allocate the fixed array that will be trimmed later.
+ Handle<FixedArray> array = isolate->factory()->NewFixedArray(100, TENURED);
+ Address start_address = array->address();
+ Address end_address = start_address + array->Size();
+ Page* page = Page::FromAddress(start_address);
+ CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array)));
+ CHECK(page->markbits()->AllBitsSetInRange(
+ page->AddressToMarkbitIndex(start_address),
+ page->AddressToMarkbitIndex(end_address)));
+ CHECK(heap->old_space()->Contains(*array));
+
+ FixedArrayBase* previous = *array;
+ FixedArrayBase* trimmed;
+
+ // First trim in one word steps.
+ for (int i = 0; i < 10; i++) {
+ trimmed = heap->LeftTrimFixedArray(previous, 1);
+ HeapObject* filler = HeapObject::FromAddress(previous->address());
+ CHECK(filler->IsFiller());
+ CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(trimmed)));
+ CHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(previous)));
+ previous = trimmed;
+ }
+
+ // Then trim in two and three word steps.
+ for (int i = 2; i <= 3; i++) {
+ for (int j = 0; j < 10; j++) {
+ trimmed = heap->LeftTrimFixedArray(previous, i);
+ HeapObject* filler = HeapObject::FromAddress(previous->address());
+ CHECK(filler->IsFiller());
+ CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(trimmed)));
+ CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(previous)));
+ previous = trimmed;
+ }
+ }
+
+ heap::GcAndSweep(heap, OLD_SPACE);
+}
+
+TEST(ContinuousRightTrimFixedArrayInBlackArea) {
+ FLAG_black_allocation = true;
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Heap* heap = CcTest::heap();
+ Isolate* isolate = heap->isolate();
+ heap->CollectAllGarbage();
+
+ i::MarkCompactCollector* collector = heap->mark_compact_collector();
+ i::IncrementalMarking* marking = heap->incremental_marking();
+ if (collector->sweeping_in_progress()) {
+ collector->EnsureSweepingCompleted();
+ }
+ CHECK(marking->IsMarking() || marking->IsStopped());
+ if (marking->IsStopped()) {
+ heap->StartIncrementalMarking();
+ }
+ CHECK(marking->IsMarking());
+ marking->StartBlackAllocationForTesting();
+
+ // Ensure that we allocate a new page, set up a bump pointer area, and
+ // perform the allocation in a black area.
+ heap::SimulateFullSpace(heap->old_space());
+ isolate->factory()->NewFixedArray(10, TENURED);
+
+ // Allocate the fixed array that will be trimmed later.
+ Handle<FixedArray> array = isolate->factory()->NewFixedArray(100, TENURED);
+ Address start_address = array->address();
+ Address end_address = start_address + array->Size();
+ Page* page = Page::FromAddress(start_address);
+ CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(*array)));
+ CHECK(page->markbits()->AllBitsSetInRange(
+ page->AddressToMarkbitIndex(start_address),
+ page->AddressToMarkbitIndex(end_address)));
+ CHECK(heap->old_space()->Contains(*array));
+
+ // Trim it once by one word to make checking for white marking color uniform.
+ Address previous = end_address - kPointerSize;
+ heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(*array, 1);
+ HeapObject* filler = HeapObject::FromAddress(previous);
+ CHECK(filler->IsFiller());
+ CHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(previous)));
+
+ // Trim 10 times by one, two, and three word.
+ for (int i = 1; i <= 3; i++) {
+ for (int j = 0; j < 10; j++) {
+ previous -= kPointerSize * i;
+ heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(*array, i);
+ HeapObject* filler = HeapObject::FromAddress(previous);
+ CHECK(filler->IsFiller());
+ CHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(previous)));
+ }
+ }
+
+ heap::GcAndSweep(heap, OLD_SPACE);
+}
+
TEST(Regress618958) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698