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/compiler/graph.h" | 7 #include "src/compiler/graph.h" |
8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
9 #include "src/unique.h" | 9 #include "src/unique.h" |
10 #include "test/unittests/compiler/compiler-test-utils.h" | 10 #include "test/unittests/compiler/compiler-test-utils.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), | 81 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), |
82 IsInt32Constant(interpreter::Bytecodes::Size(bytecode))); | 82 IsInt32Constant(interpreter::Bytecodes::Size(bytecode))); |
83 Matcher<Node*> target_bytecode_matcher = m.IsLoad( | 83 Matcher<Node*> target_bytecode_matcher = m.IsLoad( |
84 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 84 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
85 next_bytecode_offset_matcher); | 85 next_bytecode_offset_matcher); |
86 Matcher<Node*> code_target_matcher = m.IsLoad( | 86 Matcher<Node*> code_target_matcher = m.IsLoad( |
87 kMachPtr, IsParameter(Linkage::kInterpreterDispatchTableParameter), | 87 kMachPtr, IsParameter(Linkage::kInterpreterDispatchTableParameter), |
88 IsWord32Shl(target_bytecode_matcher, | 88 IsWord32Shl(target_bytecode_matcher, |
89 IsInt32Constant(kPointerSizeLog2))); | 89 IsInt32Constant(kPointerSizeLog2))); |
90 | 90 |
91 EXPECT_EQ(CallDescriptor::kInterpreterDispatch, | 91 EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind()); |
92 m.call_descriptor()->kind()); | 92 EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots); |
93 EXPECT_THAT( | 93 EXPECT_THAT( |
94 tail_call_node, | 94 tail_call_node, |
95 IsTailCall(m.call_descriptor(), code_target_matcher, | 95 IsTailCall(m.call_descriptor(), code_target_matcher, |
96 next_bytecode_offset_matcher, | 96 next_bytecode_offset_matcher, |
97 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 97 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
98 IsParameter(Linkage::kInterpreterDispatchTableParameter), | 98 IsParameter(Linkage::kInterpreterDispatchTableParameter), |
99 graph->start(), graph->start())); | 99 graph->start(), graph->start())); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 | 103 |
104 TARGET_TEST_F(InterpreterAssemblerTest, Return) { | 104 TARGET_TEST_F(InterpreterAssemblerTest, Return) { |
105 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 105 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
106 InterpreterAssemblerForTest m(this, bytecode); | 106 InterpreterAssemblerForTest m(this, bytecode); |
107 m.Return(); | 107 m.Return(); |
108 Graph* graph = m.GetCompletedGraph(); | 108 Graph* graph = m.GetCompletedGraph(); |
109 | 109 |
110 Node* end = graph->end(); | 110 Node* end = graph->end(); |
111 EXPECT_EQ(1, end->InputCount()); | 111 EXPECT_EQ(1, end->InputCount()); |
112 Node* tail_call_node = end->InputAt(0); | 112 Node* tail_call_node = end->InputAt(0); |
113 | 113 |
114 EXPECT_EQ(CallDescriptor::kInterpreterDispatch, | 114 EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind()); |
115 m.call_descriptor()->kind()); | 115 EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots); |
116 Matcher<Unique<HeapObject>> exit_trampoline( | 116 Matcher<Unique<HeapObject>> exit_trampoline( |
117 Unique<HeapObject>::CreateImmovable( | 117 Unique<HeapObject>::CreateImmovable( |
118 isolate()->builtins()->InterpreterExitTrampoline())); | 118 isolate()->builtins()->InterpreterExitTrampoline())); |
119 EXPECT_THAT( | 119 EXPECT_THAT( |
120 tail_call_node, | 120 tail_call_node, |
121 IsTailCall(m.call_descriptor(), IsHeapConstant(exit_trampoline), | 121 IsTailCall(m.call_descriptor(), IsHeapConstant(exit_trampoline), |
122 IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), | 122 IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), |
123 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), | 123 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
124 IsParameter(Linkage::kInterpreterDispatchTableParameter), | 124 IsParameter(Linkage::kInterpreterDispatchTableParameter), |
125 graph->start(), graph->start())); | 125 graph->start(), graph->start())); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 IsIntPtrSub(IsInt32Constant(m.kFirstRegisterOffsetFromFp), | 205 IsIntPtrSub(IsInt32Constant(m.kFirstRegisterOffsetFromFp), |
206 IsWordShl(reg_index_node, | 206 IsWordShl(reg_index_node, |
207 IsInt32Constant(kPointerSizeLog2))), | 207 IsInt32Constant(kPointerSizeLog2))), |
208 store_value)); | 208 store_value)); |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 } // namespace compiler | 212 } // namespace compiler |
213 } // namespace internal | 213 } // namespace internal |
214 } // namespace v8 | 214 } // namespace v8 |
OLD | NEW |