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 // Loading immediate values with the object pool. | 1625 // Loading immediate values with the object pool. |
1626 ASSEMBLER_TEST_GENERATE(LoadImmediatePPSmall, assembler) { | 1626 ASSEMBLER_TEST_GENERATE(LoadImmediatePPSmall, assembler) { |
1627 __ SetupDartSP(kTestStackSpace); | 1627 __ SetupDartSP(kTestStackSpace); |
1628 __ TagAndPushPP(); // Save caller's pool pointer and load a new one here. | 1628 __ EnterStubFrame(); |
1629 __ LoadPoolPointer(); | |
1630 __ LoadImmediate(R0, 42); | 1629 __ LoadImmediate(R0, 42); |
1631 __ PopAndUntagPP(); | 1630 __ LeaveStubFrame(); |
1632 __ mov(CSP, SP); | 1631 __ mov(CSP, SP); |
1633 __ ret(); | 1632 __ ret(); |
1634 } | 1633 } |
1635 | 1634 |
1636 | 1635 |
1637 ASSEMBLER_TEST_RUN(LoadImmediatePPSmall, test) { | 1636 ASSEMBLER_TEST_RUN(LoadImmediatePPSmall, test) { |
1638 typedef int64_t (*Int64Return)() DART_UNUSED; | 1637 EXPECT_EQ(42, test->Invoke<int64_t>()); |
1639 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | |
1640 } | 1638 } |
1641 | 1639 |
1642 | 1640 |
1643 ASSEMBLER_TEST_GENERATE(LoadImmediatePPMed, assembler) { | 1641 ASSEMBLER_TEST_GENERATE(LoadImmediatePPMed, assembler) { |
1644 __ SetupDartSP(kTestStackSpace); | 1642 __ SetupDartSP(kTestStackSpace); |
1645 __ TagAndPushPP(); // Save caller's pool pointer and load a new one here. | 1643 __ EnterStubFrame(); |
1646 __ LoadPoolPointer(); | |
1647 __ LoadImmediate(R0, 0xf1234123); | 1644 __ LoadImmediate(R0, 0xf1234123); |
1648 __ PopAndUntagPP(); | 1645 __ LeaveStubFrame(); |
1649 __ mov(CSP, SP); | 1646 __ mov(CSP, SP); |
1650 __ ret(); | 1647 __ ret(); |
1651 } | 1648 } |
1652 | 1649 |
1653 | 1650 |
1654 ASSEMBLER_TEST_RUN(LoadImmediatePPMed, test) { | 1651 ASSEMBLER_TEST_RUN(LoadImmediatePPMed, test) { |
1655 typedef int64_t (*Int64Return)() DART_UNUSED; | 1652 EXPECT_EQ(0xf1234123, test->Invoke<int64_t>()); |
1656 EXPECT_EQ(0xf1234123, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | |
1657 } | 1653 } |
1658 | 1654 |
1659 | 1655 |
1660 ASSEMBLER_TEST_GENERATE(LoadImmediatePPMed2, assembler) { | 1656 ASSEMBLER_TEST_GENERATE(LoadImmediatePPMed2, assembler) { |
1661 __ SetupDartSP(kTestStackSpace); | 1657 __ SetupDartSP(kTestStackSpace); |
1662 __ TagAndPushPP(); // Save caller's pool pointer and load a new one here. | 1658 __ EnterStubFrame(); |
1663 __ LoadPoolPointer(); | |
1664 __ LoadImmediate(R0, 0x4321f1234124); | 1659 __ LoadImmediate(R0, 0x4321f1234124); |
1665 __ PopAndUntagPP(); | 1660 __ LeaveStubFrame(); |
1666 __ mov(CSP, SP); | 1661 __ mov(CSP, SP); |
1667 __ ret(); | 1662 __ ret(); |
1668 } | 1663 } |
1669 | 1664 |
1670 | 1665 |
1671 ASSEMBLER_TEST_RUN(LoadImmediatePPMed2, test) { | 1666 ASSEMBLER_TEST_RUN(LoadImmediatePPMed2, test) { |
1672 typedef int64_t (*Int64Return)() DART_UNUSED; | 1667 EXPECT_EQ(0x4321f1234124, test->Invoke<int64_t>()); |
1673 EXPECT_EQ( | |
1674 0x4321f1234124, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | |
1675 } | 1668 } |
1676 | 1669 |
1677 | 1670 |
1678 ASSEMBLER_TEST_GENERATE(LoadImmediatePPLarge, assembler) { | 1671 ASSEMBLER_TEST_GENERATE(LoadImmediatePPLarge, assembler) { |
1679 __ SetupDartSP(kTestStackSpace); | 1672 __ SetupDartSP(kTestStackSpace); |
1680 __ TagAndPushPP(); // Save caller's pool pointer and load a new one here. | 1673 __ EnterStubFrame(); |
1681 __ LoadPoolPointer(); | |
1682 __ LoadImmediate(R0, 0x9287436598237465); | 1674 __ LoadImmediate(R0, 0x9287436598237465); |
1683 __ PopAndUntagPP(); | 1675 __ LeaveStubFrame(); |
1684 __ mov(CSP, SP); | 1676 __ mov(CSP, SP); |
1685 __ ret(); | 1677 __ ret(); |
1686 } | 1678 } |
1687 | 1679 |
1688 | 1680 |
1689 ASSEMBLER_TEST_RUN(LoadImmediatePPLarge, test) { | 1681 ASSEMBLER_TEST_RUN(LoadImmediatePPLarge, test) { |
1690 typedef int64_t (*Int64Return)() DART_UNUSED; | 1682 EXPECT_EQ(static_cast<int64_t>(0x9287436598237465), test->Invoke<int64_t>()); |
1691 EXPECT_EQ(static_cast<int64_t>(0x9287436598237465), | |
1692 EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | |
1693 } | 1683 } |
1694 | 1684 |
1695 | 1685 |
1696 #if defined(USING_SIMULATOR) | 1686 #define ASSEMBLER_TEST_RUN_WITH_THREAD(result_type, var_name) \ |
1697 #define ASSEMBLER_TEST_RUN_WITH_THREAD(var_name) \ | |
1698 Thread* thread = Thread::Current(); \ | 1687 Thread* thread = Thread::Current(); \ |
1699 int64_t var_name = Simulator::Current()->Call( \ | 1688 result_type var_name = test->Invoke<result_type>(thread); |
1700 bit_cast<intptr_t, uword>(test->entry()), \ | |
1701 reinterpret_cast<intptr_t>(thread), 0, 0, 0) | |
1702 #else | |
1703 #define ASSEMBLER_TEST_RUN_WITH_THREAD(var_name) \ | |
1704 Thread* thread = Thread::Current(); \ | |
1705 typedef int64_t (*Int64Return)(Thread* thread); \ | |
1706 Int64Return test_code = reinterpret_cast<Int64Return>(test->entry()); \ | |
1707 int64_t var_name = test_code(thread) | |
1708 #endif | |
1709 | 1689 |
1710 | 1690 |
1711 // LoadObject null. | 1691 // LoadObject null. |
1712 ASSEMBLER_TEST_GENERATE(LoadObjectNull, assembler) { | 1692 ASSEMBLER_TEST_GENERATE(LoadObjectNull, assembler) { |
1713 __ SetupDartSP(kTestStackSpace); | 1693 __ SetupDartSP(kTestStackSpace); |
| 1694 __ EnterStubFrame(); |
1714 __ Push(THR); | 1695 __ Push(THR); |
1715 __ mov(THR, R0); | 1696 __ mov(THR, R0); |
1716 __ TagAndPushPP(); // Save caller's pool pointer and load a new one here. | |
1717 __ LoadPoolPointer(); | |
1718 __ LoadObject(R0, Object::null_object()); | 1697 __ LoadObject(R0, Object::null_object()); |
1719 __ PopAndUntagPP(); | |
1720 __ Pop(THR); | 1698 __ Pop(THR); |
| 1699 __ LeaveStubFrame(); |
1721 __ mov(CSP, SP); | 1700 __ mov(CSP, SP); |
1722 __ ret(); | 1701 __ ret(); |
1723 } | 1702 } |
1724 | 1703 |
1725 | 1704 |
1726 ASSEMBLER_TEST_RUN(LoadObjectNull, test) { | 1705 ASSEMBLER_TEST_RUN(LoadObjectNull, test) { |
1727 ASSEMBLER_TEST_RUN_WITH_THREAD(result); | 1706 ASSEMBLER_TEST_RUN_WITH_THREAD(RawObject*, result); |
1728 EXPECT_EQ(reinterpret_cast<int64_t>(Object::null()), result); | 1707 EXPECT_EQ(Object::null(), result); |
1729 } | 1708 } |
1730 | 1709 |
1731 | 1710 |
1732 ASSEMBLER_TEST_GENERATE(LoadObjectTrue, assembler) { | 1711 ASSEMBLER_TEST_GENERATE(LoadObjectTrue, assembler) { |
1733 __ SetupDartSP(kTestStackSpace); | 1712 __ SetupDartSP(kTestStackSpace); |
| 1713 __ EnterStubFrame(); |
1734 __ Push(THR); | 1714 __ Push(THR); |
1735 __ mov(THR, R0); | 1715 __ mov(THR, R0); |
1736 __ TagAndPushPP(); // Save caller's pool pointer and load a new one here. | |
1737 __ LoadPoolPointer(); | |
1738 __ LoadObject(R0, Bool::True()); | 1716 __ LoadObject(R0, Bool::True()); |
1739 __ PopAndUntagPP(); | |
1740 __ Pop(THR); | 1717 __ Pop(THR); |
| 1718 __ LeaveDartFrame(); |
1741 __ mov(CSP, SP); | 1719 __ mov(CSP, SP); |
1742 __ ret(); | 1720 __ ret(); |
1743 } | 1721 } |
1744 | 1722 |
1745 | 1723 |
1746 ASSEMBLER_TEST_RUN(LoadObjectTrue, test) { | 1724 ASSEMBLER_TEST_RUN(LoadObjectTrue, test) { |
1747 ASSEMBLER_TEST_RUN_WITH_THREAD(result); | 1725 ASSEMBLER_TEST_RUN_WITH_THREAD(RawObject*, result); |
1748 EXPECT_EQ(reinterpret_cast<int64_t>(Bool::True().raw()), result); | 1726 EXPECT_EQ(Bool::True().raw(), result); |
1749 } | 1727 } |
1750 | 1728 |
1751 | 1729 |
1752 ASSEMBLER_TEST_GENERATE(LoadObjectFalse, assembler) { | 1730 ASSEMBLER_TEST_GENERATE(LoadObjectFalse, assembler) { |
1753 __ SetupDartSP(kTestStackSpace); | 1731 __ SetupDartSP(kTestStackSpace); |
| 1732 __ EnterStubFrame(); |
1754 __ Push(THR); | 1733 __ Push(THR); |
1755 __ mov(THR, R0); | 1734 __ mov(THR, R0); |
1756 __ TagAndPushPP(); // Save caller's pool pointer and load a new one here. | |
1757 __ LoadPoolPointer(); | |
1758 __ LoadObject(R0, Bool::False()); | 1735 __ LoadObject(R0, Bool::False()); |
1759 __ PopAndUntagPP(); | |
1760 __ Pop(THR); | 1736 __ Pop(THR); |
| 1737 __ LeaveStubFrame(); |
1761 __ mov(CSP, SP); | 1738 __ mov(CSP, SP); |
1762 __ ret(); | 1739 __ ret(); |
1763 } | 1740 } |
1764 | 1741 |
1765 | 1742 |
1766 ASSEMBLER_TEST_RUN(LoadObjectFalse, test) { | 1743 ASSEMBLER_TEST_RUN(LoadObjectFalse, test) { |
1767 ASSEMBLER_TEST_RUN_WITH_THREAD(result); | 1744 ASSEMBLER_TEST_RUN_WITH_THREAD(RawObject*, result); |
1768 EXPECT_EQ(reinterpret_cast<int64_t>(Bool::False().raw()), result); | 1745 EXPECT_EQ(Bool::False().raw(), result); |
1769 } | 1746 } |
1770 | 1747 |
1771 | 1748 |
1772 ASSEMBLER_TEST_GENERATE(CSelTrue, assembler) { | 1749 ASSEMBLER_TEST_GENERATE(CSelTrue, assembler) { |
1773 __ LoadImmediate(R1, 42); | 1750 __ LoadImmediate(R1, 42); |
1774 __ LoadImmediate(R2, 1234); | 1751 __ LoadImmediate(R2, 1234); |
1775 __ CompareRegisters(R1, R2); | 1752 __ CompareRegisters(R1, R2); |
1776 __ csel(R0, R1, R2, LT); | 1753 __ csel(R0, R1, R2, LT); |
1777 __ ret(); | 1754 __ ret(); |
1778 } | 1755 } |
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3569 } | 3546 } |
3570 | 3547 |
3571 | 3548 |
3572 // Called from assembler_test.cc. | 3549 // Called from assembler_test.cc. |
3573 // LR: return address. | 3550 // LR: return address. |
3574 // R0: value. | 3551 // R0: value. |
3575 // R1: growable array. | 3552 // R1: growable array. |
3576 // R2: current thread. | 3553 // R2: current thread. |
3577 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { | 3554 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { |
3578 __ SetupDartSP(kTestStackSpace); | 3555 __ SetupDartSP(kTestStackSpace); |
3579 __ TagAndPushPP(); | |
3580 __ LoadPoolPointer(); | |
3581 __ Push(THR); | 3556 __ Push(THR); |
3582 __ Push(LR); | 3557 __ Push(LR); |
3583 __ mov(THR, R2); | 3558 __ mov(THR, R2); |
3584 __ StoreIntoObject(R1, | 3559 __ StoreIntoObject(R1, |
3585 FieldAddress(R1, GrowableObjectArray::data_offset()), | 3560 FieldAddress(R1, GrowableObjectArray::data_offset()), |
3586 R0); | 3561 R0); |
3587 __ Pop(LR); | 3562 __ Pop(LR); |
3588 __ Pop(THR); | 3563 __ Pop(THR); |
3589 __ PopAndUntagPP(); | |
3590 __ mov(CSP, SP); | 3564 __ mov(CSP, SP); |
3591 __ ret(); | 3565 __ ret(); |
3592 } | 3566 } |
3593 | 3567 |
3594 | 3568 |
3595 ASSEMBLER_TEST_GENERATE(ComputeRange, assembler) { | 3569 ASSEMBLER_TEST_GENERATE(ComputeRange, assembler) { |
3596 __ SetupDartSP(kTestStackSpace); | 3570 __ SetupDartSP(kTestStackSpace); |
3597 __ TagAndPushPP(); | 3571 __ EnterStubFrame(); |
3598 __ LoadPoolPointer(); | |
3599 Label miss, done; | 3572 Label miss, done; |
3600 __ mov(R1, R0); | 3573 __ mov(R1, R0); |
3601 __ ComputeRange(R0, R1, R2, &miss); | 3574 __ ComputeRange(R0, R1, R2, &miss); |
3602 __ b(&done); | 3575 __ b(&done); |
3603 | 3576 |
3604 __ Bind(&miss); | 3577 __ Bind(&miss); |
3605 __ LoadImmediate(R0, -1); | 3578 __ LoadImmediate(R0, -1); |
3606 | 3579 |
3607 __ Bind(&done); | 3580 __ Bind(&done); |
3608 __ PopAndUntagPP(); | 3581 __ LeaveStubFrame(); |
3609 __ mov(CSP, SP); | 3582 __ mov(CSP, SP); |
3610 __ ret(); | 3583 __ ret(); |
3611 } | 3584 } |
3612 | 3585 |
3613 | 3586 |
3614 ASSEMBLER_TEST_RUN(ComputeRange, test) { | 3587 ASSEMBLER_TEST_RUN(ComputeRange, test) { |
3615 typedef intptr_t (*ComputeRange)(intptr_t value) DART_UNUSED; | 3588 #define RANGE_OF(arg_type, v) test->Invoke<intptr_t, arg_type>(v) |
3616 | 3589 |
3617 #define RANGE_OF(v) \ | 3590 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(0))); |
3618 (EXECUTE_TEST_CODE_INTPTR_INTPTR( \ | 3591 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(1))); |
3619 ComputeRange, test->entry(), reinterpret_cast<intptr_t>(v))) | 3592 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(kMaxInt32))); |
3620 | |
3621 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(Smi::New(0))); | |
3622 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(Smi::New(1))); | |
3623 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(Smi::New(kMaxInt32))); | |
3624 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, | 3593 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, |
3625 RANGE_OF(Smi::New(-1))); | 3594 RANGE_OF(RawSmi*, Smi::New(-1))); |
3626 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, | 3595 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, |
3627 RANGE_OF(Smi::New(kMinInt32))); | 3596 RANGE_OF(RawSmi*, Smi::New(kMinInt32))); |
3628 | 3597 |
3629 EXPECT_EQ(ICData::kUint32RangeBit, | 3598 EXPECT_EQ(ICData::kUint32RangeBit, |
3630 RANGE_OF(Smi::New(static_cast<int64_t>(kMaxInt32) + 1))); | 3599 RANGE_OF(RawSmi*, Smi::New(static_cast<int64_t>(kMaxInt32) + 1))); |
3631 EXPECT_EQ(ICData::kUint32RangeBit, | 3600 EXPECT_EQ(ICData::kUint32RangeBit, |
3632 RANGE_OF(Smi::New(kMaxUint32))); | 3601 RANGE_OF(RawSmi*, Smi::New(kMaxUint32))); |
3633 | 3602 |
3634 // On 64-bit platforms we don't track the sign of the smis outside of | 3603 // On 64-bit platforms we don't track the sign of the smis outside of |
3635 // int32 range because it is not needed to distinguish kInt32Range from | 3604 // int32 range because it is not needed to distinguish kInt32Range from |
3636 // kUint32Range. | 3605 // kUint32Range. |
3637 EXPECT_EQ(ICData::kSignedRangeBit, | 3606 EXPECT_EQ(ICData::kSignedRangeBit, |
3638 RANGE_OF(Smi::New(static_cast<int64_t>(kMinInt32) - 1))); | 3607 RANGE_OF(RawSmi*, Smi::New(static_cast<int64_t>(kMinInt32) - 1))); |
3639 EXPECT_EQ(ICData::kSignedRangeBit, | 3608 EXPECT_EQ(ICData::kSignedRangeBit, |
3640 RANGE_OF(Smi::New(static_cast<int64_t>(kMaxUint32) + 1))); | 3609 RANGE_OF(RawSmi*, Smi::New(static_cast<int64_t>(kMaxUint32) + 1))); |
3641 EXPECT_EQ(ICData::kSignedRangeBit, RANGE_OF(Smi::New(Smi::kMaxValue))); | 3610 EXPECT_EQ(ICData::kSignedRangeBit, |
3642 EXPECT_EQ(ICData::kSignedRangeBit, RANGE_OF(Smi::New(Smi::kMinValue))); | 3611 RANGE_OF(RawSmi*, Smi::New(Smi::kMaxValue))); |
| 3612 EXPECT_EQ(ICData::kSignedRangeBit, RANGE_OF(RawSmi*, |
| 3613 Smi::New(Smi::kMinValue))); |
3643 | 3614 |
3644 EXPECT_EQ(ICData::kInt64RangeBit, RANGE_OF(Integer::New(Smi::kMaxValue + 1))); | 3615 EXPECT_EQ(ICData::kInt64RangeBit, |
3645 EXPECT_EQ(ICData::kInt64RangeBit, RANGE_OF(Integer::New(Smi::kMinValue - 1))); | 3616 RANGE_OF(RawInteger*, Integer::New(Smi::kMaxValue + 1))); |
3646 EXPECT_EQ(ICData::kInt64RangeBit, RANGE_OF(Integer::New(kMaxInt64))); | 3617 EXPECT_EQ(ICData::kInt64RangeBit, |
3647 EXPECT_EQ(ICData::kInt64RangeBit, RANGE_OF(Integer::New(kMinInt64))); | 3618 RANGE_OF(RawInteger*, Integer::New(Smi::kMinValue - 1))); |
| 3619 EXPECT_EQ(ICData::kInt64RangeBit, |
| 3620 RANGE_OF(RawInteger*, Integer::New(kMaxInt64))); |
| 3621 EXPECT_EQ(ICData::kInt64RangeBit, |
| 3622 RANGE_OF(RawInteger*, Integer::New(kMinInt64))); |
3648 | 3623 |
3649 EXPECT_EQ(-1, RANGE_OF(Bool::True().raw())); | 3624 EXPECT_EQ(-1, RANGE_OF(RawBool*, Bool::True().raw())); |
3650 | 3625 |
3651 #undef RANGE_OF | 3626 #undef RANGE_OF |
3652 } | 3627 } |
3653 | 3628 |
3654 | 3629 |
3655 } // namespace dart | 3630 } // namespace dart |
3656 | 3631 |
3657 #endif // defined(TARGET_ARCH_ARM64) | 3632 #endif // defined(TARGET_ARCH_ARM64) |
OLD | NEW |