Index: src/interpreter/bytecode-array-iterator.cc |
diff --git a/src/interpreter/bytecode-array-iterator.cc b/src/interpreter/bytecode-array-iterator.cc |
index dc49308fbe87e6e449319314c830521c37541f2b..d4f277307936b0eab5fe56617f1469bd90ee44f0 100644 |
--- a/src/interpreter/bytecode-array-iterator.cc |
+++ b/src/interpreter/bytecode-array-iterator.cc |
@@ -32,31 +32,45 @@ Bytecode BytecodeArrayIterator::current_bytecode() const { |
} |
-uint8_t BytecodeArrayIterator::GetRawOperand(int operand_index, |
- OperandType operand_type) const { |
+uint32_t BytecodeArrayIterator::GetRawOperand(int operand_index, |
+ OperandType operand_type) const { |
DCHECK_GE(operand_index, 0); |
DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode())); |
DCHECK_EQ(operand_type, |
Bytecodes::GetOperandType(current_bytecode(), operand_index)); |
- int operands_start = bytecode_offset_ + 1; |
- return bytecode_array()->get(operands_start + operand_index); |
+ uint8_t* operand_start = |
+ bytecode_array()->GetFirstBytecodeAddress() + bytecode_offset_ + |
+ Bytecodes::GetOperandOffset(current_bytecode(), operand_index); |
+ switch (Bytecodes::SizeOfOperand(operand_type)) { |
+ default: |
+ case OperandSize::kNone: |
+ UNREACHABLE(); |
+ case OperandSize::kByte: |
+ return static_cast<uint32_t>(*operand_start); |
+ case OperandSize::kShort: |
+ return Bytecodes::ShortOperandFromBytes(operand_start); |
+ } |
} |
-int8_t BytecodeArrayIterator::GetSmi8Operand(int operand_index) const { |
- uint8_t operand = GetRawOperand(operand_index, OperandType::kImm8); |
+int8_t BytecodeArrayIterator::GetImmediateOperand(int operand_index) const { |
+ uint32_t operand = GetRawOperand(operand_index, OperandType::kImm8); |
return static_cast<int8_t>(operand); |
} |
int BytecodeArrayIterator::GetIndexOperand(int operand_index) const { |
- uint8_t operand = GetRawOperand(operand_index, OperandType::kIdx); |
+ OperandSize size = |
+ Bytecodes::GetOperandSize(current_bytecode(), operand_index); |
+ OperandType type = |
+ (size == OperandSize::kByte) ? OperandType::kIdx8 : OperandType::kIdx16; |
+ uint32_t operand = GetRawOperand(operand_index, type); |
return static_cast<int>(operand); |
} |
Register BytecodeArrayIterator::GetRegisterOperand(int operand_index) const { |
- uint8_t operand = GetRawOperand(operand_index, OperandType::kReg); |
+ uint32_t operand = GetRawOperand(operand_index, OperandType::kReg8); |
return Register::FromOperand(operand); |
} |