| 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 EXPECT_THAT( | 464 EXPECT_THAT( |
| 465 load_constant, | 465 load_constant, |
| 466 m.IsLoad(kMachAnyTagged, constant_pool_matcher, | 466 m.IsLoad(kMachAnyTagged, constant_pool_matcher, |
| 467 IsIntPtrAdd( | 467 IsIntPtrAdd( |
| 468 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), | 468 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), |
| 469 IsWordShl(index, IsInt32Constant(kPointerSizeLog2))))); | 469 IsWordShl(index, IsInt32Constant(kPointerSizeLog2))))); |
| 470 } | 470 } |
| 471 } | 471 } |
| 472 | 472 |
| 473 | 473 |
| 474 TARGET_TEST_F(InterpreterAssemblerTest, LoadFixedArrayElement) { |
| 475 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 476 InterpreterAssemblerForTest m(this, bytecode); |
| 477 int index = 3; |
| 478 Node* fixed_array = m.IntPtrConstant(0xdeadbeef); |
| 479 Node* load_element = m.LoadFixedArrayElement(fixed_array, index); |
| 480 EXPECT_THAT( |
| 481 load_element, |
| 482 m.IsLoad(kMachAnyTagged, fixed_array, |
| 483 IsIntPtrAdd( |
| 484 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), |
| 485 IsWordShl(IsInt32Constant(index), |
| 486 IsInt32Constant(kPointerSizeLog2))))); |
| 487 } |
| 488 } |
| 489 |
| 490 |
| 491 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { |
| 492 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 493 InterpreterAssemblerForTest m(this, bytecode); |
| 494 Node* object = m.IntPtrConstant(0xdeadbeef); |
| 495 int offset = 16; |
| 496 Node* load_field = m.LoadObjectField(object, offset); |
| 497 EXPECT_THAT(load_field, |
| 498 m.IsLoad(kMachAnyTagged, object, |
| 499 IsIntPtrConstant(offset - kHeapObjectTag))); |
| 500 } |
| 501 } |
| 502 |
| 503 |
| 474 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { | 504 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { |
| 475 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 505 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 476 InterpreterAssemblerForTest m(this, bytecode); | 506 InterpreterAssemblerForTest m(this, bytecode); |
| 477 Node* context = m.Int32Constant(1); | 507 Node* context = m.Int32Constant(1); |
| 478 Node* slot_index = m.Int32Constant(22); | 508 Node* slot_index = m.Int32Constant(22); |
| 479 Node* load_context_slot = m.LoadContextSlot(context, slot_index); | 509 Node* load_context_slot = m.LoadContextSlot(context, slot_index); |
| 480 | 510 |
| 481 Matcher<Node*> offset = | 511 Matcher<Node*> offset = |
| 482 IsIntPtrAdd(IsWordShl(slot_index, IsInt32Constant(kPointerSizeLog2)), | 512 IsIntPtrAdd(IsWordShl(slot_index, IsInt32Constant(kPointerSizeLog2)), |
| 483 IsInt32Constant(Context::kHeaderSize - kHeapObjectTag)); | 513 IsInt32Constant(Context::kHeaderSize - kHeapObjectTag)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 498 IsIntPtrAdd(IsWordShl(slot_index, IsInt32Constant(kPointerSizeLog2)), | 528 IsIntPtrAdd(IsWordShl(slot_index, IsInt32Constant(kPointerSizeLog2)), |
| 499 IsInt32Constant(Context::kHeaderSize - kHeapObjectTag)); | 529 IsInt32Constant(Context::kHeaderSize - kHeapObjectTag)); |
| 500 EXPECT_THAT( | 530 EXPECT_THAT( |
| 501 store_context_slot, | 531 store_context_slot, |
| 502 m.IsStore(StoreRepresentation(kMachAnyTagged, kFullWriteBarrier), | 532 m.IsStore(StoreRepresentation(kMachAnyTagged, kFullWriteBarrier), |
| 503 context, offset, value)); | 533 context, offset, value)); |
| 504 } | 534 } |
| 505 } | 535 } |
| 506 | 536 |
| 507 | 537 |
| 508 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { | |
| 509 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | |
| 510 InterpreterAssemblerForTest m(this, bytecode); | |
| 511 Node* object = m.IntPtrConstant(0xdeadbeef); | |
| 512 int offset = 16; | |
| 513 Node* load_field = m.LoadObjectField(object, offset); | |
| 514 EXPECT_THAT(load_field, | |
| 515 m.IsLoad(kMachAnyTagged, object, | |
| 516 IsIntPtrConstant(offset - kHeapObjectTag))); | |
| 517 } | |
| 518 } | |
| 519 | |
| 520 | |
| 521 TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime2) { | 538 TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime2) { |
| 522 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 539 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 523 InterpreterAssemblerForTest m(this, bytecode); | 540 InterpreterAssemblerForTest m(this, bytecode); |
| 524 Node* arg1 = m.Int32Constant(2); | 541 Node* arg1 = m.Int32Constant(2); |
| 525 Node* arg2 = m.Int32Constant(3); | 542 Node* arg2 = m.Int32Constant(3); |
| 526 Node* call_runtime = m.CallRuntime(Runtime::kAdd, arg1, arg2); | 543 Node* call_runtime = m.CallRuntime(Runtime::kAdd, arg1, arg2); |
| 527 EXPECT_THAT(call_runtime, | 544 EXPECT_THAT(call_runtime, |
| 528 m.IsCall(_, _, arg1, arg2, _, IsInt32Constant(2), | 545 m.IsCall(_, _, arg1, arg2, _, IsInt32Constant(2), |
| 529 IsParameter(Linkage::kInterpreterContextParameter))); | 546 IsParameter(Linkage::kInterpreterContextParameter))); |
| 530 } | 547 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 feedback_vector, | 626 feedback_vector, |
| 610 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, | 627 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, |
| 611 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - | 628 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - |
| 612 kHeapObjectTag))); | 629 kHeapObjectTag))); |
| 613 } | 630 } |
| 614 } | 631 } |
| 615 | 632 |
| 616 } // namespace compiler | 633 } // namespace compiler |
| 617 } // namespace internal | 634 } // namespace internal |
| 618 } // namespace v8 | 635 } // namespace v8 |
| OLD | NEW |