Index: test/cctest/test-heap.cc |
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc |
index 5ddbc99fea932c4a65e6ac40946cc67da05541c6..047cd922277c73a3e14f16661be0e6f956bd1839 100644 |
--- a/test/cctest/test-heap.cc |
+++ b/test/cctest/test-heap.cc |
@@ -1467,6 +1467,7 @@ TEST(TestInternalWeakLists) { |
// Some flags turn Scavenge collections into Mark-sweep collections |
// and hence are incompatible with this test case. |
if (FLAG_gc_global || FLAG_stress_compaction) return; |
+ FLAG_retain_maps_for_n_gc = 0; |
static const int kNumTestContexts = 10; |
@@ -2886,6 +2887,7 @@ TEST(Regress1465) { |
i::FLAG_stress_compaction = false; |
i::FLAG_allow_natives_syntax = true; |
i::FLAG_trace_incremental_marking = true; |
+ i::FLAG_retain_maps_for_n_gc = 0; |
CcTest::InitializeVM(); |
v8::HandleScope scope(CcTest::isolate()); |
static const int transitions_count = 256; |
@@ -2948,6 +2950,7 @@ static void AddPropertyTo( |
Handle<Smi> twenty_three(Smi::FromInt(23), isolate); |
i::FLAG_gc_interval = gc_count; |
i::FLAG_gc_global = true; |
+ i::FLAG_retain_maps_for_n_gc = 0; |
CcTest::heap()->set_allocation_timeout(gc_count); |
JSReceiver::SetProperty(object, prop_name, twenty_three, SLOPPY).Check(); |
} |
@@ -4146,7 +4149,7 @@ TEST(EnsureAllocationSiteDependentCodesProcessed) { |
// Now make sure that a gc should get rid of the function, even though we |
// still have the allocation site alive. |
for (int i = 0; i < 4; i++) { |
- heap->CollectAllGarbage(Heap::kNoGCFlags); |
+ heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
} |
// The site still exists because of our global handle, but the code is no |
@@ -4248,6 +4251,7 @@ TEST(NoWeakHashTableLeakWithIncrementalMarking) { |
i::FLAG_weak_embedded_objects_in_optimized_code = true; |
i::FLAG_allow_natives_syntax = true; |
i::FLAG_compilation_cache = false; |
+ i::FLAG_retain_maps_for_n_gc = 0; |
CcTest::InitializeVM(); |
Isolate* isolate = CcTest::i_isolate(); |
v8::internal::Heap* heap = CcTest::heap(); |
@@ -5082,6 +5086,37 @@ TEST(Regress3877) { |
} |
+void CheckMapRetainingFor(int n) { |
+ FLAG_retain_maps_for_n_gc = n; |
+ Isolate* isolate = CcTest::i_isolate(); |
+ Heap* heap = isolate->heap(); |
+ Handle<WeakCell> weak_cell; |
+ { |
+ HandleScope inner_scope(isolate); |
+ Handle<Map> map = Map::Create(isolate, 1); |
+ heap->AddRetainedMap(map); |
+ weak_cell = inner_scope.CloseAndEscape(Map::WeakCellForMap(map)); |
+ } |
+ CHECK(!weak_cell->cleared()); |
+ for (int i = 0; i < n; i++) { |
+ heap->CollectGarbage(OLD_POINTER_SPACE); |
+ } |
+ CHECK(!weak_cell->cleared()); |
+ heap->CollectGarbage(OLD_POINTER_SPACE); |
+ CHECK(weak_cell->cleared()); |
+} |
+ |
+ |
+TEST(MapRetaining) { |
+ CcTest::InitializeVM(); |
+ v8::HandleScope scope(CcTest::isolate()); |
+ CheckMapRetainingFor(FLAG_retain_maps_for_n_gc); |
+ CheckMapRetainingFor(0); |
+ CheckMapRetainingFor(1); |
+ CheckMapRetainingFor(7); |
+} |
+ |
+ |
#ifdef DEBUG |
TEST(PathTracer) { |
CcTest::InitializeVM(); |