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 "test/unittests/interpreter/interpreter-assembler-unittest.h" | 5 #include "test/unittests/interpreter/interpreter-assembler-unittest.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
10 #include "src/interface-descriptors.h" | 10 #include "src/interface-descriptors.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsStore( | 71 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsStore( |
72 const Matcher<StoreRepresentation>& rep_matcher, | 72 const Matcher<StoreRepresentation>& rep_matcher, |
73 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, | 73 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, |
74 const Matcher<Node*>& value_matcher) { | 74 const Matcher<Node*>& value_matcher) { |
75 return ::i::compiler::IsStore(rep_matcher, base_matcher, index_matcher, | 75 return ::i::compiler::IsStore(rep_matcher, base_matcher, index_matcher, |
76 value_matcher, _, _); | 76 value_matcher, _, _); |
77 } | 77 } |
78 | 78 |
79 Matcher<Node*> | 79 Matcher<Node*> |
80 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperand( | 80 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedByteOperand( |
81 int offset) { | 81 int offset) { |
82 return IsLoad( | 82 return IsLoad( |
83 MachineType::Uint8(), | 83 MachineType::Uint8(), |
84 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | 84 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
85 IsIntPtrAdd( | 85 IsIntPtrAdd( |
86 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 86 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
87 IsIntPtrConstant(offset))); | 87 IsIntPtrConstant(offset))); |
88 } | 88 } |
89 | 89 |
90 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest:: | 90 Matcher<Node*> |
91 IsBytecodeOperandSignExtended(int offset) { | 91 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedByteOperand( |
| 92 int offset) { |
92 Matcher<Node*> load_matcher = IsLoad( | 93 Matcher<Node*> load_matcher = IsLoad( |
93 MachineType::Int8(), | 94 MachineType::Int8(), |
94 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | 95 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
95 IsIntPtrAdd( | 96 IsIntPtrAdd( |
96 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 97 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
97 IsIntPtrConstant(offset))); | 98 IsIntPtrConstant(offset))); |
98 if (kPointerSize == 8) { | 99 if (kPointerSize == 8) { |
99 load_matcher = IsChangeInt32ToInt64(load_matcher); | 100 load_matcher = IsChangeInt32ToInt64(load_matcher); |
100 } | 101 } |
101 return load_matcher; | 102 return load_matcher; |
102 } | 103 } |
103 | 104 |
104 Matcher<Node*> | 105 Matcher<Node*> |
105 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperandShort( | 106 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand( |
106 int offset) { | 107 int offset) { |
107 if (TargetSupportsUnalignedAccess()) { | 108 if (TargetSupportsUnalignedAccess()) { |
108 return IsLoad( | 109 return IsLoad( |
109 MachineType::Uint16(), | 110 MachineType::Uint16(), |
110 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | 111 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
111 IsIntPtrAdd( | 112 IsIntPtrAdd( |
112 IsParameter( | 113 IsParameter( |
113 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 114 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
114 IsIntPtrConstant(offset))); | 115 IsIntPtrConstant(offset))); |
115 } else { | 116 } else { |
116 Matcher<Node*> first_byte = IsLoad( | |
117 MachineType::Uint8(), | |
118 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | |
119 IsIntPtrAdd( | |
120 IsParameter( | |
121 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | |
122 IsIntPtrConstant(offset))); | |
123 Matcher<Node*> second_byte = IsLoad( | |
124 MachineType::Uint8(), | |
125 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | |
126 IsIntPtrAdd( | |
127 IsParameter( | |
128 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | |
129 IsIntPtrConstant(offset + 1))); | |
130 #if V8_TARGET_LITTLE_ENDIAN | 117 #if V8_TARGET_LITTLE_ENDIAN |
131 return IsWordOr(IsWordShl(second_byte, IsIntPtrConstant(kBitsPerByte)), | 118 const int kStep = -1; |
132 first_byte); | 119 const int kMsbOffset = 1; |
133 #elif V8_TARGET_BIG_ENDIAN | 120 #elif V8_TARGET_BIG_ENDIAN |
134 return IsWordOr(IsWordShl(first_byte, IsIntPtrConstant(kBitsPerByte)), | 121 const int kStep = 1; |
135 second_byte); | 122 const int kMsbOffset = 0; |
136 #else | 123 #else |
137 #error "Unknown Architecture" | 124 #error "Unknown Architecture" |
138 #endif | 125 #endif |
| 126 Matcher<Node*> bytes[2]; |
| 127 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { |
| 128 bytes[i] = IsLoad( |
| 129 MachineType::Uint8(), |
| 130 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 131 IsIntPtrAdd( |
| 132 IsParameter( |
| 133 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
| 134 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); |
| 135 } |
| 136 return IsWord32Or(IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), |
| 137 bytes[1]); |
139 } | 138 } |
140 } | 139 } |
141 | 140 |
142 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest:: | 141 Matcher<Node*> |
143 IsBytecodeOperandShortSignExtended(int offset) { | 142 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand( |
| 143 int offset) { |
144 Matcher<Node*> load_matcher; | 144 Matcher<Node*> load_matcher; |
145 if (TargetSupportsUnalignedAccess()) { | 145 if (TargetSupportsUnalignedAccess()) { |
146 load_matcher = IsLoad( | 146 load_matcher = IsLoad( |
147 MachineType::Int16(), | 147 MachineType::Int16(), |
148 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | 148 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
149 IsIntPtrAdd( | 149 IsIntPtrAdd( |
150 IsParameter( | 150 IsParameter( |
151 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 151 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
152 IsIntPtrConstant(offset))); | 152 IsIntPtrConstant(offset))); |
153 } else { | 153 } else { |
154 #if V8_TARGET_LITTLE_ENDIAN | 154 #if V8_TARGET_LITTLE_ENDIAN |
155 int hi_byte_offset = offset + 1; | 155 const int kStep = -1; |
156 int lo_byte_offset = offset; | 156 const int kMsbOffset = 1; |
157 | |
158 #elif V8_TARGET_BIG_ENDIAN | 157 #elif V8_TARGET_BIG_ENDIAN |
159 int hi_byte_offset = offset; | 158 const int kStep = 1; |
160 int lo_byte_offset = offset + 1; | 159 const int kMsbOffset = 0; |
161 #else | 160 #else |
162 #error "Unknown Architecture" | 161 #error "Unknown Architecture" |
163 #endif | 162 #endif |
164 Matcher<Node*> hi_byte = IsLoad( | 163 Matcher<Node*> bytes[2]; |
165 MachineType::Int8(), | 164 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { |
| 165 bytes[i] = IsLoad( |
| 166 (i == 0) ? MachineType::Int8() : MachineType::Uint8(), |
| 167 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 168 IsIntPtrAdd( |
| 169 IsParameter( |
| 170 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
| 171 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); |
| 172 } |
| 173 load_matcher = IsWord32Or( |
| 174 IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), bytes[1]); |
| 175 } |
| 176 |
| 177 if (kPointerSize == 8) { |
| 178 load_matcher = IsChangeInt32ToInt64(load_matcher); |
| 179 } |
| 180 return load_matcher; |
| 181 } |
| 182 |
| 183 Matcher<Node*> |
| 184 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand( |
| 185 int offset) { |
| 186 if (TargetSupportsUnalignedAccess()) { |
| 187 return IsLoad( |
| 188 MachineType::Uint32(), |
166 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | 189 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
167 IsIntPtrAdd( | 190 IsIntPtrAdd( |
168 IsParameter( | 191 IsParameter( |
169 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 192 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
170 IsIntPtrConstant(hi_byte_offset))); | 193 IsIntPtrConstant(offset))); |
171 hi_byte = IsWord32Shl(hi_byte, IsInt32Constant(kBitsPerByte)); | 194 } else { |
172 Matcher<Node*> lo_byte = IsLoad( | 195 #if V8_TARGET_LITTLE_ENDIAN |
173 MachineType::Uint8(), | 196 const int kStep = -1; |
| 197 const int kMsbOffset = 3; |
| 198 #elif V8_TARGET_BIG_ENDIAN |
| 199 const int kStep = 1; |
| 200 const int kMsbOffset = 0; |
| 201 #else |
| 202 #error "Unknown Architecture" |
| 203 #endif |
| 204 Matcher<Node*> bytes[4]; |
| 205 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { |
| 206 bytes[i] = IsLoad( |
| 207 MachineType::Uint8(), |
| 208 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 209 IsIntPtrAdd( |
| 210 IsParameter( |
| 211 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
| 212 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); |
| 213 } |
| 214 return IsWord32Or( |
| 215 IsWord32Shl(bytes[0], IsInt32Constant(3 * kBitsPerByte)), |
| 216 IsWord32Or( |
| 217 IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)), |
| 218 IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)), |
| 219 bytes[3]))); |
| 220 } |
| 221 } |
| 222 |
| 223 Matcher<Node*> |
| 224 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand( |
| 225 int offset) { |
| 226 Matcher<Node*> load_matcher; |
| 227 if (TargetSupportsUnalignedAccess()) { |
| 228 load_matcher = IsLoad( |
| 229 MachineType::Int32(), |
174 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | 230 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
175 IsIntPtrAdd( | 231 IsIntPtrAdd( |
176 IsParameter( | 232 IsParameter( |
177 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 233 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
178 IsIntPtrConstant(lo_byte_offset))); | 234 IsIntPtrConstant(offset))); |
179 load_matcher = IsWord32Or(hi_byte, lo_byte); | 235 } else { |
| 236 #if V8_TARGET_LITTLE_ENDIAN |
| 237 const int kStep = -1; |
| 238 int kMsbOffset = 3; |
| 239 #elif V8_TARGET_BIG_ENDIAN |
| 240 const int kStep = 1; |
| 241 int kMsbOffset = 0; |
| 242 #else |
| 243 #error "Unknown Architecture" |
| 244 #endif |
| 245 Matcher<Node*> bytes[4]; |
| 246 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { |
| 247 bytes[i] = IsLoad( |
| 248 (i == 0) ? MachineType::Int8() : MachineType::Uint8(), |
| 249 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 250 IsIntPtrAdd( |
| 251 IsParameter( |
| 252 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
| 253 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); |
| 254 } |
| 255 load_matcher = IsWord32Or( |
| 256 IsWord32Shl(bytes[0], IsInt32Constant(3 * kBitsPerByte)), |
| 257 IsWord32Or( |
| 258 IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)), |
| 259 IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)), |
| 260 bytes[3]))); |
180 } | 261 } |
181 | 262 |
182 if (kPointerSize == 8) { | 263 if (kPointerSize == 8) { |
183 load_matcher = IsChangeInt32ToInt64(load_matcher); | 264 load_matcher = IsChangeInt32ToInt64(load_matcher); |
184 } | 265 } |
185 return load_matcher; | 266 return load_matcher; |
186 } | 267 } |
187 | 268 |
| 269 Matcher<Node*> |
| 270 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedOperand( |
| 271 int offset, OperandSize operand_size) { |
| 272 switch (operand_size) { |
| 273 case OperandSize::kByte: |
| 274 return IsSignedByteOperand(offset); |
| 275 case OperandSize::kShort: |
| 276 return IsSignedShortOperand(offset); |
| 277 case OperandSize::kQuad: |
| 278 return IsSignedQuadOperand(offset); |
| 279 case OperandSize::kNone: |
| 280 UNREACHABLE(); |
| 281 } |
| 282 return nullptr; |
| 283 } |
| 284 |
| 285 Matcher<Node*> |
| 286 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedOperand( |
| 287 int offset, OperandSize operand_size) { |
| 288 switch (operand_size) { |
| 289 case OperandSize::kByte: |
| 290 return IsUnsignedByteOperand(offset); |
| 291 case OperandSize::kShort: |
| 292 return IsUnsignedShortOperand(offset); |
| 293 case OperandSize::kQuad: |
| 294 return IsUnsignedQuadOperand(offset); |
| 295 case OperandSize::kNone: |
| 296 UNREACHABLE(); |
| 297 } |
| 298 return nullptr; |
| 299 } |
| 300 |
188 TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) { | 301 TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) { |
189 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 302 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
190 InterpreterAssemblerForTest m(this, bytecode); | 303 InterpreterAssemblerForTest m(this, bytecode); |
191 m.Dispatch(); | 304 m.Dispatch(); |
192 Graph* graph = m.graph(); | 305 Graph* graph = m.graph(); |
193 | 306 |
194 Node* end = graph->end(); | 307 Node* end = graph->end(); |
195 EXPECT_EQ(1, end->InputCount()); | 308 EXPECT_EQ(1, end->InputCount()); |
196 Node* tail_call_node = end->InputAt(0); | 309 Node* tail_call_node = end->InputAt(0); |
197 | 310 |
| 311 OperandScale operand_scale = OperandScale::kSingle; |
198 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( | 312 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( |
199 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 313 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
200 IsIntPtrConstant(interpreter::Bytecodes::Size(bytecode))); | 314 IsIntPtrConstant( |
| 315 interpreter::Bytecodes::Size(bytecode, operand_scale))); |
201 Matcher<Node*> target_bytecode_matcher = m.IsLoad( | 316 Matcher<Node*> target_bytecode_matcher = m.IsLoad( |
202 MachineType::Uint8(), | 317 MachineType::Uint8(), |
203 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | 318 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
204 next_bytecode_offset_matcher); | 319 next_bytecode_offset_matcher); |
205 if (kPointerSize == 8) { | 320 if (kPointerSize == 8) { |
206 target_bytecode_matcher = IsChangeUint32ToUint64(target_bytecode_matcher); | 321 target_bytecode_matcher = IsChangeUint32ToUint64(target_bytecode_matcher); |
207 } | 322 } |
208 Matcher<Node*> code_target_matcher = m.IsLoad( | 323 Matcher<Node*> code_target_matcher = m.IsLoad( |
209 MachineType::Pointer(), | 324 MachineType::Pointer(), |
210 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), | 325 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 394 |
280 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 395 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
281 InterpreterAssemblerForTest m(this, bytecode); | 396 InterpreterAssemblerForTest m(this, bytecode); |
282 Node* lhs = m.IntPtrConstant(0); | 397 Node* lhs = m.IntPtrConstant(0); |
283 Node* rhs = m.IntPtrConstant(1); | 398 Node* rhs = m.IntPtrConstant(1); |
284 m.JumpIfWordEqual(lhs, rhs, m.IntPtrConstant(kJumpIfTrueOffset)); | 399 m.JumpIfWordEqual(lhs, rhs, m.IntPtrConstant(kJumpIfTrueOffset)); |
285 Graph* graph = m.graph(); | 400 Graph* graph = m.graph(); |
286 Node* end = graph->end(); | 401 Node* end = graph->end(); |
287 EXPECT_EQ(2, end->InputCount()); | 402 EXPECT_EQ(2, end->InputCount()); |
288 | 403 |
289 int jump_offsets[] = {kJumpIfTrueOffset, | 404 OperandScale operand_scale = OperandScale::kSingle; |
290 interpreter::Bytecodes::Size(bytecode)}; | 405 int jump_offsets[] = {kJumpIfTrueOffset, interpreter::Bytecodes::Size( |
| 406 bytecode, operand_scale)}; |
291 for (int i = 0; i < static_cast<int>(arraysize(jump_offsets)); i++) { | 407 for (int i = 0; i < static_cast<int>(arraysize(jump_offsets)); i++) { |
292 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( | 408 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( |
293 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 409 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
294 IsIntPtrConstant(jump_offsets[i])); | 410 IsIntPtrConstant(jump_offsets[i])); |
295 Matcher<Node*> target_bytecode_matcher = | 411 Matcher<Node*> target_bytecode_matcher = |
296 m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher); | 412 m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher); |
297 if (kPointerSize == 8) { | 413 if (kPointerSize == 8) { |
298 target_bytecode_matcher = | 414 target_bytecode_matcher = |
299 IsChangeUint32ToUint64(target_bytecode_matcher); | 415 IsChangeUint32ToUint64(target_bytecode_matcher); |
300 } | 416 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 IsParameter( | 461 IsParameter( |
346 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 462 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
347 _, | 463 _, |
348 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), | 464 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), |
349 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _, | 465 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _, |
350 _)); | 466 _)); |
351 } | 467 } |
352 } | 468 } |
353 | 469 |
354 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { | 470 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { |
| 471 static const OperandScale kOperandScales[] = { |
| 472 OperandScale::kSingle, OperandScale::kDouble, OperandScale::kQuadruple}; |
355 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 473 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
356 InterpreterAssemblerForTest m(this, bytecode); | 474 TRACED_FOREACH(interpreter::OperandScale, operand_scale, kOperandScales) { |
357 int number_of_operands = interpreter::Bytecodes::NumberOfOperands(bytecode); | 475 InterpreterAssemblerForTest m(this, bytecode, operand_scale); |
358 for (int i = 0; i < number_of_operands; i++) { | 476 int number_of_operands = |
359 int offset = interpreter::Bytecodes::GetOperandOffset(bytecode, i); | 477 interpreter::Bytecodes::NumberOfOperands(bytecode); |
360 switch (interpreter::Bytecodes::GetOperandType(bytecode, i)) { | 478 for (int i = 0; i < number_of_operands; i++) { |
361 case interpreter::OperandType::kRegCount8: | 479 int offset = interpreter::Bytecodes::GetOperandOffset(bytecode, i, |
362 EXPECT_THAT(m.BytecodeOperandCount(i), m.IsBytecodeOperand(offset)); | 480 operand_scale); |
363 break; | 481 OperandType operand_type = |
364 case interpreter::OperandType::kIdx8: | 482 interpreter::Bytecodes::GetOperandType(bytecode, i); |
365 EXPECT_THAT(m.BytecodeOperandIdx(i), m.IsBytecodeOperand(offset)); | 483 OperandSize operand_size = |
366 break; | 484 Bytecodes::SizeOfOperand(operand_type, operand_scale); |
367 case interpreter::OperandType::kImm8: | 485 switch (interpreter::Bytecodes::GetOperandType(bytecode, i)) { |
368 EXPECT_THAT(m.BytecodeOperandImm(i), | 486 case interpreter::OperandType::kRegCount: |
369 m.IsBytecodeOperandSignExtended(offset)); | 487 EXPECT_THAT(m.BytecodeOperandCount(i), |
370 break; | 488 m.IsUnsignedOperand(offset, operand_size)); |
371 case interpreter::OperandType::kMaybeReg8: | 489 break; |
372 case interpreter::OperandType::kReg8: | 490 case interpreter::OperandType::kFlag8: |
373 case interpreter::OperandType::kRegOut8: | 491 EXPECT_THAT(m.BytecodeOperandFlag(i), |
374 case interpreter::OperandType::kRegOutPair8: | 492 m.IsUnsignedOperand(offset, operand_size)); |
375 case interpreter::OperandType::kRegOutTriple8: | 493 break; |
376 case interpreter::OperandType::kRegPair8: | 494 case interpreter::OperandType::kIdx: |
377 EXPECT_THAT(m.BytecodeOperandReg(i), | 495 EXPECT_THAT(m.BytecodeOperandIdx(i), |
378 m.IsBytecodeOperandSignExtended(offset)); | 496 m.IsUnsignedOperand(offset, operand_size)); |
379 break; | 497 break; |
380 case interpreter::OperandType::kRegCount16: | 498 case interpreter::OperandType::kImm: { |
381 EXPECT_THAT(m.BytecodeOperandCount(i), | 499 EXPECT_THAT(m.BytecodeOperandImm(i), |
382 m.IsBytecodeOperandShort(offset)); | 500 m.IsSignedOperand(offset, operand_size)); |
383 break; | 501 break; |
384 case interpreter::OperandType::kIdx16: | 502 } |
385 EXPECT_THAT(m.BytecodeOperandIdx(i), | 503 case interpreter::OperandType::kMaybeReg: |
386 m.IsBytecodeOperandShort(offset)); | 504 case interpreter::OperandType::kReg: |
387 break; | 505 case interpreter::OperandType::kRegOut: |
388 case interpreter::OperandType::kMaybeReg16: | 506 case interpreter::OperandType::kRegOutPair: |
389 case interpreter::OperandType::kReg16: | 507 case interpreter::OperandType::kRegOutTriple: |
390 case interpreter::OperandType::kRegOut16: | 508 case interpreter::OperandType::kRegPair: |
391 case interpreter::OperandType::kRegOutPair16: | 509 EXPECT_THAT(m.BytecodeOperandReg(i), |
392 case interpreter::OperandType::kRegOutTriple16: | 510 m.IsSignedOperand(offset, operand_size)); |
393 case interpreter::OperandType::kRegPair16: | 511 break; |
394 EXPECT_THAT(m.BytecodeOperandReg(i), | 512 case interpreter::OperandType::kRuntimeId: |
395 m.IsBytecodeOperandShortSignExtended(offset)); | 513 EXPECT_THAT(m.BytecodeOperandRuntimeId(i), |
396 break; | 514 m.IsUnsignedOperand(offset, operand_size)); |
397 case interpreter::OperandType::kNone: | 515 break; |
398 UNREACHABLE(); | 516 case interpreter::OperandType::kNone: |
399 break; | 517 UNREACHABLE(); |
| 518 break; |
| 519 } |
400 } | 520 } |
401 } | 521 } |
402 } | 522 } |
403 } | 523 } |
404 | 524 |
405 TARGET_TEST_F(InterpreterAssemblerTest, GetSetAccumulator) { | 525 TARGET_TEST_F(InterpreterAssemblerTest, GetSetAccumulator) { |
406 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 526 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
407 InterpreterAssemblerForTest m(this, bytecode); | 527 InterpreterAssemblerForTest m(this, bytecode); |
408 // Should be incoming accumulator if not set. | 528 // Should be incoming accumulator if not set. |
409 EXPECT_THAT( | 529 EXPECT_THAT( |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 feedback_vector, | 803 feedback_vector, |
684 m.IsLoad(MachineType::AnyTagged(), load_shared_function_info_matcher, | 804 m.IsLoad(MachineType::AnyTagged(), load_shared_function_info_matcher, |
685 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - | 805 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - |
686 kHeapObjectTag))); | 806 kHeapObjectTag))); |
687 } | 807 } |
688 } | 808 } |
689 | 809 |
690 } // namespace interpreter | 810 } // namespace interpreter |
691 } // namespace internal | 811 } // namespace internal |
692 } // namespace v8 | 812 } // namespace v8 |
OLD | NEW |