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/interpreter/bytecode-decoder.h" |
7 #include "src/interpreter/interpreter-intrinsics.h" | 8 #include "src/interpreter/interpreter-intrinsics.h" |
8 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
9 | 10 |
10 namespace v8 { | 11 namespace v8 { |
11 namespace internal { | 12 namespace internal { |
12 namespace interpreter { | 13 namespace interpreter { |
13 | 14 |
14 BytecodeArrayIterator::BytecodeArrayIterator( | 15 BytecodeArrayIterator::BytecodeArrayIterator( |
15 Handle<BytecodeArray> bytecode_array) | 16 Handle<BytecodeArray> bytecode_array) |
16 : bytecode_array_(bytecode_array), | 17 : bytecode_array_(bytecode_array), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 DCHECK_GE(operand_index, 0); | 64 DCHECK_GE(operand_index, 0); |
64 DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode())); | 65 DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode())); |
65 DCHECK_EQ(operand_type, | 66 DCHECK_EQ(operand_type, |
66 Bytecodes::GetOperandType(current_bytecode(), operand_index)); | 67 Bytecodes::GetOperandType(current_bytecode(), operand_index)); |
67 DCHECK(Bytecodes::IsUnsignedOperandType(operand_type)); | 68 DCHECK(Bytecodes::IsUnsignedOperandType(operand_type)); |
68 const uint8_t* operand_start = | 69 const uint8_t* operand_start = |
69 bytecode_array()->GetFirstBytecodeAddress() + bytecode_offset_ + | 70 bytecode_array()->GetFirstBytecodeAddress() + bytecode_offset_ + |
70 current_prefix_offset() + | 71 current_prefix_offset() + |
71 Bytecodes::GetOperandOffset(current_bytecode(), operand_index, | 72 Bytecodes::GetOperandOffset(current_bytecode(), operand_index, |
72 current_operand_scale()); | 73 current_operand_scale()); |
73 return Bytecodes::DecodeUnsignedOperand(operand_start, operand_type, | 74 return BytecodeDecoder::DecodeUnsignedOperand(operand_start, operand_type, |
74 current_operand_scale()); | 75 current_operand_scale()); |
75 } | 76 } |
76 | 77 |
77 int32_t BytecodeArrayIterator::GetSignedOperand( | 78 int32_t BytecodeArrayIterator::GetSignedOperand( |
78 int operand_index, OperandType operand_type) const { | 79 int operand_index, OperandType operand_type) const { |
79 DCHECK_GE(operand_index, 0); | 80 DCHECK_GE(operand_index, 0); |
80 DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode())); | 81 DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(current_bytecode())); |
81 DCHECK_EQ(operand_type, | 82 DCHECK_EQ(operand_type, |
82 Bytecodes::GetOperandType(current_bytecode(), operand_index)); | 83 Bytecodes::GetOperandType(current_bytecode(), operand_index)); |
83 DCHECK(!Bytecodes::IsUnsignedOperandType(operand_type)); | 84 DCHECK(!Bytecodes::IsUnsignedOperandType(operand_type)); |
84 const uint8_t* operand_start = | 85 const uint8_t* operand_start = |
85 bytecode_array()->GetFirstBytecodeAddress() + bytecode_offset_ + | 86 bytecode_array()->GetFirstBytecodeAddress() + bytecode_offset_ + |
86 current_prefix_offset() + | 87 current_prefix_offset() + |
87 Bytecodes::GetOperandOffset(current_bytecode(), operand_index, | 88 Bytecodes::GetOperandOffset(current_bytecode(), operand_index, |
88 current_operand_scale()); | 89 current_operand_scale()); |
89 return Bytecodes::DecodeSignedOperand(operand_start, operand_type, | 90 return BytecodeDecoder::DecodeSignedOperand(operand_start, operand_type, |
90 current_operand_scale()); | 91 current_operand_scale()); |
91 } | 92 } |
92 | 93 |
93 uint32_t BytecodeArrayIterator::GetFlagOperand(int operand_index) const { | 94 uint32_t BytecodeArrayIterator::GetFlagOperand(int operand_index) const { |
94 DCHECK_EQ(Bytecodes::GetOperandType(current_bytecode(), operand_index), | 95 DCHECK_EQ(Bytecodes::GetOperandType(current_bytecode(), operand_index), |
95 OperandType::kFlag8); | 96 OperandType::kFlag8); |
96 return GetUnsignedOperand(operand_index, OperandType::kFlag8); | 97 return GetUnsignedOperand(operand_index, OperandType::kFlag8); |
97 } | 98 } |
98 | 99 |
99 int32_t BytecodeArrayIterator::GetImmediateOperand(int operand_index) const { | 100 int32_t BytecodeArrayIterator::GetImmediateOperand(int operand_index) const { |
100 DCHECK_EQ(Bytecodes::GetOperandType(current_bytecode(), operand_index), | 101 DCHECK_EQ(Bytecodes::GetOperandType(current_bytecode(), operand_index), |
(...skipping 16 matching lines...) Expand all Loading... |
117 } | 118 } |
118 | 119 |
119 Register BytecodeArrayIterator::GetRegisterOperand(int operand_index) const { | 120 Register BytecodeArrayIterator::GetRegisterOperand(int operand_index) const { |
120 OperandType operand_type = | 121 OperandType operand_type = |
121 Bytecodes::GetOperandType(current_bytecode(), operand_index); | 122 Bytecodes::GetOperandType(current_bytecode(), operand_index); |
122 const uint8_t* operand_start = | 123 const uint8_t* operand_start = |
123 bytecode_array()->GetFirstBytecodeAddress() + bytecode_offset_ + | 124 bytecode_array()->GetFirstBytecodeAddress() + bytecode_offset_ + |
124 current_prefix_offset() + | 125 current_prefix_offset() + |
125 Bytecodes::GetOperandOffset(current_bytecode(), operand_index, | 126 Bytecodes::GetOperandOffset(current_bytecode(), operand_index, |
126 current_operand_scale()); | 127 current_operand_scale()); |
127 return Bytecodes::DecodeRegisterOperand(operand_start, operand_type, | 128 return BytecodeDecoder::DecodeRegisterOperand(operand_start, operand_type, |
128 current_operand_scale()); | 129 current_operand_scale()); |
129 } | 130 } |
130 | 131 |
131 int BytecodeArrayIterator::GetRegisterOperandRange(int operand_index) const { | 132 int BytecodeArrayIterator::GetRegisterOperandRange(int operand_index) const { |
132 DCHECK_LE(operand_index, Bytecodes::NumberOfOperands(current_bytecode())); | 133 DCHECK_LE(operand_index, Bytecodes::NumberOfOperands(current_bytecode())); |
133 const OperandType* operand_types = | 134 const OperandType* operand_types = |
134 Bytecodes::GetOperandTypes(current_bytecode()); | 135 Bytecodes::GetOperandTypes(current_bytecode()); |
135 DCHECK(Bytecodes::IsRegisterOperandType(operand_types[operand_index])); | 136 DCHECK(Bytecodes::IsRegisterOperandType(operand_types[operand_index])); |
136 if (operand_types[operand_index + 1] == OperandType::kRegCount) { | 137 if (operand_types[operand_index + 1] == OperandType::kRegCount) { |
137 return GetRegisterCountOperand(operand_index + 1); | 138 return GetRegisterCountOperand(operand_index + 1); |
138 } else { | 139 } else { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 return current_offset() + smi->value() + current_prefix_offset(); | 179 return current_offset() + smi->value() + current_prefix_offset(); |
179 } else { | 180 } else { |
180 UNREACHABLE(); | 181 UNREACHABLE(); |
181 return kMinInt; | 182 return kMinInt; |
182 } | 183 } |
183 } | 184 } |
184 | 185 |
185 } // namespace interpreter | 186 } // namespace interpreter |
186 } // namespace internal | 187 } // namespace internal |
187 } // namespace v8 | 188 } // namespace v8 |
OLD | NEW |