Commit 41cac47d authored by yangguo@chromium.org's avatar yangguo@chromium.org

Avoid data race in debug mode on the parallel thread.

R=jkummerow@chromium.org
BUG=

Review URL: https://codereview.chromium.org/18194004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15376 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent bf632a83
...@@ -39,7 +39,9 @@ namespace internal { ...@@ -39,7 +39,9 @@ namespace internal {
void OptimizingCompilerThread::Run() { void OptimizingCompilerThread::Run() {
#ifdef DEBUG #ifdef DEBUG
thread_id_ = ThreadId::Current().ToInteger(); { ScopedLock lock(thread_id_mutex_);
thread_id_ = ThreadId::Current().ToInteger();
}
#endif #endif
Isolate::SetIsolateThreadLocals(isolate_, NULL); Isolate::SetIsolateThreadLocals(isolate_, NULL);
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
...@@ -156,6 +158,7 @@ void OptimizingCompilerThread::QueueForOptimization( ...@@ -156,6 +158,7 @@ void OptimizingCompilerThread::QueueForOptimization(
#ifdef DEBUG #ifdef DEBUG
bool OptimizingCompilerThread::IsOptimizerThread() { bool OptimizingCompilerThread::IsOptimizerThread() {
if (!FLAG_parallel_recompilation) return false; if (!FLAG_parallel_recompilation) return false;
ScopedLock lock(thread_id_mutex_);
return ThreadId::Current().ToInteger() == thread_id_; return ThreadId::Current().ToInteger() == thread_id_;
} }
#endif #endif
......
...@@ -46,6 +46,7 @@ class OptimizingCompilerThread : public Thread { ...@@ -46,6 +46,7 @@ class OptimizingCompilerThread : public Thread {
Thread("OptimizingCompilerThread"), Thread("OptimizingCompilerThread"),
#ifdef DEBUG #ifdef DEBUG
thread_id_(0), thread_id_(0),
thread_id_mutex_(OS::CreateMutex()),
#endif #endif
isolate_(isolate), isolate_(isolate),
stop_semaphore_(OS::CreateSemaphore(0)), stop_semaphore_(OS::CreateSemaphore(0)),
...@@ -89,6 +90,7 @@ class OptimizingCompilerThread : public Thread { ...@@ -89,6 +90,7 @@ class OptimizingCompilerThread : public Thread {
private: private:
#ifdef DEBUG #ifdef DEBUG
int thread_id_; int thread_id_;
Mutex* thread_id_mutex_;
#endif #endif
Isolate* isolate_; Isolate* isolate_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment