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

Unified Diff: src/v8threads.cc

Issue 48009: Add thread information to the debugger (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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
« src/runtime.cc ('K') | « src/v8threads.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8threads.cc
===================================================================
--- src/v8threads.cc (revision 1518)
+++ src/v8threads.cc (working copy)
@@ -38,6 +38,8 @@
static internal::Thread::LocalStorageKey thread_state_key =
internal::Thread::CreateThreadLocalKey();
+static internal::Thread::LocalStorageKey thread_id_key =
+ internal::Thread::CreateThreadLocalKey();
// Track whether this V8 instance has ever called v8::Locker. This allows the
@@ -61,6 +63,9 @@
}
}
ASSERT(internal::ThreadManager::IsLockedByCurrentThread());
+
+ // Make sure this thread is assigned a thread id.
+ internal::ThreadManager::AssignId();
}
@@ -115,6 +120,7 @@
lazily_archived_thread_.Initialize(ThreadHandle::INVALID);
ASSERT(Thread::GetThreadLocal(thread_state_key) ==
lazily_archived_thread_state_);
+ lazily_archived_thread_state_->set_id(kInvalidId);
lazily_archived_thread_state_->LinkInto(ThreadState::FREE_LIST);
lazily_archived_thread_state_ = NULL;
Thread::SetThreadLocal(thread_state_key, NULL);
@@ -143,6 +149,7 @@
from = RegExpStack::RestoreStack(from);
from = Bootstrapper::RestoreState(from);
Thread::SetThreadLocal(thread_state_key, NULL);
+ state->set_id(kInvalidId);
state->Unlink();
state->LinkInto(ThreadState::FREE_LIST);
return true;
@@ -176,7 +183,8 @@
ThreadState* ThreadState::in_use_anchor_ = new ThreadState();
-ThreadState::ThreadState() : next_(this), previous_(this) {
+ThreadState::ThreadState() : id_(ThreadManager::kInvalidId),
+ next_(this), previous_(this) {
}
@@ -224,6 +232,7 @@
}
+int ThreadManager::next_id_ = 0;
Mutex* ThreadManager::mutex_ = OS::CreateMutex();
ThreadHandle ThreadManager::mutex_owner_(ThreadHandle::INVALID);
ThreadHandle ThreadManager::lazily_archived_thread_(ThreadHandle::INVALID);
@@ -238,6 +247,9 @@
Thread::SetThreadLocal(thread_state_key, reinterpret_cast<void*>(state));
lazily_archived_thread_.Initialize(ThreadHandle::SELF);
lazily_archived_thread_state_ = state;
+ ASSERT(state->id() == kInvalidId);
+ state->set_id(CurrentId());
+ ASSERT(state->id() != kInvalidId);
}
@@ -290,6 +302,18 @@
}
+int ThreadManager::CurrentId() {
+ return bit_cast<int, void*>(Thread::GetThreadLocal(thread_id_key));
+}
+
+
+void ThreadManager::AssignId() {
+ if (Thread::GetThreadLocal(thread_id_key) == NULL) {
+ Thread::SetThreadLocal(thread_id_key, bit_cast<void*, int>(next_id_++));
+ }
+}
+
+
// This is the ContextSwitcher singleton. There is at most a single thread
// running which delivers preemption events to V8 threads.
ContextSwitcher* ContextSwitcher::singleton_ = NULL;
« src/runtime.cc ('K') | « src/v8threads.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698