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

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

Issue 2504193002: [heap] Simplify adjusting of live bytes. (Closed)
Patch Set: fix test Created 4 years, 1 month 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/heap/test-heap.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/heap/test-spaces.cc
diff --git a/test/cctest/heap/test-spaces.cc b/test/cctest/heap/test-spaces.cc
index 9a7585d68180dd2269cce67000747f1d723574eb..763b7038ad09724848c2355a5d2186617e9965ea 100644
--- a/test/cctest/heap/test-spaces.cc
+++ b/test/cctest/heap/test-spaces.cc
@@ -797,5 +797,38 @@ TEST(ShrinkPageToHighWaterMarkTwoWordFiller) {
CHECK_EQ(0u, shrinked);
}
+HEAP_TEST(AdjustBytes) {
+ CcTest::InitializeVM();
+ Isolate* isolate = CcTest::i_isolate();
+ HandleScope scope(isolate);
+ Heap* heap = isolate->heap();
+ for (int i = 0; i < 3; i++) {
+ heap->CollectGarbage(OLD_SPACE, i::GarbageCollectionReason::kTesting);
+ }
+ heap->mark_compact_collector()->EnsureSweepingCompleted();
+ heap::SealCurrentObjects(CcTest::heap());
+
+ Handle<FixedArray> array = isolate->factory()->NewFixedArray(5000, TENURED);
+
+ heap->CollectGarbage(OLD_SPACE, i::GarbageCollectionReason::kTesting);
+ heap->delay_sweeper_tasks_for_testing_ = false;
+
+ size_t size_before = heap->SizeOfObjects();
+ heap->RightTrimFixedArray(*array, 1000);
+ heap->mark_compact_collector()->sweeper().StartSweeperTasks();
+ heap->mark_compact_collector()->EnsureSweepingCompleted();
+ size_t size_after = heap->SizeOfObjects();
+ // Right trimming during sweeping does not affect size counters.
+ CHECK_EQ(size_before, size_after);
+ heap->RightTrimFixedArray(*array, 1000);
+ size_after = heap->SizeOfObjects();
+ // Right trimming before incremental marking runs does not affect size
+ // counters.
+ CHECK_EQ(size_before, size_after);
+ heap->CollectGarbage(OLD_SPACE, i::GarbageCollectionReason::kTesting);
+ size_after = heap->SizeOfObjects();
+ CHECK_EQ(size_before, size_after + 2000 * kPointerSize);
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698