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

Side by Side Diff: src/compiler/compiler-source-position-table.h

Issue 2451853002: Uniform and precise source positions for inlining (Closed)
Patch Set: fixed gcmole issue Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 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 #ifndef V8_COMPILER_SOURCE_POSITION_H_ 5 #ifndef V8_COMPILER_COMPILER_SOURCE_POSITION_TABLE_H_
6 #define V8_COMPILER_SOURCE_POSITION_H_ 6 #define V8_COMPILER_COMPILER_SOURCE_POSITION_TABLE_H_
7 7
8 #include "src/base/compiler-specific.h" 8 #include "src/base/compiler-specific.h"
9 #include "src/compiler/node-aux-data.h" 9 #include "src/compiler/node-aux-data.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
11 #include "src/source-position.h"
11 12
12 namespace v8 { 13 namespace v8 {
13 namespace internal { 14 namespace internal {
14 namespace compiler { 15 namespace compiler {
15 16
16 // Encapsulates encoding and decoding of sources positions from which Nodes
17 // originated.
18 class SourcePosition final {
19 public:
20 explicit SourcePosition(int raw = kUnknownPosition) : raw_(raw) {}
21
22 static SourcePosition Unknown() { return SourcePosition(kUnknownPosition); }
23 bool IsUnknown() const { return raw() == kUnknownPosition; }
24 bool IsKnown() const { return raw() != kUnknownPosition; }
25
26 int raw() const { return raw_; }
27
28 private:
29 static const int kUnknownPosition = kNoSourcePosition;
30 int raw_;
31 };
32
33
34 inline bool operator==(const SourcePosition& lhs, const SourcePosition& rhs) {
35 return lhs.raw() == rhs.raw();
36 }
37
38 inline bool operator!=(const SourcePosition& lhs, const SourcePosition& rhs) {
39 return !(lhs == rhs);
40 }
41
42 class V8_EXPORT_PRIVATE SourcePositionTable final 17 class V8_EXPORT_PRIVATE SourcePositionTable final
43 : public NON_EXPORTED_BASE(ZoneObject) { 18 : public NON_EXPORTED_BASE(ZoneObject) {
44 public: 19 public:
45 class Scope final { 20 class Scope final {
46 public: 21 public:
47 Scope(SourcePositionTable* source_positions, SourcePosition position) 22 Scope(SourcePositionTable* source_positions, SourcePosition position)
48 : source_positions_(source_positions), 23 : source_positions_(source_positions),
49 prev_position_(source_positions->current_position_) { 24 prev_position_(source_positions->current_position_) {
50 Init(position); 25 Init(position);
51 } 26 }
(...skipping 15 matching lines...) Expand all
67 }; 42 };
68 43
69 explicit SourcePositionTable(Graph* graph); 44 explicit SourcePositionTable(Graph* graph);
70 45
71 void AddDecorator(); 46 void AddDecorator();
72 void RemoveDecorator(); 47 void RemoveDecorator();
73 48
74 SourcePosition GetSourcePosition(Node* node) const; 49 SourcePosition GetSourcePosition(Node* node) const;
75 void SetSourcePosition(Node* node, SourcePosition position); 50 void SetSourcePosition(Node* node, SourcePosition position);
76 51
77 void set_current_position(int position) { 52 void SetCurrentPosition(const SourcePosition& pos) {
78 current_position_ = SourcePosition(position); 53 current_position_ = pos;
79 } 54 }
80 55
81 void Print(std::ostream& os) const; 56 void Print(std::ostream& os) const;
82 57
83 private: 58 private:
84 class Decorator; 59 class Decorator;
85 60
86 Graph* const graph_; 61 Graph* const graph_;
87 Decorator* decorator_; 62 Decorator* decorator_;
88 SourcePosition current_position_; 63 SourcePosition current_position_;
89 NodeAuxData<SourcePosition> table_; 64 NodeAuxData<SourcePosition, SourcePosition::Unknown> table_;
90 65
91 DISALLOW_COPY_AND_ASSIGN(SourcePositionTable); 66 DISALLOW_COPY_AND_ASSIGN(SourcePositionTable);
92 }; 67 };
93 68
94 } // namespace compiler 69 } // namespace compiler
95 } // namespace internal 70 } // namespace internal
96 } // namespace v8 71 } // namespace v8
97 72
98 #endif // V8_COMPILER_SOURCE_POSITION_H_ 73 #endif // V8_COMPILER_COMPILER_SOURCE_POSITION_TABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698