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

Unified Diff: src/v8threads.cc

Issue 174056: Add support for forceful termination of JavaScript execution. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 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/v8threads.h ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8threads.cc
===================================================================
--- src/v8threads.cc (revision 2717)
+++ src/v8threads.cc (working copy)
@@ -151,6 +151,10 @@
from = RegExpStack::RestoreStack(from);
from = Bootstrapper::RestoreState(from);
Thread::SetThreadLocal(thread_state_key, NULL);
+ if (state->terminate_on_restore()) {
+ StackGuard::TerminateExecution();
+ state->set_terminate_on_restore(false);
+ }
state->set_id(kInvalidId);
state->Unlink();
state->LinkInto(ThreadState::FREE_LIST);
@@ -188,6 +192,7 @@
ThreadState::ThreadState() : id_(ThreadManager::kInvalidId),
+ terminate_on_restore_(false),
next_(this), previous_(this) {
}
@@ -317,11 +322,25 @@
void ThreadManager::AssignId() {
if (!Thread::HasThreadLocal(thread_id_key)) {
- Thread::SetThreadLocalInt(thread_id_key, next_id_++);
+ ASSERT(Locker::IsLocked());
+ int thread_id = next_id_++;
+ Thread::SetThreadLocalInt(thread_id_key, thread_id);
+ Top::set_thread_id(thread_id);
}
}
+void ThreadManager::TerminateExecution(int thread_id) {
+ for (ThreadState* state = ThreadState::FirstInUse();
+ state != NULL;
+ state = state->Next()) {
+ if (thread_id == state->id()) {
+ state->set_terminate_on_restore(true);
+ }
+ }
+}
+
+
// This is the ContextSwitcher singleton. There is at most a single thread
// running which delivers preemption events to V8 threads.
ContextSwitcher* ContextSwitcher::singleton_ = NULL;
« no previous file with comments | « src/v8threads.h ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698