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/node.h" | 8 #include "src/compiler/node.h" |
9 #include "src/interface-descriptors.h" | 9 #include "src/interface-descriptors.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 return kPointerSize == 8 ? IsInt64Add(lhs_matcher, rhs_matcher) | 44 return kPointerSize == 8 ? IsInt64Add(lhs_matcher, rhs_matcher) |
45 : IsInt32Add(lhs_matcher, rhs_matcher); | 45 : IsInt32Add(lhs_matcher, rhs_matcher); |
46 } | 46 } |
47 | 47 |
48 Matcher<Node*> IsIntPtrSub(const Matcher<Node*>& lhs_matcher, | 48 Matcher<Node*> IsIntPtrSub(const Matcher<Node*>& lhs_matcher, |
49 const Matcher<Node*>& rhs_matcher) { | 49 const Matcher<Node*>& rhs_matcher) { |
50 return kPointerSize == 8 ? IsInt64Sub(lhs_matcher, rhs_matcher) | 50 return kPointerSize == 8 ? IsInt64Sub(lhs_matcher, rhs_matcher) |
51 : IsInt32Sub(lhs_matcher, rhs_matcher); | 51 : IsInt32Sub(lhs_matcher, rhs_matcher); |
52 } | 52 } |
53 | 53 |
| 54 Matcher<Node*> IsIntPtrMul(const Matcher<Node*>& lhs_matcher, |
| 55 const Matcher<Node*>& rhs_matcher) { |
| 56 return kPointerSize == 8 ? IsInt64Mul(lhs_matcher, rhs_matcher) |
| 57 : IsInt32Mul(lhs_matcher, rhs_matcher); |
| 58 } |
| 59 |
54 Matcher<Node*> IsWordShl(const Matcher<Node*>& lhs_matcher, | 60 Matcher<Node*> IsWordShl(const Matcher<Node*>& lhs_matcher, |
55 const Matcher<Node*>& rhs_matcher) { | 61 const Matcher<Node*>& rhs_matcher) { |
56 return kPointerSize == 8 ? IsWord64Shl(lhs_matcher, rhs_matcher) | 62 return kPointerSize == 8 ? IsWord64Shl(lhs_matcher, rhs_matcher) |
57 : IsWord32Shl(lhs_matcher, rhs_matcher); | 63 : IsWord32Shl(lhs_matcher, rhs_matcher); |
58 } | 64 } |
59 | 65 |
60 Matcher<Node*> IsWordSar(const Matcher<Node*>& lhs_matcher, | 66 Matcher<Node*> IsWordSar(const Matcher<Node*>& lhs_matcher, |
61 const Matcher<Node*>& rhs_matcher) { | 67 const Matcher<Node*>& rhs_matcher) { |
62 return kPointerSize == 8 ? IsWord64Sar(lhs_matcher, rhs_matcher) | 68 return kPointerSize == 8 ? IsWord64Sar(lhs_matcher, rhs_matcher) |
63 : IsWord32Sar(lhs_matcher, rhs_matcher); | 69 : IsWord32Sar(lhs_matcher, rhs_matcher); |
64 } | 70 } |
65 | 71 |
66 Matcher<Node*> IsWordOr(const Matcher<Node*>& lhs_matcher, | 72 Matcher<Node*> IsWordOr(const Matcher<Node*>& lhs_matcher, |
67 const Matcher<Node*>& rhs_matcher) { | 73 const Matcher<Node*>& rhs_matcher) { |
68 return kPointerSize == 8 ? IsWord64Or(lhs_matcher, rhs_matcher) | 74 return kPointerSize == 8 ? IsWord64Or(lhs_matcher, rhs_matcher) |
69 : IsWord32Or(lhs_matcher, rhs_matcher); | 75 : IsWord32Or(lhs_matcher, rhs_matcher); |
70 } | 76 } |
71 | 77 |
| 78 Matcher<Node*> IsChangeInt32ToIntPtr(const Matcher<Node*>& matcher) { |
| 79 return kPointerSize == 8 ? IsChangeInt32ToInt64(matcher) : matcher; |
| 80 } |
| 81 |
| 82 Matcher<Node*> IsChangeUint32ToWord(const Matcher<Node*>& matcher) { |
| 83 return kPointerSize == 8 ? IsChangeUint32ToUint64(matcher) : matcher; |
| 84 } |
| 85 |
| 86 Matcher<Node*> IsTruncateWordToWord32(const Matcher<Node*>& matcher) { |
| 87 return kPointerSize == 8 ? IsTruncateInt64ToInt32(matcher) : matcher; |
| 88 } |
| 89 |
72 InterpreterAssemblerTest::InterpreterAssemblerForTest:: | 90 InterpreterAssemblerTest::InterpreterAssemblerForTest:: |
73 ~InterpreterAssemblerForTest() { | 91 ~InterpreterAssemblerForTest() { |
74 // Tests don't necessarily read and write accumulator but | 92 // Tests don't necessarily read and write accumulator but |
75 // InterpreterAssembler checks accumulator uses. | 93 // InterpreterAssembler checks accumulator uses. |
76 if (Bytecodes::ReadsAccumulator(bytecode())) { | 94 if (Bytecodes::ReadsAccumulator(bytecode())) { |
77 GetAccumulator(); | 95 GetAccumulator(); |
78 } | 96 } |
79 if (Bytecodes::WritesAccumulator(bytecode())) { | 97 if (Bytecodes::WritesAccumulator(bytecode())) { |
80 SetAccumulator(nullptr); | 98 SetAccumulator(nullptr); |
81 } | 99 } |
(...skipping 19 matching lines...) Expand all Loading... |
101 return IsLoad( | 119 return IsLoad( |
102 MachineType::Uint8(), | 120 MachineType::Uint8(), |
103 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 121 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
104 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 122 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
105 IsIntPtrConstant(offset))); | 123 IsIntPtrConstant(offset))); |
106 } | 124 } |
107 | 125 |
108 Matcher<Node*> | 126 Matcher<Node*> |
109 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedByteOperand( | 127 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedByteOperand( |
110 int offset) { | 128 int offset) { |
111 Matcher<Node*> load_matcher = IsLoad( | 129 return IsLoad( |
112 MachineType::Int8(), | 130 MachineType::Int8(), |
113 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 131 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
114 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 132 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
115 IsIntPtrConstant(offset))); | 133 IsIntPtrConstant(offset))); |
116 if (kPointerSize == 8) { | |
117 load_matcher = IsChangeInt32ToInt64(load_matcher); | |
118 } | |
119 return load_matcher; | |
120 } | 134 } |
121 | 135 |
122 Matcher<Node*> | 136 Matcher<Node*> |
123 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand( | 137 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand( |
124 int offset) { | 138 int offset) { |
125 if (TargetSupportsUnalignedAccess()) { | 139 if (TargetSupportsUnalignedAccess()) { |
126 return IsLoad( | 140 return IsLoad( |
127 MachineType::Uint16(), | 141 MachineType::Uint16(), |
128 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 142 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
129 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 143 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
(...skipping 18 matching lines...) Expand all Loading... |
148 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); | 162 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); |
149 } | 163 } |
150 return IsWord32Or(IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), | 164 return IsWord32Or(IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), |
151 bytes[1]); | 165 bytes[1]); |
152 } | 166 } |
153 } | 167 } |
154 | 168 |
155 Matcher<Node*> | 169 Matcher<Node*> |
156 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand( | 170 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand( |
157 int offset) { | 171 int offset) { |
158 Matcher<Node*> load_matcher; | |
159 if (TargetSupportsUnalignedAccess()) { | 172 if (TargetSupportsUnalignedAccess()) { |
160 load_matcher = IsLoad( | 173 return IsLoad( |
161 MachineType::Int16(), | 174 MachineType::Int16(), |
162 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 175 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
163 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 176 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
164 IsIntPtrConstant(offset))); | 177 IsIntPtrConstant(offset))); |
165 } else { | 178 } else { |
166 #if V8_TARGET_LITTLE_ENDIAN | 179 #if V8_TARGET_LITTLE_ENDIAN |
167 const int kStep = -1; | 180 const int kStep = -1; |
168 const int kMsbOffset = 1; | 181 const int kMsbOffset = 1; |
169 #elif V8_TARGET_BIG_ENDIAN | 182 #elif V8_TARGET_BIG_ENDIAN |
170 const int kStep = 1; | 183 const int kStep = 1; |
171 const int kMsbOffset = 0; | 184 const int kMsbOffset = 0; |
172 #else | 185 #else |
173 #error "Unknown Architecture" | 186 #error "Unknown Architecture" |
174 #endif | 187 #endif |
175 Matcher<Node*> bytes[2]; | 188 Matcher<Node*> bytes[2]; |
176 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { | 189 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { |
177 bytes[i] = IsLoad( | 190 bytes[i] = IsLoad( |
178 (i == 0) ? MachineType::Int8() : MachineType::Uint8(), | 191 (i == 0) ? MachineType::Int8() : MachineType::Uint8(), |
179 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 192 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
180 IsIntPtrAdd( | 193 IsIntPtrAdd( |
181 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 194 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
182 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); | 195 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); |
183 } | 196 } |
184 load_matcher = IsWord32Or( | 197 return IsWord32Or(IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), |
185 IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), bytes[1]); | 198 bytes[1]); |
186 } | 199 } |
187 | |
188 if (kPointerSize == 8) { | |
189 load_matcher = IsChangeInt32ToInt64(load_matcher); | |
190 } | |
191 return load_matcher; | |
192 } | 200 } |
193 | 201 |
194 Matcher<Node*> | 202 Matcher<Node*> |
195 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand( | 203 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand( |
196 int offset) { | 204 int offset) { |
197 if (TargetSupportsUnalignedAccess()) { | 205 if (TargetSupportsUnalignedAccess()) { |
198 return IsLoad( | 206 return IsLoad( |
199 MachineType::Uint32(), | 207 MachineType::Uint32(), |
200 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 208 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
201 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 209 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
(...skipping 22 matching lines...) Expand all Loading... |
224 IsWord32Or( | 232 IsWord32Or( |
225 IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)), | 233 IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)), |
226 IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)), | 234 IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)), |
227 bytes[3]))); | 235 bytes[3]))); |
228 } | 236 } |
229 } | 237 } |
230 | 238 |
231 Matcher<Node*> | 239 Matcher<Node*> |
232 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand( | 240 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand( |
233 int offset) { | 241 int offset) { |
234 Matcher<Node*> load_matcher; | |
235 if (TargetSupportsUnalignedAccess()) { | 242 if (TargetSupportsUnalignedAccess()) { |
236 load_matcher = IsLoad( | 243 return IsLoad( |
237 MachineType::Int32(), | 244 MachineType::Int32(), |
238 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 245 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
239 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 246 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
240 IsIntPtrConstant(offset))); | 247 IsIntPtrConstant(offset))); |
241 } else { | 248 } else { |
242 #if V8_TARGET_LITTLE_ENDIAN | 249 #if V8_TARGET_LITTLE_ENDIAN |
243 const int kStep = -1; | 250 const int kStep = -1; |
244 int kMsbOffset = 3; | 251 int kMsbOffset = 3; |
245 #elif V8_TARGET_BIG_ENDIAN | 252 #elif V8_TARGET_BIG_ENDIAN |
246 const int kStep = 1; | 253 const int kStep = 1; |
247 int kMsbOffset = 0; | 254 int kMsbOffset = 0; |
248 #else | 255 #else |
249 #error "Unknown Architecture" | 256 #error "Unknown Architecture" |
250 #endif | 257 #endif |
251 Matcher<Node*> bytes[4]; | 258 Matcher<Node*> bytes[4]; |
252 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { | 259 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { |
253 bytes[i] = IsLoad( | 260 bytes[i] = IsLoad( |
254 (i == 0) ? MachineType::Int8() : MachineType::Uint8(), | 261 (i == 0) ? MachineType::Int8() : MachineType::Uint8(), |
255 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 262 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
256 IsIntPtrAdd( | 263 IsIntPtrAdd( |
257 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 264 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
258 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); | 265 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); |
259 } | 266 } |
260 load_matcher = IsWord32Or( | 267 return IsWord32Or( |
261 IsWord32Shl(bytes[0], IsInt32Constant(3 * kBitsPerByte)), | 268 IsWord32Shl(bytes[0], IsInt32Constant(3 * kBitsPerByte)), |
262 IsWord32Or( | 269 IsWord32Or( |
263 IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)), | 270 IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)), |
264 IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)), | 271 IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)), |
265 bytes[3]))); | 272 bytes[3]))); |
266 } | 273 } |
267 | |
268 if (kPointerSize == 8) { | |
269 load_matcher = IsChangeInt32ToInt64(load_matcher); | |
270 } | |
271 return load_matcher; | |
272 } | 274 } |
273 | 275 |
274 Matcher<Node*> | 276 Matcher<Node*> |
275 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedOperand( | 277 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedOperand( |
276 int offset, OperandSize operand_size) { | 278 int offset, OperandSize operand_size) { |
277 switch (operand_size) { | 279 switch (operand_size) { |
278 case OperandSize::kByte: | 280 case OperandSize::kByte: |
279 return IsSignedByteOperand(offset); | 281 return IsSignedByteOperand(offset); |
280 case OperandSize::kShort: | 282 case OperandSize::kShort: |
281 return IsSignedShortOperand(offset); | 283 return IsSignedShortOperand(offset); |
(...skipping 29 matching lines...) Expand all Loading... |
311 | 313 |
312 OperandScale operand_scale = OperandScale::kSingle; | 314 OperandScale operand_scale = OperandScale::kSingle; |
313 Matcher<Node*> next_bytecode_offset_matcher = | 315 Matcher<Node*> next_bytecode_offset_matcher = |
314 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 316 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
315 IsIntPtrConstant( | 317 IsIntPtrConstant( |
316 interpreter::Bytecodes::Size(bytecode, operand_scale))); | 318 interpreter::Bytecodes::Size(bytecode, operand_scale))); |
317 Matcher<Node*> target_bytecode_matcher = | 319 Matcher<Node*> target_bytecode_matcher = |
318 m.IsLoad(MachineType::Uint8(), | 320 m.IsLoad(MachineType::Uint8(), |
319 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 321 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
320 next_bytecode_offset_matcher); | 322 next_bytecode_offset_matcher); |
321 if (kPointerSize == 8) { | 323 target_bytecode_matcher = IsChangeUint32ToWord(target_bytecode_matcher); |
322 target_bytecode_matcher = IsChangeUint32ToUint64(target_bytecode_matcher); | |
323 } | |
324 Matcher<Node*> code_target_matcher = m.IsLoad( | 324 Matcher<Node*> code_target_matcher = m.IsLoad( |
325 MachineType::Pointer(), | 325 MachineType::Pointer(), |
326 IsParameter(InterpreterDispatchDescriptor::kDispatchTable), | 326 IsParameter(InterpreterDispatchDescriptor::kDispatchTable), |
327 IsWordShl(target_bytecode_matcher, IsIntPtrConstant(kPointerSizeLog2))); | 327 IsWordShl(target_bytecode_matcher, IsIntPtrConstant(kPointerSizeLog2))); |
328 | 328 |
329 if (interpreter::Bytecodes::IsStarLookahead(bytecode, operand_scale)) { | 329 if (interpreter::Bytecodes::IsStarLookahead(bytecode, operand_scale)) { |
330 Matcher<Node*> after_lookahead_offset = | 330 Matcher<Node*> after_lookahead_offset = |
331 IsIntPtrAdd(next_bytecode_offset_matcher, | 331 IsIntPtrAdd(next_bytecode_offset_matcher, |
332 IsIntPtrConstant(interpreter::Bytecodes::Size( | 332 IsIntPtrConstant(interpreter::Bytecodes::Size( |
333 Bytecode::kStar, operand_scale))); | 333 Bytecode::kStar, operand_scale))); |
334 next_bytecode_offset_matcher = | 334 next_bytecode_offset_matcher = |
335 IsPhi(MachineType::PointerRepresentation(), | 335 IsPhi(MachineType::PointerRepresentation(), |
336 next_bytecode_offset_matcher, after_lookahead_offset, _); | 336 next_bytecode_offset_matcher, after_lookahead_offset, _); |
337 Matcher<Node*> after_lookahead_bytecode = | 337 Matcher<Node*> after_lookahead_bytecode = |
338 m.IsLoad(MachineType::Uint8(), | 338 m.IsLoad(MachineType::Uint8(), |
339 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 339 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
340 after_lookahead_offset); | 340 after_lookahead_offset); |
341 if (kPointerSize == 8) { | 341 after_lookahead_bytecode = IsChangeUint32ToWord(after_lookahead_bytecode); |
342 after_lookahead_bytecode = | |
343 IsChangeUint32ToUint64(after_lookahead_bytecode); | |
344 } | |
345 target_bytecode_matcher = | 342 target_bytecode_matcher = |
346 IsPhi(MachineType::PointerRepresentation(), target_bytecode_matcher, | 343 IsPhi(MachineType::PointerRepresentation(), target_bytecode_matcher, |
347 after_lookahead_bytecode, _); | 344 after_lookahead_bytecode, _); |
348 code_target_matcher = | 345 code_target_matcher = |
349 m.IsLoad(MachineType::Pointer(), | 346 m.IsLoad(MachineType::Pointer(), |
350 IsParameter(InterpreterDispatchDescriptor::kDispatchTable), | 347 IsParameter(InterpreterDispatchDescriptor::kDispatchTable), |
351 IsWordShl(target_bytecode_matcher, | 348 IsWordShl(target_bytecode_matcher, |
352 IsIntPtrConstant(kPointerSizeLog2))); | 349 IsIntPtrConstant(kPointerSizeLog2))); |
353 } | 350 } |
354 | 351 |
(...skipping 19 matching lines...) Expand all Loading... |
374 | 371 |
375 InterpreterAssemblerTestState state(this, bytecode); | 372 InterpreterAssemblerTestState state(this, bytecode); |
376 InterpreterAssemblerForTest m(&state, bytecode); | 373 InterpreterAssemblerForTest m(&state, bytecode); |
377 Node* tail_call_node = m.Jump(m.IntPtrConstant(jump_offset)); | 374 Node* tail_call_node = m.Jump(m.IntPtrConstant(jump_offset)); |
378 | 375 |
379 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( | 376 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( |
380 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 377 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
381 IsIntPtrConstant(jump_offset)); | 378 IsIntPtrConstant(jump_offset)); |
382 Matcher<Node*> target_bytecode_matcher = | 379 Matcher<Node*> target_bytecode_matcher = |
383 m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher); | 380 m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher); |
384 if (kPointerSize == 8) { | 381 target_bytecode_matcher = IsChangeUint32ToWord(target_bytecode_matcher); |
385 target_bytecode_matcher = | |
386 IsChangeUint32ToUint64(target_bytecode_matcher); | |
387 } | |
388 Matcher<Node*> code_target_matcher = | 382 Matcher<Node*> code_target_matcher = |
389 m.IsLoad(MachineType::Pointer(), | 383 m.IsLoad(MachineType::Pointer(), |
390 IsParameter(InterpreterDispatchDescriptor::kDispatchTable), | 384 IsParameter(InterpreterDispatchDescriptor::kDispatchTable), |
391 IsWordShl(target_bytecode_matcher, | 385 IsWordShl(target_bytecode_matcher, |
392 IsIntPtrConstant(kPointerSizeLog2))); | 386 IsIntPtrConstant(kPointerSizeLog2))); |
393 | 387 |
394 EXPECT_THAT( | 388 EXPECT_THAT( |
395 tail_call_node, | 389 tail_call_node, |
396 IsTailCall(_, code_target_matcher, | 390 IsTailCall(_, code_target_matcher, |
397 IsParameter(InterpreterDispatchDescriptor::kAccumulator), | 391 IsParameter(InterpreterDispatchDescriptor::kAccumulator), |
(...skipping 24 matching lines...) Expand all Loading... |
422 case interpreter::OperandType::kRegCount: | 416 case interpreter::OperandType::kRegCount: |
423 EXPECT_THAT(m.BytecodeOperandCount(i), | 417 EXPECT_THAT(m.BytecodeOperandCount(i), |
424 m.IsUnsignedOperand(offset, operand_size)); | 418 m.IsUnsignedOperand(offset, operand_size)); |
425 break; | 419 break; |
426 case interpreter::OperandType::kFlag8: | 420 case interpreter::OperandType::kFlag8: |
427 EXPECT_THAT(m.BytecodeOperandFlag(i), | 421 EXPECT_THAT(m.BytecodeOperandFlag(i), |
428 m.IsUnsignedOperand(offset, operand_size)); | 422 m.IsUnsignedOperand(offset, operand_size)); |
429 break; | 423 break; |
430 case interpreter::OperandType::kIdx: | 424 case interpreter::OperandType::kIdx: |
431 EXPECT_THAT(m.BytecodeOperandIdx(i), | 425 EXPECT_THAT(m.BytecodeOperandIdx(i), |
432 m.IsUnsignedOperand(offset, operand_size)); | 426 IsChangeUint32ToWord( |
| 427 m.IsUnsignedOperand(offset, operand_size))); |
433 break; | 428 break; |
434 case interpreter::OperandType::kUImm: | 429 case interpreter::OperandType::kUImm: |
435 EXPECT_THAT(m.BytecodeOperandUImm(i), | 430 EXPECT_THAT(m.BytecodeOperandUImm(i), |
436 m.IsUnsignedOperand(offset, operand_size)); | 431 m.IsUnsignedOperand(offset, operand_size)); |
437 break; | 432 break; |
438 case interpreter::OperandType::kImm: { | 433 case interpreter::OperandType::kImm: { |
439 EXPECT_THAT(m.BytecodeOperandImm(i), | 434 EXPECT_THAT(m.BytecodeOperandImm(i), |
440 m.IsSignedOperand(offset, operand_size)); | 435 m.IsSignedOperand(offset, operand_size)); |
441 break; | 436 break; |
442 } | 437 } |
443 case interpreter::OperandType::kRegList: | 438 case interpreter::OperandType::kRegList: |
444 case interpreter::OperandType::kReg: | 439 case interpreter::OperandType::kReg: |
445 case interpreter::OperandType::kRegOut: | 440 case interpreter::OperandType::kRegOut: |
446 case interpreter::OperandType::kRegOutPair: | 441 case interpreter::OperandType::kRegOutPair: |
447 case interpreter::OperandType::kRegOutTriple: | 442 case interpreter::OperandType::kRegOutTriple: |
448 case interpreter::OperandType::kRegPair: | 443 case interpreter::OperandType::kRegPair: |
449 EXPECT_THAT(m.BytecodeOperandReg(i), | 444 EXPECT_THAT( |
450 m.IsSignedOperand(offset, operand_size)); | 445 m.BytecodeOperandReg(i), |
| 446 IsChangeInt32ToIntPtr(m.IsSignedOperand(offset, operand_size))); |
451 break; | 447 break; |
452 case interpreter::OperandType::kRuntimeId: | 448 case interpreter::OperandType::kRuntimeId: |
453 EXPECT_THAT(m.BytecodeOperandRuntimeId(i), | 449 EXPECT_THAT(m.BytecodeOperandRuntimeId(i), |
454 m.IsUnsignedOperand(offset, operand_size)); | 450 m.IsUnsignedOperand(offset, operand_size)); |
455 break; | 451 break; |
456 case interpreter::OperandType::kIntrinsicId: | 452 case interpreter::OperandType::kIntrinsicId: |
457 EXPECT_THAT(m.BytecodeOperandIntrinsicId(i), | 453 EXPECT_THAT(m.BytecodeOperandIntrinsicId(i), |
458 m.IsUnsignedOperand(offset, operand_size)); | 454 m.IsUnsignedOperand(offset, operand_size)); |
459 break; | 455 break; |
460 case interpreter::OperandType::kNone: | 456 case interpreter::OperandType::kNone: |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 Node* a = m.IntPtrConstant(0); | 588 Node* a = m.IntPtrConstant(0); |
593 Node* add = m.WordShl(a, 10); | 589 Node* add = m.WordShl(a, 10); |
594 EXPECT_THAT(add, IsWordShl(a, IsIntPtrConstant(10))); | 590 EXPECT_THAT(add, IsWordShl(a, IsIntPtrConstant(10))); |
595 } | 591 } |
596 } | 592 } |
597 | 593 |
598 TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { | 594 TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { |
599 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 595 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
600 InterpreterAssemblerTestState state(this, bytecode); | 596 InterpreterAssemblerTestState state(this, bytecode); |
601 InterpreterAssemblerForTest m(&state, bytecode); | 597 InterpreterAssemblerForTest m(&state, bytecode); |
602 Node* index = m.IntPtrConstant(2); | 598 { |
603 Node* load_constant = m.LoadConstantPoolEntry(index); | 599 Node* index = m.IntPtrConstant(2); |
604 Matcher<Node*> constant_pool_matcher = m.IsLoad( | 600 Node* load_constant = m.LoadConstantPoolEntry(index); |
605 MachineType::AnyTagged(), | 601 Matcher<Node*> constant_pool_matcher = |
606 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 602 m.IsLoad(MachineType::AnyTagged(), |
607 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - kHeapObjectTag)); | 603 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
608 EXPECT_THAT( | 604 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - |
609 load_constant, | 605 kHeapObjectTag)); |
610 m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher, | 606 EXPECT_THAT(load_constant, |
611 IsIntPtrAdd( | 607 m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher, |
612 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), | 608 IsIntPtrConstant(FixedArray::OffsetOfElementAt(2) - |
613 IsWordShl(index, IsIntPtrConstant(kPointerSizeLog2))))); | 609 kHeapObjectTag))); |
| 610 } |
| 611 { |
| 612 Node* index = m.Parameter(2); |
| 613 Node* load_constant = m.LoadConstantPoolEntry(index); |
| 614 Matcher<Node*> constant_pool_matcher = |
| 615 m.IsLoad(MachineType::AnyTagged(), |
| 616 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| 617 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - |
| 618 kHeapObjectTag)); |
| 619 EXPECT_THAT( |
| 620 load_constant, |
| 621 m.IsLoad( |
| 622 MachineType::AnyTagged(), constant_pool_matcher, |
| 623 IsIntPtrAdd( |
| 624 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), |
| 625 IsWordShl(index, IsIntPtrConstant(kPointerSizeLog2))))); |
| 626 } |
614 } | 627 } |
615 } | 628 } |
616 | 629 |
617 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { | 630 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { |
618 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 631 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
619 InterpreterAssemblerTestState state(this, bytecode); | 632 InterpreterAssemblerTestState state(this, bytecode); |
620 InterpreterAssemblerForTest m(&state, bytecode); | 633 InterpreterAssemblerForTest m(&state, bytecode); |
621 Node* object = m.IntPtrConstant(0xdeadbeef); | 634 Node* object = m.IntPtrConstant(0xdeadbeef); |
622 int offset = 16; | 635 int offset = 16; |
623 Node* load_field = m.LoadObjectField(object, offset); | 636 Node* load_field = m.LoadObjectField(object, offset); |
(...skipping 18 matching lines...) Expand all Loading... |
642 | 655 |
643 TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) { | 656 TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) { |
644 const int kResultSizes[] = {1, 2}; | 657 const int kResultSizes[] = {1, 2}; |
645 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 658 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
646 TRACED_FOREACH(int, result_size, kResultSizes) { | 659 TRACED_FOREACH(int, result_size, kResultSizes) { |
647 InterpreterAssemblerTestState state(this, bytecode); | 660 InterpreterAssemblerTestState state(this, bytecode); |
648 InterpreterAssemblerForTest m(&state, bytecode); | 661 InterpreterAssemblerForTest m(&state, bytecode); |
649 Callable builtin = CodeFactory::InterpreterCEntry(isolate(), result_size); | 662 Callable builtin = CodeFactory::InterpreterCEntry(isolate(), result_size); |
650 | 663 |
651 Node* function_id = m.Int32Constant(0); | 664 Node* function_id = m.Int32Constant(0); |
652 Node* first_arg = m.Int32Constant(1); | 665 Node* first_arg = m.IntPtrConstant(1); |
653 Node* arg_count = m.Int32Constant(2); | 666 Node* arg_count = m.Int32Constant(2); |
654 Node* context = m.Int32Constant(4); | 667 Node* context = m.IntPtrConstant(4); |
655 | 668 |
656 Matcher<Node*> function_table = IsExternalConstant( | 669 Matcher<Node*> function_table = IsExternalConstant( |
657 ExternalReference::runtime_function_table_address(isolate())); | 670 ExternalReference::runtime_function_table_address(isolate())); |
658 Matcher<Node*> function = IsIntPtrAdd( | 671 Matcher<Node*> function = IsIntPtrAdd( |
659 function_table, | 672 function_table, |
660 IsInt32Mul(function_id, IsInt32Constant(sizeof(Runtime::Function)))); | 673 IsChangeUint32ToWord(IsInt32Mul( |
| 674 function_id, IsInt32Constant(sizeof(Runtime::Function))))); |
661 Matcher<Node*> function_entry = | 675 Matcher<Node*> function_entry = |
662 m.IsLoad(MachineType::Pointer(), function, | 676 m.IsLoad(MachineType::Pointer(), function, |
663 IsIntPtrConstant(offsetof(Runtime::Function, entry))); | 677 IsIntPtrConstant(offsetof(Runtime::Function, entry))); |
664 | 678 |
665 Node* call_runtime = m.CallRuntimeN(function_id, context, first_arg, | 679 Node* call_runtime = m.CallRuntimeN(function_id, context, first_arg, |
666 arg_count, result_size); | 680 arg_count, result_size); |
667 EXPECT_THAT(call_runtime, | 681 EXPECT_THAT(call_runtime, |
668 IsCall(_, IsHeapConstant(builtin.code()), arg_count, | 682 IsCall(_, IsHeapConstant(builtin.code()), arg_count, |
669 first_arg, function_entry, context, _, _)); | 683 first_arg, function_entry, context, _, _)); |
670 } | 684 } |
671 } | 685 } |
672 } | 686 } |
673 | 687 |
674 TARGET_TEST_F(InterpreterAssemblerTest, CallJS) { | 688 TARGET_TEST_F(InterpreterAssemblerTest, CallJS) { |
675 TailCallMode tail_call_modes[] = {TailCallMode::kDisallow, | 689 TailCallMode tail_call_modes[] = {TailCallMode::kDisallow, |
676 TailCallMode::kAllow}; | 690 TailCallMode::kAllow}; |
677 TRACED_FOREACH(TailCallMode, tail_call_mode, tail_call_modes) { | 691 TRACED_FOREACH(TailCallMode, tail_call_mode, tail_call_modes) { |
678 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 692 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
679 InterpreterAssemblerTestState state(this, bytecode); | 693 InterpreterAssemblerTestState state(this, bytecode); |
680 InterpreterAssemblerForTest m(&state, bytecode); | 694 InterpreterAssemblerForTest m(&state, bytecode); |
681 Callable builtin = | 695 Callable builtin = |
682 CodeFactory::InterpreterPushArgsAndCall(isolate(), tail_call_mode); | 696 CodeFactory::InterpreterPushArgsAndCall(isolate(), tail_call_mode); |
683 Node* function = m.Int32Constant(0); | 697 Node* function = m.IntPtrConstant(0); |
684 Node* first_arg = m.Int32Constant(1); | 698 Node* first_arg = m.IntPtrConstant(1); |
685 Node* arg_count = m.Int32Constant(2); | 699 Node* arg_count = m.Int32Constant(2); |
686 Node* context = m.Int32Constant(3); | 700 Node* context = m.IntPtrConstant(3); |
687 Node* call_js = | 701 Node* call_js = |
688 m.CallJS(function, context, first_arg, arg_count, tail_call_mode); | 702 m.CallJS(function, context, first_arg, arg_count, tail_call_mode); |
689 EXPECT_THAT(call_js, IsCall(_, IsHeapConstant(builtin.code()), arg_count, | 703 EXPECT_THAT(call_js, IsCall(_, IsHeapConstant(builtin.code()), arg_count, |
690 first_arg, function, context, _, _)); | 704 first_arg, function, context, _, _)); |
691 } | 705 } |
692 } | 706 } |
693 } | 707 } |
694 | 708 |
695 TARGET_TEST_F(InterpreterAssemblerTest, LoadTypeFeedbackVector) { | 709 TARGET_TEST_F(InterpreterAssemblerTest, LoadTypeFeedbackVector) { |
696 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 710 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
(...skipping 12 matching lines...) Expand all Loading... |
709 EXPECT_THAT(feedback_vector, | 723 EXPECT_THAT(feedback_vector, |
710 m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, | 724 m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, |
711 IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | 725 IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - |
712 kHeapObjectTag))); | 726 kHeapObjectTag))); |
713 } | 727 } |
714 } | 728 } |
715 | 729 |
716 } // namespace interpreter | 730 } // namespace interpreter |
717 } // namespace internal | 731 } // namespace internal |
718 } // namespace v8 | 732 } // namespace v8 |
OLD | NEW |