OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include "src/compiler/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
6 | 6 |
7 #include "src/compiler/bytecode-branch-analysis.h" | 7 #include "src/compiler/bytecode-branch-analysis.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/operator-properties.h" | 9 #include "src/compiler/operator-properties.h" |
10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 namespace compiler { | 14 namespace compiler { |
15 | 15 |
16 // The abstract execution environment simulates the content of the interpreter | 16 // The abstract execution environment simulates the content of the interpreter |
17 // register file. The environment performs SSA-renaming of all tracked nodes at | 17 // register file. The environment performs SSA-renaming of all tracked nodes at |
18 // split and merge points in the control flow. | 18 // split and merge points in the control flow. |
19 class BytecodeGraphBuilder::Environment : public ZoneObject { | 19 class BytecodeGraphBuilder::Environment : public ZoneObject { |
20 public: | 20 public: |
21 Environment(BytecodeGraphBuilder* builder, int register_count, | 21 Environment(BytecodeGraphBuilder* builder, int register_count, |
22 int parameter_count, Node* control_dependency, Node* context); | 22 int parameter_count, Node* control_dependency, Node* context); |
23 | 23 |
24 int parameter_count() const { return parameter_count_; } | 24 int parameter_count() const { return parameter_count_; } |
25 int register_count() const { return register_count_; } | 25 int register_count() const { return register_count_; } |
26 | 26 |
27 Node* LookupAccumulator() const; | 27 Node* LookupAccumulator() const; |
28 Node* LookupRegister(interpreter::Register the_register) const; | 28 Node* LookupRegister(interpreter::Register the_register) const; |
29 | 29 |
30 void ExchangeRegisters(interpreter::Register reg0, | |
31 interpreter::Register reg1); | |
32 | |
33 void BindAccumulator(Node* node, FrameStateBeforeAndAfter* states = nullptr); | 30 void BindAccumulator(Node* node, FrameStateBeforeAndAfter* states = nullptr); |
34 void BindRegister(interpreter::Register the_register, Node* node, | 31 void BindRegister(interpreter::Register the_register, Node* node, |
35 FrameStateBeforeAndAfter* states = nullptr); | 32 FrameStateBeforeAndAfter* states = nullptr); |
36 void BindRegistersToProjections(interpreter::Register first_reg, Node* node, | 33 void BindRegistersToProjections(interpreter::Register first_reg, Node* node, |
37 FrameStateBeforeAndAfter* states = nullptr); | 34 FrameStateBeforeAndAfter* states = nullptr); |
38 void RecordAfterState(Node* node, FrameStateBeforeAndAfter* states); | 35 void RecordAfterState(Node* node, FrameStateBeforeAndAfter* states); |
39 | 36 |
40 // Effect dependency tracked by this environment. | 37 // Effect dependency tracked by this environment. |
41 Node* GetEffectDependency() { return effect_dependency_; } | 38 Node* GetEffectDependency() { return effect_dependency_; } |
42 void UpdateEffectDependency(Node* dependency) { | 39 void UpdateEffectDependency(Node* dependency) { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 return builder()->GetFunctionClosure(); | 242 return builder()->GetFunctionClosure(); |
246 } else if (the_register.is_new_target()) { | 243 } else if (the_register.is_new_target()) { |
247 return builder()->GetNewTarget(); | 244 return builder()->GetNewTarget(); |
248 } else { | 245 } else { |
249 int values_index = RegisterToValuesIndex(the_register); | 246 int values_index = RegisterToValuesIndex(the_register); |
250 return values()->at(values_index); | 247 return values()->at(values_index); |
251 } | 248 } |
252 } | 249 } |
253 | 250 |
254 | 251 |
255 void BytecodeGraphBuilder::Environment::ExchangeRegisters( | |
256 interpreter::Register reg0, interpreter::Register reg1) { | |
257 int reg0_index = RegisterToValuesIndex(reg0); | |
258 int reg1_index = RegisterToValuesIndex(reg1); | |
259 Node* saved_reg0_value = values()->at(reg0_index); | |
260 values()->at(reg0_index) = values()->at(reg1_index); | |
261 values()->at(reg1_index) = saved_reg0_value; | |
262 } | |
263 | |
264 | |
265 void BytecodeGraphBuilder::Environment::BindAccumulator( | 252 void BytecodeGraphBuilder::Environment::BindAccumulator( |
266 Node* node, FrameStateBeforeAndAfter* states) { | 253 Node* node, FrameStateBeforeAndAfter* states) { |
267 if (states) { | 254 if (states) { |
268 states->AddToNode(node, OutputFrameStateCombine::PokeAt(0)); | 255 states->AddToNode(node, OutputFrameStateCombine::PokeAt(0)); |
269 } | 256 } |
270 values()->at(accumulator_base_) = node; | 257 values()->at(accumulator_base_) = node; |
271 } | 258 } |
272 | 259 |
273 | 260 |
274 void BytecodeGraphBuilder::Environment::BindRegister( | 261 void BytecodeGraphBuilder::Environment::BindRegister( |
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 // Phi does not exist yet, introduce one. | 1828 // Phi does not exist yet, introduce one. |
1842 value = NewPhi(inputs, value, control); | 1829 value = NewPhi(inputs, value, control); |
1843 value->ReplaceInput(inputs - 1, other); | 1830 value->ReplaceInput(inputs - 1, other); |
1844 } | 1831 } |
1845 return value; | 1832 return value; |
1846 } | 1833 } |
1847 | 1834 |
1848 } // namespace compiler | 1835 } // namespace compiler |
1849 } // namespace internal | 1836 } // namespace internal |
1850 } // namespace v8 | 1837 } // namespace v8 |
OLD | NEW |