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 fixed_register_count, int parameter_count, | 34 Isolate* isolate, int 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; | |
50 | 47 |
51 // Update internal state for register transfer from |input| to | 48 // Update internal state for register transfer from |input| to |
52 // |output| using |source_info| as source position information if | 49 // |output| using |source_info| as source position information if |
53 // any bytecodes are emitted due to transfer. | 50 // any bytecodes are emitted due to transfer. |
54 void RegisterTransfer(RegisterInfo* input, RegisterInfo* output, | 51 void RegisterTransfer(RegisterInfo* input, RegisterInfo* output, |
55 const BytecodeSourceInfo& source_info); | 52 BytecodeSourceInfo* source_info); |
56 | 53 |
57 // Emit a register transfer bytecode from |input| to |output|. | 54 // Emit a register transfer bytecode from |input| to |output|. |
58 void OutputRegisterTransfer( | 55 void OutputRegisterTransfer(RegisterInfo* input, RegisterInfo* output, |
59 RegisterInfo* input, RegisterInfo* output, | 56 BytecodeSourceInfo* source_info = nullptr); |
60 const BytecodeSourceInfo& source_info = BytecodeSourceInfo()); | |
61 | 57 |
62 // Emits a Nop to preserve source position information in the | 58 // Emits a Nop to preserve source position information in the |
63 // bytecode pipeline. | 59 // bytecode pipeline. |
64 void EmitNopForSourceInfo(const BytecodeSourceInfo& source_info) const; | 60 void EmitNopForSourceInfo(BytecodeSourceInfo* source_info) const; |
65 | 61 |
66 // Handlers for bytecode nodes for register to register transfers. | 62 // Handlers for bytecode nodes for register to register transfers. |
67 void DoLdar(const BytecodeNode* const node); | 63 void DoLdar(BytecodeNode* node); |
68 void DoMov(const BytecodeNode* const node); | 64 void DoMov(BytecodeNode* node); |
69 void DoStar(const BytecodeNode* const node); | 65 void DoStar(BytecodeNode* node); |
70 | 66 |
71 // Operand processing methods for bytecodes other than those | 67 // Operand processing methods for bytecodes other than those |
72 // performing register to register transfers. | 68 // performing register to register transfers. |
73 void PrepareOperands(BytecodeNode* const node); | 69 void PrepareOperands(BytecodeNode* const node); |
74 void PrepareAccumulator(BytecodeNode* const node); | 70 void PrepareAccumulator(BytecodeNode* const node); |
75 void PrepareRegisterOperands(BytecodeNode* const node); | 71 void PrepareRegisterOperands(BytecodeNode* const node); |
76 | 72 |
77 void PrepareRegisterOutputOperand(RegisterInfo* reg_info); | 73 void PrepareRegisterOutputOperand(RegisterInfo* reg_info); |
78 void PrepareRegisterRangeOutputOperand(Register start, int count); | 74 void PrepareRegisterRangeOutputOperand(Register start, int count); |
79 void PrepareRegisterInputOperand(BytecodeNode* const node, Register reg, | 75 void PrepareRegisterInputOperand(BytecodeNode* const node, Register reg, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 equivalence_id_++; | 122 equivalence_id_++; |
127 CHECK_NE(equivalence_id_, kInvalidEquivalenceId); | 123 CHECK_NE(equivalence_id_, kInvalidEquivalenceId); |
128 return equivalence_id_; | 124 return equivalence_id_; |
129 } | 125 } |
130 | 126 |
131 Zone* zone() { return zone_; } | 127 Zone* zone() { return zone_; } |
132 | 128 |
133 const Register accumulator_; | 129 const Register accumulator_; |
134 RegisterInfo* accumulator_info_; | 130 RegisterInfo* accumulator_info_; |
135 const Register temporary_base_; | 131 const Register temporary_base_; |
| 132 int max_register_index_; |
136 | 133 |
137 // Direct mapping to register info. | 134 // Direct mapping to register info. |
138 ZoneVector<RegisterInfo*> register_info_table_; | 135 ZoneVector<RegisterInfo*> register_info_table_; |
139 int register_info_table_offset_; | 136 int register_info_table_offset_; |
140 | 137 |
141 // Counter for equivalence sets identifiers. | 138 // Counter for equivalence sets identifiers. |
142 int equivalence_id_; | 139 int equivalence_id_; |
143 | 140 |
144 BytecodePipelineStage* next_stage_; | 141 BytecodePipelineStage* next_stage_; |
145 bool flush_required_; | 142 bool flush_required_; |
146 Zone* zone_; | 143 Zone* zone_; |
147 | 144 |
148 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterOptimizer); | 145 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterOptimizer); |
149 }; | 146 }; |
150 | 147 |
151 } // namespace interpreter | 148 } // namespace interpreter |
152 } // namespace internal | 149 } // namespace internal |
153 } // namespace v8 | 150 } // namespace v8 |
154 | 151 |
155 #endif // V8_INTERPRETER_BYTECODE_REGISTER_OPTIMIZER_H_ | 152 #endif // V8_INTERPRETER_BYTECODE_REGISTER_OPTIMIZER_H_ |
OLD | NEW |