| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 if (!optimizing_compiler->info()->osr_ast_id().IsNone()) { | 111 if (!optimizing_compiler->info()->osr_ast_id().IsNone()) { |
| 112 ASSERT(FLAG_concurrent_osr); | 112 ASSERT(FLAG_concurrent_osr); |
| 113 LockGuard<Mutex> access_osr_lists(&osr_list_mutex_); | 113 LockGuard<Mutex> access_osr_lists(&osr_list_mutex_); |
| 114 osr_candidates_.RemoveElement(optimizing_compiler); | 114 osr_candidates_.RemoveElement(optimizing_compiler); |
| 115 ready_for_osr_.Add(optimizing_compiler); | 115 ready_for_osr_.Add(optimizing_compiler); |
| 116 } else { | 116 } else { |
| 117 LockGuard<Mutex> mark_and_queue(&install_mutex_); | |
| 118 Heap::RelocationLock relocation_lock(isolate_->heap()); | |
| 119 AllowHandleDereference ahd; | |
| 120 optimizing_compiler->info()->closure()->MarkForInstallingRecompiledCode(); | |
| 121 output_queue_.Enqueue(optimizing_compiler); | 117 output_queue_.Enqueue(optimizing_compiler); |
| 118 isolate_->stack_guard()->RequestInstallCode(); |
| 122 } | 119 } |
| 123 } | 120 } |
| 124 | 121 |
| 125 | 122 |
| 126 void OptimizingCompilerThread::FlushInputQueue(bool restore_function_code) { | 123 void OptimizingCompilerThread::FlushInputQueue(bool restore_function_code) { |
| 127 OptimizingCompiler* optimizing_compiler; | 124 OptimizingCompiler* optimizing_compiler; |
| 128 // The optimizing compiler is allocated in the CompilationInfo's zone. | 125 // The optimizing compiler is allocated in the CompilationInfo's zone. |
| 129 while (input_queue_.Dequeue(&optimizing_compiler)) { | 126 while (input_queue_.Dequeue(&optimizing_compiler)) { |
| 130 // This should not block, since we have one signal on the input queue | 127 // This should not block, since we have one signal on the input queue |
| 131 // semaphore corresponding to each element in the input queue. | 128 // semaphore corresponding to each element in the input queue. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 191 |
| 195 Join(); | 192 Join(); |
| 196 } | 193 } |
| 197 | 194 |
| 198 | 195 |
| 199 void OptimizingCompilerThread::InstallOptimizedFunctions() { | 196 void OptimizingCompilerThread::InstallOptimizedFunctions() { |
| 200 ASSERT(!IsOptimizerThread()); | 197 ASSERT(!IsOptimizerThread()); |
| 201 HandleScope handle_scope(isolate_); | 198 HandleScope handle_scope(isolate_); |
| 202 OptimizingCompiler* compiler; | 199 OptimizingCompiler* compiler; |
| 203 while (true) { | 200 while (true) { |
| 204 { // Memory barrier to ensure marked functions are queued. | 201 if (!output_queue_.Dequeue(&compiler)) return; |
| 205 LockGuard<Mutex> marked_and_queued(&install_mutex_); | |
| 206 if (!output_queue_.Dequeue(&compiler)) return; | |
| 207 } | |
| 208 Compiler::InstallOptimizedCode(compiler); | 202 Compiler::InstallOptimizedCode(compiler); |
| 209 } | 203 } |
| 210 | 204 |
| 211 // Remove the oldest OSR candidates that are ready so that we | 205 // Remove the oldest OSR candidates that are ready so that we |
| 212 // only have limited number of them waiting. | 206 // only have limited number of them waiting. |
| 213 if (FLAG_concurrent_osr) RemoveStaleOSRCandidates(); | 207 if (FLAG_concurrent_osr) RemoveStaleOSRCandidates(); |
| 214 } | 208 } |
| 215 | 209 |
| 216 | 210 |
| 217 void OptimizingCompilerThread::QueueForOptimization( | 211 void OptimizingCompilerThread::QueueForOptimization( |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 #ifdef DEBUG | 288 #ifdef DEBUG |
| 295 bool OptimizingCompilerThread::IsOptimizerThread() { | 289 bool OptimizingCompilerThread::IsOptimizerThread() { |
| 296 if (!FLAG_concurrent_recompilation) return false; | 290 if (!FLAG_concurrent_recompilation) return false; |
| 297 LockGuard<Mutex> lock_guard(&thread_id_mutex_); | 291 LockGuard<Mutex> lock_guard(&thread_id_mutex_); |
| 298 return ThreadId::Current().ToInteger() == thread_id_; | 292 return ThreadId::Current().ToInteger() == thread_id_; |
| 299 } | 293 } |
| 300 #endif | 294 #endif |
| 301 | 295 |
| 302 | 296 |
| 303 } } // namespace v8::internal | 297 } } // namespace v8::internal |
| OLD | NEW |