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

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

Issue 1165004: New GCCallbacks with additional parameters. (Closed)
Patch Set: Created 10 years, 9 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 | « src/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/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 80254fd0b08b0d8743cfa678d49a7b84bb9c241a..2eacf5a755e72d13f8ac5a80116ea12645cfd01b 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -9956,3 +9956,57 @@ TEST(Bug618) {
CHECK_EQ(23, c1->Get(v8_str("y"))->Int32Value());
}
}
+
+int prologue_call_count = 0;
+int epilogue_call_count = 0;
+int prologue_call_count_second = 0;
+int epilogue_call_count_second = 0;
+
+void PrologueCallback(v8::GCType, v8::GCCallbackFlags) {
+ ++prologue_call_count;
+}
+
+void EpilogueCallback(v8::GCType, v8::GCCallbackFlags) {
+ ++epilogue_call_count;
+}
+
+void PrologueCallbackSecond(v8::GCType, v8::GCCallbackFlags) {
+ ++prologue_call_count_second;
+}
+
+void EpilogueCallbackSecond(v8::GCType, v8::GCCallbackFlags) {
+ ++epilogue_call_count_second;
+}
+
+TEST(GCCallbacks) {
+ LocalContext context;
+
+ v8::V8::AddGCPrologueCallback(PrologueCallback);
+ v8::V8::AddGCEpilogueCallback(EpilogueCallback);
+ CHECK_EQ(0, prologue_call_count);
+ CHECK_EQ(0, epilogue_call_count);
+ i::Heap::CollectAllGarbage(false);
+ CHECK_EQ(1, prologue_call_count);
+ CHECK_EQ(1, epilogue_call_count);
+ v8::V8::AddGCPrologueCallback(PrologueCallbackSecond);
+ v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond);
+ i::Heap::CollectAllGarbage(false);
+ CHECK_EQ(2, prologue_call_count);
+ CHECK_EQ(2, epilogue_call_count);
+ CHECK_EQ(1, prologue_call_count_second);
+ CHECK_EQ(1, epilogue_call_count_second);
+ v8::V8::RemoveGCPrologueCallback(PrologueCallback);
+ v8::V8::RemoveGCEpilogueCallback(EpilogueCallback);
+ i::Heap::CollectAllGarbage(false);
+ CHECK_EQ(2, prologue_call_count);
+ CHECK_EQ(2, epilogue_call_count);
+ CHECK_EQ(2, prologue_call_count_second);
+ CHECK_EQ(2, epilogue_call_count_second);
+ v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond);
+ v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond);
+ i::Heap::CollectAllGarbage(false);
+ CHECK_EQ(2, prologue_call_count);
+ CHECK_EQ(2, epilogue_call_count);
+ CHECK_EQ(2, prologue_call_count_second);
+ CHECK_EQ(2, epilogue_call_count_second);
+}
« no previous file with comments | « src/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698