OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/instruction-selector-unittest.h" | 5 #include "test/unittests/compiler/instruction-selector-unittest.h" |
6 | 6 |
7 #include "src/compiler/graph.h" | 7 #include "src/compiler/graph.h" |
8 #include "src/compiler/schedule.h" | 8 #include "src/compiler/schedule.h" |
9 #include "src/flags.h" | 9 #include "src/flags.h" |
10 #include "test/unittests/compiler/compiler-test-utils.h" | 10 #include "test/unittests/compiler/compiler-test-utils.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 241 } |
242 | 242 |
243 | 243 |
244 // ----------------------------------------------------------------------------- | 244 // ----------------------------------------------------------------------------- |
245 // Finish. | 245 // Finish. |
246 | 246 |
247 | 247 |
248 TARGET_TEST_F(InstructionSelectorTest, Finish) { | 248 TARGET_TEST_F(InstructionSelectorTest, Finish) { |
249 StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged); | 249 StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged); |
250 Node* param = m.Parameter(0); | 250 Node* param = m.Parameter(0); |
251 Node* finish = m.NewNode(m.common()->Finish(1), param, m.graph()->start()); | 251 Node* finish = m.AddNode(m.common()->Finish(1), param, m.graph()->start()); |
252 m.Return(finish); | 252 m.Return(finish); |
253 Stream s = m.Build(kAllInstructions); | 253 Stream s = m.Build(kAllInstructions); |
254 ASSERT_EQ(4U, s.size()); | 254 ASSERT_EQ(4U, s.size()); |
255 EXPECT_EQ(kArchNop, s[0]->arch_opcode()); | 255 EXPECT_EQ(kArchNop, s[0]->arch_opcode()); |
256 ASSERT_EQ(1U, s[0]->OutputCount()); | 256 ASSERT_EQ(1U, s[0]->OutputCount()); |
257 ASSERT_TRUE(s[0]->Output()->IsUnallocated()); | 257 ASSERT_TRUE(s[0]->Output()->IsUnallocated()); |
258 EXPECT_EQ(s.ToVreg(param), s.ToVreg(s[0]->Output())); | 258 EXPECT_EQ(s.ToVreg(param), s.ToVreg(s[0]->Output())); |
259 EXPECT_EQ(kArchNop, s[1]->arch_opcode()); | 259 EXPECT_EQ(kArchNop, s[1]->arch_opcode()); |
260 ASSERT_EQ(1U, s[1]->InputCount()); | 260 ASSERT_EQ(1U, s[1]->InputCount()); |
261 ASSERT_TRUE(s[1]->InputAt(0)->IsUnallocated()); | 261 ASSERT_TRUE(s[1]->InputAt(0)->IsUnallocated()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 // ValueEffect. | 327 // ValueEffect. |
328 | 328 |
329 | 329 |
330 TARGET_TEST_F(InstructionSelectorTest, ValueEffect) { | 330 TARGET_TEST_F(InstructionSelectorTest, ValueEffect) { |
331 StreamBuilder m1(this, kMachInt32, kMachPtr); | 331 StreamBuilder m1(this, kMachInt32, kMachPtr); |
332 Node* p1 = m1.Parameter(0); | 332 Node* p1 = m1.Parameter(0); |
333 m1.Return(m1.Load(kMachInt32, p1, m1.Int32Constant(0))); | 333 m1.Return(m1.Load(kMachInt32, p1, m1.Int32Constant(0))); |
334 Stream s1 = m1.Build(kAllInstructions); | 334 Stream s1 = m1.Build(kAllInstructions); |
335 StreamBuilder m2(this, kMachInt32, kMachPtr); | 335 StreamBuilder m2(this, kMachInt32, kMachPtr); |
336 Node* p2 = m2.Parameter(0); | 336 Node* p2 = m2.Parameter(0); |
337 m2.Return(m2.NewNode(m2.machine()->Load(kMachInt32), p2, m2.Int32Constant(0), | 337 m2.Return(m2.AddNode(m2.machine()->Load(kMachInt32), p2, m2.Int32Constant(0), |
338 m2.NewNode(m2.common()->ValueEffect(1), p2))); | 338 m2.AddNode(m2.common()->ValueEffect(1), p2))); |
339 Stream s2 = m2.Build(kAllInstructions); | 339 Stream s2 = m2.Build(kAllInstructions); |
340 EXPECT_LE(3U, s1.size()); | 340 EXPECT_LE(3U, s1.size()); |
341 ASSERT_EQ(s1.size(), s2.size()); | 341 ASSERT_EQ(s1.size(), s2.size()); |
342 TRACED_FORRANGE(size_t, i, 0, s1.size() - 1) { | 342 TRACED_FORRANGE(size_t, i, 0, s1.size() - 1) { |
343 const Instruction* i1 = s1[i]; | 343 const Instruction* i1 = s1[i]; |
344 const Instruction* i2 = s2[i]; | 344 const Instruction* i2 = s2[i]; |
345 EXPECT_EQ(i1->arch_opcode(), i2->arch_opcode()); | 345 EXPECT_EQ(i1->arch_opcode(), i2->arch_opcode()); |
346 EXPECT_EQ(i1->InputCount(), i2->InputCount()); | 346 EXPECT_EQ(i1->InputCount(), i2->InputCount()); |
347 EXPECT_EQ(i1->OutputCount(), i2->OutputCount()); | 347 EXPECT_EQ(i1->OutputCount(), i2->OutputCount()); |
348 } | 348 } |
(...skipping 14 matching lines...) Expand all Loading... |
363 Node* receiver = m.Parameter(1); | 363 Node* receiver = m.Parameter(1); |
364 Node* context = m.Parameter(2); | 364 Node* context = m.Parameter(2); |
365 | 365 |
366 ZoneVector<MachineType> int32_type(1, kMachInt32, zone()); | 366 ZoneVector<MachineType> int32_type(1, kMachInt32, zone()); |
367 ZoneVector<MachineType> empty_types(zone()); | 367 ZoneVector<MachineType> empty_types(zone()); |
368 | 368 |
369 CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( | 369 CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( |
370 zone(), false, 1, CallDescriptor::kNeedsFrameState); | 370 zone(), false, 1, CallDescriptor::kNeedsFrameState); |
371 | 371 |
372 Node* parameters = | 372 Node* parameters = |
373 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(1)); | 373 m.AddNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(1)); |
374 Node* locals = m.NewNode(m.common()->TypedStateValues(&empty_types)); | 374 Node* locals = m.AddNode(m.common()->TypedStateValues(&empty_types)); |
375 Node* stack = m.NewNode(m.common()->TypedStateValues(&empty_types)); | 375 Node* stack = m.AddNode(m.common()->TypedStateValues(&empty_types)); |
376 Node* context_dummy = m.Int32Constant(0); | 376 Node* context_dummy = m.Int32Constant(0); |
377 | 377 |
378 Node* state_node = m.NewNode( | 378 Node* state_node = m.AddNode( |
379 m.common()->FrameState(bailout_id, OutputFrameStateCombine::Push(), | 379 m.common()->FrameState(bailout_id, OutputFrameStateCombine::Push(), |
380 m.GetFrameStateFunctionInfo(1, 0)), | 380 m.GetFrameStateFunctionInfo(1, 0)), |
381 parameters, locals, stack, context_dummy, function_node, | 381 parameters, locals, stack, context_dummy, function_node, |
382 m.UndefinedConstant()); | 382 m.UndefinedConstant()); |
383 Node* args[] = {receiver, context}; | 383 Node* args[] = {receiver, context}; |
384 Node* call = | 384 Node* call = |
385 m.CallNWithFrameState(descriptor, function_node, args, state_node); | 385 m.CallNWithFrameState(descriptor, function_node, args, state_node); |
386 m.Return(call); | 386 m.Return(call); |
387 | 387 |
388 Stream s = m.Build(kAllExceptNopInstructions); | 388 Stream s = m.Build(kAllExceptNopInstructions); |
(...skipping 23 matching lines...) Expand all Loading... |
412 Node* function_node = m.Parameter(0); | 412 Node* function_node = m.Parameter(0); |
413 Node* receiver = m.Parameter(1); | 413 Node* receiver = m.Parameter(1); |
414 Node* context = m.Int32Constant(1); // Context is ignored. | 414 Node* context = m.Int32Constant(1); // Context is ignored. |
415 | 415 |
416 ZoneVector<MachineType> int32_type(1, kMachInt32, zone()); | 416 ZoneVector<MachineType> int32_type(1, kMachInt32, zone()); |
417 ZoneVector<MachineType> float64_type(1, kMachFloat64, zone()); | 417 ZoneVector<MachineType> float64_type(1, kMachFloat64, zone()); |
418 ZoneVector<MachineType> tagged_type(1, kMachAnyTagged, zone()); | 418 ZoneVector<MachineType> tagged_type(1, kMachAnyTagged, zone()); |
419 | 419 |
420 // Build frame state for the state before the call. | 420 // Build frame state for the state before the call. |
421 Node* parameters = | 421 Node* parameters = |
422 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(43)); | 422 m.AddNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(43)); |
423 Node* locals = m.NewNode(m.common()->TypedStateValues(&float64_type), | 423 Node* locals = m.AddNode(m.common()->TypedStateValues(&float64_type), |
424 m.Float64Constant(0.5)); | 424 m.Float64Constant(0.5)); |
425 Node* stack = m.NewNode(m.common()->TypedStateValues(&tagged_type), | 425 Node* stack = m.AddNode(m.common()->TypedStateValues(&tagged_type), |
426 m.UndefinedConstant()); | 426 m.UndefinedConstant()); |
427 | 427 |
428 Node* context_sentinel = m.Int32Constant(0); | 428 Node* context_sentinel = m.Int32Constant(0); |
429 Node* frame_state_before = m.NewNode( | 429 Node* frame_state_before = m.AddNode( |
430 m.common()->FrameState(bailout_id_before, OutputFrameStateCombine::Push(), | 430 m.common()->FrameState(bailout_id_before, OutputFrameStateCombine::Push(), |
431 m.GetFrameStateFunctionInfo(1, 1)), | 431 m.GetFrameStateFunctionInfo(1, 1)), |
432 parameters, locals, stack, context_sentinel, function_node, | 432 parameters, locals, stack, context_sentinel, function_node, |
433 m.UndefinedConstant()); | 433 m.UndefinedConstant()); |
434 | 434 |
435 // Build the call. | 435 // Build the call. |
436 Node* call = m.CallFunctionStub0(function_node, receiver, context, | 436 Node* call = m.CallFunctionStub0(function_node, receiver, context, |
437 frame_state_before, CALL_AS_METHOD); | 437 frame_state_before, CALL_AS_METHOD); |
438 | 438 |
439 m.Return(call); | 439 m.Return(call); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 Node* function_node = m.Parameter(0); | 508 Node* function_node = m.Parameter(0); |
509 Node* receiver = m.Parameter(1); | 509 Node* receiver = m.Parameter(1); |
510 Node* context = m.Int32Constant(66); | 510 Node* context = m.Int32Constant(66); |
511 | 511 |
512 ZoneVector<MachineType> int32_type(1, kMachInt32, zone()); | 512 ZoneVector<MachineType> int32_type(1, kMachInt32, zone()); |
513 ZoneVector<MachineType> int32x2_type(2, kMachInt32, zone()); | 513 ZoneVector<MachineType> int32x2_type(2, kMachInt32, zone()); |
514 ZoneVector<MachineType> float64_type(1, kMachFloat64, zone()); | 514 ZoneVector<MachineType> float64_type(1, kMachFloat64, zone()); |
515 | 515 |
516 // Build frame state for the state before the call. | 516 // Build frame state for the state before the call. |
517 Node* parameters = | 517 Node* parameters = |
518 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(63)); | 518 m.AddNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(63)); |
519 Node* locals = | 519 Node* locals = |
520 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(64)); | 520 m.AddNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(64)); |
521 Node* stack = | 521 Node* stack = |
522 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(65)); | 522 m.AddNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(65)); |
523 Node* frame_state_parent = m.NewNode( | 523 Node* frame_state_parent = m.AddNode( |
524 m.common()->FrameState(bailout_id_parent, | 524 m.common()->FrameState(bailout_id_parent, |
525 OutputFrameStateCombine::Ignore(), | 525 OutputFrameStateCombine::Ignore(), |
526 m.GetFrameStateFunctionInfo(1, 1)), | 526 m.GetFrameStateFunctionInfo(1, 1)), |
527 parameters, locals, stack, context, function_node, m.UndefinedConstant()); | 527 parameters, locals, stack, context, function_node, m.UndefinedConstant()); |
528 | 528 |
529 Node* context2 = m.Int32Constant(46); | 529 Node* context2 = m.Int32Constant(46); |
530 Node* parameters2 = | 530 Node* parameters2 = |
531 m.NewNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(43)); | 531 m.AddNode(m.common()->TypedStateValues(&int32_type), m.Int32Constant(43)); |
532 Node* locals2 = m.NewNode(m.common()->TypedStateValues(&float64_type), | 532 Node* locals2 = m.AddNode(m.common()->TypedStateValues(&float64_type), |
533 m.Float64Constant(0.25)); | 533 m.Float64Constant(0.25)); |
534 Node* stack2 = m.NewNode(m.common()->TypedStateValues(&int32x2_type), | 534 Node* stack2 = m.AddNode(m.common()->TypedStateValues(&int32x2_type), |
535 m.Int32Constant(44), m.Int32Constant(45)); | 535 m.Int32Constant(44), m.Int32Constant(45)); |
536 Node* frame_state_before = m.NewNode( | 536 Node* frame_state_before = m.AddNode( |
537 m.common()->FrameState(bailout_id_before, OutputFrameStateCombine::Push(), | 537 m.common()->FrameState(bailout_id_before, OutputFrameStateCombine::Push(), |
538 m.GetFrameStateFunctionInfo(1, 1)), | 538 m.GetFrameStateFunctionInfo(1, 1)), |
539 parameters2, locals2, stack2, context2, function_node, | 539 parameters2, locals2, stack2, context2, function_node, |
540 frame_state_parent); | 540 frame_state_parent); |
541 | 541 |
542 // Build the call. | 542 // Build the call. |
543 Node* call = m.CallFunctionStub0(function_node, receiver, context2, | 543 Node* call = m.CallFunctionStub0(function_node, receiver, context2, |
544 frame_state_before, CALL_AS_METHOD); | 544 frame_state_before, CALL_AS_METHOD); |
545 | 545 |
546 m.Return(call); | 546 m.Return(call); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 EXPECT_EQ(s.ToVreg(context2), s.ToVreg(call_instr->InputAt(14))); | 611 EXPECT_EQ(s.ToVreg(context2), s.ToVreg(call_instr->InputAt(14))); |
612 // Continuation. | 612 // Continuation. |
613 | 613 |
614 EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); | 614 EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); |
615 EXPECT_EQ(index, s.size()); | 615 EXPECT_EQ(index, s.size()); |
616 } | 616 } |
617 | 617 |
618 } // namespace compiler | 618 } // namespace compiler |
619 } // namespace internal | 619 } // namespace internal |
620 } // namespace v8 | 620 } // namespace v8 |
OLD | NEW |