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/base/compiler-specific.h" |
| 9 #include "src/globals.h" |
8 #include "src/interpreter/bytecode-pipeline.h" | 10 #include "src/interpreter/bytecode-pipeline.h" |
9 | 11 |
10 namespace v8 { | 12 namespace v8 { |
11 namespace internal { | 13 namespace internal { |
12 namespace interpreter { | 14 namespace interpreter { |
13 | 15 |
14 // An optimization stage for eliminating unnecessary transfers between | 16 // An optimization stage for eliminating unnecessary transfers between |
15 // registers. The bytecode generator uses temporary registers | 17 // registers. The bytecode generator uses temporary registers |
16 // liberally for correctness and convenience and this stage removes | 18 // liberally for correctness and convenience and this stage removes |
17 // transfers that are not required and preserves correctness. | 19 // transfers that are not required and preserves correctness. |
18 class BytecodeRegisterOptimizer final | 20 class V8_EXPORT_PRIVATE BytecodeRegisterOptimizer final |
19 : public BytecodePipelineStage, | 21 : public NON_EXPORTED_BASE(BytecodePipelineStage), |
20 public BytecodeRegisterAllocator::Observer, | 22 public NON_EXPORTED_BASE(BytecodeRegisterAllocator::Observer), |
21 public ZoneObject { | 23 public NON_EXPORTED_BASE(ZoneObject) { |
22 public: | 24 public: |
23 BytecodeRegisterOptimizer(Zone* zone, | 25 BytecodeRegisterOptimizer(Zone* zone, |
24 BytecodeRegisterAllocator* register_allocator, | 26 BytecodeRegisterAllocator* register_allocator, |
25 int fixed_registers_count, int parameter_count, | 27 int fixed_registers_count, int parameter_count, |
26 BytecodePipelineStage* next_stage); | 28 BytecodePipelineStage* next_stage); |
27 virtual ~BytecodeRegisterOptimizer() {} | 29 virtual ~BytecodeRegisterOptimizer() {} |
28 | 30 |
29 // BytecodePipelineStage interface. | 31 // BytecodePipelineStage interface. |
30 void Write(BytecodeNode* node) override; | 32 void Write(BytecodeNode* node) override; |
31 void WriteJump(BytecodeNode* node, BytecodeLabel* label) override; | 33 void WriteJump(BytecodeNode* node, BytecodeLabel* label) override; |
32 void BindLabel(BytecodeLabel* label) override; | 34 void BindLabel(BytecodeLabel* label) override; |
33 void BindLabel(const BytecodeLabel& target, BytecodeLabel* label) override; | 35 void BindLabel(const BytecodeLabel& target, BytecodeLabel* label) override; |
34 Handle<BytecodeArray> ToBytecodeArray( | 36 Handle<BytecodeArray> ToBytecodeArray( |
35 Isolate* isolate, int register_count, int parameter_count, | 37 Isolate* isolate, int register_count, int parameter_count, |
36 Handle<FixedArray> handler_table) override; | 38 Handle<FixedArray> handler_table) override; |
37 | 39 |
38 private: | 40 private: |
39 static const uint32_t kInvalidEquivalenceId = kMaxUInt32; | 41 static const uint32_t kInvalidEquivalenceId; |
40 | 42 |
41 class RegisterInfo; | 43 class RegisterInfo; |
42 | 44 |
43 // BytecodeRegisterAllocator::Observer interface. | 45 // BytecodeRegisterAllocator::Observer interface. |
44 void RegisterAllocateEvent(Register reg) override; | 46 void RegisterAllocateEvent(Register reg) override; |
45 void RegisterListAllocateEvent(RegisterList reg_list) override; | 47 void RegisterListAllocateEvent(RegisterList reg_list) override; |
46 void RegisterListFreeEvent(RegisterList reg) override; | 48 void RegisterListFreeEvent(RegisterList reg) override; |
47 | 49 |
48 // Helpers for BytecodePipelineStage interface. | 50 // Helpers for BytecodePipelineStage interface. |
49 void FlushState(); | 51 void FlushState(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 Zone* zone_; | 148 Zone* zone_; |
147 | 149 |
148 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterOptimizer); | 150 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterOptimizer); |
149 }; | 151 }; |
150 | 152 |
151 } // namespace interpreter | 153 } // namespace interpreter |
152 } // namespace internal | 154 } // namespace internal |
153 } // namespace v8 | 155 } // namespace v8 |
154 | 156 |
155 #endif // V8_INTERPRETER_BYTECODE_REGISTER_OPTIMIZER_H_ | 157 #endif // V8_INTERPRETER_BYTECODE_REGISTER_OPTIMIZER_H_ |
OLD | NEW |