Revision: 16577
Author: [email protected]
Date: Fri Sep 6 13:18:26 2013 UTC
Log: Some thread data simplifications.
[email protected]
Review URL: https://codereview.chromium.org/24036002
http://code.google.com/p/v8/source/detail?r=16577
Modified:
/branches/bleeding_edge/src/isolate.cc
/branches/bleeding_edge/src/isolate.h
=======================================
--- /branches/bleeding_edge/src/isolate.cc Thu Sep 5 11:27:22 2013 UTC
+++ /branches/bleeding_edge/src/isolate.cc Fri Sep 6 13:18:26 2013 UTC
@@ -343,35 +343,23 @@
#ifdef DEBUG
Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key;
#endif // DEBUG
-RecursiveMutex Isolate::process_wide_mutex_;
+Mutex Isolate::process_wide_mutex_;
Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL;
Atomic32 Isolate::isolate_counter_ = 0;
-Isolate::PerIsolateThreadData* Isolate::AllocatePerIsolateThreadData(
- ThreadId thread_id) {
- ASSERT(!thread_id.Equals(ThreadId::Invalid()));
- PerIsolateThreadData* per_thread = new PerIsolateThreadData(this,
thread_id);
- {
- LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_);
- ASSERT(thread_data_table_->Lookup(this, thread_id) == NULL);
- thread_data_table_->Insert(per_thread);
- ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread);
- }
- return per_thread;
-}
-
-
Isolate::PerIsolateThreadData*
Isolate::FindOrAllocatePerThreadDataForThisThread() {
ThreadId thread_id = ThreadId::Current();
PerIsolateThreadData* per_thread = NULL;
{
- LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_);
+ LockGuard<Mutex> lock_guard(&process_wide_mutex_);
per_thread = thread_data_table_->Lookup(this, thread_id);
if (per_thread == NULL) {
- per_thread = AllocatePerIsolateThreadData(thread_id);
+ per_thread = new PerIsolateThreadData(this, thread_id);
+ thread_data_table_->Insert(per_thread);
}
}
+ ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread);
return per_thread;
}
@@ -386,7 +374,7 @@
ThreadId thread_id) {
PerIsolateThreadData* per_thread = NULL;
{
- LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_);
+ LockGuard<Mutex> lock_guard(&process_wide_mutex_);
per_thread = thread_data_table_->Lookup(this, thread_id);
}
return per_thread;
@@ -394,7 +382,7 @@
void Isolate::EnsureDefaultIsolate() {
- LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_);
+ LockGuard<Mutex> lock_guard(&process_wide_mutex_);
if (default_isolate_ == NULL) {
isolate_key_ = Thread::CreateThreadLocalKey();
thread_id_key_ = Thread::CreateThreadLocalKey();
@@ -1715,15 +1703,6 @@
if (data->prev_ != NULL) data->prev_->next_ = data->next_;
delete data;
}
-
-
-void Isolate::ThreadDataTable::Remove(Isolate* isolate,
- ThreadId thread_id) {
- PerIsolateThreadData* data = Lookup(isolate, thread_id);
- if (data != NULL) {
- Remove(data);
- }
-}
void Isolate::ThreadDataTable::RemoveAllThreads(Isolate* isolate) {
@@ -1864,7 +1843,7 @@
Deinit();
- { LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_);
+ { LockGuard<Mutex> lock_guard(&process_wide_mutex_);
thread_data_table_->RemoveAllThreads(this);
}
=======================================
--- /branches/bleeding_edge/src/isolate.h Fri Sep 6 11:24:26 2013 UTC
+++ /branches/bleeding_edge/src/isolate.h Fri Sep 6 13:18:26 2013 UTC
@@ -1155,7 +1155,6 @@
PerIsolateThreadData* Lookup(Isolate* isolate, ThreadId thread_id);
void Insert(PerIsolateThreadData* data);
- void Remove(Isolate* isolate, ThreadId thread_id);
void Remove(PerIsolateThreadData* data);
void RemoveAllThreads(Isolate* isolate);
@@ -1190,7 +1189,7 @@
// This mutex protects highest_thread_id_, thread_data_table_ and
// default_isolate_.
- static RecursiveMutex process_wide_mutex_;
+ static Mutex process_wide_mutex_;
static Thread::LocalStorageKey per_isolate_thread_data_key_;
static Thread::LocalStorageKey isolate_key_;
@@ -1206,10 +1205,6 @@
static void SetIsolateThreadLocals(Isolate* isolate,
PerIsolateThreadData* data);
- // Allocate and insert PerIsolateThreadData into the ThreadDataTable
- // (regardless of whether such data already exists).
- PerIsolateThreadData* AllocatePerIsolateThreadData(ThreadId thread_id);
-
// Find the PerThread for this particular (isolate, thread) combination.
// If one does not yet exist, allocate a new one.
PerIsolateThreadData* FindOrAllocatePerThreadDataForThisThread();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.