OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/os.h" | 10 #include "vm/os.h" |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 | 1618 |
1619 ASSEMBLER_TEST_RUN(LoadImmediateMedNeg4, test) { | 1619 ASSEMBLER_TEST_RUN(LoadImmediateMedNeg4, test) { |
1620 typedef int64_t (*Int64Return)() DART_UNUSED; | 1620 typedef int64_t (*Int64Return)() DART_UNUSED; |
1621 EXPECT_EQ(-0x12341234, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 1621 EXPECT_EQ(-0x12341234, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
1622 } | 1622 } |
1623 | 1623 |
1624 | 1624 |
1625 static void EnterTestFrame(Assembler* assembler) { | 1625 static void EnterTestFrame(Assembler* assembler) { |
1626 __ EnterFrame(0); | 1626 __ EnterFrame(0); |
1627 __ Push(CODE_REG); | 1627 __ Push(CODE_REG); |
| 1628 __ Push(THR); |
1628 __ TagAndPushPP(); | 1629 __ TagAndPushPP(); |
1629 __ ldr(CODE_REG, Address(R0, VMHandles::kOffsetOfRawPtrInHandle)); | 1630 __ ldr(CODE_REG, Address(R0, VMHandles::kOffsetOfRawPtrInHandle)); |
| 1631 __ mov(THR, R1); |
1630 __ LoadPoolPointer(PP); | 1632 __ LoadPoolPointer(PP); |
1631 } | 1633 } |
1632 | 1634 |
1633 | 1635 |
1634 static void LeaveTestFrame(Assembler* assembler) { | 1636 static void LeaveTestFrame(Assembler* assembler) { |
1635 __ PopAndUntagPP(); | 1637 __ PopAndUntagPP(); |
| 1638 __ Pop(THR); |
1636 __ Pop(CODE_REG); | 1639 __ Pop(CODE_REG); |
1637 __ LeaveFrame(); | 1640 __ LeaveFrame(); |
1638 } | 1641 } |
1639 | 1642 |
1640 | 1643 |
1641 | 1644 |
1642 | 1645 |
1643 // Loading immediate values with the object pool. | 1646 // Loading immediate values with the object pool. |
1644 ASSEMBLER_TEST_GENERATE(LoadImmediatePPSmall, assembler) { | 1647 ASSEMBLER_TEST_GENERATE(LoadImmediatePPSmall, assembler) { |
1645 __ SetupDartSP(kTestStackSpace); | 1648 __ SetupDartSP(kTestStackSpace); |
1646 EnterTestFrame(assembler); | 1649 EnterTestFrame(assembler); |
1647 __ LoadImmediate(R0, 42); | 1650 __ LoadImmediate(R0, 42); |
1648 LeaveTestFrame(assembler); | 1651 LeaveTestFrame(assembler); |
1649 __ mov(CSP, SP); | 1652 __ mov(CSP, SP); |
1650 __ ret(); | 1653 __ ret(); |
1651 } | 1654 } |
1652 | 1655 |
1653 | 1656 |
1654 ASSEMBLER_TEST_RUN(LoadImmediatePPSmall, test) { | 1657 ASSEMBLER_TEST_RUN(LoadImmediatePPSmall, test) { |
1655 EXPECT_EQ(42, test->InvokeWithCode<int64_t>()); | 1658 EXPECT_EQ(42, test->InvokeWithCodeAndThread<int64_t>()); |
1656 } | 1659 } |
1657 | 1660 |
1658 | 1661 |
1659 ASSEMBLER_TEST_GENERATE(LoadImmediatePPMed, assembler) { | 1662 ASSEMBLER_TEST_GENERATE(LoadImmediatePPMed, assembler) { |
1660 __ SetupDartSP(kTestStackSpace); | 1663 __ SetupDartSP(kTestStackSpace); |
1661 EnterTestFrame(assembler); | 1664 EnterTestFrame(assembler); |
1662 __ LoadImmediate(R0, 0xf1234123); | 1665 __ LoadImmediate(R0, 0xf1234123); |
1663 LeaveTestFrame(assembler); | 1666 LeaveTestFrame(assembler); |
1664 __ mov(CSP, SP); | 1667 __ mov(CSP, SP); |
1665 __ ret(); | 1668 __ ret(); |
1666 } | 1669 } |
1667 | 1670 |
1668 | 1671 |
1669 ASSEMBLER_TEST_RUN(LoadImmediatePPMed, test) { | 1672 ASSEMBLER_TEST_RUN(LoadImmediatePPMed, test) { |
1670 EXPECT_EQ(0xf1234123, test->InvokeWithCode<int64_t>()); | 1673 EXPECT_EQ(0xf1234123, test->InvokeWithCodeAndThread<int64_t>()); |
1671 } | 1674 } |
1672 | 1675 |
1673 | 1676 |
1674 ASSEMBLER_TEST_GENERATE(LoadImmediatePPMed2, assembler) { | 1677 ASSEMBLER_TEST_GENERATE(LoadImmediatePPMed2, assembler) { |
1675 __ SetupDartSP(kTestStackSpace); | 1678 __ SetupDartSP(kTestStackSpace); |
1676 EnterTestFrame(assembler); | 1679 EnterTestFrame(assembler); |
1677 __ LoadImmediate(R0, 0x4321f1234124); | 1680 __ LoadImmediate(R0, 0x4321f1234124); |
1678 LeaveTestFrame(assembler); | 1681 LeaveTestFrame(assembler); |
1679 __ mov(CSP, SP); | 1682 __ mov(CSP, SP); |
1680 __ ret(); | 1683 __ ret(); |
1681 } | 1684 } |
1682 | 1685 |
1683 | 1686 |
1684 ASSEMBLER_TEST_RUN(LoadImmediatePPMed2, test) { | 1687 ASSEMBLER_TEST_RUN(LoadImmediatePPMed2, test) { |
1685 EXPECT_EQ(0x4321f1234124, test->InvokeWithCode<int64_t>()); | 1688 EXPECT_EQ(0x4321f1234124, test->InvokeWithCodeAndThread<int64_t>()); |
1686 } | 1689 } |
1687 | 1690 |
1688 | 1691 |
1689 ASSEMBLER_TEST_GENERATE(LoadImmediatePPLarge, assembler) { | 1692 ASSEMBLER_TEST_GENERATE(LoadImmediatePPLarge, assembler) { |
1690 __ SetupDartSP(kTestStackSpace); | 1693 __ SetupDartSP(kTestStackSpace); |
1691 EnterTestFrame(assembler); | 1694 EnterTestFrame(assembler); |
1692 __ LoadImmediate(R0, 0x9287436598237465); | 1695 __ LoadImmediate(R0, 0x9287436598237465); |
1693 LeaveTestFrame(assembler); | 1696 LeaveTestFrame(assembler); |
1694 __ mov(CSP, SP); | 1697 __ mov(CSP, SP); |
1695 __ ret(); | 1698 __ ret(); |
1696 } | 1699 } |
1697 | 1700 |
1698 | 1701 |
1699 ASSEMBLER_TEST_RUN(LoadImmediatePPLarge, test) { | 1702 ASSEMBLER_TEST_RUN(LoadImmediatePPLarge, test) { |
1700 EXPECT_EQ(static_cast<int64_t>(0x9287436598237465), | 1703 EXPECT_EQ(static_cast<int64_t>(0x9287436598237465), |
1701 test->InvokeWithCode<int64_t>()); | 1704 test->InvokeWithCodeAndThread<int64_t>()); |
1702 } | 1705 } |
1703 | 1706 |
1704 | 1707 |
1705 #define ASSEMBLER_TEST_RUN_WITH_THREAD(result_type, var_name) \ | |
1706 Thread* thread = Thread::Current(); \ | |
1707 result_type var_name = test->InvokeWithCode<result_type>(thread); | |
1708 | |
1709 | |
1710 // LoadObject null. | 1708 // LoadObject null. |
1711 ASSEMBLER_TEST_GENERATE(LoadObjectNull, assembler) { | 1709 ASSEMBLER_TEST_GENERATE(LoadObjectNull, assembler) { |
1712 __ SetupDartSP(kTestStackSpace); | 1710 __ SetupDartSP(kTestStackSpace); |
1713 EnterTestFrame(assembler); | 1711 EnterTestFrame(assembler); |
1714 __ Push(THR); | |
1715 __ mov(THR, R1); | |
1716 __ LoadObject(R0, Object::null_object()); | 1712 __ LoadObject(R0, Object::null_object()); |
1717 __ Pop(THR); | |
1718 LeaveTestFrame(assembler); | 1713 LeaveTestFrame(assembler); |
1719 __ mov(CSP, SP); | 1714 __ mov(CSP, SP); |
1720 __ ret(); | 1715 __ ret(); |
1721 } | 1716 } |
1722 | 1717 |
1723 | 1718 |
1724 ASSEMBLER_TEST_RUN(LoadObjectNull, test) { | 1719 ASSEMBLER_TEST_RUN(LoadObjectNull, test) { |
1725 ASSEMBLER_TEST_RUN_WITH_THREAD(RawObject*, result); | 1720 EXPECT_EQ(Object::null(), test->InvokeWithCodeAndThread<RawObject*>()); |
1726 EXPECT_EQ(Object::null(), result); | |
1727 } | 1721 } |
1728 | 1722 |
1729 | 1723 |
1730 ASSEMBLER_TEST_GENERATE(LoadObjectTrue, assembler) { | 1724 ASSEMBLER_TEST_GENERATE(LoadObjectTrue, assembler) { |
1731 __ SetupDartSP(kTestStackSpace); | 1725 __ SetupDartSP(kTestStackSpace); |
1732 EnterTestFrame(assembler); | 1726 EnterTestFrame(assembler); |
1733 __ Push(THR); | |
1734 __ mov(THR, R1); | |
1735 __ LoadObject(R0, Bool::True()); | 1727 __ LoadObject(R0, Bool::True()); |
1736 __ Pop(THR); | |
1737 LeaveTestFrame(assembler); | 1728 LeaveTestFrame(assembler); |
1738 __ mov(CSP, SP); | 1729 __ mov(CSP, SP); |
1739 __ ret(); | 1730 __ ret(); |
1740 } | 1731 } |
1741 | 1732 |
1742 | 1733 |
1743 ASSEMBLER_TEST_RUN(LoadObjectTrue, test) { | 1734 ASSEMBLER_TEST_RUN(LoadObjectTrue, test) { |
1744 ASSEMBLER_TEST_RUN_WITH_THREAD(RawObject*, result); | 1735 EXPECT_EQ(Bool::True().raw(), test->InvokeWithCodeAndThread<RawObject*>()); |
1745 EXPECT_EQ(Bool::True().raw(), result); | |
1746 } | 1736 } |
1747 | 1737 |
1748 | 1738 |
1749 ASSEMBLER_TEST_GENERATE(LoadObjectFalse, assembler) { | 1739 ASSEMBLER_TEST_GENERATE(LoadObjectFalse, assembler) { |
1750 __ SetupDartSP(kTestStackSpace); | 1740 __ SetupDartSP(kTestStackSpace); |
1751 EnterTestFrame(assembler); | 1741 EnterTestFrame(assembler); |
1752 __ Push(THR); | |
1753 __ mov(THR, R1); | |
1754 __ LoadObject(R0, Bool::False()); | 1742 __ LoadObject(R0, Bool::False()); |
1755 __ Pop(THR); | |
1756 LeaveTestFrame(assembler); | 1743 LeaveTestFrame(assembler); |
1757 __ mov(CSP, SP); | 1744 __ mov(CSP, SP); |
1758 __ ret(); | 1745 __ ret(); |
1759 } | 1746 } |
1760 | 1747 |
1761 | 1748 |
1762 ASSEMBLER_TEST_RUN(LoadObjectFalse, test) { | 1749 ASSEMBLER_TEST_RUN(LoadObjectFalse, test) { |
1763 ASSEMBLER_TEST_RUN_WITH_THREAD(RawObject*, result); | 1750 EXPECT_EQ(Bool::False().raw(), test->InvokeWithCodeAndThread<RawObject*>()); |
1764 EXPECT_EQ(Bool::False().raw(), result); | |
1765 } | 1751 } |
1766 | 1752 |
1767 | 1753 |
1768 ASSEMBLER_TEST_GENERATE(CSelTrue, assembler) { | 1754 ASSEMBLER_TEST_GENERATE(CSelTrue, assembler) { |
1769 __ LoadImmediate(R1, 42); | 1755 __ LoadImmediate(R1, 42); |
1770 __ LoadImmediate(R2, 1234); | 1756 __ LoadImmediate(R2, 1234); |
1771 __ CompareRegisters(R1, R2); | 1757 __ CompareRegisters(R1, R2); |
1772 __ csel(R0, R1, R2, LT); | 1758 __ csel(R0, R1, R2, LT); |
1773 __ ret(); | 1759 __ ret(); |
1774 } | 1760 } |
(...skipping 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3584 __ Pop(CODE_REG); | 3570 __ Pop(CODE_REG); |
3585 __ mov(CSP, SP); | 3571 __ mov(CSP, SP); |
3586 __ ret(); | 3572 __ ret(); |
3587 } | 3573 } |
3588 | 3574 |
3589 | 3575 |
3590 ASSEMBLER_TEST_GENERATE(ComputeRange, assembler) { | 3576 ASSEMBLER_TEST_GENERATE(ComputeRange, assembler) { |
3591 __ SetupDartSP(kTestStackSpace); | 3577 __ SetupDartSP(kTestStackSpace); |
3592 EnterTestFrame(assembler); | 3578 EnterTestFrame(assembler); |
3593 Label miss, done; | 3579 Label miss, done; |
3594 __ ComputeRange(R0, R1, R2, &miss); | 3580 __ ComputeRange(R0, R2, R3, &miss); |
3595 __ b(&done); | 3581 __ b(&done); |
3596 | 3582 |
3597 __ Bind(&miss); | 3583 __ Bind(&miss); |
3598 __ LoadImmediate(R0, -1); | 3584 __ LoadImmediate(R0, -1); |
3599 | 3585 |
3600 __ Bind(&done); | 3586 __ Bind(&done); |
3601 LeaveTestFrame(assembler); | 3587 LeaveTestFrame(assembler); |
3602 __ mov(CSP, SP); | 3588 __ mov(CSP, SP); |
3603 __ ret(); | 3589 __ ret(); |
3604 } | 3590 } |
3605 | 3591 |
3606 | 3592 |
3607 ASSEMBLER_TEST_RUN(ComputeRange, test) { | 3593 ASSEMBLER_TEST_RUN(ComputeRange, test) { |
3608 #define RANGE_OF(arg_type, v) test->InvokeWithCode<intptr_t, arg_type>(v) | 3594 #define RANGE_OF(arg_type, v) \ |
| 3595 test->InvokeWithCodeAndThread<intptr_t, arg_type>(v) |
3609 | 3596 |
3610 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(0))); | 3597 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(0))); |
3611 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(1))); | 3598 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(1))); |
3612 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(kMaxInt32))); | 3599 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(kMaxInt32))); |
3613 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, | 3600 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, |
3614 RANGE_OF(RawSmi*, Smi::New(-1))); | 3601 RANGE_OF(RawSmi*, Smi::New(-1))); |
3615 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, | 3602 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, |
3616 RANGE_OF(RawSmi*, Smi::New(kMinInt32))); | 3603 RANGE_OF(RawSmi*, Smi::New(kMinInt32))); |
3617 | 3604 |
3618 EXPECT_EQ(ICData::kUint32RangeBit, | 3605 EXPECT_EQ(ICData::kUint32RangeBit, |
(...skipping 24 matching lines...) Expand all Loading... |
3643 | 3630 |
3644 EXPECT_EQ(-1, RANGE_OF(RawBool*, Bool::True().raw())); | 3631 EXPECT_EQ(-1, RANGE_OF(RawBool*, Bool::True().raw())); |
3645 | 3632 |
3646 #undef RANGE_OF | 3633 #undef RANGE_OF |
3647 } | 3634 } |
3648 | 3635 |
3649 | 3636 |
3650 } // namespace dart | 3637 } // namespace dart |
3651 | 3638 |
3652 #endif // defined(TARGET_ARCH_ARM64) | 3639 #endif // defined(TARGET_ARCH_ARM64) |
OLD | NEW |