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

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

Issue 23690003: Revert "Add Chromium-style TimeDelta, Time and TimeTicks classes, and a new ElapsedTimer class." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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/parser.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 30 matching lines...) Expand all
41 #ifdef DEBUG 41 #ifdef DEBUG
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 ElapsedTimer total_timer; 51 int64_t epoch = 0;
52 if (FLAG_trace_concurrent_recompilation) total_timer.Start(); 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_concurrent); 57 isolate_, Logger::TimerEventScope::v8_recompile_concurrent);
58 58
59 if (FLAG_concurrent_recompilation_delay != 0) { 59 if (FLAG_concurrent_recompilation_delay != 0) {
60 OS::Sleep(FLAG_concurrent_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_concurrent_recompilation) { 67 if (FLAG_trace_concurrent_recompilation) {
68 time_spent_total_ = total_timer.Elapsed(); 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 ElapsedTimer compiling_timer; 84 int64_t compiling_start = 0;
85 if (FLAG_trace_concurrent_recompilation) compiling_timer.Start(); 85 if (FLAG_trace_concurrent_recompilation) compiling_start = OS::Ticks();
86 86
87 CompileNext(); 87 CompileNext();
88 88
89 if (FLAG_trace_concurrent_recompilation) { 89 if (FLAG_trace_concurrent_recompilation) {
90 time_spent_compiling_ += compiling_timer.Elapsed(); 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);
100 ASSERT(result); 100 ASSERT(result);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_concurrent_recompilation) { 177 if (FLAG_trace_concurrent_recompilation) {
178 double percentage = time_spent_compiling_.PercentOf(time_spent_total_); 178 double compile_time = static_cast<double>(time_spent_compiling_);
179 double total_time = static_cast<double>(time_spent_total_);
180 double percentage = (compile_time * 100) / total_time;
179 PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage); 181 PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage);
180 } 182 }
181 183
182 Join(); 184 Join();
183 } 185 }
184 186
185 187
186 void OptimizingCompilerThread::InstallOptimizedFunctions() { 188 void OptimizingCompilerThread::InstallOptimizedFunctions() {
187 ASSERT(!IsOptimizerThread()); 189 ASSERT(!IsOptimizerThread());
188 HandleScope handle_scope(isolate_); 190 HandleScope handle_scope(isolate_);
(...skipping 22 matching lines...) Expand all
211 #ifdef DEBUG 213 #ifdef DEBUG
212 bool OptimizingCompilerThread::IsOptimizerThread() { 214 bool OptimizingCompilerThread::IsOptimizerThread() {
213 if (!FLAG_concurrent_recompilation) return false; 215 if (!FLAG_concurrent_recompilation) return false;
214 ScopedLock lock(thread_id_mutex_); 216 ScopedLock lock(thread_id_mutex_);
215 return ThreadId::Current().ToInteger() == thread_id_; 217 return ThreadId::Current().ToInteger() == thread_id_;
216 } 218 }
217 #endif 219 #endif
218 220
219 221
220 } } // namespace v8::internal 222 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/optimizing-compiler-thread.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698