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/tracing/traced-value.h" | 5 #include "src/tracing/traced-value.h" |
6 | 6 |
7 #include "src/base/platform/platform.h" | 7 #include "src/base/platform/platform.h" |
| 8 #include "src/conversions.h" |
8 | 9 |
9 namespace v8 { | 10 namespace v8 { |
10 namespace tracing { | 11 namespace tracing { |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 #define DCHECK_CURRENT_CONTAINER_IS(x) DCHECK_EQ(x, nesting_stack_.back()) | 15 #define DCHECK_CURRENT_CONTAINER_IS(x) DCHECK_EQ(x, nesting_stack_.back()) |
15 #define DCHECK_CONTAINER_STACK_DEPTH_EQ(x) DCHECK_EQ(x, nesting_stack_.size()) | 16 #define DCHECK_CONTAINER_STACK_DEPTH_EQ(x) DCHECK_EQ(x, nesting_stack_.size()) |
16 #ifdef DEBUG | 17 #ifdef DEBUG |
17 const bool kStackTypeDict = false; | 18 const bool kStackTypeDict = false; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 74 |
74 void TracedValue::SetInteger(const char* name, int value) { | 75 void TracedValue::SetInteger(const char* name, int value) { |
75 DCHECK_CURRENT_CONTAINER_IS(kStackTypeDict); | 76 DCHECK_CURRENT_CONTAINER_IS(kStackTypeDict); |
76 WriteName(name); | 77 WriteName(name); |
77 data_ += std::to_string(value); | 78 data_ += std::to_string(value); |
78 } | 79 } |
79 | 80 |
80 void TracedValue::SetDouble(const char* name, double value) { | 81 void TracedValue::SetDouble(const char* name, double value) { |
81 DCHECK_CURRENT_CONTAINER_IS(kStackTypeDict); | 82 DCHECK_CURRENT_CONTAINER_IS(kStackTypeDict); |
82 WriteName(name); | 83 WriteName(name); |
83 data_ += std::to_string(value); | 84 i::EmbeddedVector<char, 100> buffer; |
| 85 data_ += DoubleToCString(value, buffer); |
84 } | 86 } |
85 | 87 |
86 void TracedValue::SetBoolean(const char* name, bool value) { | 88 void TracedValue::SetBoolean(const char* name, bool value) { |
87 DCHECK_CURRENT_CONTAINER_IS(kStackTypeDict); | 89 DCHECK_CURRENT_CONTAINER_IS(kStackTypeDict); |
88 WriteName(name); | 90 WriteName(name); |
89 data_ += value ? "true" : "false"; | 91 data_ += value ? "true" : "false"; |
90 } | 92 } |
91 | 93 |
92 void TracedValue::SetString(const char* name, const char* value) { | 94 void TracedValue::SetString(const char* name, const char* value) { |
93 DCHECK_CURRENT_CONTAINER_IS(kStackTypeDict); | 95 DCHECK_CURRENT_CONTAINER_IS(kStackTypeDict); |
(...skipping 19 matching lines...) Expand all Loading... |
113 | 115 |
114 void TracedValue::AppendInteger(int value) { | 116 void TracedValue::AppendInteger(int value) { |
115 DCHECK_CURRENT_CONTAINER_IS(kStackTypeArray); | 117 DCHECK_CURRENT_CONTAINER_IS(kStackTypeArray); |
116 WriteComma(); | 118 WriteComma(); |
117 data_ += std::to_string(value); | 119 data_ += std::to_string(value); |
118 } | 120 } |
119 | 121 |
120 void TracedValue::AppendDouble(double value) { | 122 void TracedValue::AppendDouble(double value) { |
121 DCHECK_CURRENT_CONTAINER_IS(kStackTypeArray); | 123 DCHECK_CURRENT_CONTAINER_IS(kStackTypeArray); |
122 WriteComma(); | 124 WriteComma(); |
123 data_ += std::to_string(value); | 125 i::EmbeddedVector<char, 100> buffer; |
| 126 data_ += DoubleToCString(value, buffer); |
124 } | 127 } |
125 | 128 |
126 void TracedValue::AppendBoolean(bool value) { | 129 void TracedValue::AppendBoolean(bool value) { |
127 DCHECK_CURRENT_CONTAINER_IS(kStackTypeArray); | 130 DCHECK_CURRENT_CONTAINER_IS(kStackTypeArray); |
128 WriteComma(); | 131 WriteComma(); |
129 data_ += value ? "true" : "false"; | 132 data_ += value ? "true" : "false"; |
130 } | 133 } |
131 | 134 |
132 void TracedValue::AppendString(const char* value) { | 135 void TracedValue::AppendString(const char* value) { |
133 DCHECK_CURRENT_CONTAINER_IS(kStackTypeArray); | 136 DCHECK_CURRENT_CONTAINER_IS(kStackTypeArray); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 184 } |
182 | 185 |
183 void TracedValue::AppendAsTraceFormat(std::string* out) const { | 186 void TracedValue::AppendAsTraceFormat(std::string* out) const { |
184 *out += '{'; | 187 *out += '{'; |
185 *out += data_; | 188 *out += data_; |
186 *out += '}'; | 189 *out += '}'; |
187 } | 190 } |
188 | 191 |
189 } // namespace tracing | 192 } // namespace tracing |
190 } // namespace v8 | 193 } // namespace v8 |
OLD | NEW |