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

Unified Diff: test/cctest/test-thread-termination.cc

Issue 359963004: Reland "Add mechanism to postpone interrupts selectively." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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/test-debug.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-thread-termination.cc
diff --git a/test/cctest/test-thread-termination.cc b/test/cctest/test-thread-termination.cc
index 9c3401f2c9f246cb7edb39d605cb9b3a46586c87..2f419ed27cea8a1b3931672ededd99a29f5da0c2 100644
--- a/test/cctest/test-thread-termination.cc
+++ b/test/cctest/test-thread-termination.cc
@@ -403,3 +403,59 @@ TEST(TerminateFromOtherThreadWhileMicrotaskRunning) {
delete semaphore;
semaphore = NULL;
}
+
+
+static int callback_counter = 0;
+
+
+static void CounterCallback(v8::Isolate* isolate, void* data) {
+ callback_counter++;
+}
+
+
+TEST(PostponeTerminateException) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::ObjectTemplate> global =
+ CreateGlobalTemplate(CcTest::isolate(), TerminateCurrentThread, DoLoop);
+ v8::Handle<v8::Context> context =
+ v8::Context::New(CcTest::isolate(), NULL, global);
+ v8::Context::Scope context_scope(context);
+
+ v8::TryCatch try_catch;
+ static const char* terminate_and_loop =
+ "terminate(); for (var i = 0; i < 10000; i++);";
+
+ { // Postpone terminate execution interrupts.
+ i::PostponeInterruptsScope p1(CcTest::i_isolate(),
+ i::StackGuard::TERMINATE_EXECUTION) ;
+
+ // API interrupts should still be triggered.
+ CcTest::isolate()->RequestInterrupt(&CounterCallback, NULL);
+ CHECK_EQ(0, callback_counter);
+ CompileRun(terminate_and_loop);
+ CHECK(!try_catch.HasTerminated());
+ CHECK_EQ(1, callback_counter);
+
+ { // Postpone API interrupts as well.
+ i::PostponeInterruptsScope p2(CcTest::i_isolate(),
+ i::StackGuard::API_INTERRUPT);
+
+ // None of the two interrupts should trigger.
+ CcTest::isolate()->RequestInterrupt(&CounterCallback, NULL);
+ CompileRun(terminate_and_loop);
+ CHECK(!try_catch.HasTerminated());
+ CHECK_EQ(1, callback_counter);
+ }
+
+ // Now the previously requested API interrupt should trigger.
+ CompileRun(terminate_and_loop);
+ CHECK(!try_catch.HasTerminated());
+ CHECK_EQ(2, callback_counter);
+ }
+
+ // Now the previously requested terminate execution interrupt should trigger.
+ CompileRun("for (var i = 0; i < 10000; i++);");
+ CHECK(try_catch.HasTerminated());
+ CHECK_EQ(2, callback_counter);
+}
« no previous file with comments | « test/cctest/test-debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698