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/cctest/cctest.h" | 5 #include "test/cctest/cctest.h" |
6 #include "test/cctest/compiler/codegen-tester.h" | 6 #include "test/cctest/compiler/codegen-tester.h" |
7 #include "test/cctest/compiler/value-helper.h" | 7 #include "test/cctest/compiler/value-helper.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 | 563 |
564 { | 564 { |
565 RawMachineAssemblerTester<int32_t> m; | 565 RawMachineAssemblerTester<int32_t> m; |
566 Float64BinopTester bt(&m); | 566 Float64BinopTester bt(&m); |
567 bt.AddReturn(bt.param1); | 567 bt.AddReturn(bt.param1); |
568 | 568 |
569 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(*i, bt.call(-11.25, *i)); } | 569 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(*i, bt.call(-11.25, *i)); } |
570 } | 570 } |
571 } | 571 } |
572 | 572 |
| 573 |
| 574 #if V8_TARGET_ARCH_64_BIT |
| 575 // TODO(ahaas): run int64 tests on all platforms when supported. |
| 576 TEST(RunBufferedRawMachineAssemblerTesterTester) { |
| 577 { |
| 578 BufferedRawMachineAssemblerTester<int64_t> m; |
| 579 m.Return(m.Int64Constant(0x12500000000)); |
| 580 CHECK_EQ(0x12500000000, m.Call()); |
| 581 } |
| 582 { |
| 583 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); |
| 584 m.Return(m.Parameter(0)); |
| 585 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(*i, m.Call(*i)); } |
| 586 } |
| 587 { |
| 588 BufferedRawMachineAssemblerTester<int64_t> m(kMachInt64, kMachInt64); |
| 589 m.Return(m.Int64Add(m.Parameter(0), m.Parameter(1))); |
| 590 FOR_INT64_INPUTS(i) { |
| 591 FOR_INT64_INPUTS(j) { |
| 592 CHECK_EQ(*i + *j, m.Call(*i, *j)); |
| 593 CHECK_EQ(*j + *i, m.Call(*j, *i)); |
| 594 } |
| 595 } |
| 596 } |
| 597 { |
| 598 BufferedRawMachineAssemblerTester<int64_t> m(kMachInt64, kMachInt64, |
| 599 kMachInt64); |
| 600 m.Return( |
| 601 m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); |
| 602 FOR_INT64_INPUTS(i) { |
| 603 FOR_INT64_INPUTS(j) { |
| 604 CHECK_EQ(*i + *i + *j, m.Call(*i, *i, *j)); |
| 605 CHECK_EQ(*i + *j + *i, m.Call(*i, *j, *i)); |
| 606 CHECK_EQ(*j + *i + *i, m.Call(*j, *i, *i)); |
| 607 } |
| 608 } |
| 609 } |
| 610 { |
| 611 BufferedRawMachineAssemblerTester<int64_t> m(kMachInt64, kMachInt64, |
| 612 kMachInt64, kMachInt64); |
| 613 m.Return(m.Int64Add( |
| 614 m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2)), |
| 615 m.Parameter(3))); |
| 616 FOR_INT64_INPUTS(i) { |
| 617 FOR_INT64_INPUTS(j) { |
| 618 CHECK_EQ(*i + *i + *i + *j, m.Call(*i, *i, *i, *j)); |
| 619 CHECK_EQ(*i + *i + *j + *i, m.Call(*i, *i, *j, *i)); |
| 620 CHECK_EQ(*i + *j + *i + *i, m.Call(*i, *j, *i, *i)); |
| 621 CHECK_EQ(*j + *i + *i + *i, m.Call(*j, *i, *i, *i)); |
| 622 } |
| 623 } |
| 624 } |
| 625 { |
| 626 BufferedRawMachineAssemblerTester<void> m; |
| 627 int64_t result; |
| 628 m.Store(MachineTypeForC<int64_t>(), m.PointerConstant(&result), |
| 629 m.Int64Constant(0x12500000000), kNoWriteBarrier); |
| 630 m.Return(m.Int32Constant(0)); |
| 631 m.Call(); |
| 632 CHECK_EQ(0x12500000000, result); |
| 633 } |
| 634 { |
| 635 BufferedRawMachineAssemblerTester<void> m(kMachFloat64); |
| 636 double result; |
| 637 m.Store(MachineTypeForC<double>(), m.PointerConstant(&result), |
| 638 m.Parameter(0), kNoWriteBarrier); |
| 639 m.Return(m.Int32Constant(0)); |
| 640 FOR_FLOAT64_INPUTS(i) { |
| 641 m.Call(*i); |
| 642 CheckDoubleEq(*i, result); |
| 643 } |
| 644 } |
| 645 { |
| 646 BufferedRawMachineAssemblerTester<void> m(kMachInt64, kMachInt64); |
| 647 int64_t result; |
| 648 m.Store(MachineTypeForC<int64_t>(), m.PointerConstant(&result), |
| 649 m.Int64Add(m.Parameter(0), m.Parameter(1)), kNoWriteBarrier); |
| 650 m.Return(m.Int32Constant(0)); |
| 651 FOR_INT64_INPUTS(i) { |
| 652 FOR_INT64_INPUTS(j) { |
| 653 m.Call(*i, *j); |
| 654 CHECK_EQ(*i + *j, result); |
| 655 |
| 656 m.Call(*j, *i); |
| 657 CHECK_EQ(*j + *i, result); |
| 658 } |
| 659 } |
| 660 } |
| 661 { |
| 662 BufferedRawMachineAssemblerTester<void> m(kMachInt64, kMachInt64, |
| 663 kMachInt64); |
| 664 int64_t result; |
| 665 m.Store( |
| 666 MachineTypeForC<int64_t>(), m.PointerConstant(&result), |
| 667 m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2)), |
| 668 kNoWriteBarrier); |
| 669 m.Return(m.Int32Constant(0)); |
| 670 FOR_INT64_INPUTS(i) { |
| 671 FOR_INT64_INPUTS(j) { |
| 672 m.Call(*i, *i, *j); |
| 673 CHECK_EQ(*i + *i + *j, result); |
| 674 |
| 675 m.Call(*i, *j, *i); |
| 676 CHECK_EQ(*i + *j + *i, result); |
| 677 |
| 678 m.Call(*j, *i, *i); |
| 679 CHECK_EQ(*j + *i + *i, result); |
| 680 } |
| 681 } |
| 682 } |
| 683 { |
| 684 BufferedRawMachineAssemblerTester<void> m(kMachInt64, kMachInt64, |
| 685 kMachInt64, kMachInt64); |
| 686 int64_t result; |
| 687 m.Store(MachineTypeForC<int64_t>(), m.PointerConstant(&result), |
| 688 m.Int64Add(m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), |
| 689 m.Parameter(2)), |
| 690 m.Parameter(3)), |
| 691 kNoWriteBarrier); |
| 692 m.Return(m.Int32Constant(0)); |
| 693 FOR_INT64_INPUTS(i) { |
| 694 FOR_INT64_INPUTS(j) { |
| 695 m.Call(*i, *i, *i, *j); |
| 696 CHECK_EQ(*i + *i + *i + *j, result); |
| 697 |
| 698 m.Call(*i, *i, *j, *i); |
| 699 CHECK_EQ(*i + *i + *j + *i, result); |
| 700 |
| 701 m.Call(*i, *j, *i, *i); |
| 702 CHECK_EQ(*i + *j + *i + *i, result); |
| 703 |
| 704 m.Call(*j, *i, *i, *i); |
| 705 CHECK_EQ(*j + *i + *i + *i, result); |
| 706 } |
| 707 } |
| 708 } |
| 709 } |
| 710 |
| 711 #endif |
573 } // namespace compiler | 712 } // namespace compiler |
574 } // namespace internal | 713 } // namespace internal |
575 } // namespace v8 | 714 } // namespace v8 |
OLD | NEW |