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 #ifndef V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ |
6 #define V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ | 6 #define V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ |
7 | 7 |
8 #include "src/interpreter/bytecodes.h" | 8 #include "src/interpreter/bytecodes.h" |
9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 // A class than allows the instantiator to allocate temporary registers that are | 68 // A class than allows the instantiator to allocate temporary registers that are |
69 // cleaned up when scope is closed. | 69 // cleaned up when scope is closed. |
70 class BytecodeRegisterAllocator final { | 70 class BytecodeRegisterAllocator final { |
71 public: | 71 public: |
72 explicit BytecodeRegisterAllocator(Zone* zone, | 72 explicit BytecodeRegisterAllocator(Zone* zone, |
73 TemporaryRegisterAllocator* allocator); | 73 TemporaryRegisterAllocator* allocator); |
74 ~BytecodeRegisterAllocator(); | 74 ~BytecodeRegisterAllocator(); |
75 Register NewRegister(); | 75 Register NewRegister(); |
76 | 76 |
| 77 // Ensure |count| consecutive allocations are available. |
77 void PrepareForConsecutiveAllocations(size_t count); | 78 void PrepareForConsecutiveAllocations(size_t count); |
| 79 |
| 80 // Get the next consecutive allocation after calling |
| 81 // PrepareForConsecutiveAllocations. |
78 Register NextConsecutiveRegister(); | 82 Register NextConsecutiveRegister(); |
79 | 83 |
| 84 // Prepare consecutive register allocations and initialize an array |
| 85 // of registers with the allocations. |
| 86 void PrepareAndInitializeConsecutiveAllocations(Register* registers, |
| 87 size_t count); |
| 88 |
| 89 // Returns true if |reg| is allocated in this allocator. |
80 bool RegisterIsAllocatedInThisScope(Register reg) const; | 90 bool RegisterIsAllocatedInThisScope(Register reg) const; |
81 | 91 |
| 92 // Returns true if unused consecutive allocations remain. |
82 bool HasConsecutiveAllocations() const { return next_consecutive_count_ > 0; } | 93 bool HasConsecutiveAllocations() const { return next_consecutive_count_ > 0; } |
83 | 94 |
84 private: | 95 private: |
85 TemporaryRegisterAllocator* base_allocator() const { return base_allocator_; } | 96 TemporaryRegisterAllocator* base_allocator() const { return base_allocator_; } |
86 | 97 |
87 TemporaryRegisterAllocator* base_allocator_; | 98 TemporaryRegisterAllocator* base_allocator_; |
88 ZoneVector<int> allocated_; | 99 ZoneVector<int> allocated_; |
89 int next_consecutive_register_; | 100 int next_consecutive_register_; |
90 int next_consecutive_count_; | 101 int next_consecutive_count_; |
91 | 102 |
92 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterAllocator); | 103 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterAllocator); |
93 }; | 104 }; |
94 | 105 |
95 } // namespace interpreter | 106 } // namespace interpreter |
96 } // namespace internal | 107 } // namespace internal |
97 } // namespace v8 | 108 } // namespace v8 |
98 | 109 |
99 | 110 |
100 #endif // V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ | 111 #endif // V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ |
OLD | NEW |