Revision: 15376
Author:   [email protected]
Date:     Fri Jun 28 04:24:27 2013
Log:      Avoid data race in debug mode on the parallel thread.

[email protected]
BUG=

Review URL: https://codereview.chromium.org/18194004
http://code.google.com/p/v8/source/detail?r=15376

Modified:
 /branches/bleeding_edge/src/optimizing-compiler-thread.cc
 /branches/bleeding_edge/src/optimizing-compiler-thread.h

=======================================
--- /branches/bleeding_edge/src/optimizing-compiler-thread.cc Fri Jun 21 01:38:12 2013 +++ /branches/bleeding_edge/src/optimizing-compiler-thread.cc Fri Jun 28 04:24:27 2013
@@ -39,7 +39,9 @@

 void OptimizingCompilerThread::Run() {
 #ifdef DEBUG
-  thread_id_ = ThreadId::Current().ToInteger();
+  { ScopedLock lock(thread_id_mutex_);
+    thread_id_ = ThreadId::Current().ToInteger();
+  }
 #endif
   Isolate::SetIsolateThreadLocals(isolate_, NULL);
   DisallowHeapAllocation no_allocation;
@@ -156,6 +158,7 @@
 #ifdef DEBUG
 bool OptimizingCompilerThread::IsOptimizerThread() {
   if (!FLAG_parallel_recompilation) return false;
+  ScopedLock lock(thread_id_mutex_);
   return ThreadId::Current().ToInteger() == thread_id_;
 }
 #endif
=======================================
--- /branches/bleeding_edge/src/optimizing-compiler-thread.h Fri Jun 21 01:38:12 2013 +++ /branches/bleeding_edge/src/optimizing-compiler-thread.h Fri Jun 28 04:24:27 2013
@@ -46,6 +46,7 @@
       Thread("OptimizingCompilerThread"),
 #ifdef DEBUG
       thread_id_(0),
+      thread_id_mutex_(OS::CreateMutex()),
 #endif
       isolate_(isolate),
       stop_semaphore_(OS::CreateSemaphore(0)),
@@ -89,6 +90,7 @@
  private:
 #ifdef DEBUG
   int thread_id_;
+  Mutex* thread_id_mutex_;
 #endif

   Isolate* isolate_;

--
--
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.


Reply via email to