v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
node-origin-table.h
Go to the documentation of this file.
1// Copyright 2014 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_COMPILER_NODE_ORIGIN_TABLE_H_
6#define V8_COMPILER_NODE_ORIGIN_TABLE_H_
7
8#include <limits>
9
12
13namespace v8 {
14namespace internal {
15namespace compiler {
16
18 public:
26
33
34 NodeOrigin(const NodeOrigin& other) V8_NOEXCEPT = default;
35 NodeOrigin& operator=(const NodeOrigin& other) V8_NOEXCEPT = default;
36 static NodeOrigin Unknown() { return NodeOrigin(); }
37
38 bool IsKnown() { return created_from_ >= 0; }
39 int64_t created_from() const { return created_from_; }
40 const char* reducer_name() const { return reducer_name_; }
41 const char* phase_name() const { return phase_name_; }
42
44
45 bool operator==(const NodeOrigin& o) const {
47 }
48
49 void PrintJson(std::ostream& out) const;
50
51 private:
53 : phase_name_(""),
54 reducer_name_(""),
55 created_from_(std::numeric_limits<int64_t>::min()) {}
56 const char* phase_name_;
57 const char* reducer_name_;
60};
61
62inline bool operator!=(const NodeOrigin& lhs, const NodeOrigin& rhs) {
63 return !(lhs == rhs);
64}
65
67 : public NON_EXPORTED_BASE(ZoneObject) {
68 public:
69 class V8_NODISCARD Scope final {
70 public:
71 Scope(NodeOriginTable* origins, const char* reducer_name, Node* node)
72 : origins_(origins), prev_origin_(NodeOrigin::Unknown()) {
73 if (origins) {
74 prev_origin_ = origins->current_origin_;
75 origins->current_origin_ =
76 NodeOrigin(origins->current_phase_name_, reducer_name, node->id());
77 }
78 }
79
81 if (origins_) origins_->current_origin_ = prev_origin_;
82 }
83
84 Scope(const Scope&) = delete;
85 Scope& operator=(const Scope&) = delete;
86
87 private:
90 };
91
93 public:
94 PhaseScope(NodeOriginTable* origins, const char* phase_name)
95 : origins_(origins) {
96 if (origins != nullptr) {
97 prev_phase_name_ = origins->current_phase_name_;
98 origins->current_phase_name_ =
99 phase_name == nullptr ? "unnamed" : phase_name;
100 }
101 }
102
104 if (origins_) origins_->current_phase_name_ = prev_phase_name_;
105 }
106
107 PhaseScope(const PhaseScope&) = delete;
108 PhaseScope& operator=(const PhaseScope&) = delete;
109
110 private:
112 const char* prev_phase_name_;
113 };
114
115 explicit NodeOriginTable(TFGraph* graph);
116 explicit NodeOriginTable(Zone* zone);
119
120 void AddDecorator();
121 void RemoveDecorator();
122
123 NodeOrigin GetNodeOrigin(Node* node) const;
124 NodeOrigin GetNodeOrigin(NodeId id) const;
125 void SetNodeOrigin(Node* node, const NodeOrigin& no);
126 void SetNodeOrigin(NodeId id, NodeId origin);
127 void SetNodeOrigin(NodeId id, NodeOrigin::OriginKind kind, NodeId origin);
128
129 void SetCurrentPosition(const NodeOrigin& no) { current_origin_ = no; }
130
132 current_bytecode_position_ = offset;
133 }
134
135 int GetCurrentBytecodePosition() { return current_bytecode_position_; }
136
137 void PrintJson(std::ostream& os) const;
138
139 private:
140 class Decorator;
141
146
149 return NodeOrigin::Unknown();
150 }
152};
153
154} // namespace compiler
155} // namespace internal
156} // namespace v8
157
158#endif // V8_COMPILER_NODE_ORIGIN_TABLE_H_
Builtins::Kind kind
Definition builtins.cc:40
PhaseScope & operator=(const PhaseScope &)=delete
PhaseScope(NodeOriginTable *origins, const char *phase_name)
Scope & operator=(const Scope &)=delete
Scope(NodeOriginTable *origins, const char *reducer_name, Node *node)
static NodeOrigin UnknownNodeOrigin(Zone *zone)
void SetCurrentPosition(const NodeOrigin &no)
NodeOriginTable & operator=(const NodeOriginTable &)=delete
NodeOriginTable(const NodeOriginTable &)=delete
NodeAuxData< NodeOrigin, UnknownNodeOrigin > table_
NodeOrigin(const char *phase_name, const char *reducer_name, NodeId created_from)
NodeOrigin(const char *phase_name, const char *reducer_name, OriginKind origin_kind, uint64_t created_from)
void PrintJson(std::ostream &out) const
bool operator==(const NodeOrigin &o) const
NodeOrigin(const NodeOrigin &other) V8_NOEXCEPT=default
NodeOrigin & operator=(const NodeOrigin &other) V8_NOEXCEPT=default
NodeOriginTable * origins
int32_t offset
STL namespace.
bool operator!=(DeoptimizeParameters lhs, DeoptimizeParameters rhs)
#define V8_NOEXCEPT
#define NON_EXPORTED_BASE(code)
#define V8_EXPORT_PRIVATE
Definition macros.h:460
#define V8_NODISCARD
Definition v8config.h:693