Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Side by Side Diff: runtime/vm/assembler_arm64_test.cc

Issue 1192103004: VM: New calling convention for generated code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fixed comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/assembler_arm64.cc ('k') | runtime/vm/assembler_ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 __ ret(); 1615 __ ret();
1616 } 1616 }
1617 1617
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) {
1626 __ EnterFrame(0);
1627 __ Push(CODE_REG);
1628 __ TagAndPushPP();
1629 __ ldr(CODE_REG, Address(R0, VMHandles::kOffsetOfRawPtrInHandle));
1630 __ LoadPoolPointer(PP);
1631 }
1632
1633
1634 static void LeaveTestFrame(Assembler* assembler) {
1635 __ PopAndUntagPP();
1636 __ Pop(CODE_REG);
1637 __ LeaveFrame();
1638 }
1639
1640
1641
1642
1625 // Loading immediate values with the object pool. 1643 // Loading immediate values with the object pool.
1626 ASSEMBLER_TEST_GENERATE(LoadImmediatePPSmall, assembler) { 1644 ASSEMBLER_TEST_GENERATE(LoadImmediatePPSmall, assembler) {
1627 __ SetupDartSP(kTestStackSpace); 1645 __ SetupDartSP(kTestStackSpace);
1628 __ EnterStubFrame(); 1646 EnterTestFrame(assembler);
1629 __ LoadImmediate(R0, 42); 1647 __ LoadImmediate(R0, 42);
1630 __ LeaveStubFrame(); 1648 LeaveTestFrame(assembler);
1631 __ mov(CSP, SP); 1649 __ mov(CSP, SP);
1632 __ ret(); 1650 __ ret();
1633 } 1651 }
1634 1652
1635 1653
1636 ASSEMBLER_TEST_RUN(LoadImmediatePPSmall, test) { 1654 ASSEMBLER_TEST_RUN(LoadImmediatePPSmall, test) {
1637 EXPECT_EQ(42, test->Invoke<int64_t>()); 1655 EXPECT_EQ(42, test->InvokeWithCode<int64_t>());
1638 } 1656 }
1639 1657
1640 1658
1641 ASSEMBLER_TEST_GENERATE(LoadImmediatePPMed, assembler) { 1659 ASSEMBLER_TEST_GENERATE(LoadImmediatePPMed, assembler) {
1642 __ SetupDartSP(kTestStackSpace); 1660 __ SetupDartSP(kTestStackSpace);
1643 __ EnterStubFrame(); 1661 EnterTestFrame(assembler);
1644 __ LoadImmediate(R0, 0xf1234123); 1662 __ LoadImmediate(R0, 0xf1234123);
1645 __ LeaveStubFrame(); 1663 LeaveTestFrame(assembler);
1646 __ mov(CSP, SP); 1664 __ mov(CSP, SP);
1647 __ ret(); 1665 __ ret();
1648 } 1666 }
1649 1667
1650 1668
1651 ASSEMBLER_TEST_RUN(LoadImmediatePPMed, test) { 1669 ASSEMBLER_TEST_RUN(LoadImmediatePPMed, test) {
1652 EXPECT_EQ(0xf1234123, test->Invoke<int64_t>()); 1670 EXPECT_EQ(0xf1234123, test->InvokeWithCode<int64_t>());
1653 } 1671 }
1654 1672
1655 1673
1656 ASSEMBLER_TEST_GENERATE(LoadImmediatePPMed2, assembler) { 1674 ASSEMBLER_TEST_GENERATE(LoadImmediatePPMed2, assembler) {
1657 __ SetupDartSP(kTestStackSpace); 1675 __ SetupDartSP(kTestStackSpace);
1658 __ EnterStubFrame(); 1676 EnterTestFrame(assembler);
1659 __ LoadImmediate(R0, 0x4321f1234124); 1677 __ LoadImmediate(R0, 0x4321f1234124);
1660 __ LeaveStubFrame(); 1678 LeaveTestFrame(assembler);
1661 __ mov(CSP, SP); 1679 __ mov(CSP, SP);
1662 __ ret(); 1680 __ ret();
1663 } 1681 }
1664 1682
1665 1683
1666 ASSEMBLER_TEST_RUN(LoadImmediatePPMed2, test) { 1684 ASSEMBLER_TEST_RUN(LoadImmediatePPMed2, test) {
1667 EXPECT_EQ(0x4321f1234124, test->Invoke<int64_t>()); 1685 EXPECT_EQ(0x4321f1234124, test->InvokeWithCode<int64_t>());
1668 } 1686 }
1669 1687
1670 1688
1671 ASSEMBLER_TEST_GENERATE(LoadImmediatePPLarge, assembler) { 1689 ASSEMBLER_TEST_GENERATE(LoadImmediatePPLarge, assembler) {
1672 __ SetupDartSP(kTestStackSpace); 1690 __ SetupDartSP(kTestStackSpace);
1673 __ EnterStubFrame(); 1691 EnterTestFrame(assembler);
1674 __ LoadImmediate(R0, 0x9287436598237465); 1692 __ LoadImmediate(R0, 0x9287436598237465);
1675 __ LeaveStubFrame(); 1693 LeaveTestFrame(assembler);
1676 __ mov(CSP, SP); 1694 __ mov(CSP, SP);
1677 __ ret(); 1695 __ ret();
1678 } 1696 }
1679 1697
1680 1698
1681 ASSEMBLER_TEST_RUN(LoadImmediatePPLarge, test) { 1699 ASSEMBLER_TEST_RUN(LoadImmediatePPLarge, test) {
1682 EXPECT_EQ(static_cast<int64_t>(0x9287436598237465), test->Invoke<int64_t>()); 1700 EXPECT_EQ(static_cast<int64_t>(0x9287436598237465),
1701 test->InvokeWithCode<int64_t>());
1683 } 1702 }
1684 1703
1685 1704
1686 #define ASSEMBLER_TEST_RUN_WITH_THREAD(result_type, var_name) \ 1705 #define ASSEMBLER_TEST_RUN_WITH_THREAD(result_type, var_name) \
1687 Thread* thread = Thread::Current(); \ 1706 Thread* thread = Thread::Current(); \
1688 result_type var_name = test->Invoke<result_type>(thread); 1707 result_type var_name = test->InvokeWithCode<result_type>(thread);
1689 1708
1690 1709
1691 // LoadObject null. 1710 // LoadObject null.
1692 ASSEMBLER_TEST_GENERATE(LoadObjectNull, assembler) { 1711 ASSEMBLER_TEST_GENERATE(LoadObjectNull, assembler) {
1693 __ SetupDartSP(kTestStackSpace); 1712 __ SetupDartSP(kTestStackSpace);
1694 __ EnterStubFrame(); 1713 EnterTestFrame(assembler);
1695 __ Push(THR); 1714 __ Push(THR);
1696 __ mov(THR, R0); 1715 __ mov(THR, R1);
1697 __ LoadObject(R0, Object::null_object()); 1716 __ LoadObject(R0, Object::null_object());
1698 __ Pop(THR); 1717 __ Pop(THR);
1699 __ LeaveStubFrame(); 1718 LeaveTestFrame(assembler);
1700 __ mov(CSP, SP); 1719 __ mov(CSP, SP);
1701 __ ret(); 1720 __ ret();
1702 } 1721 }
1703 1722
1704 1723
1705 ASSEMBLER_TEST_RUN(LoadObjectNull, test) { 1724 ASSEMBLER_TEST_RUN(LoadObjectNull, test) {
1706 ASSEMBLER_TEST_RUN_WITH_THREAD(RawObject*, result); 1725 ASSEMBLER_TEST_RUN_WITH_THREAD(RawObject*, result);
1707 EXPECT_EQ(Object::null(), result); 1726 EXPECT_EQ(Object::null(), result);
1708 } 1727 }
1709 1728
1710 1729
1711 ASSEMBLER_TEST_GENERATE(LoadObjectTrue, assembler) { 1730 ASSEMBLER_TEST_GENERATE(LoadObjectTrue, assembler) {
1712 __ SetupDartSP(kTestStackSpace); 1731 __ SetupDartSP(kTestStackSpace);
1713 __ EnterStubFrame(); 1732 EnterTestFrame(assembler);
1714 __ Push(THR); 1733 __ Push(THR);
1715 __ mov(THR, R0); 1734 __ mov(THR, R1);
1716 __ LoadObject(R0, Bool::True()); 1735 __ LoadObject(R0, Bool::True());
1717 __ Pop(THR); 1736 __ Pop(THR);
1718 __ LeaveDartFrame(); 1737 LeaveTestFrame(assembler);
1719 __ mov(CSP, SP); 1738 __ mov(CSP, SP);
1720 __ ret(); 1739 __ ret();
1721 } 1740 }
1722 1741
1723 1742
1724 ASSEMBLER_TEST_RUN(LoadObjectTrue, test) { 1743 ASSEMBLER_TEST_RUN(LoadObjectTrue, test) {
1725 ASSEMBLER_TEST_RUN_WITH_THREAD(RawObject*, result); 1744 ASSEMBLER_TEST_RUN_WITH_THREAD(RawObject*, result);
1726 EXPECT_EQ(Bool::True().raw(), result); 1745 EXPECT_EQ(Bool::True().raw(), result);
1727 } 1746 }
1728 1747
1729 1748
1730 ASSEMBLER_TEST_GENERATE(LoadObjectFalse, assembler) { 1749 ASSEMBLER_TEST_GENERATE(LoadObjectFalse, assembler) {
1731 __ SetupDartSP(kTestStackSpace); 1750 __ SetupDartSP(kTestStackSpace);
1732 __ EnterStubFrame(); 1751 EnterTestFrame(assembler);
1733 __ Push(THR); 1752 __ Push(THR);
1734 __ mov(THR, R0); 1753 __ mov(THR, R1);
1735 __ LoadObject(R0, Bool::False()); 1754 __ LoadObject(R0, Bool::False());
1736 __ Pop(THR); 1755 __ Pop(THR);
1737 __ LeaveStubFrame(); 1756 LeaveTestFrame(assembler);
1738 __ mov(CSP, SP); 1757 __ mov(CSP, SP);
1739 __ ret(); 1758 __ ret();
1740 } 1759 }
1741 1760
1742 1761
1743 ASSEMBLER_TEST_RUN(LoadObjectFalse, test) { 1762 ASSEMBLER_TEST_RUN(LoadObjectFalse, test) {
1744 ASSEMBLER_TEST_RUN_WITH_THREAD(RawObject*, result); 1763 ASSEMBLER_TEST_RUN_WITH_THREAD(RawObject*, result);
1745 EXPECT_EQ(Bool::False().raw(), result); 1764 EXPECT_EQ(Bool::False().raw(), result);
1746 } 1765 }
1747 1766
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after
3546 } 3565 }
3547 3566
3548 3567
3549 // Called from assembler_test.cc. 3568 // Called from assembler_test.cc.
3550 // LR: return address. 3569 // LR: return address.
3551 // R0: value. 3570 // R0: value.
3552 // R1: growable array. 3571 // R1: growable array.
3553 // R2: current thread. 3572 // R2: current thread.
3554 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { 3573 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) {
3555 __ SetupDartSP(kTestStackSpace); 3574 __ SetupDartSP(kTestStackSpace);
3575 __ Push(CODE_REG);
3556 __ Push(THR); 3576 __ Push(THR);
3557 __ Push(LR); 3577 __ Push(LR);
3558 __ mov(THR, R2); 3578 __ mov(THR, R2);
3559 __ StoreIntoObject(R1, 3579 __ StoreIntoObject(R1,
3560 FieldAddress(R1, GrowableObjectArray::data_offset()), 3580 FieldAddress(R1, GrowableObjectArray::data_offset()),
3561 R0); 3581 R0);
3562 __ Pop(LR); 3582 __ Pop(LR);
3563 __ Pop(THR); 3583 __ Pop(THR);
3584 __ Pop(CODE_REG);
3564 __ mov(CSP, SP); 3585 __ mov(CSP, SP);
3565 __ ret(); 3586 __ ret();
3566 } 3587 }
3567 3588
3568 3589
3569 ASSEMBLER_TEST_GENERATE(ComputeRange, assembler) { 3590 ASSEMBLER_TEST_GENERATE(ComputeRange, assembler) {
3570 __ SetupDartSP(kTestStackSpace); 3591 __ SetupDartSP(kTestStackSpace);
3571 __ EnterStubFrame(); 3592 EnterTestFrame(assembler);
3572 Label miss, done; 3593 Label miss, done;
3573 __ mov(R1, R0);
3574 __ ComputeRange(R0, R1, R2, &miss); 3594 __ ComputeRange(R0, R1, R2, &miss);
3575 __ b(&done); 3595 __ b(&done);
3576 3596
3577 __ Bind(&miss); 3597 __ Bind(&miss);
3578 __ LoadImmediate(R0, -1); 3598 __ LoadImmediate(R0, -1);
3579 3599
3580 __ Bind(&done); 3600 __ Bind(&done);
3581 __ LeaveStubFrame(); 3601 LeaveTestFrame(assembler);
3582 __ mov(CSP, SP); 3602 __ mov(CSP, SP);
3583 __ ret(); 3603 __ ret();
3584 } 3604 }
3585 3605
3586 3606
3587 ASSEMBLER_TEST_RUN(ComputeRange, test) { 3607 ASSEMBLER_TEST_RUN(ComputeRange, test) {
3588 #define RANGE_OF(arg_type, v) test->Invoke<intptr_t, arg_type>(v) 3608 #define RANGE_OF(arg_type, v) test->InvokeWithCode<intptr_t, arg_type>(v)
3589 3609
3590 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(0))); 3610 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(0)));
3591 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(1))); 3611 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(1)));
3592 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(kMaxInt32))); 3612 EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(RawSmi*, Smi::New(kMaxInt32)));
3593 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, 3613 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit,
3594 RANGE_OF(RawSmi*, Smi::New(-1))); 3614 RANGE_OF(RawSmi*, Smi::New(-1)));
3595 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, 3615 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit,
3596 RANGE_OF(RawSmi*, Smi::New(kMinInt32))); 3616 RANGE_OF(RawSmi*, Smi::New(kMinInt32)));
3597 3617
3598 EXPECT_EQ(ICData::kUint32RangeBit, 3618 EXPECT_EQ(ICData::kUint32RangeBit,
(...skipping 24 matching lines...) Expand all
3623 3643
3624 EXPECT_EQ(-1, RANGE_OF(RawBool*, Bool::True().raw())); 3644 EXPECT_EQ(-1, RANGE_OF(RawBool*, Bool::True().raw()));
3625 3645
3626 #undef RANGE_OF 3646 #undef RANGE_OF
3627 } 3647 }
3628 3648
3629 3649
3630 } // namespace dart 3650 } // namespace dart
3631 3651
3632 #endif // defined(TARGET_ARCH_ARM64) 3652 #endif // defined(TARGET_ARCH_ARM64)
OLDNEW
« no previous file with comments | « runtime/vm/assembler_arm64.cc ('k') | runtime/vm/assembler_ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698