OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/tracing/tracing-flag.h" |
| 6 |
| 7 #include "include/v8.h" |
| 8 #include "src/flags.h" |
| 9 #include "src/tracing/trace-event.h" |
| 10 #include "src/v8.h" |
| 11 |
| 12 namespace v8 { |
| 13 |
| 14 std::unique_ptr<Platform::TracingFlag> Platform::TracingFlag::Create() { |
| 15 return std::unique_ptr<Platform::TracingFlag>(new tracing::TracingFlagImpl()); |
| 16 } |
| 17 |
| 18 namespace tracing { |
| 19 |
| 20 TracingFlagImpl::TracingFlagImpl() |
| 21 : platform_(v8::internal::V8::GetCurrentPlatform()) { |
| 22 platform_->AddTraceStateObserver(this); |
| 23 } |
| 24 |
| 25 TracingFlagImpl::~TracingFlagImpl() { |
| 26 OnTraceDisabled(); |
| 27 platform_->RemoveTraceStateObserver(this); |
| 28 } |
| 29 |
| 30 void TracingFlagImpl::OnTraceEnabled() { |
| 31 bool enabled = false; |
| 32 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
| 33 TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"), &enabled); |
| 34 if (enabled) { |
| 35 v8::internal::FLAG_runtime_stats |= ENABLED_BY_TRACING; |
| 36 } |
| 37 } |
| 38 |
| 39 void TracingFlagImpl::OnTraceDisabled() { |
| 40 v8::internal::FLAG_runtime_stats &= ~ENABLED_BY_TRACING; |
| 41 } |
| 42 |
| 43 } // namespace tracing |
| 44 } // namespace v8 |
OLD | NEW |