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/compiler/interpreter-assembler-unittest.h" | 5 #include "test/unittests/compiler/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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 const Matcher<const CallDescriptor*>& descriptor_matcher, A... args) { | 89 const Matcher<const CallDescriptor*>& descriptor_matcher, A... args) { |
90 return ::i::compiler::IsCall(descriptor_matcher, args..., graph()->start(), | 90 return ::i::compiler::IsCall(descriptor_matcher, args..., graph()->start(), |
91 graph()->start()); | 91 graph()->start()); |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 Matcher<Node*> | 95 Matcher<Node*> |
96 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperand( | 96 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperand( |
97 int offset) { | 97 int offset) { |
98 return IsLoad( | 98 return IsLoad( |
99 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 99 MachineType::Uint8(), |
| 100 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
100 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), | 101 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), |
101 IsInt32Constant(offset))); | 102 IsInt32Constant(offset))); |
102 } | 103 } |
103 | 104 |
104 | 105 |
105 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest:: | 106 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest:: |
106 IsBytecodeOperandSignExtended(int offset) { | 107 IsBytecodeOperandSignExtended(int offset) { |
107 Matcher<Node*> load_matcher = IsLoad( | 108 Matcher<Node*> load_matcher = IsLoad( |
108 kMachInt8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 109 MachineType::Int8(), |
| 110 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
109 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), | 111 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), |
110 IsInt32Constant(offset))); | 112 IsInt32Constant(offset))); |
111 if (kPointerSize == 8) { | 113 if (kPointerSize == 8) { |
112 load_matcher = IsChangeInt32ToInt64(load_matcher); | 114 load_matcher = IsChangeInt32ToInt64(load_matcher); |
113 } | 115 } |
114 return load_matcher; | 116 return load_matcher; |
115 } | 117 } |
116 | 118 |
117 | 119 |
118 Matcher<Node*> | 120 Matcher<Node*> |
119 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperandShort( | 121 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperandShort( |
120 int offset) { | 122 int offset) { |
121 if (TargetSupportsUnalignedAccess()) { | 123 if (TargetSupportsUnalignedAccess()) { |
122 return IsLoad( | 124 return IsLoad( |
123 kMachUint16, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 125 MachineType::Uint16(), |
| 126 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
124 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), | 127 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), |
125 IsInt32Constant(offset))); | 128 IsInt32Constant(offset))); |
126 } else { | 129 } else { |
127 Matcher<Node*> first_byte = IsLoad( | 130 Matcher<Node*> first_byte = IsLoad( |
128 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 131 MachineType::Uint8(), |
| 132 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
129 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), | 133 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), |
130 IsInt32Constant(offset))); | 134 IsInt32Constant(offset))); |
131 Matcher<Node*> second_byte = IsLoad( | 135 Matcher<Node*> second_byte = IsLoad( |
132 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 136 MachineType::Uint8(), |
| 137 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
133 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), | 138 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), |
134 IsInt32Constant(offset + 1))); | 139 IsInt32Constant(offset + 1))); |
135 #if V8_TARGET_LITTLE_ENDIAN | 140 #if V8_TARGET_LITTLE_ENDIAN |
136 return IsWordOr(IsWordShl(second_byte, IsInt32Constant(kBitsPerByte)), | 141 return IsWordOr(IsWordShl(second_byte, IsInt32Constant(kBitsPerByte)), |
137 first_byte); | 142 first_byte); |
138 #elif V8_TARGET_BIG_ENDIAN | 143 #elif V8_TARGET_BIG_ENDIAN |
139 return IsWordOr(IsWordShl(first_byte, IsInt32Constant(kBitsPerByte)), | 144 return IsWordOr(IsWordShl(first_byte, IsInt32Constant(kBitsPerByte)), |
140 second_byte); | 145 second_byte); |
141 #else | 146 #else |
142 #error "Unknown Architecture" | 147 #error "Unknown Architecture" |
143 #endif | 148 #endif |
144 } | 149 } |
145 } | 150 } |
146 | 151 |
147 | 152 |
148 TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) { | 153 TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) { |
149 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 154 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
150 InterpreterAssemblerForTest m(this, bytecode); | 155 InterpreterAssemblerForTest m(this, bytecode); |
151 m.Dispatch(); | 156 m.Dispatch(); |
152 Graph* graph = m.graph(); | 157 Graph* graph = m.graph(); |
153 | 158 |
154 Node* end = graph->end(); | 159 Node* end = graph->end(); |
155 EXPECT_EQ(1, end->InputCount()); | 160 EXPECT_EQ(1, end->InputCount()); |
156 Node* tail_call_node = end->InputAt(0); | 161 Node* tail_call_node = end->InputAt(0); |
157 | 162 |
158 Matcher<Node*> next_bytecode_offset_matcher = | 163 Matcher<Node*> next_bytecode_offset_matcher = |
159 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), | 164 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), |
160 IsInt32Constant(interpreter::Bytecodes::Size(bytecode))); | 165 IsInt32Constant(interpreter::Bytecodes::Size(bytecode))); |
161 Matcher<Node*> target_bytecode_matcher = m.IsLoad( | 166 Matcher<Node*> target_bytecode_matcher = |
162 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 167 m.IsLoad(MachineType::Uint8(), |
163 next_bytecode_offset_matcher); | 168 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
164 Matcher<Node*> code_target_matcher = m.IsLoad( | 169 next_bytecode_offset_matcher); |
165 kMachPtr, IsParameter(Linkage::kInterpreterDispatchTableParameter), | 170 Matcher<Node*> code_target_matcher = |
166 IsWord32Shl(target_bytecode_matcher, | 171 m.IsLoad(MachineType::Pointer(), |
167 IsInt32Constant(kPointerSizeLog2))); | 172 IsParameter(Linkage::kInterpreterDispatchTableParameter), |
| 173 IsWord32Shl(target_bytecode_matcher, |
| 174 IsInt32Constant(kPointerSizeLog2))); |
168 | 175 |
169 EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind()); | 176 EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind()); |
170 EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots); | 177 EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots); |
171 EXPECT_THAT( | 178 EXPECT_THAT( |
172 tail_call_node, | 179 tail_call_node, |
173 IsTailCall(m.call_descriptor(), code_target_matcher, | 180 IsTailCall(m.call_descriptor(), code_target_matcher, |
174 IsParameter(Linkage::kInterpreterAccumulatorParameter), | 181 IsParameter(Linkage::kInterpreterAccumulatorParameter), |
175 IsParameter(Linkage::kInterpreterRegisterFileParameter), | 182 IsParameter(Linkage::kInterpreterRegisterFileParameter), |
176 next_bytecode_offset_matcher, | 183 next_bytecode_offset_matcher, |
177 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 184 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
(...skipping 11 matching lines...) Expand all Loading... |
189 InterpreterAssemblerForTest m(this, bytecode); | 196 InterpreterAssemblerForTest m(this, bytecode); |
190 m.Jump(m.Int32Constant(jump_offset)); | 197 m.Jump(m.Int32Constant(jump_offset)); |
191 Graph* graph = m.graph(); | 198 Graph* graph = m.graph(); |
192 Node* end = graph->end(); | 199 Node* end = graph->end(); |
193 EXPECT_EQ(1, end->InputCount()); | 200 EXPECT_EQ(1, end->InputCount()); |
194 Node* tail_call_node = end->InputAt(0); | 201 Node* tail_call_node = end->InputAt(0); |
195 | 202 |
196 Matcher<Node*> next_bytecode_offset_matcher = | 203 Matcher<Node*> next_bytecode_offset_matcher = |
197 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), | 204 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), |
198 IsInt32Constant(jump_offset)); | 205 IsInt32Constant(jump_offset)); |
199 Matcher<Node*> target_bytecode_matcher = m.IsLoad( | 206 Matcher<Node*> target_bytecode_matcher = |
200 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 207 m.IsLoad(MachineType::Uint8(), |
201 next_bytecode_offset_matcher); | 208 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
202 Matcher<Node*> code_target_matcher = m.IsLoad( | 209 next_bytecode_offset_matcher); |
203 kMachPtr, IsParameter(Linkage::kInterpreterDispatchTableParameter), | 210 Matcher<Node*> code_target_matcher = |
204 IsWord32Shl(target_bytecode_matcher, | 211 m.IsLoad(MachineType::Pointer(), |
205 IsInt32Constant(kPointerSizeLog2))); | 212 IsParameter(Linkage::kInterpreterDispatchTableParameter), |
| 213 IsWord32Shl(target_bytecode_matcher, |
| 214 IsInt32Constant(kPointerSizeLog2))); |
206 | 215 |
207 EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind()); | 216 EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind()); |
208 EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots); | 217 EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots); |
209 EXPECT_THAT( | 218 EXPECT_THAT( |
210 tail_call_node, | 219 tail_call_node, |
211 IsTailCall(m.call_descriptor(), code_target_matcher, | 220 IsTailCall(m.call_descriptor(), code_target_matcher, |
212 IsParameter(Linkage::kInterpreterAccumulatorParameter), | 221 IsParameter(Linkage::kInterpreterAccumulatorParameter), |
213 IsParameter(Linkage::kInterpreterRegisterFileParameter), | 222 IsParameter(Linkage::kInterpreterRegisterFileParameter), |
214 next_bytecode_offset_matcher, | 223 next_bytecode_offset_matcher, |
215 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 224 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
(...skipping 18 matching lines...) Expand all Loading... |
234 Graph* graph = m.graph(); | 243 Graph* graph = m.graph(); |
235 Node* end = graph->end(); | 244 Node* end = graph->end(); |
236 EXPECT_EQ(2, end->InputCount()); | 245 EXPECT_EQ(2, end->InputCount()); |
237 | 246 |
238 int jump_offsets[] = {kJumpIfTrueOffset, | 247 int jump_offsets[] = {kJumpIfTrueOffset, |
239 interpreter::Bytecodes::Size(bytecode)}; | 248 interpreter::Bytecodes::Size(bytecode)}; |
240 for (int i = 0; i < static_cast<int>(arraysize(jump_offsets)); i++) { | 249 for (int i = 0; i < static_cast<int>(arraysize(jump_offsets)); i++) { |
241 Matcher<Node*> next_bytecode_offset_matcher = | 250 Matcher<Node*> next_bytecode_offset_matcher = |
242 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), | 251 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), |
243 IsInt32Constant(jump_offsets[i])); | 252 IsInt32Constant(jump_offsets[i])); |
244 Matcher<Node*> target_bytecode_matcher = m.IsLoad( | 253 Matcher<Node*> target_bytecode_matcher = |
245 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 254 m.IsLoad(MachineType::Uint8(), |
246 next_bytecode_offset_matcher); | 255 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
247 Matcher<Node*> code_target_matcher = m.IsLoad( | 256 next_bytecode_offset_matcher); |
248 kMachPtr, IsParameter(Linkage::kInterpreterDispatchTableParameter), | 257 Matcher<Node*> code_target_matcher = |
249 IsWord32Shl(target_bytecode_matcher, | 258 m.IsLoad(MachineType::Pointer(), |
250 IsInt32Constant(kPointerSizeLog2))); | 259 IsParameter(Linkage::kInterpreterDispatchTableParameter), |
| 260 IsWord32Shl(target_bytecode_matcher, |
| 261 IsInt32Constant(kPointerSizeLog2))); |
251 EXPECT_THAT( | 262 EXPECT_THAT( |
252 end->InputAt(i), | 263 end->InputAt(i), |
253 IsTailCall(m.call_descriptor(), code_target_matcher, | 264 IsTailCall(m.call_descriptor(), code_target_matcher, |
254 IsParameter(Linkage::kInterpreterAccumulatorParameter), | 265 IsParameter(Linkage::kInterpreterAccumulatorParameter), |
255 IsParameter(Linkage::kInterpreterRegisterFileParameter), | 266 IsParameter(Linkage::kInterpreterRegisterFileParameter), |
256 next_bytecode_offset_matcher, | 267 next_bytecode_offset_matcher, |
257 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 268 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
258 IsParameter(Linkage::kInterpreterDispatchTableParameter), | 269 IsParameter(Linkage::kInterpreterDispatchTableParameter), |
259 IsParameter(Linkage::kInterpreterContextParameter), | 270 IsParameter(Linkage::kInterpreterContextParameter), |
260 graph->start(), graph->start())); | 271 graph->start(), graph->start())); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 } | 387 } |
377 | 388 |
378 | 389 |
379 TARGET_TEST_F(InterpreterAssemblerTest, LoadRegister) { | 390 TARGET_TEST_F(InterpreterAssemblerTest, LoadRegister) { |
380 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 391 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
381 InterpreterAssemblerForTest m(this, bytecode); | 392 InterpreterAssemblerForTest m(this, bytecode); |
382 Node* reg_index_node = m.Int32Constant(44); | 393 Node* reg_index_node = m.Int32Constant(44); |
383 Node* load_reg_node = m.LoadRegister(reg_index_node); | 394 Node* load_reg_node = m.LoadRegister(reg_index_node); |
384 EXPECT_THAT( | 395 EXPECT_THAT( |
385 load_reg_node, | 396 load_reg_node, |
386 m.IsLoad(kMachAnyTagged, | 397 m.IsLoad(MachineType::AnyTagged(), |
387 IsParameter(Linkage::kInterpreterRegisterFileParameter), | 398 IsParameter(Linkage::kInterpreterRegisterFileParameter), |
388 IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2)))); | 399 IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2)))); |
389 } | 400 } |
390 } | 401 } |
391 | 402 |
392 | 403 |
393 TARGET_TEST_F(InterpreterAssemblerTest, StoreRegister) { | 404 TARGET_TEST_F(InterpreterAssemblerTest, StoreRegister) { |
394 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 405 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
395 InterpreterAssemblerForTest m(this, bytecode); | 406 InterpreterAssemblerForTest m(this, bytecode); |
396 Node* store_value = m.Int32Constant(0xdeadbeef); | 407 Node* store_value = m.Int32Constant(0xdeadbeef); |
397 Node* reg_index_node = m.Int32Constant(44); | 408 Node* reg_index_node = m.Int32Constant(44); |
398 Node* store_reg_node = m.StoreRegister(store_value, reg_index_node); | 409 Node* store_reg_node = m.StoreRegister(store_value, reg_index_node); |
399 EXPECT_THAT( | 410 EXPECT_THAT( |
400 store_reg_node, | 411 store_reg_node, |
401 m.IsStore(StoreRepresentation(kMachAnyTagged, kNoWriteBarrier), | 412 m.IsStore( |
402 IsParameter(Linkage::kInterpreterRegisterFileParameter), | 413 StoreRepresentation(MachineType::AnyTagged(), kNoWriteBarrier), |
403 IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2)), | 414 IsParameter(Linkage::kInterpreterRegisterFileParameter), |
404 store_value)); | 415 IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2)), |
| 416 store_value)); |
405 } | 417 } |
406 } | 418 } |
407 | 419 |
408 | 420 |
409 TARGET_TEST_F(InterpreterAssemblerTest, SmiTag) { | 421 TARGET_TEST_F(InterpreterAssemblerTest, SmiTag) { |
410 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 422 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
411 InterpreterAssemblerForTest m(this, bytecode); | 423 InterpreterAssemblerForTest m(this, bytecode); |
412 Node* value = m.Int32Constant(44); | 424 Node* value = m.Int32Constant(44); |
413 EXPECT_THAT(m.SmiTag(value), | 425 EXPECT_THAT(m.SmiTag(value), |
414 IsWordShl(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize))); | 426 IsWordShl(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize))); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 } | 461 } |
450 } | 462 } |
451 | 463 |
452 | 464 |
453 TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { | 465 TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { |
454 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 466 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
455 InterpreterAssemblerForTest m(this, bytecode); | 467 InterpreterAssemblerForTest m(this, bytecode); |
456 Node* index = m.Int32Constant(2); | 468 Node* index = m.Int32Constant(2); |
457 Node* load_constant = m.LoadConstantPoolEntry(index); | 469 Node* load_constant = m.LoadConstantPoolEntry(index); |
458 Matcher<Node*> constant_pool_matcher = m.IsLoad( | 470 Matcher<Node*> constant_pool_matcher = m.IsLoad( |
459 kMachAnyTagged, | 471 MachineType::AnyTagged(), |
460 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 472 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
461 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - kHeapObjectTag)); | 473 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - kHeapObjectTag)); |
462 EXPECT_THAT( | 474 EXPECT_THAT( |
463 load_constant, | 475 load_constant, |
464 m.IsLoad(kMachAnyTagged, constant_pool_matcher, | 476 m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher, |
465 IsIntPtrAdd( | 477 IsIntPtrAdd( |
466 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), | 478 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), |
467 IsWordShl(index, IsInt32Constant(kPointerSizeLog2))))); | 479 IsWordShl(index, IsInt32Constant(kPointerSizeLog2))))); |
468 } | 480 } |
469 } | 481 } |
470 | 482 |
471 | 483 |
472 TARGET_TEST_F(InterpreterAssemblerTest, LoadFixedArrayElement) { | 484 TARGET_TEST_F(InterpreterAssemblerTest, LoadFixedArrayElement) { |
473 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 485 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
474 InterpreterAssemblerForTest m(this, bytecode); | 486 InterpreterAssemblerForTest m(this, bytecode); |
475 int index = 3; | 487 int index = 3; |
476 Node* fixed_array = m.IntPtrConstant(0xdeadbeef); | 488 Node* fixed_array = m.IntPtrConstant(0xdeadbeef); |
477 Node* load_element = m.LoadFixedArrayElement(fixed_array, index); | 489 Node* load_element = m.LoadFixedArrayElement(fixed_array, index); |
478 EXPECT_THAT( | 490 EXPECT_THAT( |
479 load_element, | 491 load_element, |
480 m.IsLoad(kMachAnyTagged, fixed_array, | 492 m.IsLoad(MachineType::AnyTagged(), fixed_array, |
481 IsIntPtrAdd( | 493 IsIntPtrAdd( |
482 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), | 494 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), |
483 IsWordShl(IsInt32Constant(index), | 495 IsWordShl(IsInt32Constant(index), |
484 IsInt32Constant(kPointerSizeLog2))))); | 496 IsInt32Constant(kPointerSizeLog2))))); |
485 } | 497 } |
486 } | 498 } |
487 | 499 |
488 | 500 |
489 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { | 501 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { |
490 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 502 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
491 InterpreterAssemblerForTest m(this, bytecode); | 503 InterpreterAssemblerForTest m(this, bytecode); |
492 Node* object = m.IntPtrConstant(0xdeadbeef); | 504 Node* object = m.IntPtrConstant(0xdeadbeef); |
493 int offset = 16; | 505 int offset = 16; |
494 Node* load_field = m.LoadObjectField(object, offset); | 506 Node* load_field = m.LoadObjectField(object, offset); |
495 EXPECT_THAT(load_field, | 507 EXPECT_THAT(load_field, |
496 m.IsLoad(kMachAnyTagged, object, | 508 m.IsLoad(MachineType::AnyTagged(), object, |
497 IsIntPtrConstant(offset - kHeapObjectTag))); | 509 IsIntPtrConstant(offset - kHeapObjectTag))); |
498 } | 510 } |
499 } | 511 } |
500 | 512 |
501 | 513 |
502 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { | 514 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { |
503 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 515 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
504 InterpreterAssemblerForTest m(this, bytecode); | 516 InterpreterAssemblerForTest m(this, bytecode); |
505 Node* context = m.Int32Constant(1); | 517 Node* context = m.Int32Constant(1); |
506 Node* slot_index = m.Int32Constant(22); | 518 Node* slot_index = m.Int32Constant(22); |
507 Node* load_context_slot = m.LoadContextSlot(context, slot_index); | 519 Node* load_context_slot = m.LoadContextSlot(context, slot_index); |
508 | 520 |
509 Matcher<Node*> offset = | 521 Matcher<Node*> offset = |
510 IsIntPtrAdd(IsWordShl(slot_index, IsInt32Constant(kPointerSizeLog2)), | 522 IsIntPtrAdd(IsWordShl(slot_index, IsInt32Constant(kPointerSizeLog2)), |
511 IsInt32Constant(Context::kHeaderSize - kHeapObjectTag)); | 523 IsInt32Constant(Context::kHeaderSize - kHeapObjectTag)); |
512 EXPECT_THAT(load_context_slot, m.IsLoad(kMachAnyTagged, context, offset)); | 524 EXPECT_THAT(load_context_slot, |
| 525 m.IsLoad(MachineType::AnyTagged(), context, offset)); |
513 } | 526 } |
514 } | 527 } |
515 | 528 |
516 | 529 |
517 TARGET_TEST_F(InterpreterAssemblerTest, StoreContextSlot) { | 530 TARGET_TEST_F(InterpreterAssemblerTest, StoreContextSlot) { |
518 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 531 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
519 InterpreterAssemblerForTest m(this, bytecode); | 532 InterpreterAssemblerForTest m(this, bytecode); |
520 Node* context = m.Int32Constant(1); | 533 Node* context = m.Int32Constant(1); |
521 Node* slot_index = m.Int32Constant(22); | 534 Node* slot_index = m.Int32Constant(22); |
522 Node* value = m.Int32Constant(100); | 535 Node* value = m.Int32Constant(100); |
523 Node* store_context_slot = m.StoreContextSlot(context, slot_index, value); | 536 Node* store_context_slot = m.StoreContextSlot(context, slot_index, value); |
524 | 537 |
525 Matcher<Node*> offset = | 538 Matcher<Node*> offset = |
526 IsIntPtrAdd(IsWordShl(slot_index, IsInt32Constant(kPointerSizeLog2)), | 539 IsIntPtrAdd(IsWordShl(slot_index, IsInt32Constant(kPointerSizeLog2)), |
527 IsInt32Constant(Context::kHeaderSize - kHeapObjectTag)); | 540 IsInt32Constant(Context::kHeaderSize - kHeapObjectTag)); |
528 EXPECT_THAT( | 541 EXPECT_THAT(store_context_slot, |
529 store_context_slot, | 542 m.IsStore(StoreRepresentation(MachineType::AnyTagged(), |
530 m.IsStore(StoreRepresentation(kMachAnyTagged, kFullWriteBarrier), | 543 kFullWriteBarrier), |
531 context, offset, value)); | 544 context, offset, value)); |
532 } | 545 } |
533 } | 546 } |
534 | 547 |
535 | 548 |
536 TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime2) { | 549 TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime2) { |
537 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 550 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
538 InterpreterAssemblerForTest m(this, bytecode); | 551 InterpreterAssemblerForTest m(this, bytecode); |
539 Node* arg1 = m.Int32Constant(2); | 552 Node* arg1 = m.Int32Constant(2); |
540 Node* arg2 = m.Int32Constant(3); | 553 Node* arg2 = m.Int32Constant(3); |
541 Node* call_runtime = m.CallRuntime(Runtime::kAdd, arg1, arg2); | 554 Node* call_runtime = m.CallRuntime(Runtime::kAdd, arg1, arg2); |
(...skipping 12 matching lines...) Expand all Loading... |
554 Node* function_id = m.Int32Constant(0); | 567 Node* function_id = m.Int32Constant(0); |
555 Node* first_arg = m.Int32Constant(1); | 568 Node* first_arg = m.Int32Constant(1); |
556 Node* arg_count = m.Int32Constant(2); | 569 Node* arg_count = m.Int32Constant(2); |
557 | 570 |
558 Matcher<Node*> function_table = IsExternalConstant( | 571 Matcher<Node*> function_table = IsExternalConstant( |
559 ExternalReference::runtime_function_table_address(isolate())); | 572 ExternalReference::runtime_function_table_address(isolate())); |
560 Matcher<Node*> function = IsIntPtrAdd( | 573 Matcher<Node*> function = IsIntPtrAdd( |
561 function_table, | 574 function_table, |
562 IsInt32Mul(function_id, IsInt32Constant(sizeof(Runtime::Function)))); | 575 IsInt32Mul(function_id, IsInt32Constant(sizeof(Runtime::Function)))); |
563 Matcher<Node*> function_entry = | 576 Matcher<Node*> function_entry = |
564 m.IsLoad(kMachPtr, function, | 577 m.IsLoad(MachineType::Pointer(), function, |
565 IsInt32Constant(offsetof(Runtime::Function, entry))); | 578 IsInt32Constant(offsetof(Runtime::Function, entry))); |
566 | 579 |
567 Node* call_runtime = m.CallRuntime(function_id, first_arg, arg_count); | 580 Node* call_runtime = m.CallRuntime(function_id, first_arg, arg_count); |
568 EXPECT_THAT(call_runtime, | 581 EXPECT_THAT(call_runtime, |
569 m.IsCall(_, IsHeapConstant(builtin.code()), arg_count, | 582 m.IsCall(_, IsHeapConstant(builtin.code()), arg_count, |
570 first_arg, function_entry, | 583 first_arg, function_entry, |
571 IsParameter(Linkage::kInterpreterContextParameter))); | 584 IsParameter(Linkage::kInterpreterContextParameter))); |
572 } | 585 } |
573 } | 586 } |
574 | 587 |
(...skipping 29 matching lines...) Expand all Loading... |
604 function, IsParameter(Linkage::kInterpreterContextParameter))); | 617 function, IsParameter(Linkage::kInterpreterContextParameter))); |
605 } | 618 } |
606 } | 619 } |
607 | 620 |
608 | 621 |
609 TARGET_TEST_F(InterpreterAssemblerTest, LoadTypeFeedbackVector) { | 622 TARGET_TEST_F(InterpreterAssemblerTest, LoadTypeFeedbackVector) { |
610 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 623 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
611 InterpreterAssemblerForTest m(this, bytecode); | 624 InterpreterAssemblerForTest m(this, bytecode); |
612 Node* feedback_vector = m.LoadTypeFeedbackVector(); | 625 Node* feedback_vector = m.LoadTypeFeedbackVector(); |
613 | 626 |
614 Matcher<Node*> load_function_matcher = m.IsLoad( | 627 Matcher<Node*> load_function_matcher = |
615 kMachAnyTagged, IsParameter(Linkage::kInterpreterRegisterFileParameter), | 628 m.IsLoad(MachineType::AnyTagged(), |
616 IsIntPtrConstant( | 629 IsParameter(Linkage::kInterpreterRegisterFileParameter), |
617 InterpreterFrameConstants::kFunctionFromRegisterPointer)); | 630 IsIntPtrConstant( |
| 631 InterpreterFrameConstants::kFunctionFromRegisterPointer)); |
618 Matcher<Node*> load_shared_function_info_matcher = | 632 Matcher<Node*> load_shared_function_info_matcher = |
619 m.IsLoad(kMachAnyTagged, load_function_matcher, | 633 m.IsLoad(MachineType::AnyTagged(), load_function_matcher, |
620 IsIntPtrConstant(JSFunction::kSharedFunctionInfoOffset - | 634 IsIntPtrConstant(JSFunction::kSharedFunctionInfoOffset - |
621 kHeapObjectTag)); | 635 kHeapObjectTag)); |
622 | 636 |
623 EXPECT_THAT( | 637 EXPECT_THAT( |
624 feedback_vector, | 638 feedback_vector, |
625 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, | 639 m.IsLoad(MachineType::AnyTagged(), load_shared_function_info_matcher, |
626 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - | 640 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - |
627 kHeapObjectTag))); | 641 kHeapObjectTag))); |
628 } | 642 } |
629 } | 643 } |
630 | 644 |
631 } // namespace compiler | 645 } // namespace compiler |
632 } // namespace internal | 646 } // namespace internal |
633 } // namespace v8 | 647 } // namespace v8 |
OLD | NEW |