| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_DBC) | 6 #if defined(TARGET_ARCH_DBC) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/stack_frame.h" | 9 #include "vm/stack_frame.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 __ LoadConstant(2, Smi::Handle(Smi::New(42))); | 787 __ LoadConstant(2, Smi::Handle(Smi::New(42))); |
| 788 __ Return(2); | 788 __ Return(2); |
| 789 } | 789 } |
| 790 | 790 |
| 791 | 791 |
| 792 ASSEMBLER_TEST_RUN(ShrNegShift, test) { | 792 ASSEMBLER_TEST_RUN(ShrNegShift, test) { |
| 793 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); | 793 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 794 } | 794 } |
| 795 | 795 |
| 796 | 796 |
| 797 // - Neg rA , rD |
| 798 // |
| 799 // FP[rA] <- -FP[rD]. Assumes FP[rD] is a Smi. If there is no overflow the |
| 800 // immediately following instruction is skipped. |
| 801 ASSEMBLER_TEST_GENERATE(NegPos, assembler) { |
| 802 __ Frame(2); |
| 803 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 804 __ LoadConstant(1, Smi::Handle(Smi::New(-1))); |
| 805 __ Neg(1, 0); |
| 806 __ LoadConstant(1, Smi::Handle(Smi::New(-1))); |
| 807 __ Return(1); |
| 808 } |
| 809 |
| 810 |
| 811 ASSEMBLER_TEST_RUN(NegPos, test) { |
| 812 EXPECT_EQ(-42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 813 } |
| 814 |
| 815 |
| 816 ASSEMBLER_TEST_GENERATE(NegNeg, assembler) { |
| 817 __ Frame(2); |
| 818 __ LoadConstant(0, Smi::Handle(Smi::New(-42))); |
| 819 __ LoadConstant(1, Smi::Handle(Smi::New(-1))); |
| 820 __ Neg(1, 0); |
| 821 __ LoadConstant(1, Smi::Handle(Smi::New(-1))); |
| 822 __ Return(1); |
| 823 } |
| 824 |
| 825 |
| 826 ASSEMBLER_TEST_RUN(NegNeg, test) { |
| 827 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 828 } |
| 829 |
| 830 |
| 831 ASSEMBLER_TEST_GENERATE(NegOverflow, assembler) { |
| 832 __ Frame(2); |
| 833 __ LoadConstant(0, Smi::Handle(Smi::New(Smi::kMinValue))); |
| 834 __ LoadConstant(1, Smi::Handle(Smi::New(-1))); |
| 835 __ Neg(1, 0); |
| 836 __ LoadConstant(1, Smi::Handle(Smi::New(42))); |
| 837 __ Return(1); |
| 838 } |
| 839 |
| 840 |
| 841 ASSEMBLER_TEST_RUN(NegOverflow, test) { |
| 842 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 843 } |
| 844 |
| 845 |
| 797 // - BitOr, BitAnd, BitXor rA, rB, rC | 846 // - BitOr, BitAnd, BitXor rA, rB, rC |
| 798 // | 847 // |
| 799 // FP[rA] <- FP[rB] op FP[rC] | 848 // FP[rA] <- FP[rB] op FP[rC] |
| 800 ASSEMBLER_TEST_GENERATE(BitOr, assembler) { | 849 ASSEMBLER_TEST_GENERATE(BitOr, assembler) { |
| 801 __ Frame(3); | 850 __ Frame(3); |
| 802 __ LoadConstant(0, Smi::Handle(Smi::New(0x2))); | 851 __ LoadConstant(0, Smi::Handle(Smi::New(0x2))); |
| 803 __ LoadConstant(1, Smi::Handle(Smi::New(0x28))); | 852 __ LoadConstant(1, Smi::Handle(Smi::New(0x28))); |
| 804 __ LoadConstant(2, Smi::Handle(Smi::New(-1))); | 853 __ LoadConstant(2, Smi::Handle(Smi::New(-1))); |
| 805 __ BitOr(2, 0, 1); | 854 __ BitOr(2, 0, 1); |
| 806 __ Return(2); | 855 __ Return(2); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 835 __ BitXor(2, 0, 1); | 884 __ BitXor(2, 0, 1); |
| 836 __ Return(2); | 885 __ Return(2); |
| 837 } | 886 } |
| 838 | 887 |
| 839 | 888 |
| 840 ASSEMBLER_TEST_RUN(BitXor, test) { | 889 ASSEMBLER_TEST_RUN(BitXor, test) { |
| 841 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); | 890 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 842 } | 891 } |
| 843 | 892 |
| 844 | 893 |
| 894 // - BitNot rA, rD |
| 895 // |
| 896 // FP[rA] <- ~FP[rD]. As above, assumes FP[rD] is a Smi. |
| 897 ASSEMBLER_TEST_GENERATE(BitNot, assembler) { |
| 898 __ Frame(2); |
| 899 __ LoadConstant(0, Smi::Handle(Smi::New(~42))); |
| 900 __ LoadConstant(1, Smi::Handle(Smi::New(-1))); |
| 901 __ BitNot(1, 0); |
| 902 __ Return(1); |
| 903 } |
| 904 |
| 905 |
| 906 ASSEMBLER_TEST_RUN(BitNot, test) { |
| 907 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 908 } |
| 909 |
| 845 // - IfNeStrictTOS; IfEqStrictTOS; IfNeStrictNumTOS; IfEqStrictNumTOS | 910 // - IfNeStrictTOS; IfEqStrictTOS; IfNeStrictNumTOS; IfEqStrictNumTOS |
| 846 // | 911 // |
| 847 // Skips the next instruction unless the given condition holds. 'Num' | 912 // Skips the next instruction unless the given condition holds. 'Num' |
| 848 // variants perform number check while non-Num variants just compare | 913 // variants perform number check while non-Num variants just compare |
| 849 // RawObject pointers. | 914 // RawObject pointers. |
| 850 // | 915 // |
| 851 // Used to implement conditional jump: | 916 // Used to implement conditional jump: |
| 852 // | 917 // |
| 853 // IfNeStrictTOS | 918 // IfNeStrictTOS |
| 854 // Jump T ;; jump if not equal | 919 // Jump T ;; jump if not equal |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 __ CheckSmi(0); | 1582 __ CheckSmi(0); |
| 1518 __ PushConstant(Smi::Handle(Smi::New(42))); | 1583 __ PushConstant(Smi::Handle(Smi::New(42))); |
| 1519 __ ReturnTOS(); | 1584 __ ReturnTOS(); |
| 1520 } | 1585 } |
| 1521 | 1586 |
| 1522 | 1587 |
| 1523 ASSEMBLER_TEST_RUN(CheckSmiFail, test) { | 1588 ASSEMBLER_TEST_RUN(CheckSmiFail, test) { |
| 1524 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); | 1589 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1525 } | 1590 } |
| 1526 | 1591 |
| 1592 |
| 1593 // - CheckClassId rA, D |
| 1594 // |
| 1595 // If the object at FP[rA]'s class id matches hthe class id in PP[D], then |
| 1596 // skip the following instruction. |
| 1597 ASSEMBLER_TEST_GENERATE(CheckClassIdSmiPass, assembler) { |
| 1598 __ Frame(1); |
| 1599 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1600 __ CheckClassId(0, __ AddConstant(Smi::Handle(Smi::New(kSmiCid)))); |
| 1601 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1602 __ Return(0); |
| 1603 } |
| 1604 |
| 1605 |
| 1606 ASSEMBLER_TEST_RUN(CheckClassIdSmiPass, test) { |
| 1607 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1608 } |
| 1609 |
| 1610 |
| 1611 ASSEMBLER_TEST_GENERATE(CheckClassIdNonSmiPass, assembler) { |
| 1612 __ Frame(1); |
| 1613 __ LoadConstant(0, Bool::True()); |
| 1614 __ CheckClassId(0, __ AddConstant(Smi::Handle(Smi::New(kBoolCid)))); |
| 1615 __ LoadConstant(0, Bool::False()); |
| 1616 __ Return(0); |
| 1617 } |
| 1618 |
| 1619 |
| 1620 ASSEMBLER_TEST_RUN(CheckClassIdNonSmiPass, test) { |
| 1621 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code())); |
| 1622 } |
| 1623 |
| 1624 |
| 1625 ASSEMBLER_TEST_GENERATE(CheckClassIdFail, assembler) { |
| 1626 __ Frame(1); |
| 1627 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); |
| 1628 __ CheckClassId(0, __ AddConstant(Smi::Handle(Smi::New(kBoolCid)))); |
| 1629 __ LoadConstant(0, Smi::Handle(Smi::New(42))); |
| 1630 __ Return(0); |
| 1631 } |
| 1632 |
| 1633 |
| 1634 ASSEMBLER_TEST_RUN(CheckClassIdFail, test) { |
| 1635 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 1636 } |
| 1637 |
| 1527 } // namespace dart | 1638 } // namespace dart |
| 1528 | 1639 |
| 1529 #endif // defined(TARGET_ARCH_DBC) | 1640 #endif // defined(TARGET_ARCH_DBC) |
| OLD | NEW |