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/compiler/graph.h" | 7 #include "src/compiler/graph.h" |
8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
| 9 #include "src/interface-descriptors.h" |
9 #include "src/isolate.h" | 10 #include "src/isolate.h" |
10 #include "test/unittests/compiler/compiler-test-utils.h" | 11 #include "test/unittests/compiler/compiler-test-utils.h" |
11 #include "test/unittests/compiler/node-test-utils.h" | 12 #include "test/unittests/compiler/node-test-utils.h" |
12 | 13 |
13 using ::testing::_; | 14 using ::testing::_; |
14 | 15 |
15 namespace v8 { | 16 namespace v8 { |
16 namespace internal { | 17 namespace internal { |
17 namespace compiler { | 18 namespace compiler { |
18 | 19 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsStore( | 69 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsStore( |
69 const Matcher<StoreRepresentation>& rep_matcher, | 70 const Matcher<StoreRepresentation>& rep_matcher, |
70 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, | 71 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, |
71 const Matcher<Node*>& value_matcher) { | 72 const Matcher<Node*>& value_matcher) { |
72 return ::i::compiler::IsStore(rep_matcher, base_matcher, index_matcher, | 73 return ::i::compiler::IsStore(rep_matcher, base_matcher, index_matcher, |
73 value_matcher, graph()->start(), | 74 value_matcher, graph()->start(), |
74 graph()->start()); | 75 graph()->start()); |
75 } | 76 } |
76 | 77 |
77 | 78 |
| 79 template <class... A> |
| 80 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsCall( |
| 81 const Matcher<CallDescriptor*>& descriptor_matcher, A... args) { |
| 82 return ::i::compiler::IsCall(descriptor_matcher, args..., graph()->start(), |
| 83 graph()->start()); |
| 84 } |
| 85 |
| 86 |
78 Matcher<Node*> | 87 Matcher<Node*> |
79 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperand( | 88 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsBytecodeOperand( |
80 int operand) { | 89 int operand) { |
81 return IsLoad( | 90 return IsLoad( |
82 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 91 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
83 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), | 92 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), |
84 IsInt32Constant(1 + operand))); | 93 IsInt32Constant(1 + operand))); |
85 } | 94 } |
86 | 95 |
87 | 96 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 Matcher<Node*> load_native_context_matcher = m.IsLoad( | 341 Matcher<Node*> load_native_context_matcher = m.IsLoad( |
333 kMachAnyTagged, load_globals_matcher, | 342 kMachAnyTagged, load_globals_matcher, |
334 IsIntPtrConstant(GlobalObject::kNativeContextOffset - kHeapObjectTag)); | 343 IsIntPtrConstant(GlobalObject::kNativeContextOffset - kHeapObjectTag)); |
335 Matcher<Node*> function_matcher = m.IsLoad( | 344 Matcher<Node*> function_matcher = m.IsLoad( |
336 kMachAnyTagged, load_native_context_matcher, | 345 kMachAnyTagged, load_native_context_matcher, |
337 IsIntPtrConstant(Context::SlotOffset(Context::SUB_BUILTIN_INDEX))); | 346 IsIntPtrConstant(Context::SlotOffset(Context::SUB_BUILTIN_INDEX))); |
338 Matcher<Node*> context_matcher = | 347 Matcher<Node*> context_matcher = |
339 m.IsLoad(kMachAnyTagged, function_matcher, | 348 m.IsLoad(kMachAnyTagged, function_matcher, |
340 IsIntPtrConstant(JSFunction::kContextOffset - kHeapObjectTag)); | 349 IsIntPtrConstant(JSFunction::kContextOffset - kHeapObjectTag)); |
341 EXPECT_THAT(call_js_builtin_0, | 350 EXPECT_THAT(call_js_builtin_0, |
342 IsCall(_, function_matcher, receiver, context_matcher, | 351 m.IsCall(_, function_matcher, receiver, context_matcher)); |
343 m.graph()->start(), m.graph()->start())); | |
344 | 352 |
345 Node* arg1 = m.Int32Constant(0xabcd); | 353 Node* arg1 = m.Int32Constant(0xabcd); |
346 Node* call_js_builtin_1 = | 354 Node* call_js_builtin_1 = |
347 m.CallJSBuiltin(Context::SUB_BUILTIN_INDEX, receiver, arg1); | 355 m.CallJSBuiltin(Context::SUB_BUILTIN_INDEX, receiver, arg1); |
348 EXPECT_THAT(call_js_builtin_1, | 356 EXPECT_THAT(call_js_builtin_1, |
349 IsCall(_, function_matcher, receiver, arg1, context_matcher, | 357 m.IsCall(_, function_matcher, receiver, arg1, context_matcher)); |
350 m.graph()->start(), m.graph()->start())); | |
351 } | 358 } |
352 } | 359 } |
353 | 360 |
| 361 |
| 362 TARGET_TEST_F(InterpreterAssemblerTest, CallIC) { |
| 363 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 364 InterpreterAssemblerForTest m(this, bytecode); |
| 365 LoadWithVectorDescriptor descriptor(isolate()); |
| 366 Node* target = m.Int32Constant(1); |
| 367 Node* arg1 = m.Int32Constant(2); |
| 368 Node* arg2 = m.Int32Constant(3); |
| 369 Node* arg3 = m.Int32Constant(4); |
| 370 Node* arg4 = m.Int32Constant(5); |
| 371 Node* call_ic = m.CallIC(descriptor, target, arg1, arg2, arg3, arg4); |
| 372 EXPECT_THAT(call_ic, |
| 373 m.IsCall(_, target, arg1, arg2, arg3, arg4, |
| 374 IsParameter(Linkage::kInterpreterContextParameter))); |
| 375 } |
| 376 } |
| 377 |
| 378 |
| 379 TARGET_TEST_F(InterpreterAssemblerTest, LoadTypeFeedbackVector) { |
| 380 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 381 InterpreterAssemblerForTest m(this, bytecode); |
| 382 Node* feedback_vector = m.LoadTypeFeedbackVector(); |
| 383 |
| 384 Matcher<Node*> load_function_matcher = m.IsLoad( |
| 385 kMachAnyTagged, IsParameter(Linkage::kInterpreterRegisterFileParameter), |
| 386 IsIntPtrConstant( |
| 387 InterpreterFrameConstants::kFunctionFromRegisterPointer)); |
| 388 Matcher<Node*> load_shared_function_info_matcher = |
| 389 m.IsLoad(kMachAnyTagged, load_function_matcher, |
| 390 IsIntPtrConstant(JSFunction::kSharedFunctionInfoOffset - |
| 391 kHeapObjectTag)); |
| 392 |
| 393 EXPECT_THAT( |
| 394 feedback_vector, |
| 395 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, |
| 396 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - |
| 397 kHeapObjectTag))); |
| 398 } |
| 399 } |
| 400 |
354 } // namespace compiler | 401 } // namespace compiler |
355 } // namespace internal | 402 } // namespace internal |
356 } // namespace v8 | 403 } // namespace v8 |
OLD | NEW |