OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 "content/renderer/devtools/v8_sampling_profiler.h" | 5 #include "content/renderer/devtools/v8_sampling_profiler.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 record->Collect(isolate_, timestamp, state); | 296 record->Collect(isolate_, timestamp, state); |
297 samples_data_->FinishEnqueue(); | 297 samples_data_->FinishEnqueue(); |
298 } | 298 } |
299 | 299 |
300 void Sampler::InjectPendingEvents() { | 300 void Sampler::InjectPendingEvents() { |
301 SampleRecord* record = samples_data_->Peek(); | 301 SampleRecord* record = samples_data_->Peek(); |
302 while (record) { | 302 while (record) { |
303 TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP1( | 303 TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP1( |
304 TRACE_DISABLED_BY_DEFAULT("v8.cpu_profile"), "V8Sample", | 304 TRACE_DISABLED_BY_DEFAULT("v8.cpu_profile"), "V8Sample", |
305 platform_data_.thread_id(), | 305 platform_data_.thread_id(), |
306 (record->timestamp() - base::TimeTicks()).InMicroseconds(), "data", | 306 record->timestamp(), "data", record->ToTraceFormat()); |
307 record->ToTraceFormat()); | |
308 samples_data_->Remove(); | 307 samples_data_->Remove(); |
309 record = samples_data_->Peek(); | 308 record = samples_data_->Peek(); |
310 base::subtle::NoBarrier_AtomicIncrement(&samples_count_, 1); | 309 base::subtle::NoBarrier_AtomicIncrement(&samples_count_, 1); |
311 } | 310 } |
312 } | 311 } |
313 | 312 |
314 // static | 313 // static |
315 void Sampler::InstallJitCodeEventHandler(Isolate* isolate, void* data) { | 314 void Sampler::InstallJitCodeEventHandler(Isolate* isolate, void* data) { |
316 // Called on the sampled V8 thread. | 315 // Called on the sampled V8 thread. |
317 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profile"), | 316 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profile"), |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 waitable_event_for_testing_.reset( | 641 waitable_event_for_testing_.reset( |
643 new base::WaitableEvent(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 642 new base::WaitableEvent(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
644 base::WaitableEvent::InitialState::NOT_SIGNALED)); | 643 base::WaitableEvent::InitialState::NOT_SIGNALED)); |
645 } | 644 } |
646 | 645 |
647 void V8SamplingProfiler::WaitSamplingEventForTesting() { | 646 void V8SamplingProfiler::WaitSamplingEventForTesting() { |
648 waitable_event_for_testing_->Wait(); | 647 waitable_event_for_testing_->Wait(); |
649 } | 648 } |
650 | 649 |
651 } // namespace content | 650 } // namespace content |
OLD | NEW |