Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: src/tracing/tracing-category-observer.cc

Issue 2459903003: [Tracing] Use TracingCategoryObserver in gc statistics (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/mark-compact.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/tracing/tracing-category-observer.h" 5 #include "src/tracing/tracing-category-observer.h"
6 6
7 #include "src/flags.h" 7 #include "src/flags.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 namespace v8 { 11 namespace v8 {
12 namespace tracing { 12 namespace tracing {
13 13
14 TracingCategoryObserver* TracingCategoryObserver::instance_ = nullptr; 14 TracingCategoryObserver* TracingCategoryObserver::instance_ = nullptr;
15 15
16 void TracingCategoryObserver::SetUp() { 16 void TracingCategoryObserver::SetUp() {
17 TracingCategoryObserver::instance_ = new TracingCategoryObserver(); 17 TracingCategoryObserver::instance_ = new TracingCategoryObserver();
18 v8::internal::V8::GetCurrentPlatform()->AddTraceStateObserver( 18 v8::internal::V8::GetCurrentPlatform()->AddTraceStateObserver(
19 TracingCategoryObserver::instance_); 19 TracingCategoryObserver::instance_);
20 TRACE_EVENT_WARMUP_CATEGORY(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats")); 20 TRACE_EVENT_WARMUP_CATEGORY(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"));
21 TRACE_EVENT_WARMUP_CATEGORY( 21 TRACE_EVENT_WARMUP_CATEGORY(
22 TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats_sampling")); 22 TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats_sampling"));
23 TRACE_EVENT_WARMUP_CATEGORY(TRACE_DISABLED_BY_DEFAULT("v8.gc_stats"));
23 } 24 }
24 25
25 void TracingCategoryObserver::TearDown() { 26 void TracingCategoryObserver::TearDown() {
26 v8::internal::V8::GetCurrentPlatform()->RemoveTraceStateObserver( 27 v8::internal::V8::GetCurrentPlatform()->RemoveTraceStateObserver(
27 TracingCategoryObserver::instance_); 28 TracingCategoryObserver::instance_);
28 delete TracingCategoryObserver::instance_; 29 delete TracingCategoryObserver::instance_;
29 } 30 }
30 31
31 void TracingCategoryObserver::OnTraceEnabled() { 32 void TracingCategoryObserver::OnTraceEnabled() {
32 bool enabled = false; 33 bool enabled = false;
33 TRACE_EVENT_CATEGORY_GROUP_ENABLED( 34 TRACE_EVENT_CATEGORY_GROUP_ENABLED(
34 TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"), &enabled); 35 TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"), &enabled);
35 if (enabled) { 36 if (enabled) {
36 v8::internal::FLAG_runtime_stats |= ENABLED_BY_TRACING; 37 v8::internal::FLAG_runtime_stats |= ENABLED_BY_TRACING;
37 } 38 }
38 TRACE_EVENT_CATEGORY_GROUP_ENABLED( 39 TRACE_EVENT_CATEGORY_GROUP_ENABLED(
39 TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats_sampling"), &enabled); 40 TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats_sampling"), &enabled);
40 if (enabled) { 41 if (enabled) {
41 v8::internal::FLAG_runtime_stats |= ENABLED_BY_SAMPLING; 42 v8::internal::FLAG_runtime_stats |= ENABLED_BY_SAMPLING;
42 } 43 }
44 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("v8.gc_stats"),
45 &enabled);
46 if (enabled) {
47 v8::internal::FLAG_gc_stats |= ENABLED_BY_TRACING;
48 }
43 } 49 }
44 50
45 void TracingCategoryObserver::OnTraceDisabled() { 51 void TracingCategoryObserver::OnTraceDisabled() {
46 v8::internal::FLAG_runtime_stats &= 52 v8::internal::FLAG_runtime_stats &=
47 ~(ENABLED_BY_TRACING | ENABLED_BY_SAMPLING); 53 ~(ENABLED_BY_TRACING | ENABLED_BY_SAMPLING);
54 v8::internal::FLAG_gc_stats &= ~ENABLED_BY_TRACING;
48 } 55 }
49 56
50 } // namespace tracing 57 } // namespace tracing
51 } // namespace v8 58 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698