| 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/bytecode-register.h" | 8 #include "src/interpreter/bytecode-register.h" |
| 9 #include "src/interpreter/bytecodes.h" | 9 #include "src/interpreter/bytecodes.h" |
| 10 #include "src/zone/zone-containers.h" | 10 #include "src/zone/zone-containers.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 RegisterList NewRegisterList(int count) { | 45 RegisterList NewRegisterList(int count) { |
| 46 RegisterList reg_list(next_register_index_, count); | 46 RegisterList reg_list(next_register_index_, count); |
| 47 next_register_index_ += count; | 47 next_register_index_ += count; |
| 48 max_register_count_ = std::max(next_register_index_, max_register_count_); | 48 max_register_count_ = std::max(next_register_index_, max_register_count_); |
| 49 if (observer_) { | 49 if (observer_) { |
| 50 observer_->RegisterListAllocateEvent(reg_list); | 50 observer_->RegisterListAllocateEvent(reg_list); |
| 51 } | 51 } |
| 52 return reg_list; | 52 return reg_list; |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Returns a growable register list. |
| 56 RegisterList NewGrowableRegisterList() { |
| 57 RegisterList reg_list(next_register_index_, 0); |
| 58 return reg_list; |
| 59 } |
| 60 |
| 61 // Appends a new register to |reg_list| increasing it's count by one and |
| 62 // returning the register added. |
| 63 // |
| 64 // Note: no other new registers must be currently allocated since the register |
| 65 // list was originally allocated. |
| 66 Register GrowRegisterList(RegisterList* reg_list) { |
| 67 Register reg(NewRegister()); |
| 68 reg_list->IncrementRegisterCount(); |
| 69 // If the following CHECK fails then a register was allocated (and not |
| 70 // freed) between the creation of the RegisterList and this call to add a |
| 71 // Register. |
| 72 CHECK_EQ(reg.index(), reg_list->last_register().index()); |
| 73 return reg; |
| 74 } |
| 75 |
| 55 // Release all registers above |register_index|. | 76 // Release all registers above |register_index|. |
| 56 void ReleaseRegisters(int register_index) { | 77 void ReleaseRegisters(int register_index) { |
| 57 if (observer_) { | 78 if (observer_) { |
| 58 observer_->RegisterListFreeEvent( | 79 observer_->RegisterListFreeEvent( |
| 59 RegisterList(register_index, next_register_index_ - register_index)); | 80 RegisterList(register_index, next_register_index_ - register_index)); |
| 60 } | 81 } |
| 61 next_register_index_ = register_index; | 82 next_register_index_ = register_index; |
| 62 } | 83 } |
| 63 | 84 |
| 64 // Returns true if the register |reg| is a live register. | 85 // Returns true if the register |reg| is a live register. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 78 | 99 |
| 79 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterAllocator); | 100 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterAllocator); |
| 80 }; | 101 }; |
| 81 | 102 |
| 82 } // namespace interpreter | 103 } // namespace interpreter |
| 83 } // namespace internal | 104 } // namespace internal |
| 84 } // namespace v8 | 105 } // namespace v8 |
| 85 | 106 |
| 86 | 107 |
| 87 #endif // V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ | 108 #endif // V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ |
| OLD | NEW |