| 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 InterpreterAssemblerForTest m(this, bytecode); | 599 InterpreterAssemblerForTest m(this, bytecode); |
| 600 Node* object = m.IntPtrConstant(0xdeadbeef); | 600 Node* object = m.IntPtrConstant(0xdeadbeef); |
| 601 int offset = 16; | 601 int offset = 16; |
| 602 Node* load_field = m.LoadObjectField(object, offset); | 602 Node* load_field = m.LoadObjectField(object, offset); |
| 603 EXPECT_THAT(load_field, | 603 EXPECT_THAT(load_field, |
| 604 m.IsLoad(MachineType::AnyTagged(), object, | 604 m.IsLoad(MachineType::AnyTagged(), object, |
| 605 IsIntPtrConstant(offset - kHeapObjectTag))); | 605 IsIntPtrConstant(offset - kHeapObjectTag))); |
| 606 } | 606 } |
| 607 } | 607 } |
| 608 | 608 |
| 609 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { | |
| 610 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | |
| 611 InterpreterAssemblerForTest m(this, bytecode); | |
| 612 Node* context = m.IntPtrConstant(1); | |
| 613 Node* slot_index = m.IntPtrConstant(22); | |
| 614 Node* load_context_slot = m.LoadContextSlot(context, slot_index); | |
| 615 | |
| 616 Matcher<Node*> offset = | |
| 617 IsIntPtrAdd(IsWordShl(slot_index, IsIntPtrConstant(kPointerSizeLog2)), | |
| 618 IsIntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); | |
| 619 EXPECT_THAT(load_context_slot, | |
| 620 m.IsLoad(MachineType::AnyTagged(), context, offset)); | |
| 621 } | |
| 622 } | |
| 623 | |
| 624 TARGET_TEST_F(InterpreterAssemblerTest, StoreContextSlot) { | |
| 625 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | |
| 626 InterpreterAssemblerForTest m(this, bytecode); | |
| 627 Node* context = m.IntPtrConstant(1); | |
| 628 Node* slot_index = m.IntPtrConstant(22); | |
| 629 Node* value = m.SmiConstant(Smi::FromInt(100)); | |
| 630 Node* store_context_slot = m.StoreContextSlot(context, slot_index, value); | |
| 631 | |
| 632 Matcher<Node*> offset = | |
| 633 IsIntPtrAdd(IsWordShl(slot_index, IsIntPtrConstant(kPointerSizeLog2)), | |
| 634 IsIntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); | |
| 635 EXPECT_THAT(store_context_slot, | |
| 636 m.IsStore(StoreRepresentation(MachineRepresentation::kTagged, | |
| 637 kFullWriteBarrier), | |
| 638 context, offset, value)); | |
| 639 } | |
| 640 } | |
| 641 | |
| 642 TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime2) { | 609 TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime2) { |
| 643 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 610 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 644 InterpreterAssemblerForTest m(this, bytecode); | 611 InterpreterAssemblerForTest m(this, bytecode); |
| 645 Node* arg1 = m.Int32Constant(2); | 612 Node* arg1 = m.Int32Constant(2); |
| 646 Node* arg2 = m.Int32Constant(3); | 613 Node* arg2 = m.Int32Constant(3); |
| 647 Node* context = m.Int32Constant(4); | 614 Node* context = m.Int32Constant(4); |
| 648 Node* call_runtime = m.CallRuntime(Runtime::kAdd, context, arg1, arg2); | 615 Node* call_runtime = m.CallRuntime(Runtime::kAdd, context, arg1, arg2); |
| 649 EXPECT_THAT(call_runtime, | 616 EXPECT_THAT(call_runtime, |
| 650 IsCall(_, _, arg1, arg2, _, IsInt32Constant(2), context, _, _)); | 617 IsCall(_, _, arg1, arg2, _, IsInt32Constant(2), context, _, _)); |
| 651 } | 618 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 EXPECT_THAT(feedback_vector, | 684 EXPECT_THAT(feedback_vector, |
| 718 m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, | 685 m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, |
| 719 IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | 686 IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - |
| 720 kHeapObjectTag))); | 687 kHeapObjectTag))); |
| 721 } | 688 } |
| 722 } | 689 } |
| 723 | 690 |
| 724 } // namespace interpreter | 691 } // namespace interpreter |
| 725 } // namespace internal | 692 } // namespace internal |
| 726 } // namespace v8 | 693 } // namespace v8 |
| OLD | NEW |