| 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 #include "src/interpreter/bytecode-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace interpreter { | 9 namespace interpreter { |
| 10 | 10 |
| (...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 | 1056 |
| 1057 Register TemporaryRegisterScope::NewRegister() { | 1057 Register TemporaryRegisterScope::NewRegister() { |
| 1058 int allocated = builder_->BorrowTemporaryRegister(); | 1058 int allocated = builder_->BorrowTemporaryRegister(); |
| 1059 allocated_.push_back(allocated); | 1059 allocated_.push_back(allocated); |
| 1060 return Register(allocated); | 1060 return Register(allocated); |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 | 1063 |
| 1064 bool TemporaryRegisterScope::RegisterIsAllocatedInThisScope( |
| 1065 Register reg) const { |
| 1066 for (auto i = allocated_.begin(); i != allocated_.end(); i++) { |
| 1067 if (*i == reg.index()) return true; |
| 1068 } |
| 1069 return false; |
| 1070 } |
| 1071 |
| 1072 |
| 1064 void TemporaryRegisterScope::PrepareForConsecutiveAllocations(size_t count) { | 1073 void TemporaryRegisterScope::PrepareForConsecutiveAllocations(size_t count) { |
| 1065 if (static_cast<int>(count) > next_consecutive_count_) { | 1074 if (static_cast<int>(count) > next_consecutive_count_) { |
| 1066 next_consecutive_register_ = | 1075 next_consecutive_register_ = |
| 1067 builder_->PrepareForConsecutiveTemporaryRegisters(count); | 1076 builder_->PrepareForConsecutiveTemporaryRegisters(count); |
| 1068 next_consecutive_count_ = static_cast<int>(count); | 1077 next_consecutive_count_ = static_cast<int>(count); |
| 1069 } | 1078 } |
| 1070 } | 1079 } |
| 1071 | 1080 |
| 1072 | 1081 |
| 1073 Register TemporaryRegisterScope::NextConsecutiveRegister() { | 1082 Register TemporaryRegisterScope::NextConsecutiveRegister() { |
| 1074 DCHECK_GE(next_consecutive_register_, 0); | 1083 DCHECK_GE(next_consecutive_register_, 0); |
| 1075 DCHECK_GT(next_consecutive_count_, 0); | 1084 DCHECK_GT(next_consecutive_count_, 0); |
| 1076 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); | 1085 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); |
| 1077 allocated_.push_back(next_consecutive_register_); | 1086 allocated_.push_back(next_consecutive_register_); |
| 1078 next_consecutive_count_--; | 1087 next_consecutive_count_--; |
| 1079 return Register(next_consecutive_register_++); | 1088 return Register(next_consecutive_register_++); |
| 1080 } | 1089 } |
| 1081 | 1090 |
| 1082 } // namespace interpreter | 1091 } // namespace interpreter |
| 1083 } // namespace internal | 1092 } // namespace internal |
| 1084 } // namespace v8 | 1093 } // namespace v8 |
| OLD | NEW |