| 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-compile-dispatcher.h" | 5 #include "src/optimizing-compile-dispatcher.h" |
| 6 | 6 |
| 7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
| 8 #include "src/full-codegen/full-codegen.h" | 8 #include "src/full-codegen/full-codegen.h" |
| 9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
| 10 #include "src/tracing/trace-event.h" | 10 #include "src/tracing/trace-event.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 OptimizedCompileJob* OptimizingCompileDispatcher::NextInput( | 89 OptimizedCompileJob* OptimizingCompileDispatcher::NextInput( |
| 90 bool check_if_flushing) { | 90 bool check_if_flushing) { |
| 91 base::LockGuard<base::Mutex> access_input_queue_(&input_queue_mutex_); | 91 base::LockGuard<base::Mutex> access_input_queue_(&input_queue_mutex_); |
| 92 if (input_queue_length_ == 0) return NULL; | 92 if (input_queue_length_ == 0) return NULL; |
| 93 OptimizedCompileJob* job = input_queue_[InputQueueIndex(0)]; | 93 OptimizedCompileJob* job = input_queue_[InputQueueIndex(0)]; |
| 94 DCHECK_NOT_NULL(job); | 94 DCHECK_NOT_NULL(job); |
| 95 input_queue_shift_ = InputQueueIndex(1); | 95 input_queue_shift_ = InputQueueIndex(1); |
| 96 input_queue_length_--; | 96 input_queue_length_--; |
| 97 if (check_if_flushing) { | 97 if (check_if_flushing) { |
| 98 if (static_cast<ModeFlag>(base::Acquire_Load(&mode_)) == FLUSH) { | 98 if (static_cast<ModeFlag>(base::Acquire_Load(&mode_)) == FLUSH) { |
| 99 if (!job->info()->is_osr()) { | 99 AllowHandleDereference allow_handle_dereference; |
| 100 AllowHandleDereference allow_handle_dereference; | 100 DisposeOptimizedCompileJob(job, true); |
| 101 DisposeOptimizedCompileJob(job, true); | |
| 102 } | |
| 103 return NULL; | 101 return NULL; |
| 104 } | 102 } |
| 105 } | 103 } |
| 106 return job; | 104 return job; |
| 107 } | 105 } |
| 108 | 106 |
| 109 | 107 |
| 110 void OptimizingCompileDispatcher::CompileNext(OptimizedCompileJob* job) { | 108 void OptimizingCompileDispatcher::CompileNext(OptimizedCompileJob* job) { |
| 111 if (!job) return; | 109 if (!job) return; |
| 112 | 110 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 127 void OptimizingCompileDispatcher::FlushOutputQueue(bool restore_function_code) { | 125 void OptimizingCompileDispatcher::FlushOutputQueue(bool restore_function_code) { |
| 128 for (;;) { | 126 for (;;) { |
| 129 OptimizedCompileJob* job = NULL; | 127 OptimizedCompileJob* job = NULL; |
| 130 { | 128 { |
| 131 base::LockGuard<base::Mutex> access_output_queue_(&output_queue_mutex_); | 129 base::LockGuard<base::Mutex> access_output_queue_(&output_queue_mutex_); |
| 132 if (output_queue_.empty()) return; | 130 if (output_queue_.empty()) return; |
| 133 job = output_queue_.front(); | 131 job = output_queue_.front(); |
| 134 output_queue_.pop(); | 132 output_queue_.pop(); |
| 135 } | 133 } |
| 136 | 134 |
| 137 // OSR jobs are dealt with separately. | 135 DisposeOptimizedCompileJob(job, restore_function_code); |
| 138 if (!job->info()->is_osr()) { | |
| 139 DisposeOptimizedCompileJob(job, restore_function_code); | |
| 140 } | |
| 141 } | 136 } |
| 142 } | 137 } |
| 143 | 138 |
| 144 | 139 |
| 145 void OptimizingCompileDispatcher::Flush() { | 140 void OptimizingCompileDispatcher::Flush() { |
| 146 base::Release_Store(&mode_, static_cast<base::AtomicWord>(FLUSH)); | 141 base::Release_Store(&mode_, static_cast<base::AtomicWord>(FLUSH)); |
| 147 if (FLAG_block_concurrent_recompilation) Unblock(); | 142 if (FLAG_block_concurrent_recompilation) Unblock(); |
| 148 { | 143 { |
| 149 base::LockGuard<base::Mutex> lock_guard(&ref_count_mutex_); | 144 base::LockGuard<base::Mutex> lock_guard(&ref_count_mutex_); |
| 150 while (ref_count_ > 0) ref_count_zero_.Wait(&ref_count_mutex_); | 145 while (ref_count_ > 0) ref_count_zero_.Wait(&ref_count_mutex_); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 while (blocked_jobs_ > 0) { | 222 while (blocked_jobs_ > 0) { |
| 228 V8::GetCurrentPlatform()->CallOnBackgroundThread( | 223 V8::GetCurrentPlatform()->CallOnBackgroundThread( |
| 229 new CompileTask(isolate_), v8::Platform::kShortRunningTask); | 224 new CompileTask(isolate_), v8::Platform::kShortRunningTask); |
| 230 blocked_jobs_--; | 225 blocked_jobs_--; |
| 231 } | 226 } |
| 232 } | 227 } |
| 233 | 228 |
| 234 | 229 |
| 235 } // namespace internal | 230 } // namespace internal |
| 236 } // namespace v8 | 231 } // namespace v8 |
| OLD | NEW |