| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/assembler_macros.h" | 9 #include "vm/assembler_macros.h" |
| 10 #include "vm/code_generator.h" | 10 #include "vm/code_generator.h" |
| (...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1747 Label ic_cache_one_arg; | 1747 Label ic_cache_one_arg; |
| 1748 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset())); | 1748 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset())); |
| 1749 __ cmpq(RCX, Immediate(1)); | 1749 __ cmpq(RCX, Immediate(1)); |
| 1750 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump); | 1750 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump); |
| 1751 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel()); | 1751 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel()); |
| 1752 __ Bind(&ic_cache_one_arg); | 1752 __ Bind(&ic_cache_one_arg); |
| 1753 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); | 1753 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); |
| 1754 } | 1754 } |
| 1755 | 1755 |
| 1756 | 1756 |
| 1757 void StubCode::GenerateSubtype1TestCacheStub(Assembler* assembler) { | 1757 // Used to check class and type arguments. Arguments passed on stack: |
| 1758 __ Unimplemented("Subtype1TestCache Stub"); | 1758 // TOS + 0: return address. |
| 1759 // TOS + 1: instantiator type arguments (can be NULL). |
| 1760 // TOS + 2: instance. |
| 1761 // TOS + 3: SubtypeTestCache. |
| 1762 // Result in RCX: null -> not found, otherwise result (true or false). |
| 1763 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) { |
| 1764 ASSERT((1 <= n) && (n <= 3)); |
| 1765 const Immediate raw_null = |
| 1766 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1767 // const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; |
| 1768 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; |
| 1769 const intptr_t kCacheOffsetInBytes = 3 * kWordSize; |
| 1770 __ movq(RAX, Address(RSP, kInstanceOffsetInBytes)); |
| 1771 __ movq(R10, FieldAddress(RAX, Object::class_offset())); |
| 1772 // RAX: instance, R10: instance class. |
| 1773 if (n > 1) { |
| 1774 __ Unimplemented("GenerateSubtypeNTestCacheStub n > 1"); |
| 1775 } |
| 1776 // TODO(srdjan): R13: instance type arguments or null, used only if n > 1. |
| 1777 __ movq(RDX, Address(RSP, kCacheOffsetInBytes)); |
| 1778 // RDX: SubtypeTestCache. |
| 1779 __ movq(RDX, FieldAddress(RDX, SubtypeTestCache::cache_offset())); |
| 1780 __ addq(RDX, Immediate(Array::data_offset() - kHeapObjectTag)); |
| 1781 // RDX: Entry start. |
| 1782 // R10: instance class. |
| 1783 // R13: instance type arguments |
| 1784 Label loop, found, not_found, next_iteration; |
| 1785 __ Bind(&loop); |
| 1786 __ movq(RDI, Address(RDX, kWordSize * SubtypeTestCache::kInstanceClass)); |
| 1787 __ cmpq(RDI, raw_null); |
| 1788 __ j(EQUAL, ¬_found, Assembler::kNearJump); |
| 1789 __ cmpq(RDI, R10); |
| 1790 if (n == 1) { |
| 1791 __ j(EQUAL, &found, Assembler::kNearJump); |
| 1792 } else { |
| 1793 __ Unimplemented("GenerateSubtypeNTestCacheStub n > 1"); |
| 1794 } |
| 1795 |
| 1796 __ Bind(&next_iteration); |
| 1797 __ addq(RDX, Immediate(kWordSize * SubtypeTestCache::kTestEntryLength)); |
| 1798 __ jmp(&loop, Assembler::kNearJump); |
| 1799 // Fall through to not found. |
| 1800 __ Bind(¬_found); |
| 1801 __ movq(RCX, raw_null); |
| 1802 __ ret(); |
| 1803 |
| 1804 __ Bind(&found); |
| 1805 __ movq(RCX, Address(RDX, kWordSize * SubtypeTestCache::kTestResult)); |
| 1806 __ ret(); |
| 1759 } | 1807 } |
| 1760 | 1808 |
| 1761 | 1809 |
| 1762 void StubCode::GenerateSubtype2TestCacheStub(Assembler* assembler) { | 1810 // Used to check class and type arguments. Arguments passed on stack: |
| 1763 __ Unimplemented("Subtype2TestCache Stub"); | 1811 // TOS + 0: return address. |
| 1812 // TOS + 1: instantiator type arguments or NULL. |
| 1813 // TOS + 2: instance. |
| 1814 // TOS + 3: cache array. |
| 1815 // Result in RCX: null -> not found, otherwise result (true or false). |
| 1816 void StubCode::GenerateSubtype1TestCacheStub(Assembler* assembler) { |
| 1817 GenerateSubtypeNTestCacheStub(assembler, 1); |
| 1764 } | 1818 } |
| 1765 | 1819 |
| 1766 | 1820 |
| 1821 // Used to check class and type arguments. Arguments passed on stack: |
| 1822 // TOS + 0: return address. |
| 1823 // TOS + 1: instantiator type arguments or NULL. |
| 1824 // TOS + 2: instance. |
| 1825 // TOS + 3: cache array. |
| 1826 // Result in RCX: null -> not found, otherwise result (true or false). |
| 1827 void StubCode::GenerateSubtype2TestCacheStub(Assembler* assembler) { |
| 1828 GenerateSubtypeNTestCacheStub(assembler, 2); |
| 1829 } |
| 1830 |
| 1831 |
| 1832 // Used to check class and type arguments. Arguments passed on stack: |
| 1833 // TOS + 0: return address. |
| 1834 // TOS + 1: instantiator type arguments. |
| 1835 // TOS + 2: instance. |
| 1836 // TOS + 3: cache array. |
| 1837 // Result in RCX: null -> not found, otherwise result (true or false). |
| 1767 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { | 1838 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { |
| 1768 __ Unimplemented("Subtype3TestCache Stub"); | 1839 GenerateSubtypeNTestCacheStub(assembler, 3); |
| 1769 } | 1840 } |
| 1770 | 1841 |
| 1771 } // namespace dart | 1842 } // namespace dart |
| 1772 | 1843 |
| 1773 #endif // defined TARGET_ARCH_X64 | 1844 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |