| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(-1)); | 101 Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(-1)); |
| 102 | 102 |
| 103 // The function may have already been optimized by OSR. Simply continue. | 103 // The function may have already been optimized by OSR. Simply continue. |
| 104 RecompileJob::Status status = job->OptimizeGraph(); | 104 RecompileJob::Status status = job->OptimizeGraph(); |
| 105 USE(status); // Prevent an unused-variable error in release mode. | 105 USE(status); // Prevent an unused-variable error in release mode. |
| 106 ASSERT(status != RecompileJob::FAILED); | 106 ASSERT(status != RecompileJob::FAILED); |
| 107 | 107 |
| 108 // The function may have already been optimized by OSR. Simply continue. | 108 // The function may have already been optimized by OSR. Simply continue. |
| 109 // Use a mutex to make sure that functions marked for install | 109 // Use a mutex to make sure that functions marked for install |
| 110 // are always also queued. | 110 // are always also queued. |
| 111 LockGuard<Mutex> access_queue(&queue_mutex_); | |
| 112 output_queue_.Enqueue(job); | 111 output_queue_.Enqueue(job); |
| 113 isolate_->stack_guard()->RequestInstallCode(); | 112 isolate_->stack_guard()->RequestInstallCode(); |
| 114 } | 113 } |
| 115 | 114 |
| 116 | 115 |
| 117 static void DisposeRecompileJob(RecompileJob* job, | 116 static void DisposeRecompileJob(RecompileJob* job, |
| 118 bool restore_function_code) { | 117 bool restore_function_code) { |
| 119 // The recompile job is allocated in the CompilationInfo's zone. | 118 // The recompile job is allocated in the CompilationInfo's zone. |
| 120 CompilationInfo* info = job->info(); | 119 CompilationInfo* info = job->info(); |
| 121 if (restore_function_code) { | 120 if (restore_function_code) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 140 if (!job->info()->is_osr()) { | 139 if (!job->info()->is_osr()) { |
| 141 DisposeRecompileJob(job, restore_function_code); | 140 DisposeRecompileJob(job, restore_function_code); |
| 142 } | 141 } |
| 143 } | 142 } |
| 144 Release_Store(&queue_length_, static_cast<AtomicWord>(0)); | 143 Release_Store(&queue_length_, static_cast<AtomicWord>(0)); |
| 145 } | 144 } |
| 146 | 145 |
| 147 | 146 |
| 148 void OptimizingCompilerThread::FlushOutputQueue(bool restore_function_code) { | 147 void OptimizingCompilerThread::FlushOutputQueue(bool restore_function_code) { |
| 149 RecompileJob* job; | 148 RecompileJob* job; |
| 150 while (true) { | 149 while (output_queue_.Dequeue(&job)) { |
| 151 { LockGuard<Mutex> access_queue(&queue_mutex_); | |
| 152 if (!output_queue_.Dequeue(&job)) break; | |
| 153 } | |
| 154 // OSR jobs are dealt with separately. | 150 // OSR jobs are dealt with separately. |
| 155 if (!job->info()->is_osr()) { | 151 if (!job->info()->is_osr()) { |
| 156 DisposeRecompileJob(job, restore_function_code); | 152 DisposeRecompileJob(job, restore_function_code); |
| 157 } | 153 } |
| 158 } | 154 } |
| 159 } | 155 } |
| 160 | 156 |
| 161 | 157 |
| 162 void OptimizingCompilerThread::FlushOsrBuffer(bool restore_function_code) { | 158 void OptimizingCompilerThread::FlushOsrBuffer(bool restore_function_code) { |
| 163 RecompileJob* job; | 159 RecompileJob* job; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 209 |
| 214 Join(); | 210 Join(); |
| 215 } | 211 } |
| 216 | 212 |
| 217 | 213 |
| 218 void OptimizingCompilerThread::InstallOptimizedFunctions() { | 214 void OptimizingCompilerThread::InstallOptimizedFunctions() { |
| 219 ASSERT(!IsOptimizerThread()); | 215 ASSERT(!IsOptimizerThread()); |
| 220 HandleScope handle_scope(isolate_); | 216 HandleScope handle_scope(isolate_); |
| 221 | 217 |
| 222 RecompileJob* job; | 218 RecompileJob* job; |
| 223 while (true) { | 219 while (output_queue_.Dequeue(&job)) { |
| 224 { LockGuard<Mutex> access_queue(&queue_mutex_); | |
| 225 if (!output_queue_.Dequeue(&job)) break; | |
| 226 } | |
| 227 CompilationInfo* info = job->info(); | 220 CompilationInfo* info = job->info(); |
| 228 if (info->is_osr()) { | 221 if (info->is_osr()) { |
| 229 if (FLAG_trace_osr) { | 222 if (FLAG_trace_osr) { |
| 230 PrintF("[COSR - "); | 223 PrintF("[COSR - "); |
| 231 info->closure()->PrintName(); | 224 info->closure()->PrintName(); |
| 232 PrintF(" is ready for install and entry at AST id %d]\n", | 225 PrintF(" is ready for install and entry at AST id %d]\n", |
| 233 info->osr_ast_id().ToInt()); | 226 info->osr_ast_id().ToInt()); |
| 234 } | 227 } |
| 235 job->WaitForInstall(); | 228 job->WaitForInstall(); |
| 236 BackEdgeTable::RemoveStackCheck(info); | 229 BackEdgeTable::RemoveStackCheck(info); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 #ifdef DEBUG | 328 #ifdef DEBUG |
| 336 bool OptimizingCompilerThread::IsOptimizerThread() { | 329 bool OptimizingCompilerThread::IsOptimizerThread() { |
| 337 if (!FLAG_concurrent_recompilation) return false; | 330 if (!FLAG_concurrent_recompilation) return false; |
| 338 LockGuard<Mutex> lock_guard(&thread_id_mutex_); | 331 LockGuard<Mutex> lock_guard(&thread_id_mutex_); |
| 339 return ThreadId::Current().ToInteger() == thread_id_; | 332 return ThreadId::Current().ToInteger() == thread_id_; |
| 340 } | 333 } |
| 341 #endif | 334 #endif |
| 342 | 335 |
| 343 | 336 |
| 344 } } // namespace v8::internal | 337 } } // namespace v8::internal |
| OLD | NEW |