| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/os.h" | 9 #include "vm/os.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1718 __ ret(); | 1718 __ ret(); |
| 1719 } | 1719 } |
| 1720 | 1720 |
| 1721 | 1721 |
| 1722 ASSEMBLER_TEST_RUN(TestObjectCompare, entry) { | 1722 ASSEMBLER_TEST_RUN(TestObjectCompare, entry) { |
| 1723 typedef bool (*TestObjectCompare)(); | 1723 typedef bool (*TestObjectCompare)(); |
| 1724 bool res = reinterpret_cast<TestObjectCompare>(entry)(); | 1724 bool res = reinterpret_cast<TestObjectCompare>(entry)(); |
| 1725 EXPECT_EQ(true, res); | 1725 EXPECT_EQ(true, res); |
| 1726 } | 1726 } |
| 1727 | 1727 |
| 1728 |
| 1729 ASSEMBLER_TEST_GENERATE(TestNop, assembler) { |
| 1730 __ nop(1); |
| 1731 __ nop(2); |
| 1732 __ nop(3); |
| 1733 __ nop(4); |
| 1734 __ nop(5); |
| 1735 __ nop(6); |
| 1736 __ nop(7); |
| 1737 __ nop(8); |
| 1738 __ movl(EAX, Immediate(assembler->CodeSize())); // Return code size. |
| 1739 __ ret(); |
| 1740 } |
| 1741 |
| 1742 |
| 1743 ASSEMBLER_TEST_RUN(TestNop, entry) { |
| 1744 typedef int (*TestNop)(); |
| 1745 int res = reinterpret_cast<TestNop>(entry)(); |
| 1746 EXPECT_EQ(36, res); // 36 nop bytes emitted. |
| 1747 } |
| 1748 |
| 1749 |
| 1750 ASSEMBLER_TEST_GENERATE(TestAlign0, assembler) { |
| 1751 __ Align(4, 0); |
| 1752 __ movl(EAX, Immediate(assembler->CodeSize())); // Return code size. |
| 1753 __ ret(); |
| 1754 } |
| 1755 |
| 1756 |
| 1757 ASSEMBLER_TEST_RUN(TestAlign0, entry) { |
| 1758 typedef int (*TestAlign0)(); |
| 1759 int res = reinterpret_cast<TestAlign0>(entry)(); |
| 1760 EXPECT_EQ(0, res); // 0 bytes emitted. |
| 1761 } |
| 1762 |
| 1763 |
| 1764 ASSEMBLER_TEST_GENERATE(TestAlign1, assembler) { |
| 1765 __ nop(1); |
| 1766 __ Align(4, 0); |
| 1767 __ movl(EAX, Immediate(assembler->CodeSize())); // Return code size. |
| 1768 __ ret(); |
| 1769 } |
| 1770 |
| 1771 |
| 1772 ASSEMBLER_TEST_RUN(TestAlign1, entry) { |
| 1773 typedef int (*TestAlign1)(); |
| 1774 int res = reinterpret_cast<TestAlign1>(entry)(); |
| 1775 EXPECT_EQ(4, res); // 4 bytes emitted. |
| 1776 } |
| 1777 |
| 1778 |
| 1779 ASSEMBLER_TEST_GENERATE(TestAlign1Offset1, assembler) { |
| 1780 __ nop(1); |
| 1781 __ Align(4, 1); |
| 1782 __ movl(EAX, Immediate(assembler->CodeSize())); // Return code size. |
| 1783 __ ret(); |
| 1784 } |
| 1785 |
| 1786 |
| 1787 ASSEMBLER_TEST_RUN(TestAlign1Offset1, entry) { |
| 1788 typedef int (*TestAlign1Offset1)(); |
| 1789 int res = reinterpret_cast<TestAlign1Offset1>(entry)(); |
| 1790 EXPECT_EQ(3, res); // 3 bytes emitted. |
| 1791 } |
| 1792 |
| 1793 |
| 1794 ASSEMBLER_TEST_GENERATE(TestAlignLarge, assembler) { |
| 1795 __ nop(1); |
| 1796 __ Align(16, 0); |
| 1797 __ movl(EAX, Immediate(assembler->CodeSize())); // Return code size. |
| 1798 __ ret(); |
| 1799 } |
| 1800 |
| 1801 |
| 1802 ASSEMBLER_TEST_RUN(TestAlignLarge, entry) { |
| 1803 typedef int (*TestAlignLarge)(); |
| 1804 int res = reinterpret_cast<TestAlignLarge>(entry)(); |
| 1805 EXPECT_EQ(16, res); // 16 bytes emitted. |
| 1806 } |
| 1807 |
| 1808 |
| 1728 } // namespace dart | 1809 } // namespace dart |
| 1729 | 1810 |
| 1730 #endif // defined TARGET_ARCH_IA32 | 1811 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |