Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: test/unittests/compiler/interpreter-assembler-unittest.cc

Issue 1493963003: [turbofan] Make RawMachineAssembler handle the end node. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comment. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/unittests/compiler/interpreter-assembler-unittest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 #elif V8_TARGET_BIG_ENDIAN 138 #elif V8_TARGET_BIG_ENDIAN
139 return IsWordOr(IsWordShl(first_byte, IsInt32Constant(kBitsPerByte)), 139 return IsWordOr(IsWordShl(first_byte, IsInt32Constant(kBitsPerByte)),
140 second_byte); 140 second_byte);
141 #else 141 #else
142 #error "Unknown Architecture" 142 #error "Unknown Architecture"
143 #endif 143 #endif
144 } 144 }
145 } 145 }
146 146
147 147
148 Graph*
149 InterpreterAssemblerTest::InterpreterAssemblerForTest::GetCompletedGraph() {
150 End();
151 return graph();
152 }
153
154
155 TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) { 148 TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) {
156 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 149 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
157 InterpreterAssemblerForTest m(this, bytecode); 150 InterpreterAssemblerForTest m(this, bytecode);
158 m.Dispatch(); 151 m.Dispatch();
159 Graph* graph = m.GetCompletedGraph(); 152 Graph* graph = m.graph();
160 153
161 Node* end = graph->end(); 154 Node* end = graph->end();
162 EXPECT_EQ(1, end->InputCount()); 155 EXPECT_EQ(1, end->InputCount());
163 Node* tail_call_node = end->InputAt(0); 156 Node* tail_call_node = end->InputAt(0);
164 157
165 Matcher<Node*> next_bytecode_offset_matcher = 158 Matcher<Node*> next_bytecode_offset_matcher =
166 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), 159 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter),
167 IsInt32Constant(interpreter::Bytecodes::Size(bytecode))); 160 IsInt32Constant(interpreter::Bytecodes::Size(bytecode)));
168 Matcher<Node*> target_bytecode_matcher = m.IsLoad( 161 Matcher<Node*> target_bytecode_matcher = m.IsLoad(
169 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), 162 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
(...skipping 18 matching lines...) Expand all
188 } 181 }
189 } 182 }
190 183
191 184
192 TARGET_TEST_F(InterpreterAssemblerTest, Jump) { 185 TARGET_TEST_F(InterpreterAssemblerTest, Jump) {
193 int jump_offsets[] = {-9710, -77, 0, +3, +97109}; 186 int jump_offsets[] = {-9710, -77, 0, +3, +97109};
194 TRACED_FOREACH(int, jump_offset, jump_offsets) { 187 TRACED_FOREACH(int, jump_offset, jump_offsets) {
195 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 188 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
196 InterpreterAssemblerForTest m(this, bytecode); 189 InterpreterAssemblerForTest m(this, bytecode);
197 m.Jump(m.Int32Constant(jump_offset)); 190 m.Jump(m.Int32Constant(jump_offset));
198 Graph* graph = m.GetCompletedGraph(); 191 Graph* graph = m.graph();
199 Node* end = graph->end(); 192 Node* end = graph->end();
200 EXPECT_EQ(1, end->InputCount()); 193 EXPECT_EQ(1, end->InputCount());
201 Node* tail_call_node = end->InputAt(0); 194 Node* tail_call_node = end->InputAt(0);
202 195
203 Matcher<Node*> next_bytecode_offset_matcher = 196 Matcher<Node*> next_bytecode_offset_matcher =
204 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), 197 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter),
205 IsInt32Constant(jump_offset)); 198 IsInt32Constant(jump_offset));
206 Matcher<Node*> target_bytecode_matcher = m.IsLoad( 199 Matcher<Node*> target_bytecode_matcher = m.IsLoad(
207 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter), 200 kMachUint8, IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
208 next_bytecode_offset_matcher); 201 next_bytecode_offset_matcher);
(...skipping 22 matching lines...) Expand all
231 TARGET_TEST_F(InterpreterAssemblerTest, JumpIfWordEqual) { 224 TARGET_TEST_F(InterpreterAssemblerTest, JumpIfWordEqual) {
232 static const int kJumpIfTrueOffset = 73; 225 static const int kJumpIfTrueOffset = 73;
233 226
234 MachineOperatorBuilder machine(zone()); 227 MachineOperatorBuilder machine(zone());
235 228
236 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 229 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
237 InterpreterAssemblerForTest m(this, bytecode); 230 InterpreterAssemblerForTest m(this, bytecode);
238 Node* lhs = m.IntPtrConstant(0); 231 Node* lhs = m.IntPtrConstant(0);
239 Node* rhs = m.IntPtrConstant(1); 232 Node* rhs = m.IntPtrConstant(1);
240 m.JumpIfWordEqual(lhs, rhs, m.Int32Constant(kJumpIfTrueOffset)); 233 m.JumpIfWordEqual(lhs, rhs, m.Int32Constant(kJumpIfTrueOffset));
241 Graph* graph = m.GetCompletedGraph(); 234 Graph* graph = m.graph();
242 Node* end = graph->end(); 235 Node* end = graph->end();
243 EXPECT_EQ(2, end->InputCount()); 236 EXPECT_EQ(2, end->InputCount());
244 237
245 int jump_offsets[] = {kJumpIfTrueOffset, 238 int jump_offsets[] = {kJumpIfTrueOffset,
246 interpreter::Bytecodes::Size(bytecode)}; 239 interpreter::Bytecodes::Size(bytecode)};
247 for (int i = 0; i < static_cast<int>(arraysize(jump_offsets)); i++) { 240 for (int i = 0; i < static_cast<int>(arraysize(jump_offsets)); i++) {
248 Matcher<Node*> next_bytecode_offset_matcher = 241 Matcher<Node*> next_bytecode_offset_matcher =
249 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter), 242 IsIntPtrAdd(IsParameter(Linkage::kInterpreterBytecodeOffsetParameter),
250 IsInt32Constant(jump_offsets[i])); 243 IsInt32Constant(jump_offsets[i]));
251 Matcher<Node*> target_bytecode_matcher = m.IsLoad( 244 Matcher<Node*> target_bytecode_matcher = m.IsLoad(
(...skipping 17 matching lines...) Expand all
269 262
270 // TODO(oth): test control flow paths. 263 // TODO(oth): test control flow paths.
271 } 264 }
272 } 265 }
273 266
274 267
275 TARGET_TEST_F(InterpreterAssemblerTest, Return) { 268 TARGET_TEST_F(InterpreterAssemblerTest, Return) {
276 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 269 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
277 InterpreterAssemblerForTest m(this, bytecode); 270 InterpreterAssemblerForTest m(this, bytecode);
278 m.Return(); 271 m.Return();
279 Graph* graph = m.GetCompletedGraph(); 272 Graph* graph = m.graph();
280 273
281 Node* end = graph->end(); 274 Node* end = graph->end();
282 EXPECT_EQ(1, end->InputCount()); 275 EXPECT_EQ(1, end->InputCount());
283 Node* tail_call_node = end->InputAt(0); 276 Node* tail_call_node = end->InputAt(0);
284 277
285 EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind()); 278 EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind());
286 EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots); 279 EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots);
287 Handle<HeapObject> exit_trampoline = 280 Handle<HeapObject> exit_trampoline =
288 isolate()->builtins()->InterpreterExitTrampoline(); 281 isolate()->builtins()->InterpreterExitTrampoline();
289 EXPECT_THAT( 282 EXPECT_THAT(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Should be set by SedtAccumulator. 342 // Should be set by SedtAccumulator.
350 Node* accumulator_value_1 = m.Int32Constant(0xdeadbeef); 343 Node* accumulator_value_1 = m.Int32Constant(0xdeadbeef);
351 m.SetAccumulator(accumulator_value_1); 344 m.SetAccumulator(accumulator_value_1);
352 EXPECT_THAT(m.GetAccumulator(), accumulator_value_1); 345 EXPECT_THAT(m.GetAccumulator(), accumulator_value_1);
353 Node* accumulator_value_2 = m.Int32Constant(42); 346 Node* accumulator_value_2 = m.Int32Constant(42);
354 m.SetAccumulator(accumulator_value_2); 347 m.SetAccumulator(accumulator_value_2);
355 EXPECT_THAT(m.GetAccumulator(), accumulator_value_2); 348 EXPECT_THAT(m.GetAccumulator(), accumulator_value_2);
356 349
357 // Should be passed to next bytecode handler on dispatch. 350 // Should be passed to next bytecode handler on dispatch.
358 m.Dispatch(); 351 m.Dispatch();
359 Graph* graph = m.GetCompletedGraph(); 352 Graph* graph = m.graph();
360 353
361 Node* end = graph->end(); 354 Node* end = graph->end();
362 EXPECT_EQ(1, end->InputCount()); 355 EXPECT_EQ(1, end->InputCount());
363 Node* tail_call_node = end->InputAt(0); 356 Node* tail_call_node = end->InputAt(0);
364 357
365 EXPECT_THAT(tail_call_node, 358 EXPECT_THAT(tail_call_node,
366 IsTailCall(m.call_descriptor(), _, accumulator_value_2, _, _, _, 359 IsTailCall(m.call_descriptor(), _, accumulator_value_2, _, _, _,
367 _, graph->start(), graph->start())); 360 _, graph->start(), graph->start()));
368 } 361 }
369 } 362 }
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 feedback_vector, 624 feedback_vector,
632 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, 625 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher,
633 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - 626 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset -
634 kHeapObjectTag))); 627 kHeapObjectTag)));
635 } 628 }
636 } 629 }
637 630
638 } // namespace compiler 631 } // namespace compiler
639 } // namespace internal 632 } // namespace internal
640 } // namespace v8 633 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/interpreter-assembler-unittest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698