Index: test/cctest/test-heap.cc |
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc |
index cb08fb4c04ee7841593c525589c918e7d5c8df25..d8c89aec1b4b242a9702c3a018681bdb9b2569bc 100644 |
--- a/test/cctest/test-heap.cc |
+++ b/test/cctest/test-heap.cc |
@@ -3203,6 +3203,31 @@ TEST(ReleaseOverReservedPages) { |
CHECK_EQ(1, old_space->CountTotalPages()); |
} |
+static int forced_gc_counter = 0; |
+ |
+void MockUseCounterCallback(v8::Isolate* isolate, |
+ v8::Isolate::UseCounterFeature feature) { |
+ isolate->GetCallingContext(); |
+ if (feature == v8::Isolate::kForcedGC) { |
+ forced_gc_counter++; |
+ } |
+} |
+ |
+ |
+TEST(CountForcedGC) { |
+ i::FLAG_expose_gc = true; |
+ CcTest::InitializeVM(); |
+ Isolate* isolate = CcTest::i_isolate(); |
+ v8::HandleScope scope(CcTest::isolate()); |
+ |
+ isolate->SetUseCounterCallback(MockUseCounterCallback); |
+ |
+ forced_gc_counter = 0; |
+ const char* source = "gc();"; |
+ CompileRun(source); |
+ CHECK_GT(forced_gc_counter, 0); |
+} |
+ |
TEST(Regress2237) { |
i::FLAG_stress_compaction = false; |