Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: src/optimizing-compiler-thread.cc

Issue 23014007: Rename "parallel recompilation" to "concurrent recompilation". (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/optimizing-compiler-thread.h ('k') | src/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 { ScopedLock lock(thread_id_mutex_); 42 { ScopedLock lock(thread_id_mutex_);
43 thread_id_ = ThreadId::Current().ToInteger(); 43 thread_id_ = ThreadId::Current().ToInteger();
44 } 44 }
45 #endif 45 #endif
46 Isolate::SetIsolateThreadLocals(isolate_, NULL); 46 Isolate::SetIsolateThreadLocals(isolate_, NULL);
47 DisallowHeapAllocation no_allocation; 47 DisallowHeapAllocation no_allocation;
48 DisallowHandleAllocation no_handles; 48 DisallowHandleAllocation no_handles;
49 DisallowHandleDereference no_deref; 49 DisallowHandleDereference no_deref;
50 50
51 int64_t epoch = 0; 51 int64_t epoch = 0;
52 if (FLAG_trace_parallel_recompilation) epoch = OS::Ticks(); 52 if (FLAG_trace_concurrent_recompilation) epoch = OS::Ticks();
53 53
54 while (true) { 54 while (true) {
55 input_queue_semaphore_->Wait(); 55 input_queue_semaphore_->Wait();
56 Logger::TimerEventScope timer( 56 Logger::TimerEventScope timer(
57 isolate_, Logger::TimerEventScope::v8_recompile_parallel); 57 isolate_, Logger::TimerEventScope::v8_recompile_concurrent);
58 58
59 if (FLAG_parallel_recompilation_delay != 0) { 59 if (FLAG_concurrent_recompilation_delay != 0) {
60 OS::Sleep(FLAG_parallel_recompilation_delay); 60 OS::Sleep(FLAG_concurrent_recompilation_delay);
61 } 61 }
62 62
63 switch (static_cast<StopFlag>(Acquire_Load(&stop_thread_))) { 63 switch (static_cast<StopFlag>(Acquire_Load(&stop_thread_))) {
64 case CONTINUE: 64 case CONTINUE:
65 break; 65 break;
66 case STOP: 66 case STOP:
67 if (FLAG_trace_parallel_recompilation) { 67 if (FLAG_trace_concurrent_recompilation) {
68 time_spent_total_ = OS::Ticks() - epoch; 68 time_spent_total_ = OS::Ticks() - epoch;
69 } 69 }
70 stop_semaphore_->Signal(); 70 stop_semaphore_->Signal();
71 return; 71 return;
72 case FLUSH: 72 case FLUSH:
73 // The main thread is blocked, waiting for the stop semaphore. 73 // The main thread is blocked, waiting for the stop semaphore.
74 { AllowHandleDereference allow_handle_dereference; 74 { AllowHandleDereference allow_handle_dereference;
75 FlushInputQueue(true); 75 FlushInputQueue(true);
76 } 76 }
77 Release_Store(&queue_length_, static_cast<AtomicWord>(0)); 77 Release_Store(&queue_length_, static_cast<AtomicWord>(0));
78 Release_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE)); 78 Release_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE));
79 stop_semaphore_->Signal(); 79 stop_semaphore_->Signal();
80 // Return to start of consumer loop. 80 // Return to start of consumer loop.
81 continue; 81 continue;
82 } 82 }
83 83
84 int64_t compiling_start = 0; 84 int64_t compiling_start = 0;
85 if (FLAG_trace_parallel_recompilation) compiling_start = OS::Ticks(); 85 if (FLAG_trace_concurrent_recompilation) compiling_start = OS::Ticks();
86 86
87 CompileNext(); 87 CompileNext();
88 88
89 if (FLAG_trace_parallel_recompilation) { 89 if (FLAG_trace_concurrent_recompilation) {
90 time_spent_compiling_ += OS::Ticks() - compiling_start; 90 time_spent_compiling_ += OS::Ticks() - compiling_start;
91 } 91 }
92 } 92 }
93 } 93 }
94 94
95 95
96 void OptimizingCompilerThread::CompileNext() { 96 void OptimizingCompilerThread::CompileNext() {
97 OptimizingCompiler* optimizing_compiler = NULL; 97 OptimizingCompiler* optimizing_compiler = NULL;
98 bool result = input_queue_.Dequeue(&optimizing_compiler); 98 bool result = input_queue_.Dequeue(&optimizing_compiler);
99 USE(result); 99 USE(result);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 FlushOutputQueue(true); 156 FlushOutputQueue(true);
157 } 157 }
158 158
159 159
160 void OptimizingCompilerThread::Stop() { 160 void OptimizingCompilerThread::Stop() {
161 ASSERT(!IsOptimizerThread()); 161 ASSERT(!IsOptimizerThread());
162 Release_Store(&stop_thread_, static_cast<AtomicWord>(STOP)); 162 Release_Store(&stop_thread_, static_cast<AtomicWord>(STOP));
163 input_queue_semaphore_->Signal(); 163 input_queue_semaphore_->Signal();
164 stop_semaphore_->Wait(); 164 stop_semaphore_->Wait();
165 165
166 if (FLAG_parallel_recompilation_delay != 0) { 166 if (FLAG_concurrent_recompilation_delay != 0) {
167 // Barrier when loading queue length is not necessary since the write 167 // Barrier when loading queue length is not necessary since the write
168 // happens in CompileNext on the same thread. 168 // happens in CompileNext on the same thread.
169 // This is used only for testing. 169 // This is used only for testing.
170 while (NoBarrier_Load(&queue_length_) > 0) CompileNext(); 170 while (NoBarrier_Load(&queue_length_) > 0) CompileNext();
171 InstallOptimizedFunctions(); 171 InstallOptimizedFunctions();
172 } else { 172 } else {
173 FlushInputQueue(false); 173 FlushInputQueue(false);
174 FlushOutputQueue(false); 174 FlushOutputQueue(false);
175 } 175 }
176 176
177 if (FLAG_trace_parallel_recompilation) { 177 if (FLAG_trace_concurrent_recompilation) {
178 double compile_time = static_cast<double>(time_spent_compiling_); 178 double compile_time = static_cast<double>(time_spent_compiling_);
179 double total_time = static_cast<double>(time_spent_total_); 179 double total_time = static_cast<double>(time_spent_total_);
180 double percentage = (compile_time * 100) / total_time; 180 double percentage = (compile_time * 100) / total_time;
181 PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage); 181 PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage);
182 } 182 }
183 183
184 Join(); 184 Join();
185 } 185 }
186 186
187 187
(...skipping 17 matching lines...) Expand all
205 ASSERT(!IsOptimizerThread()); 205 ASSERT(!IsOptimizerThread());
206 Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(1)); 206 Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(1));
207 optimizing_compiler->info()->closure()->MarkInRecompileQueue(); 207 optimizing_compiler->info()->closure()->MarkInRecompileQueue();
208 input_queue_.Enqueue(optimizing_compiler); 208 input_queue_.Enqueue(optimizing_compiler);
209 input_queue_semaphore_->Signal(); 209 input_queue_semaphore_->Signal();
210 } 210 }
211 211
212 212
213 #ifdef DEBUG 213 #ifdef DEBUG
214 bool OptimizingCompilerThread::IsOptimizerThread() { 214 bool OptimizingCompilerThread::IsOptimizerThread() {
215 if (!FLAG_parallel_recompilation) return false; 215 if (!FLAG_concurrent_recompilation) return false;
216 ScopedLock lock(thread_id_mutex_); 216 ScopedLock lock(thread_id_mutex_);
217 return ThreadId::Current().ToInteger() == thread_id_; 217 return ThreadId::Current().ToInteger() == thread_id_;
218 } 218 }
219 #endif 219 #endif
220 220
221 221
222 } } // namespace v8::internal 222 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/optimizing-compiler-thread.h ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698