v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
compiler-source-position-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_COMPILER_SOURCE_POSITION_TABLE_H_
6#define V8_COMPILER_COMPILER_SOURCE_POSITION_TABLE_H_
7
11
12namespace v8 {
13namespace internal {
14namespace compiler {
15
17 : public NON_EXPORTED_BASE(ZoneObject) {
18 public:
19 class V8_NODISCARD Scope final {
20 public:
22 : source_positions_(source_positions),
23 prev_position_(source_positions->current_position_) {
24 Init(position);
25 }
27 : source_positions_(source_positions),
28 prev_position_(source_positions->current_position_) {
29 Init(source_positions_->GetSourcePosition(node));
30 }
31 ~Scope() { source_positions_->current_position_ = prev_position_; }
32 Scope(const Scope&) = delete;
33 Scope& operator=(const Scope&) = delete;
34
35 private:
37 if (position.IsKnown()) source_positions_->current_position_ = position;
38 }
39
42 };
43
44 explicit SourcePositionTable(TFGraph* graph);
47
48 void AddDecorator();
49 void RemoveDecorator();
50
51 SourcePosition GetSourcePosition(Node* node) const;
52 SourcePosition GetSourcePosition(NodeId id) const;
53 void SetSourcePosition(Node* node, SourcePosition position);
54
56 current_position_ = pos;
57 }
58 SourcePosition GetCurrentPosition() const { return current_position_; }
59
60 void Disable() { enabled_ = false; }
61 void Enable() { enabled_ = true; }
62
63 bool IsEnabled() const { return enabled_; }
64
65 void PrintJson(std::ostream& os) const;
66
67 private:
68 class Decorator;
69
71 return SourcePosition::Unknown();
72 }
73
78 bool enabled_ = true;
79};
80
81} // namespace compiler
82} // namespace internal
83} // namespace v8
84
85#endif // V8_COMPILER_COMPILER_SOURCE_POSITION_TABLE_H_
SourcePosition pos
Scope(SourcePositionTable *source_positions, SourcePosition position)
Scope(SourcePositionTable *source_positions, Node *node)
SourcePositionTable(const SourcePositionTable &)=delete
SourcePositionTable & operator=(const SourcePositionTable &)=delete
NodeAuxData< SourcePosition, UnknownSourcePosition > table_
SourcePositionTable * source_positions
int position
Definition liveedit.cc:290
#define NON_EXPORTED_BASE(code)
#define V8_EXPORT_PRIVATE
Definition macros.h:460
bool enabled_
Definition string.cc:1013
#define V8_NODISCARD
Definition v8config.h:693