OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/cpu-profiler-inl.h" | 7 #include "src/cpu-profiler-inl.h" |
8 | 8 |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 return FoundSampleForNextCodeEvent; | 113 return FoundSampleForNextCodeEvent; |
114 } | 114 } |
115 generator_->RecordTickSample(record->sample); | 115 generator_->RecordTickSample(record->sample); |
116 ticks_buffer_.Remove(); | 116 ticks_buffer_.Remove(); |
117 return OneSampleProcessed; | 117 return OneSampleProcessed; |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 void ProfilerEventsProcessor::Run() { | 121 void ProfilerEventsProcessor::Run() { |
122 while (!!base::NoBarrier_Load(&running_)) { | 122 while (!!base::NoBarrier_Load(&running_)) { |
123 base::ElapsedTimer timer; | 123 base::TimeTicks nextSampleTime = |
124 timer.Start(); | 124 base::TimeTicks::HighResolutionNow() + period_; |
125 // Keep processing existing events until we need to do next sample. | 125 base::TimeTicks now; |
126 SampleProcessingResult result; | |
127 // Keep processing existing events until we need to do next sample | |
128 // or the ticks buffer is empty. | |
126 do { | 129 do { |
127 if (FoundSampleForNextCodeEvent == ProcessOneSample()) { | 130 result = ProcessOneSample(); |
131 if (result == FoundSampleForNextCodeEvent) { | |
128 // All ticks of the current last_processed_code_event_id_ are | 132 // All ticks of the current last_processed_code_event_id_ are |
129 // processed, proceed to the next code event. | 133 // processed, proceed to the next code event. |
130 ProcessCodeEvent(); | 134 ProcessCodeEvent(); |
131 } | 135 } |
132 } while (!timer.HasExpired(period_)); | 136 now = base::TimeTicks::HighResolutionNow(); |
137 } while (result != NoSamplesInQueue && now < nextSampleTime); | |
138 | |
139 if (nextSampleTime > now) { | |
140 #if V8_OS_WIN | |
Benedikt Meurer
2015/04/30 05:06:01
I don't really like this special casing for Window
yurys
2015/04/30 08:10:02
Would "Multimedia Timers" work here?
alph
2015/04/30 10:13:34
I'm not aware of such method. I appreciate if you
alph
2015/04/30 10:13:34
They have 1ms resolution at best which is still no
| |
141 // Do not use Sleep on Windows as it is very imprecise. | |
142 // Could be up to 16ms jitter, which is unacceptable for the purpose. | |
143 while (base::TimeTicks::HighResolutionNow() < nextSampleTime) { | |
144 } | |
145 #else | |
146 base::OS::Sleep(nextSampleTime - now); | |
147 #endif | |
148 } | |
133 | 149 |
134 // Schedule next sample. sampler_ is NULL in tests. | 150 // Schedule next sample. sampler_ is NULL in tests. |
135 if (sampler_) sampler_->DoSample(); | 151 if (sampler_) sampler_->DoSample(); |
136 } | 152 } |
137 | 153 |
138 // Process remaining tick events. | 154 // Process remaining tick events. |
139 do { | 155 do { |
140 SampleProcessingResult result; | 156 SampleProcessingResult result; |
141 do { | 157 do { |
142 result = ProcessOneSample(); | 158 result = ProcessOneSample(); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 538 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; |
523 Builtins::Name id = static_cast<Builtins::Name>(i); | 539 Builtins::Name id = static_cast<Builtins::Name>(i); |
524 rec->start = builtins->builtin(id)->address(); | 540 rec->start = builtins->builtin(id)->address(); |
525 rec->builtin_id = id; | 541 rec->builtin_id = id; |
526 processor_->Enqueue(evt_rec); | 542 processor_->Enqueue(evt_rec); |
527 } | 543 } |
528 } | 544 } |
529 | 545 |
530 | 546 |
531 } } // namespace v8::internal | 547 } } // namespace v8::internal |
OLD | NEW |