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

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

Issue 153913002: A64: Synchronize with r16756. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/platform.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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 if (FLAG_trace_concurrent_recompilation) { 67 if (FLAG_trace_concurrent_recompilation) {
68 time_spent_total_ = total_timer.Elapsed(); 68 time_spent_total_ = total_timer.Elapsed();
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));
78 Release_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE)); 77 Release_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE));
79 stop_semaphore_.Signal(); 78 stop_semaphore_.Signal();
80 // Return to start of consumer loop. 79 // Return to start of consumer loop.
81 continue; 80 continue;
82 } 81 }
83 82
84 ElapsedTimer compiling_timer; 83 ElapsedTimer compiling_timer;
85 if (FLAG_trace_concurrent_recompilation) compiling_timer.Start(); 84 if (FLAG_trace_concurrent_recompilation) compiling_timer.Start();
86 85
87 CompileNext(); 86 CompileNext();
(...skipping 19 matching lines...) Expand all
107 106
108 // The function may have already been optimized by OSR. Simply continue. 107 // The function may have already been optimized by OSR. Simply continue.
109 // Use a mutex to make sure that functions marked for install 108 // Use a mutex to make sure that functions marked for install
110 // are always also queued. 109 // are always also queued.
111 if (!optimizing_compiler->info()->osr_ast_id().IsNone()) { 110 if (!optimizing_compiler->info()->osr_ast_id().IsNone()) {
112 ASSERT(FLAG_concurrent_osr); 111 ASSERT(FLAG_concurrent_osr);
113 LockGuard<Mutex> access_osr_lists(&osr_list_mutex_); 112 LockGuard<Mutex> access_osr_lists(&osr_list_mutex_);
114 osr_candidates_.RemoveElement(optimizing_compiler); 113 osr_candidates_.RemoveElement(optimizing_compiler);
115 ready_for_osr_.Add(optimizing_compiler); 114 ready_for_osr_.Add(optimizing_compiler);
116 } else { 115 } else {
117 LockGuard<Mutex> mark_and_queue(&install_mutex_); 116 LockGuard<Mutex> access_queue(&queue_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.
132 input_queue_semaphore_.Wait(); 129 input_queue_semaphore_.Wait();
133 CompilationInfo* info = optimizing_compiler->info(); 130 CompilationInfo* info = optimizing_compiler->info();
134 if (restore_function_code) { 131 if (restore_function_code) {
135 Handle<JSFunction> function = info->closure(); 132 Handle<JSFunction> function = info->closure();
136 function->ReplaceCode(function->shared()->code()); 133 function->ReplaceCode(function->shared()->code());
137 } 134 }
138 delete info; 135 delete info;
139 } 136 }
137 Release_Store(&queue_length_, static_cast<AtomicWord>(0));
138
139 LockGuard<Mutex> access_osr_lists(&osr_list_mutex_);
140 osr_candidates_.Clear();
140 } 141 }
141 142
142 143
143 void OptimizingCompilerThread::FlushOutputQueue(bool restore_function_code) { 144 void OptimizingCompilerThread::FlushOutputQueue(bool restore_function_code) {
144 OptimizingCompiler* optimizing_compiler; 145 OptimizingCompiler* optimizing_compiler;
145 // The optimizing compiler is allocated in the CompilationInfo's zone. 146 // The optimizing compiler is allocated in the CompilationInfo's zone.
146 while (output_queue_.Dequeue(&optimizing_compiler)) { 147 while (true) {
148 { LockGuard<Mutex> access_queue(&queue_mutex_);
149 if (!output_queue_.Dequeue(&optimizing_compiler)) break;
150 }
147 CompilationInfo* info = optimizing_compiler->info(); 151 CompilationInfo* info = optimizing_compiler->info();
148 if (restore_function_code) { 152 if (restore_function_code) {
149 Handle<JSFunction> function = info->closure(); 153 Handle<JSFunction> function = info->closure();
150 function->ReplaceCode(function->shared()->code()); 154 function->ReplaceCode(function->shared()->code());
151 } 155 }
152 delete info; 156 delete info;
153 } 157 }
154 158
155 osr_candidates_.Clear();
156 RemoveStaleOSRCandidates(0); 159 RemoveStaleOSRCandidates(0);
157 } 160 }
158 161
159 162
160 void OptimizingCompilerThread::Flush() { 163 void OptimizingCompilerThread::Flush() {
161 ASSERT(!IsOptimizerThread()); 164 ASSERT(!IsOptimizerThread());
162 Release_Store(&stop_thread_, static_cast<AtomicWord>(FLUSH)); 165 Release_Store(&stop_thread_, static_cast<AtomicWord>(FLUSH));
163 input_queue_semaphore_.Signal(); 166 input_queue_semaphore_.Signal();
164 stop_semaphore_.Wait(); 167 stop_semaphore_.Wait();
165 FlushOutputQueue(true); 168 FlushOutputQueue(true);
(...skipping 26 matching lines...) Expand all
192 PrintF("[COSR hit rate %d / %d]\n", osr_hits_, osr_attempts_); 195 PrintF("[COSR hit rate %d / %d]\n", osr_hits_, osr_attempts_);
193 } 196 }
194 197
195 Join(); 198 Join();
196 } 199 }
197 200
198 201
199 void OptimizingCompilerThread::InstallOptimizedFunctions() { 202 void OptimizingCompilerThread::InstallOptimizedFunctions() {
200 ASSERT(!IsOptimizerThread()); 203 ASSERT(!IsOptimizerThread());
201 HandleScope handle_scope(isolate_); 204 HandleScope handle_scope(isolate_);
205
202 OptimizingCompiler* compiler; 206 OptimizingCompiler* compiler;
203 while (true) { 207 while (true) {
204 { // Memory barrier to ensure marked functions are queued. 208 { LockGuard<Mutex> access_queue(&queue_mutex_);
205 LockGuard<Mutex> marked_and_queued(&install_mutex_); 209 if (!output_queue_.Dequeue(&compiler)) break;
206 if (!output_queue_.Dequeue(&compiler)) return;
207 } 210 }
208 Compiler::InstallOptimizedCode(compiler); 211 Compiler::InstallOptimizedCode(compiler);
209 } 212 }
210 213
211 // Remove the oldest OSR candidates that are ready so that we 214 // Remove the oldest OSR candidates that are ready so that we
212 // only have limited number of them waiting. 215 // only have limited number of them waiting.
213 if (FLAG_concurrent_osr) RemoveStaleOSRCandidates(); 216 if (FLAG_concurrent_osr) RemoveStaleOSRCandidates();
214 } 217 }
215 218
216 219
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 #ifdef DEBUG 297 #ifdef DEBUG
295 bool OptimizingCompilerThread::IsOptimizerThread() { 298 bool OptimizingCompilerThread::IsOptimizerThread() {
296 if (!FLAG_concurrent_recompilation) return false; 299 if (!FLAG_concurrent_recompilation) return false;
297 LockGuard<Mutex> lock_guard(&thread_id_mutex_); 300 LockGuard<Mutex> lock_guard(&thread_id_mutex_);
298 return ThreadId::Current().ToInteger() == thread_id_; 301 return ThreadId::Current().ToInteger() == thread_id_;
299 } 302 }
300 #endif 303 #endif
301 304
302 305
303 } } // namespace v8::internal 306 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/optimizing-compiler-thread.h ('k') | src/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698