| 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_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 __ Bind(&stepping); | 1722 __ Bind(&stepping); |
| 1723 __ EnterStubFrame(); | 1723 __ EnterStubFrame(); |
| 1724 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1724 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
| 1725 __ LeaveStubFrame(); | 1725 __ LeaveStubFrame(); |
| 1726 __ jmp(&done_stepping, Assembler::kNearJump); | 1726 __ jmp(&done_stepping, Assembler::kNearJump); |
| 1727 } | 1727 } |
| 1728 | 1728 |
| 1729 | 1729 |
| 1730 // Used to check class and type arguments. Arguments passed on stack: | 1730 // Used to check class and type arguments. Arguments passed on stack: |
| 1731 // TOS + 0: return address. | 1731 // TOS + 0: return address. |
| 1732 // TOS + 1: instantiator type arguments (can be NULL). | 1732 // TOS + 1: function type arguments (only if n == 4, can be raw_null). |
| 1733 // TOS + 2: instance. | 1733 // TOS + 2: instantiator type arguments (only if n == 4, can be raw_null). |
| 1734 // TOS + 3: SubtypeTestCache. | 1734 // TOS + 3: instance. |
| 1735 // TOS + 4: SubtypeTestCache. |
| 1735 // Result in RCX: null -> not found, otherwise result (true or false). | 1736 // Result in RCX: null -> not found, otherwise result (true or false). |
| 1736 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) { | 1737 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) { |
| 1737 ASSERT((1 <= n) && (n <= 3)); | 1738 ASSERT((n == 1) || (n == 2) || (n == 4)); |
| 1738 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; | 1739 const intptr_t kFunctionTypeArgumentsInBytes = 1 * kWordSize; |
| 1739 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; | 1740 const intptr_t kInstantiatorTypeArgumentsInBytes = 2 * kWordSize; |
| 1740 const intptr_t kCacheOffsetInBytes = 3 * kWordSize; | 1741 const intptr_t kInstanceOffsetInBytes = 3 * kWordSize; |
| 1742 const intptr_t kCacheOffsetInBytes = 4 * kWordSize; |
| 1741 __ movq(RAX, Address(RSP, kInstanceOffsetInBytes)); | 1743 __ movq(RAX, Address(RSP, kInstanceOffsetInBytes)); |
| 1742 __ LoadObject(R9, Object::null_object()); | 1744 __ LoadObject(R9, Object::null_object()); |
| 1743 if (n > 1) { | 1745 if (n > 1) { |
| 1744 __ LoadClass(R10, RAX); | 1746 __ LoadClass(R10, RAX); |
| 1745 // Compute instance type arguments into R13. | 1747 // Compute instance type arguments into R13. |
| 1746 Label has_no_type_arguments; | 1748 Label has_no_type_arguments; |
| 1747 __ movq(R13, R9); | 1749 __ movq(R13, R9); |
| 1748 __ movl(RDI, | 1750 __ movl(RDI, |
| 1749 FieldAddress(R10, | 1751 FieldAddress(R10, |
| 1750 Class::type_arguments_field_offset_in_words_offset())); | 1752 Class::type_arguments_field_offset_in_words_offset())); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1784 Address(RDX, kWordSize * SubtypeTestCache::kInstanceTypeArguments)); | 1786 Address(RDX, kWordSize * SubtypeTestCache::kInstanceTypeArguments)); |
| 1785 __ cmpq(RDI, R13); | 1787 __ cmpq(RDI, R13); |
| 1786 if (n == 2) { | 1788 if (n == 2) { |
| 1787 __ j(EQUAL, &found, Assembler::kNearJump); | 1789 __ j(EQUAL, &found, Assembler::kNearJump); |
| 1788 } else { | 1790 } else { |
| 1789 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); | 1791 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); |
| 1790 __ movq(RDI, | 1792 __ movq(RDI, |
| 1791 Address(RDX, kWordSize * | 1793 Address(RDX, kWordSize * |
| 1792 SubtypeTestCache::kInstantiatorTypeArguments)); | 1794 SubtypeTestCache::kInstantiatorTypeArguments)); |
| 1793 __ cmpq(RDI, Address(RSP, kInstantiatorTypeArgumentsInBytes)); | 1795 __ cmpq(RDI, Address(RSP, kInstantiatorTypeArgumentsInBytes)); |
| 1796 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); |
| 1797 __ movq(RDI, Address(RDX, kWordSize * |
| 1798 SubtypeTestCache::kFunctionTypeArguments)); |
| 1799 __ cmpq(RDI, Address(RSP, kFunctionTypeArgumentsInBytes)); |
| 1794 __ j(EQUAL, &found, Assembler::kNearJump); | 1800 __ j(EQUAL, &found, Assembler::kNearJump); |
| 1795 } | 1801 } |
| 1796 } | 1802 } |
| 1797 | 1803 |
| 1798 __ Bind(&next_iteration); | 1804 __ Bind(&next_iteration); |
| 1799 __ addq(RDX, Immediate(kWordSize * SubtypeTestCache::kTestEntryLength)); | 1805 __ addq(RDX, Immediate(kWordSize * SubtypeTestCache::kTestEntryLength)); |
| 1800 __ jmp(&loop, Assembler::kNearJump); | 1806 __ jmp(&loop, Assembler::kNearJump); |
| 1801 // Fall through to not found. | 1807 // Fall through to not found. |
| 1802 __ Bind(¬_found); | 1808 __ Bind(¬_found); |
| 1803 __ movq(RCX, R9); | 1809 __ movq(RCX, R9); |
| 1804 __ ret(); | 1810 __ ret(); |
| 1805 | 1811 |
| 1806 __ Bind(&found); | 1812 __ Bind(&found); |
| 1807 __ movq(RCX, Address(RDX, kWordSize * SubtypeTestCache::kTestResult)); | 1813 __ movq(RCX, Address(RDX, kWordSize * SubtypeTestCache::kTestResult)); |
| 1808 __ ret(); | 1814 __ ret(); |
| 1809 } | 1815 } |
| 1810 | 1816 |
| 1811 | 1817 |
| 1812 // Used to check class and type arguments. Arguments passed on stack: | 1818 // Used to check class and type arguments. Arguments passed on stack: |
| 1813 // TOS + 0: return address. | 1819 // TOS + 0: return address. |
| 1814 // TOS + 1: instantiator type arguments or NULL. | 1820 // TOS + 1: raw_null. |
| 1815 // TOS + 2: instance. | 1821 // TOS + 2: raw_null. |
| 1816 // TOS + 3: cache array. | 1822 // TOS + 3: instance. |
| 1823 // TOS + 4: SubtypeTestCache. |
| 1817 // Result in RCX: null -> not found, otherwise result (true or false). | 1824 // Result in RCX: null -> not found, otherwise result (true or false). |
| 1818 void StubCode::GenerateSubtype1TestCacheStub(Assembler* assembler) { | 1825 void StubCode::GenerateSubtype1TestCacheStub(Assembler* assembler) { |
| 1819 GenerateSubtypeNTestCacheStub(assembler, 1); | 1826 GenerateSubtypeNTestCacheStub(assembler, 1); |
| 1820 } | 1827 } |
| 1821 | 1828 |
| 1822 | 1829 |
| 1823 // Used to check class and type arguments. Arguments passed on stack: | 1830 // Used to check class and type arguments. Arguments passed on stack: |
| 1824 // TOS + 0: return address. | 1831 // TOS + 0: return address. |
| 1825 // TOS + 1: instantiator type arguments or NULL. | 1832 // TOS + 1: raw_null. |
| 1826 // TOS + 2: instance. | 1833 // TOS + 2: raw_null. |
| 1827 // TOS + 3: cache array. | 1834 // TOS + 3: instance. |
| 1835 // TOS + 4: SubtypeTestCache. |
| 1828 // Result in RCX: null -> not found, otherwise result (true or false). | 1836 // Result in RCX: null -> not found, otherwise result (true or false). |
| 1829 void StubCode::GenerateSubtype2TestCacheStub(Assembler* assembler) { | 1837 void StubCode::GenerateSubtype2TestCacheStub(Assembler* assembler) { |
| 1830 GenerateSubtypeNTestCacheStub(assembler, 2); | 1838 GenerateSubtypeNTestCacheStub(assembler, 2); |
| 1831 } | 1839 } |
| 1832 | 1840 |
| 1833 | 1841 |
| 1834 // Used to check class and type arguments. Arguments passed on stack: | 1842 // Used to check class and type arguments. Arguments passed on stack: |
| 1835 // TOS + 0: return address. | 1843 // TOS + 0: return address. |
| 1836 // TOS + 1: instantiator type arguments. | 1844 // TOS + 1: function type arguments (can be raw_null). |
| 1837 // TOS + 2: instance. | 1845 // TOS + 2: instantiator type arguments (can be raw_null). |
| 1838 // TOS + 3: cache array. | 1846 // TOS + 3: instance. |
| 1847 // TOS + 4: SubtypeTestCache. |
| 1839 // Result in RCX: null -> not found, otherwise result (true or false). | 1848 // Result in RCX: null -> not found, otherwise result (true or false). |
| 1840 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { | 1849 void StubCode::GenerateSubtype4TestCacheStub(Assembler* assembler) { |
| 1841 GenerateSubtypeNTestCacheStub(assembler, 3); | 1850 GenerateSubtypeNTestCacheStub(assembler, 4); |
| 1842 } | 1851 } |
| 1843 | 1852 |
| 1844 | 1853 |
| 1845 // Return the current stack pointer address, used to stack alignment | 1854 // Return the current stack pointer address, used to stack alignment |
| 1846 // checks. | 1855 // checks. |
| 1847 // TOS + 0: return address | 1856 // TOS + 0: return address |
| 1848 // Result in RAX. | 1857 // Result in RAX. |
| 1849 void StubCode::GenerateGetStackPointerStub(Assembler* assembler) { | 1858 void StubCode::GenerateGetStackPointerStub(Assembler* assembler) { |
| 1850 __ leaq(RAX, Address(RSP, kWordSize)); | 1859 __ leaq(RAX, Address(RSP, kWordSize)); |
| 1851 __ ret(); | 1860 __ ret(); |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2285 } | 2294 } |
| 2286 | 2295 |
| 2287 | 2296 |
| 2288 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { | 2297 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { |
| 2289 __ int3(); | 2298 __ int3(); |
| 2290 } | 2299 } |
| 2291 | 2300 |
| 2292 } // namespace dart | 2301 } // namespace dart |
| 2293 | 2302 |
| 2294 #endif // defined TARGET_ARCH_X64 | 2303 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |