Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/tracing-cpu-profiler.h" | 5 #include "src/profiler/tracing-cpu-profiler.h" |
| 6 | 6 |
| 7 #include "src/profiler/cpu-profiler.h" | 7 #include "src/profiler/cpu-profiler.h" |
| 8 #include "src/tracing/trace-event.h" | 8 #include "src/tracing/trace-event.h" |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| 11 #define PROFILER_TRACE_CATEGORY_ENABLED(cat) \ | 11 #define PROFILER_TRACE_CATEGORY_ENABLED(cat) \ |
| 12 (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT(cat))) | 12 (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( \ |
| 13 TRACE_DISABLED_BY_DEFAULT(cat)) & \ | |
| 14 (kEnabledForRecording_CategoryGroupEnabledFlags | \ | |
|
Primiano Tucci (use gerrit)
2017/02/06 23:10:16
Don't we have the _enabled_for_recording macro in
ssid
2017/02/07 00:11:54
ENABLED_FOR_RECORDING is defined in base/trace_eve
Primiano Tucci (use gerrit)
2017/02/07 10:50:14
So I looked at the code, the situation is the foll
alph
2017/02/07 22:04:31
+1 for using TRACE_EVENT_CATEGORY_GROUP_ENABLED
ssid
2017/02/08 02:24:12
Ah I didn't realize what you meant. Thanks fixed.
| |
| 15 kEnabledForEventCallback_CategoryGroupEnabledFlags)) | |
| 13 | 16 |
| 14 namespace v8 { | 17 namespace v8 { |
| 15 | 18 |
| 16 std::unique_ptr<TracingCpuProfiler> TracingCpuProfiler::Create( | 19 std::unique_ptr<TracingCpuProfiler> TracingCpuProfiler::Create( |
| 17 v8::Isolate* isolate) { | 20 v8::Isolate* isolate) { |
| 18 return std::unique_ptr<TracingCpuProfiler>( | 21 return std::unique_ptr<TracingCpuProfiler>( |
| 19 new internal::TracingCpuProfilerImpl( | 22 new internal::TracingCpuProfilerImpl( |
| 20 reinterpret_cast<internal::Isolate*>(isolate))); | 23 reinterpret_cast<internal::Isolate*>(isolate))); |
| 21 } | 24 } |
| 22 | 25 |
| 23 namespace internal { | 26 namespace internal { |
| 24 | 27 |
| 25 TracingCpuProfilerImpl::TracingCpuProfilerImpl(Isolate* isolate) | 28 TracingCpuProfilerImpl::TracingCpuProfilerImpl(Isolate* isolate) |
| 26 : isolate_(isolate), profiling_enabled_(false) { | 29 : isolate_(isolate), profiling_enabled_(false) { |
| 27 // Make sure tracing system notices profiler categories. | 30 // Make sure tracing system notices profiler categories. |
| 28 PROFILER_TRACE_CATEGORY_ENABLED("v8.cpu_profiler"); | 31 PROFILER_TRACE_CATEGORY_ENABLED("v8.cpu_profiler"); |
|
Primiano Tucci (use gerrit)
2017/02/07 10:50:14
since you are here this should be TRACE_EVENT_WARM
ssid
2017/02/08 02:24:12
Yes done.
| |
| 29 PROFILER_TRACE_CATEGORY_ENABLED("v8.cpu_profiler.hires"); | 32 PROFILER_TRACE_CATEGORY_ENABLED("v8.cpu_profiler.hires"); |
| 30 V8::GetCurrentPlatform()->AddTraceStateObserver(this); | 33 V8::GetCurrentPlatform()->AddTraceStateObserver(this); |
| 31 } | 34 } |
| 32 | 35 |
| 33 TracingCpuProfilerImpl::~TracingCpuProfilerImpl() { | 36 TracingCpuProfilerImpl::~TracingCpuProfilerImpl() { |
| 34 StopProfiling(); | 37 StopProfiling(); |
| 35 V8::GetCurrentPlatform()->RemoveTraceStateObserver(this); | 38 V8::GetCurrentPlatform()->RemoveTraceStateObserver(this); |
| 36 } | 39 } |
| 37 | 40 |
| 38 void TracingCpuProfilerImpl::OnTraceEnabled() { | 41 void TracingCpuProfilerImpl::OnTraceEnabled() { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 69 | 72 |
| 70 void TracingCpuProfilerImpl::StopProfiling() { | 73 void TracingCpuProfilerImpl::StopProfiling() { |
| 71 base::LockGuard<base::Mutex> lock(&mutex_); | 74 base::LockGuard<base::Mutex> lock(&mutex_); |
| 72 if (!profiler_) return; | 75 if (!profiler_) return; |
| 73 profiler_->StopProfiling(""); | 76 profiler_->StopProfiling(""); |
| 74 profiler_.reset(); | 77 profiler_.reset(); |
| 75 } | 78 } |
| 76 | 79 |
| 77 } // namespace internal | 80 } // namespace internal |
| 78 } // namespace v8 | 81 } // namespace v8 |
| OLD | NEW |