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_INTERPRETER_BYTECODE_REGISTER_OPTIMIZER_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_REGISTER_OPTIMIZER_H_ |
6 #define V8_INTERPRETER_BYTECODE_REGISTER_OPTIMIZER_H_ | 6 #define V8_INTERPRETER_BYTECODE_REGISTER_OPTIMIZER_H_ |
7 | 7 |
8 #include "src/interpreter/bytecode-pipeline.h" | 8 #include "src/interpreter/bytecode-pipeline.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 13 matching lines...) Expand all Loading... |
24 int parameter_count, | 24 int parameter_count, |
25 BytecodePipelineStage* next_stage); | 25 BytecodePipelineStage* next_stage); |
26 virtual ~BytecodeRegisterOptimizer() {} | 26 virtual ~BytecodeRegisterOptimizer() {} |
27 | 27 |
28 // BytecodePipelineStage interface. | 28 // BytecodePipelineStage interface. |
29 void Write(BytecodeNode* node) override; | 29 void Write(BytecodeNode* node) override; |
30 void WriteJump(BytecodeNode* node, BytecodeLabel* label) override; | 30 void WriteJump(BytecodeNode* node, BytecodeLabel* label) override; |
31 void BindLabel(BytecodeLabel* label) override; | 31 void BindLabel(BytecodeLabel* label) override; |
32 void BindLabel(const BytecodeLabel& target, BytecodeLabel* label) override; | 32 void BindLabel(const BytecodeLabel& target, BytecodeLabel* label) override; |
33 Handle<BytecodeArray> ToBytecodeArray( | 33 Handle<BytecodeArray> ToBytecodeArray( |
34 Isolate* isolate, int register_count, int parameter_count, | 34 Isolate* isolate, int fixed_register_count, int parameter_count, |
35 Handle<FixedArray> handler_table) override; | 35 Handle<FixedArray> handler_table) override; |
36 | 36 |
37 private: | 37 private: |
38 static const uint32_t kInvalidEquivalenceId = kMaxUInt32; | 38 static const uint32_t kInvalidEquivalenceId = kMaxUInt32; |
39 | 39 |
40 class RegisterInfo; | 40 class RegisterInfo; |
41 | 41 |
42 // TemporaryRegisterObserver interface. | 42 // TemporaryRegisterObserver interface. |
43 void TemporaryRegisterFreeEvent(Register reg) override; | 43 void TemporaryRegisterFreeEvent(Register reg) override; |
44 | 44 |
45 // Helpers for BytecodePipelineStage interface. | 45 // Helpers for BytecodePipelineStage interface. |
46 void FlushState(); | 46 void FlushState(); |
| 47 void WriteToNextStage(BytecodeNode* node) const; |
| 48 void WriteToNextStage(BytecodeNode* node, |
| 49 const BytecodeSourceInfo& output_info) const; |
47 | 50 |
48 // Update internal state for register transfer from |input| to | 51 // Update internal state for register transfer from |input| to |
49 // |output| using |source_info| as source position information if | 52 // |output| using |source_info| as source position information if |
50 // any bytecodes are emitted due to transfer. | 53 // any bytecodes are emitted due to transfer. |
51 void RegisterTransfer(RegisterInfo* input, RegisterInfo* output, | 54 void RegisterTransfer(RegisterInfo* input, RegisterInfo* output, |
52 BytecodeSourceInfo* source_info); | 55 const BytecodeSourceInfo& source_info); |
53 | 56 |
54 // Emit a register transfer bytecode from |input| to |output|. | 57 // Emit a register transfer bytecode from |input| to |output|. |
55 void OutputRegisterTransfer(RegisterInfo* input, RegisterInfo* output, | 58 void OutputRegisterTransfer( |
56 BytecodeSourceInfo* source_info = nullptr); | 59 RegisterInfo* input, RegisterInfo* output, |
| 60 const BytecodeSourceInfo& source_info = BytecodeSourceInfo()); |
57 | 61 |
58 // Emits a Nop to preserve source position information in the | 62 // Emits a Nop to preserve source position information in the |
59 // bytecode pipeline. | 63 // bytecode pipeline. |
60 void EmitNopForSourceInfo(BytecodeSourceInfo* source_info) const; | 64 void EmitNopForSourceInfo(const BytecodeSourceInfo& source_info) const; |
61 | 65 |
62 // Handlers for bytecode nodes for register to register transfers. | 66 // Handlers for bytecode nodes for register to register transfers. |
63 void DoLdar(BytecodeNode* node); | 67 void DoLdar(const BytecodeNode* const node); |
64 void DoMov(BytecodeNode* node); | 68 void DoMov(const BytecodeNode* const node); |
65 void DoStar(BytecodeNode* node); | 69 void DoStar(const BytecodeNode* const node); |
66 | 70 |
67 // Operand processing methods for bytecodes other than those | 71 // Operand processing methods for bytecodes other than those |
68 // performing register to register transfers. | 72 // performing register to register transfers. |
69 void PrepareOperands(BytecodeNode* const node); | 73 void PrepareOperands(BytecodeNode* const node); |
70 void PrepareAccumulator(BytecodeNode* const node); | 74 void PrepareAccumulator(BytecodeNode* const node); |
71 void PrepareRegisterOperands(BytecodeNode* const node); | 75 void PrepareRegisterOperands(BytecodeNode* const node); |
72 | 76 |
73 void PrepareRegisterOutputOperand(RegisterInfo* reg_info); | 77 void PrepareRegisterOutputOperand(RegisterInfo* reg_info); |
74 void PrepareRegisterRangeOutputOperand(Register start, int count); | 78 void PrepareRegisterRangeOutputOperand(Register start, int count); |
75 void PrepareRegisterInputOperand(BytecodeNode* const node, Register reg, | 79 void PrepareRegisterInputOperand(BytecodeNode* const node, Register reg, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 equivalence_id_++; | 126 equivalence_id_++; |
123 CHECK_NE(equivalence_id_, kInvalidEquivalenceId); | 127 CHECK_NE(equivalence_id_, kInvalidEquivalenceId); |
124 return equivalence_id_; | 128 return equivalence_id_; |
125 } | 129 } |
126 | 130 |
127 Zone* zone() { return zone_; } | 131 Zone* zone() { return zone_; } |
128 | 132 |
129 const Register accumulator_; | 133 const Register accumulator_; |
130 RegisterInfo* accumulator_info_; | 134 RegisterInfo* accumulator_info_; |
131 const Register temporary_base_; | 135 const Register temporary_base_; |
132 int max_register_index_; | |
133 | 136 |
134 // Direct mapping to register info. | 137 // Direct mapping to register info. |
135 ZoneVector<RegisterInfo*> register_info_table_; | 138 ZoneVector<RegisterInfo*> register_info_table_; |
136 int register_info_table_offset_; | 139 int register_info_table_offset_; |
137 | 140 |
138 // Counter for equivalence sets identifiers. | 141 // Counter for equivalence sets identifiers. |
139 int equivalence_id_; | 142 int equivalence_id_; |
140 | 143 |
141 BytecodePipelineStage* next_stage_; | 144 BytecodePipelineStage* next_stage_; |
142 bool flush_required_; | 145 bool flush_required_; |
143 Zone* zone_; | 146 Zone* zone_; |
144 | 147 |
145 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterOptimizer); | 148 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterOptimizer); |
146 }; | 149 }; |
147 | 150 |
148 } // namespace interpreter | 151 } // namespace interpreter |
149 } // namespace internal | 152 } // namespace internal |
150 } // namespace v8 | 153 } // namespace v8 |
151 | 154 |
152 #endif // V8_INTERPRETER_BYTECODE_REGISTER_OPTIMIZER_H_ | 155 #endif // V8_INTERPRETER_BYTECODE_REGISTER_OPTIMIZER_H_ |
OLD | NEW |