OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 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_LOAD_ELIMINATION_H_ | 5 #ifndef V8_COMPILER_LOAD_ELIMINATION_H_ |
6 #define V8_COMPILER_LOAD_ELIMINATION_H_ | 6 #define V8_COMPILER_LOAD_ELIMINATION_H_ |
7 | 7 |
8 #include "src/compiler/graph-reducer.h" | 8 #include "src/compiler/graph-reducer.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 namespace compiler { | 12 namespace compiler { |
13 | 13 |
14 // Foward declarations. | 14 // Foward declarations. |
15 struct FieldAccess; | 15 struct FieldAccess; |
| 16 class JSGraph; |
16 | 17 |
17 class LoadElimination final : public AdvancedReducer { | 18 class LoadElimination final : public AdvancedReducer { |
18 public: | 19 public: |
19 LoadElimination(Editor* editor, Zone* zone) | 20 LoadElimination(Editor* editor, JSGraph* jsgraph, Zone* zone) |
20 : AdvancedReducer(editor), node_states_(zone) {} | 21 : AdvancedReducer(editor), node_states_(zone), jsgraph_(jsgraph) {} |
21 ~LoadElimination() final {} | 22 ~LoadElimination() final {} |
22 | 23 |
23 Reduction Reduce(Node* node) final; | 24 Reduction Reduce(Node* node) final; |
24 | 25 |
25 private: | 26 private: |
26 static const size_t kMaxTrackedElements = 8; | 27 static const size_t kMaxTrackedElements = 8; |
27 | 28 |
28 // Abstract state to approximate the current state of an element along the | 29 // Abstract state to approximate the current state of an element along the |
29 // effect paths through the graph. | 30 // effect paths through the graph. |
30 class AbstractElements final : public ZoneObject { | 31 class AbstractElements final : public ZoneObject { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 AbstractState const* Get(Node* node) const; | 144 AbstractState const* Get(Node* node) const; |
144 void Set(Node* node, AbstractState const* state); | 145 void Set(Node* node, AbstractState const* state); |
145 | 146 |
146 Zone* zone() const { return info_for_node_.get_allocator().zone(); } | 147 Zone* zone() const { return info_for_node_.get_allocator().zone(); } |
147 | 148 |
148 private: | 149 private: |
149 ZoneVector<AbstractState const*> info_for_node_; | 150 ZoneVector<AbstractState const*> info_for_node_; |
150 }; | 151 }; |
151 | 152 |
152 Reduction ReduceCheckMaps(Node* node); | 153 Reduction ReduceCheckMaps(Node* node); |
| 154 Reduction ReduceEnsureWritableFastElements(Node* node); |
153 Reduction ReduceTransitionElementsKind(Node* node); | 155 Reduction ReduceTransitionElementsKind(Node* node); |
154 Reduction ReduceLoadField(Node* node); | 156 Reduction ReduceLoadField(Node* node); |
155 Reduction ReduceStoreField(Node* node); | 157 Reduction ReduceStoreField(Node* node); |
156 Reduction ReduceLoadElement(Node* node); | 158 Reduction ReduceLoadElement(Node* node); |
157 Reduction ReduceStoreElement(Node* node); | 159 Reduction ReduceStoreElement(Node* node); |
158 Reduction ReduceStoreTypedElement(Node* node); | 160 Reduction ReduceStoreTypedElement(Node* node); |
159 Reduction ReduceEffectPhi(Node* node); | 161 Reduction ReduceEffectPhi(Node* node); |
160 Reduction ReduceStart(Node* node); | 162 Reduction ReduceStart(Node* node); |
161 Reduction ReduceOtherNode(Node* node); | 163 Reduction ReduceOtherNode(Node* node); |
162 | 164 |
163 Reduction UpdateState(Node* node, AbstractState const* state); | 165 Reduction UpdateState(Node* node, AbstractState const* state); |
164 | 166 |
165 AbstractState const* ComputeLoopState(Node* node, | 167 AbstractState const* ComputeLoopState(Node* node, |
166 AbstractState const* state) const; | 168 AbstractState const* state) const; |
167 | 169 |
168 static int FieldIndexOf(FieldAccess const& access); | 170 static int FieldIndexOf(FieldAccess const& access); |
169 | 171 |
170 AbstractState const* empty_state() const { return &empty_state_; } | 172 AbstractState const* empty_state() const { return &empty_state_; } |
| 173 JSGraph* jsgraph() const { return jsgraph_; } |
171 Zone* zone() const { return node_states_.zone(); } | 174 Zone* zone() const { return node_states_.zone(); } |
172 | 175 |
173 AbstractState const empty_state_; | 176 AbstractState const empty_state_; |
174 AbstractStateForEffectNodes node_states_; | 177 AbstractStateForEffectNodes node_states_; |
| 178 JSGraph* const jsgraph_; |
175 | 179 |
176 DISALLOW_COPY_AND_ASSIGN(LoadElimination); | 180 DISALLOW_COPY_AND_ASSIGN(LoadElimination); |
177 }; | 181 }; |
178 | 182 |
179 } // namespace compiler | 183 } // namespace compiler |
180 } // namespace internal | 184 } // namespace internal |
181 } // namespace v8 | 185 } // namespace v8 |
182 | 186 |
183 #endif // V8_COMPILER_LOAD_ELIMINATION_H_ | 187 #endif // V8_COMPILER_LOAD_ELIMINATION_H_ |
OLD | NEW |