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

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

Issue 2906313002: [heap] Fix a missing write barrier in Heap::Allocate. (Closed)
Patch Set: fix test Created 3 years, 7 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/heap/heap-tester.h ('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-heap.cc
diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc
index d8c83f3b409d7aa7d861b52c8406461869b0e4d0..2992dc186b977e2fdf52ed9c6ecb7c045377c11f 100644
--- a/test/cctest/heap/test-heap.cc
+++ b/test/cctest/heap/test-heap.cc
@@ -6303,5 +6303,38 @@ HEAP_TEST(Regress5831) {
CHECK(chunk->NeverEvacuate());
}
+HEAP_TEST(RegressMissingWriteBarrierInAllocate) {
+ if (!FLAG_incremental_marking) return;
+ FLAG_black_allocation = true;
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Heap* heap = CcTest::heap();
+ Isolate* isolate = heap->isolate();
+ CcTest::CollectAllGarbage();
+ heap::SimulateIncrementalMarking(heap, false);
+ Map* map;
+ {
+ AlwaysAllocateScope always_allocate(isolate);
+ map = Map::cast(heap->AllocateMap(HEAP_NUMBER_TYPE, HeapNumber::kSize)
+ .ToObjectChecked());
+ }
+ heap->incremental_marking()->StartBlackAllocationForTesting();
+ Handle<HeapObject> object;
+ {
+ AlwaysAllocateScope always_allocate(isolate);
+ object = Handle<HeapObject>(
+ heap->Allocate(map, OLD_SPACE).ToObjectChecked(), isolate);
+ }
+ // The object is black. If Heap::Allocate sets the map without write-barrier,
+ // then the map is white and will be freed prematurely.
+ heap::SimulateIncrementalMarking(heap, true);
+ CcTest::CollectAllGarbage();
+ MarkCompactCollector* collector = heap->mark_compact_collector();
+ if (collector->sweeping_in_progress()) {
+ collector->EnsureSweepingCompleted();
+ }
+ CHECK(object->map()->IsMap());
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « test/cctest/heap/heap-tester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698