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

Side by Side Diff: test/cctest/test-debug.cc

Issue 309533009: Release execution lock before dispatching interrupt handling. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: small fix to rebase mistake 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/execution.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 7407 matching lines...) Expand 10 before | Expand all | Expand 10 after
7418 env->Global()->Set(v8_str("add_debug_break"), add_debug_break); 7418 env->Global()->Set(v8_str("add_debug_break"), add_debug_break);
7419 7419
7420 CompileRun("(function loop() {" 7420 CompileRun("(function loop() {"
7421 " for (var j = 0; j < 1000; j++) {" 7421 " for (var j = 0; j < 1000; j++) {"
7422 " for (var i = 0; i < 1000; i++) {" 7422 " for (var i = 0; i < 1000; i++) {"
7423 " if (i == 999) add_debug_break();" 7423 " if (i == 999) add_debug_break();"
7424 " }" 7424 " }"
7425 " }" 7425 " }"
7426 "})()"); 7426 "})()");
7427 } 7427 }
7428
7429
7430 v8::internal::Semaphore terminate_requested_semaphore(0);
7431 v8::internal::Semaphore terminate_fired_semaphore(0);
7432 bool terminate_already_fired = false;
7433
7434
7435 static void DebugBreakTriggerTerminate(
7436 const v8::Debug::EventDetails& event_details) {
7437 if (event_details.GetEvent() != v8::Break || terminate_already_fired) return;
7438 terminate_requested_semaphore.Signal();
7439 // Wait for at most 2 seconds for the terminate request.
7440 CHECK(terminate_fired_semaphore.WaitFor(i::TimeDelta::FromSeconds(2)));
7441 terminate_already_fired = true;
7442 v8::internal::Isolate* isolate =
7443 v8::Utils::OpenHandle(*event_details.GetEventContext())->GetIsolate();
7444 CHECK(isolate->stack_guard()->CheckTerminateExecution());
7445 }
7446
7447
7448 class TerminationThread : public v8::internal::Thread {
7449 public:
7450 explicit TerminationThread(v8::Isolate* isolate) : Thread("terminator"),
7451 isolate_(isolate) { }
7452
7453 virtual void Run() {
7454 terminate_requested_semaphore.Wait();
7455 v8::V8::TerminateExecution(isolate_);
7456 terminate_fired_semaphore.Signal();
7457 }
7458
7459 private:
7460 v8::Isolate* isolate_;
7461 };
7462
7463
7464 TEST(DebugBreakOffThreadTerminate) {
7465 DebugLocalContext env;
7466 v8::Isolate* isolate = env->GetIsolate();
7467 v8::HandleScope scope(isolate);
7468 v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate);
7469 TerminationThread terminator(isolate);
7470 terminator.Start();
7471 v8::Debug::DebugBreak(isolate);
7472 CompileRun("while (true);");
7473 }
OLDNEW
« no previous file with comments | « src/execution.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698