| 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 IsIntPtrAdd( | 440 IsIntPtrAdd( |
| 441 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), | 441 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), |
| 442 IsWordShl(index, IsInt32Constant(kPointerSizeLog2))))); | 442 IsWordShl(index, IsInt32Constant(kPointerSizeLog2))))); |
| 443 } | 443 } |
| 444 } | 444 } |
| 445 | 445 |
| 446 | 446 |
| 447 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { | 447 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { |
| 448 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 448 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 449 InterpreterAssemblerForTest m(this, bytecode); | 449 InterpreterAssemblerForTest m(this, bytecode); |
| 450 Node* load_from_current_context = m.LoadContextSlot(22); | 450 Node* context = m.Int32Constant(1); |
| 451 Matcher<Node*> load_from_current_context_matcher = m.IsLoad( | 451 Node* slot_index = m.Int32Constant(22); |
| 452 kMachAnyTagged, IsParameter(Linkage::kInterpreterContextParameter), | 452 Node* load_context_slot = m.LoadContextSlot(context, slot_index); |
| 453 IsIntPtrConstant(Context::SlotOffset(22))); | |
| 454 EXPECT_THAT(load_from_current_context, load_from_current_context_matcher); | |
| 455 | 453 |
| 456 // Let's imagine that the loaded context slot is another context. | 454 Matcher<Node*> offset = IsIntPtrAdd( |
| 457 Node* load_from_any_context = | 455 IsWordShl(slot_index, IsInt32Constant(kPointerSizeLog2)), |
| 458 m.LoadContextSlot(load_from_current_context, 23); | 456 IsInt32Constant(Context::kHeaderSize - kHeapObjectTag)); |
| 459 EXPECT_THAT(load_from_any_context, | 457 EXPECT_THAT(load_context_slot, |
| 460 m.IsLoad(kMachAnyTagged, load_from_current_context_matcher, | 458 m.IsLoad(kMachAnyTagged, context, offset)); |
| 461 IsIntPtrConstant(Context::SlotOffset(23)))); | |
| 462 } | 459 } |
| 463 } | 460 } |
| 464 | 461 |
| 465 | 462 |
| 466 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { | 463 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { |
| 467 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 464 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 468 InterpreterAssemblerForTest m(this, bytecode); | 465 InterpreterAssemblerForTest m(this, bytecode); |
| 469 Node* object = m.IntPtrConstant(0xdeadbeef); | 466 Node* object = m.IntPtrConstant(0xdeadbeef); |
| 470 int offset = 16; | 467 int offset = 16; |
| 471 Node* load_field = m.LoadObjectField(object, offset); | 468 Node* load_field = m.LoadObjectField(object, offset); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 feedback_vector, | 564 feedback_vector, |
| 568 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, | 565 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, |
| 569 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - | 566 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - |
| 570 kHeapObjectTag))); | 567 kHeapObjectTag))); |
| 571 } | 568 } |
| 572 } | 569 } |
| 573 | 570 |
| 574 } // namespace compiler | 571 } // namespace compiler |
| 575 } // namespace internal | 572 } // namespace internal |
| 576 } // namespace v8 | 573 } // namespace v8 |
| OLD | NEW |