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, |
36 OperandType operand_type) const { | 36 OperandType operand_type) const { |
37 DCHECK_GE(operand_index, 0); | 37 DCHECK_GE(operand_index, 0); |
38 DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode())); | 38 DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode())); |
39 DCHECK_EQ(operand_type, | 39 DCHECK_EQ(operand_type, |
40 Bytecodes::GetOperandType(current_bytecode(), operand_index)); | 40 Bytecodes::GetOperandType(current_bytecode(), operand_index)); |
41 int operands_start = bytecode_offset_ + 1; | 41 int operands_start = bytecode_offset_ + 1; |
42 return bytecode_array()->get(operands_start + operand_index); | 42 return bytecode_array()->get(operands_start + operand_index); |
43 } | 43 } |
44 | 44 |
45 | 45 |
46 int8_t BytecodeArrayIterator::GetSmi8Operand(int operand_index) const { | 46 int8_t BytecodeArrayIterator::GetSmi8Operand(int operand_index) const { |
47 uint8_t operand = GetOperand(operand_index, OperandType::kImm8); | 47 uint8_t operand = GetRawOperand(operand_index, OperandType::kImm8); |
48 return static_cast<int8_t>(operand); | 48 return static_cast<int8_t>(operand); |
49 } | 49 } |
50 | 50 |
51 | 51 |
52 int BytecodeArrayIterator::GetIndexOperand(int operand_index) const { | 52 int BytecodeArrayIterator::GetIndexOperand(int operand_index) const { |
53 uint8_t operand = GetOperand(operand_index, OperandType::kIdx); | 53 uint8_t operand = GetRawOperand(operand_index, OperandType::kIdx); |
54 return static_cast<int>(operand); | 54 return static_cast<int>(operand); |
55 } | 55 } |
56 | 56 |
57 | 57 |
58 Register BytecodeArrayIterator::GetRegisterOperand(int operand_index) const { | 58 Register BytecodeArrayIterator::GetRegisterOperand(int operand_index) const { |
59 uint8_t operand = GetOperand(operand_index, OperandType::kReg); | 59 uint8_t operand = GetRawOperand(operand_index, OperandType::kReg); |
60 return Register::FromOperand(operand); | 60 return Register::FromOperand(operand); |
61 } | 61 } |
62 | 62 |
63 | 63 |
64 Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand( | 64 Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand( |
65 int operand_index) const { | 65 int operand_index) const { |
66 Handle<FixedArray> constants = handle(bytecode_array()->constant_pool()); | 66 Handle<FixedArray> constants = handle(bytecode_array()->constant_pool()); |
67 return FixedArray::get(constants, GetIndexOperand(operand_index)); | 67 return FixedArray::get(constants, GetIndexOperand(operand_index)); |
68 } | 68 } |
69 | 69 |
70 } // namespace interpreter | 70 } // namespace interpreter |
71 } // namespace internal | 71 } // namespace internal |
72 } // namespace v8 | 72 } // namespace v8 |
OLD | NEW |