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

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: 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;
yurys 2014/06/02 11:39:11 Can we also check that TERMINATE_EXECUTION interru
Yang 2014/06/02 11:50:03 Done.
7442 }
7443
7444
7445 class TerminationThread : public v8::internal::Thread {
7446 public:
7447 explicit TerminationThread(v8::Isolate* isolate) : Thread("terminator"),
7448 isolate_(isolate) { }
7449
7450 virtual void Run() {
7451 terminate_requested_semaphore.Wait();
7452 v8::V8::TerminateExecution(isolate_);
7453 terminate_fired_semaphore.Signal();
7454 }
7455
7456 private:
7457 v8::Isolate* isolate_;
7458 };
7459
7460
7461 TEST(DebugBreakOffThreadTerminate) {
7462 DebugLocalContext env;
7463 v8::Isolate* isolate = env->GetIsolate();
7464 v8::HandleScope scope(isolate);
7465 v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate);
7466 TerminationThread terminator(isolate);
7467 terminator.Start();
7468 v8::Debug::DebugBreak(isolate);
7469 CompileRun("while (true);");
7470 }
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