Chromium Code Reviews| 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-iterator.h" | 5 #include "src/interpreter/bytecode-array-iterator.h" |
| 6 | 6 |
| 7 #include "src/objects-inl.h" | 7 #include "src/objects-inl.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 } | 25 } |
| 26 | 26 |
| 27 | 27 |
| 28 Bytecode BytecodeArrayIterator::current_bytecode() const { | 28 Bytecode BytecodeArrayIterator::current_bytecode() const { |
| 29 DCHECK(!done()); | 29 DCHECK(!done()); |
| 30 uint8_t current_byte = bytecode_array()->get(bytecode_offset_); | 30 uint8_t current_byte = bytecode_array()->get(bytecode_offset_); |
| 31 return interpreter::Bytecodes::FromByte(current_byte); | 31 return interpreter::Bytecodes::FromByte(current_byte); |
| 32 } | 32 } |
| 33 | 33 |
| 34 | 34 |
| 35 uint8_t BytecodeArrayIterator::GetOperand(int operand_index, | 35 uint8_t BytecodeArrayIterator::GetRawOperand(int operand_index) const { |
|
oth
2015/09/24 10:14:00
Although more work in the test, making GetOperand
rmcilroy
2015/09/24 11:20:12
Sounds good, done.
| |
| 36 OperandType operand_type) const { | |
| 37 DCHECK_GE(operand_index, 0); | 36 DCHECK_GE(operand_index, 0); |
| 38 DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode())); | 37 DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode())); |
| 39 DCHECK_EQ(operand_type, | |
| 40 Bytecodes::GetOperandType(current_bytecode(), operand_index)); | |
| 41 int operands_start = bytecode_offset_ + 1; | 38 int operands_start = bytecode_offset_ + 1; |
| 42 return bytecode_array()->get(operands_start + operand_index); | 39 return bytecode_array()->get(operands_start + operand_index); |
| 43 } | 40 } |
| 44 | 41 |
| 45 | 42 |
| 46 int8_t BytecodeArrayIterator::GetSmi8Operand(int operand_index) const { | 43 int8_t BytecodeArrayIterator::GetSmi8Operand(int operand_index) const { |
| 47 uint8_t operand = GetOperand(operand_index, OperandType::kImm8); | 44 DCHECK_EQ(OperandType::kImm8, |
| 45 Bytecodes::GetOperandType(current_bytecode(), operand_index)); | |
| 46 uint8_t operand = GetRawOperand(operand_index); | |
| 48 return static_cast<int8_t>(operand); | 47 return static_cast<int8_t>(operand); |
| 49 } | 48 } |
| 50 | 49 |
| 51 | 50 |
| 52 int BytecodeArrayIterator::GetIndexOperand(int operand_index) const { | 51 int BytecodeArrayIterator::GetIndexOperand(int operand_index) const { |
| 53 uint8_t operand = GetOperand(operand_index, OperandType::kIdx); | 52 DCHECK_EQ(OperandType::kIdx, |
| 53 Bytecodes::GetOperandType(current_bytecode(), operand_index)); | |
| 54 uint8_t operand = GetRawOperand(operand_index); | |
| 54 return static_cast<int>(operand); | 55 return static_cast<int>(operand); |
| 55 } | 56 } |
| 56 | 57 |
| 57 | 58 |
| 58 Register BytecodeArrayIterator::GetRegisterOperand(int operand_index) const { | 59 Register BytecodeArrayIterator::GetRegisterOperand(int operand_index) const { |
| 59 uint8_t operand = GetOperand(operand_index, OperandType::kReg); | 60 DCHECK_EQ(OperandType::kReg, |
| 61 Bytecodes::GetOperandType(current_bytecode(), operand_index)); | |
| 62 uint8_t operand = GetRawOperand(operand_index); | |
| 60 return Register::FromOperand(operand); | 63 return Register::FromOperand(operand); |
| 61 } | 64 } |
| 62 | 65 |
| 63 | 66 |
| 64 Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand( | 67 Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand( |
| 65 int operand_index) const { | 68 int operand_index) const { |
| 66 Handle<FixedArray> constants = handle(bytecode_array()->constant_pool()); | 69 Handle<FixedArray> constants = handle(bytecode_array()->constant_pool()); |
| 67 return FixedArray::get(constants, GetIndexOperand(operand_index)); | 70 return FixedArray::get(constants, GetIndexOperand(operand_index)); |
| 68 } | 71 } |
| 69 | 72 |
| 70 } // namespace interpreter | 73 } // namespace interpreter |
| 71 } // namespace internal | 74 } // namespace internal |
| 72 } // namespace v8 | 75 } // namespace v8 |
| OLD | NEW |