Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 5496995ffe4c4935a834351e9f7c84beec72c9a0..02c7358d6be99e58201409b57492c1e5d150f227 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -17696,32 +17696,73 @@ TEST(Regress618) { |
} |
} |
+v8::Isolate* gc_callbacks_isolate = NULL; |
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) { |
+void PrologueCallback(v8::GCType, v8::GCCallbackFlags flags) { |
+ CHECK_EQ(flags, v8::kNoGCCallbackFlags); |
++prologue_call_count; |
} |
-void EpilogueCallback(v8::GCType, v8::GCCallbackFlags) { |
+void PrologueCallback(v8::Isolate* isolate, |
+ v8::GCType, |
+ v8::GCCallbackFlags flags) { |
+ CHECK_EQ(flags, v8::kNoGCCallbackFlags); |
+ CHECK_EQ(gc_callbacks_isolate, isolate); |
+ ++prologue_call_count; |
+} |
+ |
+ |
+void EpilogueCallback(v8::GCType, v8::GCCallbackFlags flags) { |
+ CHECK_EQ(flags, v8::kNoGCCallbackFlags); |
++epilogue_call_count; |
} |
-void PrologueCallbackSecond(v8::GCType, v8::GCCallbackFlags) { |
+void EpilogueCallback(v8::Isolate* isolate, |
+ v8::GCType, |
+ v8::GCCallbackFlags flags) { |
+ CHECK_EQ(flags, v8::kNoGCCallbackFlags); |
+ CHECK_EQ(gc_callbacks_isolate, isolate); |
+ ++epilogue_call_count; |
+} |
+ |
+ |
+void PrologueCallbackSecond(v8::GCType, v8::GCCallbackFlags flags) { |
+ CHECK_EQ(flags, v8::kNoGCCallbackFlags); |
+ ++prologue_call_count_second; |
+} |
+ |
+ |
+void PrologueCallbackSecond(v8::Isolate* isolate, |
+ v8::GCType, |
+ v8::GCCallbackFlags flags) { |
+ CHECK_EQ(flags, v8::kNoGCCallbackFlags); |
+ CHECK_EQ(gc_callbacks_isolate, isolate); |
++prologue_call_count_second; |
} |
-void EpilogueCallbackSecond(v8::GCType, v8::GCCallbackFlags) { |
+void EpilogueCallbackSecond(v8::GCType, v8::GCCallbackFlags flags) { |
+ CHECK_EQ(flags, v8::kNoGCCallbackFlags); |
++epilogue_call_count_second; |
} |
-TEST(GCCallbacks) { |
+void EpilogueCallbackSecond(v8::Isolate* isolate, |
+ v8::GCType, |
+ v8::GCCallbackFlags flags) { |
+ CHECK_EQ(flags, v8::kNoGCCallbackFlags); |
+ CHECK_EQ(gc_callbacks_isolate, isolate); |
+ ++epilogue_call_count_second; |
+} |
+ |
+ |
+TEST(GCCallbacksOld) { |
LocalContext context; |
v8::V8::AddGCPrologueCallback(PrologueCallback); |
@@ -17755,6 +17796,41 @@ TEST(GCCallbacks) { |
} |
+TEST(GCCallbacks) { |
+ LocalContext context; |
+ v8::Isolate* isolate = context->GetIsolate(); |
+ gc_callbacks_isolate = isolate; |
+ isolate->AddGCPrologueCallback(PrologueCallback); |
+ isolate->AddGCEpilogueCallback(EpilogueCallback); |
+ CHECK_EQ(0, prologue_call_count); |
+ CHECK_EQ(0, epilogue_call_count); |
+ HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
+ CHECK_EQ(1, prologue_call_count); |
+ CHECK_EQ(1, epilogue_call_count); |
+ isolate->AddGCPrologueCallback(PrologueCallbackSecond); |
+ isolate->AddGCEpilogueCallback(EpilogueCallbackSecond); |
+ HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
+ 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); |
+ isolate->RemoveGCPrologueCallback(PrologueCallback); |
+ isolate->RemoveGCEpilogueCallback(EpilogueCallback); |
+ HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
+ 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); |
+ isolate->RemoveGCPrologueCallback(PrologueCallbackSecond); |
+ isolate->RemoveGCEpilogueCallback(EpilogueCallbackSecond); |
+ HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
+ 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); |
+} |
+ |
+ |
THREADED_TEST(AddToJSFunctionResultCache) { |
i::FLAG_stress_compaction = false; |
i::FLAG_allow_natives_syntax = true; |