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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 | 31 |
32 void BytecodeArrayBuilder::set_parameter_count(int number_of_parameters) { | 32 void BytecodeArrayBuilder::set_parameter_count(int number_of_parameters) { |
33 parameter_count_ = number_of_parameters; | 33 parameter_count_ = number_of_parameters; |
34 } | 34 } |
35 | 35 |
36 | 36 |
37 int BytecodeArrayBuilder::parameter_count() const { return parameter_count_; } | 37 int BytecodeArrayBuilder::parameter_count() const { return parameter_count_; } |
38 | 38 |
39 | 39 |
40 Register BytecodeArrayBuilder::Parameter(int param_index) { | 40 Register BytecodeArrayBuilder::Parameter(int parameter_index) { |
41 DCHECK_GE(param_index, 0); | 41 DCHECK_GE(parameter_index, 0); |
42 DCHECK_LT(param_index, parameter_count_); | 42 DCHECK_LT(parameter_index, parameter_count_); |
43 return Register(kLastParamRegisterIndex - parameter_count_ + param_index + 1); | 43 return Register::FromParameterIndex(parameter_index, parameter_count_); |
44 } | 44 } |
45 | 45 |
46 | 46 |
47 Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() { | 47 Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() { |
48 DCHECK_EQ(bytecode_generated_, false); | 48 DCHECK_EQ(bytecode_generated_, false); |
49 DCHECK_GE(parameter_count_, 0); | 49 DCHECK_GE(parameter_count_, 0); |
50 DCHECK_GE(local_register_count_, 0); | 50 DCHECK_GE(local_register_count_, 0); |
51 int bytecode_size = static_cast<int>(bytecodes_.size()); | 51 int bytecode_size = static_cast<int>(bytecodes_.size()); |
52 int register_count = local_register_count_ + temporary_register_count_; | 52 int register_count = local_register_count_ + temporary_register_count_; |
53 int frame_size = register_count * kPointerSize; | 53 int frame_size = register_count * kPointerSize; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 uint8_t operand_value) const { | 191 uint8_t operand_value) const { |
192 OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index); | 192 OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index); |
193 switch (operand_type) { | 193 switch (operand_type) { |
194 case OperandType::kNone: | 194 case OperandType::kNone: |
195 return false; | 195 return false; |
196 case OperandType::kImm8: | 196 case OperandType::kImm8: |
197 return true; | 197 return true; |
198 case OperandType::kIdx: | 198 case OperandType::kIdx: |
199 return operand_value < constants_.size(); | 199 return operand_value < constants_.size(); |
200 case OperandType::kReg: { | 200 case OperandType::kReg: { |
201 int reg_index = Register::FromOperand(operand_value).index(); | 201 Register reg = Register::FromOperand(operand_value); |
202 return (reg_index >= 0 && reg_index < temporary_register_next_) || | 202 if (reg.is_parameter()) { |
203 (reg_index <= kLastParamRegisterIndex && | 203 int parameter_index = reg.ToParameterIndex(parameter_count_); |
204 reg_index > kLastParamRegisterIndex - parameter_count_); | 204 return parameter_index >= 0 && parameter_index < parameter_count_; |
| 205 } else { |
| 206 return (reg.index() >= 0 && reg.index() < temporary_register_next_); |
| 207 } |
205 } | 208 } |
206 } | 209 } |
207 UNREACHABLE(); | 210 UNREACHABLE(); |
208 return false; | 211 return false; |
209 } | 212 } |
210 | 213 |
211 | 214 |
212 void BytecodeArrayBuilder::Output(Bytecode bytecode, uint8_t operand0, | 215 void BytecodeArrayBuilder::Output(Bytecode bytecode, uint8_t operand0, |
213 uint8_t operand1, uint8_t operand2) { | 216 uint8_t operand1, uint8_t operand2) { |
214 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 3); | 217 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 3); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 283 |
281 Register TemporaryRegisterScope::NewRegister() { | 284 Register TemporaryRegisterScope::NewRegister() { |
282 count_++; | 285 count_++; |
283 last_register_index_ = builder_->BorrowTemporaryRegister(); | 286 last_register_index_ = builder_->BorrowTemporaryRegister(); |
284 return Register(last_register_index_); | 287 return Register(last_register_index_); |
285 } | 288 } |
286 | 289 |
287 } // namespace interpreter | 290 } // namespace interpreter |
288 } // namespace internal | 291 } // namespace internal |
289 } // namespace v8 | 292 } // namespace v8 |
OLD | NEW |