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 { |
11 namespace internal { | 11 namespace internal { |
12 namespace interpreter { | 12 namespace interpreter { |
13 | 13 |
14 // An optimization stage for eliminating unnecessary transfers between | 14 // An optimization stage for eliminating unnecessary transfers between |
15 // registers. The bytecode generator uses temporary registers | 15 // registers. The bytecode generator uses temporary registers |
16 // liberally for correctness and convenience and this stage removes | 16 // liberally for correctness and convenience and this stage removes |
17 // transfers that are not required and preserves correctness. | 17 // transfers that are not required and preserves correctness. |
18 class BytecodeRegisterOptimizer final : public BytecodePipelineStage, | 18 class BytecodeRegisterOptimizer final |
19 public TemporaryRegisterObserver, | 19 : public BytecodePipelineStage, |
20 public ZoneObject { | 20 public BytecodeRegisterAllocator::Observer, |
| 21 public ZoneObject { |
21 public: | 22 public: |
22 BytecodeRegisterOptimizer(Zone* zone, | 23 BytecodeRegisterOptimizer(Zone* zone, |
23 TemporaryRegisterAllocator* register_allocator, | 24 BytecodeRegisterAllocator* register_allocator, |
24 int parameter_count, | 25 int fixed_registers_count, int parameter_count, |
25 BytecodePipelineStage* next_stage); | 26 BytecodePipelineStage* next_stage); |
26 virtual ~BytecodeRegisterOptimizer() {} | 27 virtual ~BytecodeRegisterOptimizer() {} |
27 | 28 |
28 // BytecodePipelineStage interface. | 29 // BytecodePipelineStage interface. |
29 void Write(BytecodeNode* node) override; | 30 void Write(BytecodeNode* node) override; |
30 void WriteJump(BytecodeNode* node, BytecodeLabel* label) override; | 31 void WriteJump(BytecodeNode* node, BytecodeLabel* label) override; |
31 void BindLabel(BytecodeLabel* label) override; | 32 void BindLabel(BytecodeLabel* label) override; |
32 void BindLabel(const BytecodeLabel& target, BytecodeLabel* label) override; | 33 void BindLabel(const BytecodeLabel& target, BytecodeLabel* label) override; |
33 Handle<BytecodeArray> ToBytecodeArray( | 34 Handle<BytecodeArray> ToBytecodeArray( |
34 Isolate* isolate, int register_count, int parameter_count, | 35 Isolate* isolate, int register_count, int parameter_count, |
35 Handle<FixedArray> handler_table) override; | 36 Handle<FixedArray> handler_table) override; |
36 | 37 |
37 private: | 38 private: |
38 static const uint32_t kInvalidEquivalenceId = kMaxUInt32; | 39 static const uint32_t kInvalidEquivalenceId = kMaxUInt32; |
39 | 40 |
40 class RegisterInfo; | 41 class RegisterInfo; |
41 | 42 |
42 // TemporaryRegisterObserver interface. | 43 // BytecodeRegisterAllocator::Observer interface. |
43 void TemporaryRegisterFreeEvent(Register reg) override; | 44 void RegisterAllocateEvent(Register reg) override; |
| 45 void RegisterListAllocateEvent(RegisterList reg_list) override; |
| 46 void RegisterListFreeEvent(RegisterList reg) override; |
44 | 47 |
45 // Helpers for BytecodePipelineStage interface. | 48 // Helpers for BytecodePipelineStage interface. |
46 void FlushState(); | 49 void FlushState(); |
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 BytecodeSourceInfo* source_info); |
53 | 56 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |