v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
traced-value.h
Go to the documentation of this file.
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#ifndef V8_TRACING_TRACED_VALUE_H_
6#define V8_TRACING_TRACED_VALUE_H_
7
8#include <stddef.h>
9#include <memory>
10#include <string>
11#include <vector>
12
13#include "include/v8-platform.h"
14#include "src/base/macros.h"
16
17namespace v8 {
18namespace tracing {
19
21#ifdef V8_USE_PERFETTO
22 ,
23 public perfetto::DebugAnnotation
24#endif // V8_USE_PERFETTO
25{
26 public:
27 ~TracedValue() override;
28 TracedValue(const TracedValue&) = delete;
30
31 static std::unique_ptr<TracedValue> Create();
32
33 void EndDictionary();
34 void EndArray();
35
36 // These methods assume that |name| is a long lived "quoted" string.
37 void SetInteger(const char* name, int value);
38 void SetUnsignedInteger(const char* name, uint64_t value);
39 void SetDouble(const char* name, double value);
40 void SetBoolean(const char* name, bool value);
41 void SetString(const char* name, const char* value);
42 void SetString(const char* name, const std::string& value) {
43 SetString(name, value.c_str());
44 }
45 void SetString(const char* name, std::unique_ptr<char[]> value) {
46 SetString(name, value.get());
47 }
48 void SetValue(const char* name, TracedValue* value);
49 void SetValue(const char* name, std::unique_ptr<TracedValue> value) {
50 SetValue(name, value.get());
51 }
52 void BeginDictionary(const char* name);
53 void BeginArray(const char* name);
54
55 void AppendInteger(int);
56 void AppendDouble(double);
57 void AppendBoolean(bool);
58 void AppendString(const char*);
59 void AppendString(const std::string& value) { AppendString(value.c_str()); }
60 void BeginArray();
61 void BeginDictionary();
62
63 // ConvertableToTraceFormat implementation.
64 void AppendAsTraceFormat(std::string* out) const override;
65
66#ifdef V8_USE_PERFETTO
67 // DebugAnnotation implementation.
68 void Add(perfetto::protos::pbzero::DebugAnnotation*) const override;
69#endif // V8_USE_PERFETTO
70
71 private:
73
74 void WriteComma();
75 void WriteName(const char* name);
76
77#ifdef DEBUG
78 // In debug builds checks the pairings of {Begin,End}{Dictionary,Array}
79 std::vector<bool> nesting_stack_;
80#endif
81
82 std::string data_;
84};
85
86} // namespace tracing
87} // namespace v8
88
89#endif // V8_TRACING_TRACED_VALUE_H_
void AppendString(const std::string &value)
void SetString(const char *name, std::unique_ptr< char[]> value)
TracedValue & operator=(const TracedValue &)=delete
void SetValue(const char *name, std::unique_ptr< TracedValue > value)
void SetString(const char *name, const std::string &value)
TracedValue(const TracedValue &)=delete
std::vector< CoverageBlock > nesting_stack_
#define V8_EXPORT_PRIVATE
Definition macros.h:460