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

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

Issue 21156009: Re-revert "Flush parallel recompilation queues on context dispose notification" (r15883). (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.cc » ('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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_parallel);
58 58
59 if (FLAG_parallel_recompilation_delay != 0) { 59 if (FLAG_parallel_recompilation_delay != 0) {
60 OS::Sleep(FLAG_parallel_recompilation_delay); 60 OS::Sleep(FLAG_parallel_recompilation_delay);
61 } 61 }
62 62
63 switch (static_cast<StopFlag>(Acquire_Load(&stop_thread_))) { 63 if (Acquire_Load(&stop_thread_)) {
64 case CONTINUE: 64 stop_semaphore_->Signal();
65 break; 65 if (FLAG_trace_parallel_recompilation) {
66 case STOP: 66 time_spent_total_ = OS::Ticks() - epoch;
67 if (FLAG_trace_parallel_recompilation) { 67 }
68 time_spent_total_ = OS::Ticks() - epoch; 68 return;
69 }
70 stop_semaphore_->Signal();
71 return;
72 case FLUSH:
73 // Reset input queue semaphore.
74 delete input_queue_semaphore_;
75 input_queue_semaphore_ = OS::CreateSemaphore(0);
76 // Signal for main thread to start flushing.
77 stop_semaphore_->Signal();
78 // Return to start of consumer loop.
79 continue;
80 } 69 }
81 70
82 int64_t compiling_start = 0; 71 int64_t compiling_start = 0;
83 if (FLAG_trace_parallel_recompilation) compiling_start = OS::Ticks(); 72 if (FLAG_trace_parallel_recompilation) compiling_start = OS::Ticks();
84 73
85 CompileNext(); 74 CompileNext();
86 75
87 if (FLAG_trace_parallel_recompilation) { 76 if (FLAG_trace_parallel_recompilation) {
88 time_spent_compiling_ += OS::Ticks() - compiling_start; 77 time_spent_compiling_ += OS::Ticks() - compiling_start;
89 } 78 }
(...skipping 16 matching lines...) Expand all
106 // are always also queued. 95 // are always also queued.
107 ScopedLock mark_and_queue(install_mutex_); 96 ScopedLock mark_and_queue(install_mutex_);
108 { Heap::RelocationLock relocation_lock(isolate_->heap()); 97 { Heap::RelocationLock relocation_lock(isolate_->heap());
109 AllowHandleDereference ahd; 98 AllowHandleDereference ahd;
110 optimizing_compiler->info()->closure()->MarkForInstallingRecompiledCode(); 99 optimizing_compiler->info()->closure()->MarkForInstallingRecompiledCode();
111 } 100 }
112 output_queue_.Enqueue(optimizing_compiler); 101 output_queue_.Enqueue(optimizing_compiler);
113 } 102 }
114 103
115 104
116 void OptimizingCompilerThread::FlushQueue(
117 UnboundQueue<OptimizingCompiler*>* queue,
118 bool restore_function_code) {
119 ASSERT(!IsOptimizerThread());
120 OptimizingCompiler* optimizing_compiler;
121 // The optimizing compiler is allocated in the CompilationInfo's zone.
122 while (queue->Dequeue(&optimizing_compiler)) {
123 CompilationInfo* info = optimizing_compiler->info();
124 if (restore_function_code) {
125 Handle<JSFunction> function = info->closure();
126 function->ReplaceCode(function->shared()->code());
127 }
128 delete info;
129 }
130 }
131
132
133 void OptimizingCompilerThread::Flush() {
134 ASSERT(!IsOptimizerThread());
135 Release_Store(&stop_thread_, static_cast<AtomicWord>(FLUSH));
136 input_queue_semaphore_->Signal();
137
138 FlushQueue(&input_queue_, true);
139 NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0));
140
141 stop_semaphore_->Wait();
142 Release_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE));
143
144 FlushQueue(&output_queue_, true);
145 }
146
147
148 void OptimizingCompilerThread::Stop() { 105 void OptimizingCompilerThread::Stop() {
149 ASSERT(!IsOptimizerThread()); 106 ASSERT(!IsOptimizerThread());
150 Release_Store(&stop_thread_, static_cast<AtomicWord>(STOP)); 107 Release_Store(&stop_thread_, static_cast<AtomicWord>(true));
151 input_queue_semaphore_->Signal(); 108 input_queue_semaphore_->Signal();
152 stop_semaphore_->Wait(); 109 stop_semaphore_->Wait();
153 110
154 if (FLAG_parallel_recompilation_delay != 0) { 111 if (FLAG_parallel_recompilation_delay != 0) {
155 // Barrier when loading queue length is not necessary since the write 112 // Barrier when loading queue length is not necessary since the write
156 // happens in CompileNext on the same thread. 113 // happens in CompileNext on the same thread.
157 while (NoBarrier_Load(&queue_length_) > 0) CompileNext(); 114 while (NoBarrier_Load(&queue_length_) > 0) CompileNext();
158 InstallOptimizedFunctions(); 115 InstallOptimizedFunctions();
159 } else { 116 } else {
160 FlushQueue(&input_queue_, false); 117 OptimizingCompiler* optimizing_compiler;
161 FlushQueue(&output_queue_, false); 118 // The optimizing compiler is allocated in the CompilationInfo's zone.
119 while (input_queue_.Dequeue(&optimizing_compiler)) {
120 delete optimizing_compiler->info();
121 }
122 while (output_queue_.Dequeue(&optimizing_compiler)) {
123 delete optimizing_compiler->info();
124 }
162 } 125 }
163 126
164 if (FLAG_trace_parallel_recompilation) { 127 if (FLAG_trace_parallel_recompilation) {
165 double compile_time = static_cast<double>(time_spent_compiling_); 128 double compile_time = static_cast<double>(time_spent_compiling_);
166 double total_time = static_cast<double>(time_spent_total_); 129 double total_time = static_cast<double>(time_spent_total_);
167 double percentage = (compile_time * 100) / total_time; 130 double percentage = (compile_time * 100) / total_time;
168 PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage); 131 PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage);
169 } 132 }
170 133
171 Join(); 134 Join();
(...skipping 28 matching lines...) Expand all
200 #ifdef DEBUG 163 #ifdef DEBUG
201 bool OptimizingCompilerThread::IsOptimizerThread() { 164 bool OptimizingCompilerThread::IsOptimizerThread() {
202 if (!FLAG_parallel_recompilation) return false; 165 if (!FLAG_parallel_recompilation) return false;
203 ScopedLock lock(thread_id_mutex_); 166 ScopedLock lock(thread_id_mutex_);
204 return ThreadId::Current().ToInteger() == thread_id_; 167 return ThreadId::Current().ToInteger() == thread_id_;
205 } 168 }
206 #endif 169 #endif
207 170
208 171
209 } } // namespace v8::internal 172 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/optimizing-compiler-thread.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698