| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/optimizing-compiler-thread.h" | 5 #include "src/optimizing-compiler-thread.h" |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/base/atomicops.h" | 9 #include "src/base/atomicops.h" |
| 10 #include "src/full-codegen.h" | 10 #include "src/full-codegen.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 } else { | 365 } else { |
| 366 // Add job to the back of the input queue. | 366 // Add job to the back of the input queue. |
| 367 base::LockGuard<base::Mutex> access_input_queue(&input_queue_mutex_); | 367 base::LockGuard<base::Mutex> access_input_queue(&input_queue_mutex_); |
| 368 DCHECK_LT(input_queue_length_, input_queue_capacity_); | 368 DCHECK_LT(input_queue_length_, input_queue_capacity_); |
| 369 input_queue_[InputQueueIndex(input_queue_length_)] = job; | 369 input_queue_[InputQueueIndex(input_queue_length_)] = job; |
| 370 input_queue_length_++; | 370 input_queue_length_++; |
| 371 } | 371 } |
| 372 if (FLAG_block_concurrent_recompilation) { | 372 if (FLAG_block_concurrent_recompilation) { |
| 373 blocked_jobs_++; | 373 blocked_jobs_++; |
| 374 } else if (job_based_recompilation_) { | 374 } else if (job_based_recompilation_) { |
| 375 DCHECK(!FLAG_single_threaded); |
| 375 base::LockGuard<base::RecursiveMutex> lock(&task_count_mutex_); | 376 base::LockGuard<base::RecursiveMutex> lock(&task_count_mutex_); |
| 376 ++task_count_; | 377 ++task_count_; |
| 377 V8::GetCurrentPlatform()->CallOnBackgroundThread( | 378 V8::GetCurrentPlatform()->CallOnBackgroundThread( |
| 378 new CompileTask(isolate_), v8::Platform::kShortRunningTask); | 379 new CompileTask(isolate_), v8::Platform::kShortRunningTask); |
| 379 } else { | 380 } else { |
| 380 input_queue_semaphore_.Signal(); | 381 input_queue_semaphore_.Signal(); |
| 381 } | 382 } |
| 382 } | 383 } |
| 383 | 384 |
| 384 | 385 |
| 385 void OptimizingCompilerThread::Unblock() { | 386 void OptimizingCompilerThread::Unblock() { |
| 386 DCHECK(!IsOptimizerThread()); | 387 DCHECK(!IsOptimizerThread()); |
| 387 { | 388 { |
| 388 base::LockGuard<base::RecursiveMutex> lock(&task_count_mutex_); | 389 base::LockGuard<base::RecursiveMutex> lock(&task_count_mutex_); |
| 389 task_count_ += blocked_jobs_; | 390 task_count_ += blocked_jobs_; |
| 390 } | 391 } |
| 391 while (blocked_jobs_ > 0) { | 392 while (blocked_jobs_ > 0) { |
| 392 if (job_based_recompilation_) { | 393 if (job_based_recompilation_) { |
| 394 DCHECK(!FLAG_single_threaded); |
| 393 V8::GetCurrentPlatform()->CallOnBackgroundThread( | 395 V8::GetCurrentPlatform()->CallOnBackgroundThread( |
| 394 new CompileTask(isolate_), v8::Platform::kShortRunningTask); | 396 new CompileTask(isolate_), v8::Platform::kShortRunningTask); |
| 395 } else { | 397 } else { |
| 396 input_queue_semaphore_.Signal(); | 398 input_queue_semaphore_.Signal(); |
| 397 } | 399 } |
| 398 blocked_jobs_--; | 400 blocked_jobs_--; |
| 399 } | 401 } |
| 400 } | 402 } |
| 401 | 403 |
| 402 | 404 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 479 |
| 478 | 480 |
| 479 bool OptimizingCompilerThread::IsOptimizerThread() { | 481 bool OptimizingCompilerThread::IsOptimizerThread() { |
| 480 base::LockGuard<base::Mutex> lock_guard(&thread_id_mutex_); | 482 base::LockGuard<base::Mutex> lock_guard(&thread_id_mutex_); |
| 481 return ThreadId::Current().ToInteger() == thread_id_; | 483 return ThreadId::Current().ToInteger() == thread_id_; |
| 482 } | 484 } |
| 483 #endif | 485 #endif |
| 484 | 486 |
| 485 | 487 |
| 486 } } // namespace v8::internal | 488 } } // namespace v8::internal |
| OLD | NEW |