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/profiler/cpu-profiler.h" | 5 #include "src/profiler/cpu-profiler.h" |
6 | 6 |
7 #include "src/debug/debug.h" | 7 #include "src/debug/debug.h" |
8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
10 #include "src/locked-queue-inl.h" | 10 #include "src/locked-queue-inl.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 regs.fp = frame->fp(); | 85 regs.fp = frame->fp(); |
86 regs.pc = frame->pc(); | 86 regs.pc = frame->pc(); |
87 } | 87 } |
88 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame, update_stats, | 88 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame, update_stats, |
89 false); | 89 false); |
90 ticks_from_vm_buffer_.Enqueue(record); | 90 ticks_from_vm_buffer_.Enqueue(record); |
91 } | 91 } |
92 | 92 |
93 | 93 |
94 void ProfilerEventsProcessor::StopSynchronously() { | 94 void ProfilerEventsProcessor::StopSynchronously() { |
95 if (!base::NoBarrier_AtomicExchange(&running_, 0)) return; | 95 if (!base::Relaxed_AtomicExchange(&running_, 0)) return; |
96 Join(); | 96 Join(); |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 bool ProfilerEventsProcessor::ProcessCodeEvent() { | 100 bool ProfilerEventsProcessor::ProcessCodeEvent() { |
101 CodeEventsContainer record; | 101 CodeEventsContainer record; |
102 if (events_buffer_.Dequeue(&record)) { | 102 if (events_buffer_.Dequeue(&record)) { |
103 switch (record.generic.type) { | 103 switch (record.generic.type) { |
104 #define PROFILER_TYPE_CASE(type, clss) \ | 104 #define PROFILER_TYPE_CASE(type, clss) \ |
105 case CodeEventRecord::type: \ | 105 case CodeEventRecord::type: \ |
(...skipping 30 matching lines...) Expand all Loading... |
136 if (record->order != last_processed_code_event_id_) { | 136 if (record->order != last_processed_code_event_id_) { |
137 return FoundSampleForNextCodeEvent; | 137 return FoundSampleForNextCodeEvent; |
138 } | 138 } |
139 generator_->RecordTickSample(record->sample); | 139 generator_->RecordTickSample(record->sample); |
140 ticks_buffer_.Remove(); | 140 ticks_buffer_.Remove(); |
141 return OneSampleProcessed; | 141 return OneSampleProcessed; |
142 } | 142 } |
143 | 143 |
144 | 144 |
145 void ProfilerEventsProcessor::Run() { | 145 void ProfilerEventsProcessor::Run() { |
146 while (!!base::NoBarrier_Load(&running_)) { | 146 while (!!base::Relaxed_Load(&running_)) { |
147 base::TimeTicks nextSampleTime = | 147 base::TimeTicks nextSampleTime = |
148 base::TimeTicks::HighResolutionNow() + period_; | 148 base::TimeTicks::HighResolutionNow() + period_; |
149 base::TimeTicks now; | 149 base::TimeTicks now; |
150 SampleProcessingResult result; | 150 SampleProcessingResult result; |
151 // Keep processing existing events until we need to do next sample | 151 // Keep processing existing events until we need to do next sample |
152 // or the ticks buffer is empty. | 152 // or the ticks buffer is empty. |
153 do { | 153 do { |
154 result = ProcessOneSample(); | 154 result = ProcessOneSample(); |
155 if (result == FoundSampleForNextCodeEvent) { | 155 if (result == FoundSampleForNextCodeEvent) { |
156 // All ticks of the current last_processed_code_event_id_ are | 156 // All ticks of the current last_processed_code_event_id_ are |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 379 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; |
380 Builtins::Name id = static_cast<Builtins::Name>(i); | 380 Builtins::Name id = static_cast<Builtins::Name>(i); |
381 rec->start = builtins->builtin(id)->address(); | 381 rec->start = builtins->builtin(id)->address(); |
382 rec->builtin_id = id; | 382 rec->builtin_id = id; |
383 processor_->Enqueue(evt_rec); | 383 processor_->Enqueue(evt_rec); |
384 } | 384 } |
385 } | 385 } |
386 | 386 |
387 } // namespace internal | 387 } // namespace internal |
388 } // namespace v8 | 388 } // namespace v8 |
OLD | NEW |