| 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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, LoadContextSlot) { | 474 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { |
| 475 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 475 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 476 InterpreterAssemblerForTest m(this, bytecode); | 476 InterpreterAssemblerForTest m(this, bytecode); |
| 477 Node* load_from_current_context = m.LoadContextSlot(22); | 477 Node* context = m.Int32Constant(1); |
| 478 Matcher<Node*> load_from_current_context_matcher = m.IsLoad( | 478 Node* slot_index = m.Int32Constant(22); |
| 479 kMachAnyTagged, IsParameter(Linkage::kInterpreterContextParameter), | 479 Node* load_context_slot = m.LoadContextSlot(context, slot_index); |
| 480 IsIntPtrConstant(Context::SlotOffset(22))); | |
| 481 EXPECT_THAT(load_from_current_context, load_from_current_context_matcher); | |
| 482 | 480 |
| 483 // Let's imagine that the loaded context slot is another context. | 481 Matcher<Node*> offset = |
| 484 Node* load_from_any_context = | 482 IsIntPtrAdd(IsWordShl(slot_index, IsInt32Constant(kPointerSizeLog2)), |
| 485 m.LoadContextSlot(load_from_current_context, 23); | 483 IsInt32Constant(Context::kHeaderSize - kHeapObjectTag)); |
| 486 EXPECT_THAT(load_from_any_context, | 484 EXPECT_THAT(load_context_slot, m.IsLoad(kMachAnyTagged, context, offset)); |
| 487 m.IsLoad(kMachAnyTagged, load_from_current_context_matcher, | |
| 488 IsIntPtrConstant(Context::SlotOffset(23)))); | |
| 489 } | 485 } |
| 490 } | 486 } |
| 491 | 487 |
| 492 | 488 |
| 493 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { | 489 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { |
| 494 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 490 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 495 InterpreterAssemblerForTest m(this, bytecode); | 491 InterpreterAssemblerForTest m(this, bytecode); |
| 496 Node* object = m.IntPtrConstant(0xdeadbeef); | 492 Node* object = m.IntPtrConstant(0xdeadbeef); |
| 497 int offset = 16; | 493 int offset = 16; |
| 498 Node* load_field = m.LoadObjectField(object, offset); | 494 Node* load_field = m.LoadObjectField(object, offset); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 feedback_vector, | 590 feedback_vector, |
| 595 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, | 591 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, |
| 596 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - | 592 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - |
| 597 kHeapObjectTag))); | 593 kHeapObjectTag))); |
| 598 } | 594 } |
| 599 } | 595 } |
| 600 | 596 |
| 601 } // namespace compiler | 597 } // namespace compiler |
| 602 } // namespace internal | 598 } // namespace internal |
| 603 } // namespace v8 | 599 } // namespace v8 |
| OLD | NEW |