| 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/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1790 __ movl(ECX, FieldAddress(ECX, Class::super_type_offset())); | 1790 __ movl(ECX, FieldAddress(ECX, Class::super_type_offset())); |
| 1791 // The supertype of Object is a null object. | 1791 // The supertype of Object is a null object. |
| 1792 __ cmpl(ECX, raw_null); | 1792 __ cmpl(ECX, raw_null); |
| 1793 __ j(EQUAL, ¬_found, Assembler::kNearJump); | 1793 __ j(EQUAL, ¬_found, Assembler::kNearJump); |
| 1794 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); | 1794 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); |
| 1795 __ cmpl(EDX, ECX); | 1795 __ cmpl(EDX, ECX); |
| 1796 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); | 1796 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); |
| 1797 __ jmp(&found, Assembler::kNearJump); | 1797 __ jmp(&found, Assembler::kNearJump); |
| 1798 } | 1798 } |
| 1799 | 1799 |
| 1800 |
| 1801 // Used to check class and type arguments. Arguments passed on stack: |
| 1802 // TOS + 0: return address |
| 1803 // TOS + 1: instantiator type arguments |
| 1804 // TOS + 2: instance |
| 1805 // TOS + 3: cache array. |
| 1806 // Result in ECX: null -> not found, otherwise result. |
| 1807 void StubCode::GenerateSubtypeTestCacheStub(Assembler* assembler) { |
| 1808 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; |
| 1809 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; |
| 1810 const intptr_t kCacheArrayOffsetInBytes = 3 * kWordSize; |
| 1811 const Immediate raw_null = |
| 1812 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1813 |
| 1814 __ movl(EAX, Address(ESP, kInstanceOffsetInBytes)); |
| 1815 __ movl(ECX, FieldAddress(EAX, Object::class_offset())); |
| 1816 // EAX: instance, ECX: instance-class. |
| 1817 // Get instance type arguments |
| 1818 Label has_no_type_arguments; |
| 1819 __ movl(EBX, raw_null); |
| 1820 __ movl(EDI, FieldAddress(ECX, |
| 1821 Class::type_arguments_instance_field_offset_offset())); |
| 1822 __ cmpl(EDI, Immediate(Class::kNoTypeArguments)); |
| 1823 __ j(EQUAL, &has_no_type_arguments, Assembler::kNearJump); |
| 1824 __ movl(EBX, FieldAddress(EAX, EDI, TIMES_1, 0)); |
| 1825 __ Bind(&has_no_type_arguments); |
| 1826 // EBX: instance type arguments (null if none). |
| 1827 __ movl(EDX, Address(ESP, kCacheArrayOffsetInBytes)); |
| 1828 // EDX: cache. |
| 1829 __ addl(EDX, Immediate(Array::data_offset() - kHeapObjectTag)); |
| 1830 Label loop, found, not_found, next_iteration; |
| 1831 // EDX: Entry start. |
| 1832 // ECX: instance class. |
| 1833 // EBX: instance type arguments |
| 1834 // TOS + 2: test-type-class. |
| 1835 // TOS + 1: test-type-arguments. |
| 1836 __ Bind(&loop); |
| 1837 __ movl(EDI, Address(EDX, kWordSize * SubTypeTestCache::kInstanceClass)); |
| 1838 __ cmpl(EDI, ECX); |
| 1839 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); |
| 1840 __ movl(EDI, |
| 1841 Address(EDX, kWordSize * SubTypeTestCache::kInstanceTypeArguments)); |
| 1842 __ cmpl(EDI, EBX); |
| 1843 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); |
| 1844 __ movl(EDI, |
| 1845 Address(EDX, kWordSize * |
| 1846 SubTypeTestCache::kInstantiatorTypeArguments)); |
| 1847 __ cmpl(EDI, Address(ESP, kInstantiatorTypeArgumentsInBytes)); |
| 1848 __ j(EQUAL, &found, Assembler::kNearJump); |
| 1849 |
| 1850 __ Bind(&next_iteration); |
| 1851 __ addl(EDX, Immediate(kWordSize * SubTypeTestCache::kNumEntries)); |
| 1852 // Is loop done? |
| 1853 __ cmpl(EDI, raw_null); |
| 1854 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); |
| 1855 // Fall through to not found. |
| 1856 __ Bind(¬_found); |
| 1857 __ movl(ECX, raw_null); |
| 1858 __ ret(); |
| 1859 |
| 1860 __ Bind(&found); |
| 1861 __ movl(ECX, Address(EDX, kWordSize * SubTypeTestCache::kTestResult)); |
| 1862 __ ret(); |
| 1863 } |
| 1864 |
| 1800 } // namespace dart | 1865 } // namespace dart |
| 1801 | 1866 |
| 1802 #endif // defined TARGET_ARCH_IA32 | 1867 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |