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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 return kPointerSize == 8 ? IsWord64Sar(lhs_matcher, rhs_matcher) | 55 return kPointerSize == 8 ? IsWord64Sar(lhs_matcher, rhs_matcher) |
56 : IsWord32Sar(lhs_matcher, rhs_matcher); | 56 : IsWord32Sar(lhs_matcher, rhs_matcher); |
57 } | 57 } |
58 | 58 |
59 Matcher<Node*> IsWordOr(const Matcher<Node*>& lhs_matcher, | 59 Matcher<Node*> IsWordOr(const Matcher<Node*>& lhs_matcher, |
60 const Matcher<Node*>& rhs_matcher) { | 60 const Matcher<Node*>& rhs_matcher) { |
61 return kPointerSize == 8 ? IsWord64Or(lhs_matcher, rhs_matcher) | 61 return kPointerSize == 8 ? IsWord64Or(lhs_matcher, rhs_matcher) |
62 : IsWord32Or(lhs_matcher, rhs_matcher); | 62 : IsWord32Or(lhs_matcher, rhs_matcher); |
63 } | 63 } |
64 | 64 |
| 65 InterpreterAssemblerTest::InterpreterAssemblerForTest:: |
| 66 ~InterpreterAssemblerForTest() { |
| 67 // Tests don't necessarily read and write accumulator but |
| 68 // InterpreterAssembler checks accumulator uses. |
| 69 if (Bytecodes::ReadsAccumulator(bytecode())) { |
| 70 GetAccumulator(); |
| 71 } |
| 72 if (Bytecodes::WritesAccumulator(bytecode())) { |
| 73 SetAccumulator(nullptr); |
| 74 } |
| 75 } |
| 76 |
65 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsLoad( | 77 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsLoad( |
66 const Matcher<LoadRepresentation>& rep_matcher, | 78 const Matcher<LoadRepresentation>& rep_matcher, |
67 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher) { | 79 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher) { |
68 return ::i::compiler::IsLoad(rep_matcher, base_matcher, index_matcher, _, _); | 80 return ::i::compiler::IsLoad(rep_matcher, base_matcher, index_matcher, _, _); |
69 } | 81 } |
70 | 82 |
71 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsStore( | 83 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsStore( |
72 const Matcher<StoreRepresentation>& rep_matcher, | 84 const Matcher<StoreRepresentation>& rep_matcher, |
73 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, | 85 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, |
74 const Matcher<Node*>& value_matcher) { | 86 const Matcher<Node*>& value_matcher) { |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 UNREACHABLE(); | 529 UNREACHABLE(); |
518 break; | 530 break; |
519 } | 531 } |
520 } | 532 } |
521 } | 533 } |
522 } | 534 } |
523 } | 535 } |
524 | 536 |
525 TARGET_TEST_F(InterpreterAssemblerTest, GetSetAccumulator) { | 537 TARGET_TEST_F(InterpreterAssemblerTest, GetSetAccumulator) { |
526 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 538 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 539 if (!interpreter::Bytecodes::ReadsAccumulator(bytecode) || |
| 540 !interpreter::Bytecodes::WritesAccumulator(bytecode)) { |
| 541 continue; |
| 542 } |
| 543 |
527 InterpreterAssemblerForTest m(this, bytecode); | 544 InterpreterAssemblerForTest m(this, bytecode); |
528 // Should be incoming accumulator if not set. | 545 // Should be incoming accumulator if not set. |
529 EXPECT_THAT( | 546 EXPECT_THAT( |
530 m.GetAccumulator(), | 547 m.GetAccumulator(), |
531 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter)); | 548 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter)); |
532 | |
533 // Should be set by SetAccumulator. | 549 // Should be set by SetAccumulator. |
534 Node* accumulator_value_1 = m.Int32Constant(0xdeadbeef); | 550 Node* accumulator_value_1 = m.Int32Constant(0xdeadbeef); |
535 m.SetAccumulator(accumulator_value_1); | 551 m.SetAccumulator(accumulator_value_1); |
536 EXPECT_THAT(m.GetAccumulator(), accumulator_value_1); | 552 EXPECT_THAT(m.GetAccumulator(), accumulator_value_1); |
537 Node* accumulator_value_2 = m.Int32Constant(42); | 553 Node* accumulator_value_2 = m.Int32Constant(42); |
538 m.SetAccumulator(accumulator_value_2); | 554 m.SetAccumulator(accumulator_value_2); |
539 EXPECT_THAT(m.GetAccumulator(), accumulator_value_2); | 555 EXPECT_THAT(m.GetAccumulator(), accumulator_value_2); |
540 | 556 |
541 // Should be passed to next bytecode handler on dispatch. | 557 // Should be passed to next bytecode handler on dispatch. |
542 m.Dispatch(); | 558 m.Dispatch(); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 feedback_vector, | 819 feedback_vector, |
804 m.IsLoad(MachineType::AnyTagged(), load_shared_function_info_matcher, | 820 m.IsLoad(MachineType::AnyTagged(), load_shared_function_info_matcher, |
805 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - | 821 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - |
806 kHeapObjectTag))); | 822 kHeapObjectTag))); |
807 } | 823 } |
808 } | 824 } |
809 | 825 |
810 } // namespace interpreter | 826 } // namespace interpreter |
811 } // namespace internal | 827 } // namespace internal |
812 } // namespace v8 | 828 } // namespace v8 |
OLD | NEW |