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

Side by Side Diff: src/tracing/trace-event.cc

Issue 2221853002: Revert of [Tracing] Embed V8 runtime call stats into tracing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months 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/tracing/trace-event.h ('k') | src/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/trace-event.h" 5 #include "src/tracing/trace-event.h"
6 6
7 #include <string.h>
8
9 #include "src/isolate.h"
10 #include "src/v8.h" 7 #include "src/v8.h"
11 8
12 namespace v8 { 9 namespace v8 {
13 namespace internal { 10 namespace internal {
14 namespace tracing { 11 namespace tracing {
15 12
16 // A global flag used as a shortcut to check for the
17 // v8.runtime-call-stats category due to its high frequency use.
18 base::Atomic32 kRuntimeCallStatsTracingEnabled = false;
19
20 v8::Platform* TraceEventHelper::GetCurrentPlatform() { 13 v8::Platform* TraceEventHelper::GetCurrentPlatform() {
21 return v8::internal::V8::GetCurrentPlatform(); 14 return v8::internal::V8::GetCurrentPlatform();
22 } 15 }
23 16
24 void CallStatsScopedTracer::AddEndTraceEvent() {
25 if (!has_parent_scope_) {
26 v8::internal::tracing::AddTraceEvent(
27 TRACE_EVENT_PHASE_END, p_data_->category_group_enabled, p_data_->name,
28 v8::internal::tracing::kGlobalScope, v8::internal::tracing::kNoId,
29 TRACE_EVENT_FLAG_NONE, v8::internal::tracing::kNoId,
30 "runtime-call-stat",
31 p_data_->isolate
32 ? TRACE_STR_COPY(
33 p_data_->isolate->trace_event_stats_table()->Dump())
34 : "");
35 } else {
36 v8::internal::tracing::AddTraceEvent(
37 TRACE_EVENT_PHASE_END, p_data_->category_group_enabled, p_data_->name,
38 v8::internal::tracing::kGlobalScope, v8::internal::tracing::kNoId,
39 TRACE_EVENT_FLAG_NONE, v8::internal::tracing::kNoId);
40 }
41 }
42
43 void CallStatsScopedTracer::Initialize(Isolate* isolate,
44 const uint8_t* category_group_enabled,
45 const char* name) {
46 data_.isolate = isolate;
47 data_.category_group_enabled = category_group_enabled;
48 data_.name = name;
49 p_data_ = &data_;
50 TraceEventStatsTable* table = isolate->trace_event_stats_table();
51 has_parent_scope_ = table->InUse();
52 if (!has_parent_scope_) table->Reset();
53 v8::internal::tracing::AddTraceEvent(
54 TRACE_EVENT_PHASE_BEGIN, category_group_enabled, name,
55 v8::internal::tracing::kGlobalScope, v8::internal::tracing::kNoId,
56 TRACE_EVENT_FLAG_NONE, v8::internal::tracing::kNoId);
57 }
58
59 void TraceEventStatsTable::Enter(Isolate* isolate,
60 TraceEventCallStatsTimer* timer,
61 CounterId counter_id) {
62 TraceEventStatsTable* table = isolate->trace_event_stats_table();
63 RuntimeCallCounter* counter = &(table->*counter_id);
64 timer->Start(counter, table->current_timer_);
65 table->current_timer_ = timer;
66 }
67
68 void TraceEventStatsTable::Leave(Isolate* isolate,
69 TraceEventCallStatsTimer* timer) {
70 TraceEventStatsTable* table = isolate->trace_event_stats_table();
71 if (table->current_timer_ == timer) {
72 table->current_timer_ = timer->Stop();
73 }
74 }
75
76 void TraceEventStatsTable::Reset() {
77 in_use_ = true;
78 current_timer_ = nullptr;
79 #define RESET_COUNTER(name) this->name.Reset();
80 FOR_EACH_MANUAL_COUNTER(RESET_COUNTER)
81 #undef RESET_COUNTER
82
83 #define RESET_COUNTER(name, nargs, result_size) this->Runtime_##name.Reset();
84 FOR_EACH_INTRINSIC(RESET_COUNTER)
85 #undef RESET_COUNTER
86
87 #define RESET_COUNTER(name) this->Builtin_##name.Reset();
88 BUILTIN_LIST_C(RESET_COUNTER)
89 #undef RESET_COUNTER
90
91 #define RESET_COUNTER(name) this->API_##name.Reset();
92 FOR_EACH_API_COUNTER(RESET_COUNTER)
93 #undef RESET_COUNTER
94
95 #define RESET_COUNTER(name) this->Handler_##name.Reset();
96 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER)
97 #undef RESET_COUNTER
98 }
99
100 const char* TraceEventStatsTable::Dump() {
101 buffer_.str("");
102 buffer_.clear();
103 buffer_ << "{";
104 #define DUMP_COUNTER(name) \
105 if (this->name.count > 0) this->name.Dump(buffer_);
106 FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER)
107 #undef DUMP_COUNTER
108
109 #define DUMP_COUNTER(name, nargs, result_size) \
110 if (this->Runtime_##name.count > 0) this->Runtime_##name.Dump(buffer_);
111 FOR_EACH_INTRINSIC(DUMP_COUNTER)
112 #undef DUMP_COUNTER
113
114 #define DUMP_COUNTER(name) \
115 if (this->Builtin_##name.count > 0) this->Builtin_##name.Dump(buffer_);
116 BUILTIN_LIST_C(DUMP_COUNTER)
117 #undef DUMP_COUNTER
118
119 #define DUMP_COUNTER(name) \
120 if (this->API_##name.count > 0) this->API_##name.Dump(buffer_);
121 FOR_EACH_API_COUNTER(DUMP_COUNTER)
122 #undef DUMP_COUNTER
123
124 #define DUMP_COUNTER(name) \
125 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(buffer_);
126 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER)
127 #undef DUMP_COUNTER
128 buffer_ << "\"END\":[]}";
129 std::string buffer_str = buffer_.str();
130 size_t length = buffer_str.size();
131 char* buffer_c_str = new char[length + 1];
132 memcpy(buffer_c_str, buffer_str.c_str(), length + 1);
133 in_use_ = false;
134 return buffer_c_str;
135 }
136
137 } // namespace tracing 17 } // namespace tracing
138 } // namespace internal 18 } // namespace internal
139 } // namespace v8 19 } // namespace v8
OLDNEW
« no previous file with comments | « src/tracing/trace-event.h ('k') | src/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698