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

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

Issue 1105363003: [turbofan] Don't spread global flag checks all over the compiler code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months 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
« no previous file with comments | « src/compiler/simplified-lowering.cc ('k') | src/compiler/source-position.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SOURCE_POSITION_H_
6 #define V8_COMPILER_SOURCE_POSITION_H_ 6 #define V8_COMPILER_SOURCE_POSITION_H_
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/compiler/node-aux-data.h" 9 #include "src/compiler/node-aux-data.h"
10 10
(...skipping 27 matching lines...) Expand all
38 return lhs.raw() == rhs.raw(); 38 return lhs.raw() == rhs.raw();
39 } 39 }
40 40
41 inline bool operator!=(const SourcePosition& lhs, const SourcePosition& rhs) { 41 inline bool operator!=(const SourcePosition& lhs, const SourcePosition& rhs) {
42 return !(lhs == rhs); 42 return !(lhs == rhs);
43 } 43 }
44 44
45 45
46 class SourcePositionTable final { 46 class SourcePositionTable final {
47 public: 47 public:
48 class Scope { 48 class Scope final {
49 public: 49 public:
50 Scope(SourcePositionTable* source_positions, SourcePosition position) 50 Scope(SourcePositionTable* source_positions, SourcePosition position)
51 : source_positions_(source_positions), 51 : source_positions_(source_positions),
52 prev_position_(source_positions->current_position_) { 52 prev_position_(source_positions->current_position_) {
53 Init(position); 53 Init(position);
54 } 54 }
55 Scope(SourcePositionTable* source_positions, Node* node) 55 Scope(SourcePositionTable* source_positions, Node* node)
56 : source_positions_(source_positions), 56 : source_positions_(source_positions),
57 prev_position_(source_positions->current_position_) { 57 prev_position_(source_positions->current_position_) {
58 Init(source_positions_->GetSourcePosition(node)); 58 Init(source_positions_->GetSourcePosition(node));
59 } 59 }
60 ~Scope() { source_positions_->current_position_ = prev_position_; } 60 ~Scope() { source_positions_->current_position_ = prev_position_; }
61 61
62 private: 62 private:
63 void Init(SourcePosition position) { 63 void Init(SourcePosition position) {
64 if (!position.IsUnknown() || prev_position_.IsInvalid()) { 64 if (!position.IsUnknown() || prev_position_.IsInvalid()) {
65 source_positions_->current_position_ = position; 65 source_positions_->current_position_ = position;
66 } 66 }
67 } 67 }
68 68
69 SourcePositionTable* source_positions_; 69 SourcePositionTable* const source_positions_;
70 SourcePosition prev_position_; 70 SourcePosition const prev_position_;
71 DISALLOW_COPY_AND_ASSIGN(Scope); 71 DISALLOW_COPY_AND_ASSIGN(Scope);
72 }; 72 };
73 73
74 explicit SourcePositionTable(Graph* graph); 74 explicit SourcePositionTable(Graph* graph);
75 ~SourcePositionTable() { 75 ~SourcePositionTable() {
76 if (decorator_ != NULL) RemoveDecorator(); 76 if (decorator_) RemoveDecorator();
77 } 77 }
78 78
79 void AddDecorator(); 79 void AddDecorator();
80 void RemoveDecorator(); 80 void RemoveDecorator();
81 81
82 SourcePosition GetSourcePosition(Node* node) const; 82 SourcePosition GetSourcePosition(Node* node) const;
83 83
84 void Print(std::ostream& os) const; 84 void Print(std::ostream& os) const;
85 85
86 private: 86 private:
87 class Decorator; 87 class Decorator;
88 88
89 Graph* graph_; 89 Graph* const graph_;
90 Decorator* decorator_; 90 Decorator* decorator_;
91 SourcePosition current_position_; 91 SourcePosition current_position_;
92 NodeAuxData<SourcePosition> table_; 92 NodeAuxData<SourcePosition> table_;
93 93
94 DISALLOW_COPY_AND_ASSIGN(SourcePositionTable); 94 DISALLOW_COPY_AND_ASSIGN(SourcePositionTable);
95 }; 95 };
96 96
97 } // namespace compiler 97 } // namespace compiler
98 } // namespace internal 98 } // namespace internal
99 } // namespace v8 99 } // namespace v8
100 100
101 #endif 101 #endif // V8_COMPILER_SOURCE_POSITION_H_
OLDNEW
« no previous file with comments | « src/compiler/simplified-lowering.cc ('k') | src/compiler/source-position.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698