Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 36 namespace v8 { | 36 namespace v8 { |
| 37 namespace internal { | 37 namespace internal { |
| 38 | 38 |
| 39 | 39 |
| 40 void OptimizingCompilerThread::Run() { | 40 void OptimizingCompilerThread::Run() { |
| 41 #ifdef DEBUG | 41 #ifdef DEBUG |
| 42 thread_id_ = ThreadId::Current().ToInteger(); | 42 thread_id_ = ThreadId::Current().ToInteger(); |
| 43 #endif | 43 #endif |
| 44 Isolate::SetIsolateThreadLocals(isolate_, NULL); | 44 Isolate::SetIsolateThreadLocals(isolate_, NULL); |
| 45 | 45 |
| 46 int64_t epoch = 0; | |
| 47 if (FLAG_trace_parallel_recompilation) epoch = OS::Ticks(); | |
| 48 | |
| 46 while (true) { | 49 while (true) { |
| 47 input_queue_semaphore_->Wait(); | 50 input_queue_semaphore_->Wait(); |
| 48 if (Acquire_Load(&stop_thread_)) { | 51 if (Acquire_Load(&stop_thread_)) { |
| 49 stop_semaphore_->Signal(); | 52 stop_semaphore_->Signal(); |
| 53 if (FLAG_trace_parallel_recompilation) { | |
| 54 time_spent_total_ = OS::Ticks() - epoch; | |
| 55 } | |
| 50 return; | 56 return; |
| 51 } | 57 } |
| 52 | 58 |
| 59 int64_t compiling_start = 0; | |
| 60 if (FLAG_trace_parallel_recompilation) compiling_start = OS::Ticks(); | |
| 61 | |
| 53 Heap::RelocationLock relocation_lock(isolate_->heap()); | 62 Heap::RelocationLock relocation_lock(isolate_->heap()); |
| 54 OptimizingCompiler* optimizing_compiler = NULL; | 63 OptimizingCompiler* optimizing_compiler = NULL; |
| 55 input_queue_.Dequeue(&optimizing_compiler); | 64 input_queue_.Dequeue(&optimizing_compiler); |
| 56 Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(-1)); | 65 Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(-1)); |
| 57 | 66 |
| 58 ASSERT(!optimizing_compiler->info()->closure()->IsOptimized()); | 67 ASSERT(!optimizing_compiler->info()->closure()->IsOptimized()); |
| 59 | 68 |
| 60 OptimizingCompiler::Status status = optimizing_compiler->OptimizeGraph(); | 69 OptimizingCompiler::Status status = optimizing_compiler->OptimizeGraph(); |
| 61 ASSERT(status != OptimizingCompiler::FAILED); | 70 ASSERT(status != OptimizingCompiler::FAILED); |
| 62 // Prevent an unused-variable error in release mode. | 71 // Prevent an unused-variable error in release mode. |
| 63 (void) status; | 72 (void) status; |
|
Yang
2012/07/20 08:21:38
Change this to USE(status)
| |
| 64 | 73 |
| 65 output_queue_.Enqueue(optimizing_compiler); | 74 output_queue_.Enqueue(optimizing_compiler); |
| 66 isolate_->stack_guard()->RequestCodeReadyEvent(); | 75 isolate_->stack_guard()->RequestCodeReadyEvent(); |
| 76 | |
| 77 if (FLAG_trace_parallel_recompilation) { | |
| 78 time_spent_compiling_ += OS::Ticks() - compiling_start; | |
| 79 } | |
| 67 } | 80 } |
| 68 } | 81 } |
| 69 | 82 |
| 70 | 83 |
| 71 void OptimizingCompilerThread::Stop() { | 84 void OptimizingCompilerThread::Stop() { |
| 72 Release_Store(&stop_thread_, static_cast<AtomicWord>(true)); | 85 Release_Store(&stop_thread_, static_cast<AtomicWord>(true)); |
| 73 input_queue_semaphore_->Signal(); | 86 input_queue_semaphore_->Signal(); |
| 74 stop_semaphore_->Wait(); | 87 stop_semaphore_->Wait(); |
| 88 | |
| 89 if (FLAG_trace_parallel_recompilation) { | |
| 90 double compile_time = static_cast<double>(time_spent_compiling_); | |
| 91 double total_time = static_cast<double>(time_spent_total_); | |
| 92 double percentage = (compile_time * 100) / total_time; | |
| 93 PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage); | |
| 94 } | |
| 75 } | 95 } |
| 76 | 96 |
| 77 | 97 |
| 78 void OptimizingCompilerThread::InstallOptimizedFunctions() { | 98 void OptimizingCompilerThread::InstallOptimizedFunctions() { |
| 79 HandleScope handle_scope(isolate_); | 99 HandleScope handle_scope(isolate_); |
| 80 int functions_installed = 0; | 100 int functions_installed = 0; |
| 81 while (!output_queue_.IsEmpty()) { | 101 while (!output_queue_.IsEmpty()) { |
| 82 OptimizingCompiler* compiler = NULL; | 102 OptimizingCompiler* compiler = NULL; |
| 83 output_queue_.Dequeue(&compiler); | 103 output_queue_.Dequeue(&compiler); |
| 84 Compiler::InstallOptimizedCode(compiler); | 104 Compiler::InstallOptimizedCode(compiler); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 98 | 118 |
| 99 #ifdef DEBUG | 119 #ifdef DEBUG |
| 100 bool OptimizingCompilerThread::IsOptimizerThread() { | 120 bool OptimizingCompilerThread::IsOptimizerThread() { |
| 101 if (!FLAG_parallel_recompilation) return false; | 121 if (!FLAG_parallel_recompilation) return false; |
| 102 return ThreadId::Current().ToInteger() == thread_id_; | 122 return ThreadId::Current().ToInteger() == thread_id_; |
| 103 } | 123 } |
| 104 #endif | 124 #endif |
| 105 | 125 |
| 106 | 126 |
| 107 } } // namespace v8::internal | 127 } } // namespace v8::internal |
| OLD | NEW |