| 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 1804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1815 __ cmpl(EDX, ECX); | 1815 __ cmpl(EDX, ECX); |
| 1816 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); | 1816 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); |
| 1817 __ jmp(&found, Assembler::kNearJump); | 1817 __ jmp(&found, Assembler::kNearJump); |
| 1818 } | 1818 } |
| 1819 | 1819 |
| 1820 | 1820 |
| 1821 // Used to check class and type arguments. Arguments passed on stack: | 1821 // Used to check class and type arguments. Arguments passed on stack: |
| 1822 // TOS + 0: return address. | 1822 // TOS + 0: return address. |
| 1823 // TOS + 1: instantiator type arguments (can be NULL). | 1823 // TOS + 1: instantiator type arguments (can be NULL). |
| 1824 // TOS + 2: instance. | 1824 // TOS + 2: instance. |
| 1825 // TOS + 3: cache array. | 1825 // TOS + 3: SubtypeTestCache. |
| 1826 // Result in ECX: null -> not found, otherwise result (true or false). | 1826 // Result in ECX: null -> not found, otherwise result (true or false). |
| 1827 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) { | 1827 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) { |
| 1828 ASSERT((1 <= n) && (n <= 3)); | 1828 ASSERT((1 <= n) && (n <= 3)); |
| 1829 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; | 1829 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; |
| 1830 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; | 1830 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; |
| 1831 const intptr_t kCacheArrayOffsetInBytes = 3 * kWordSize; | 1831 const intptr_t kCacheOffsetInBytes = 3 * kWordSize; |
| 1832 const Immediate raw_null = | 1832 const Immediate raw_null = |
| 1833 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1833 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1834 Label not_found; | 1834 Label not_found; |
| 1835 __ movl(EAX, Address(ESP, kInstanceOffsetInBytes)); | 1835 __ movl(EAX, Address(ESP, kInstanceOffsetInBytes)); |
| 1836 __ movl(ECX, FieldAddress(EAX, Object::class_offset())); | 1836 __ movl(ECX, FieldAddress(EAX, Object::class_offset())); |
| 1837 // EAX: instance, ECX: instance-class. | 1837 // EAX: instance, ECX: instance-class. |
| 1838 // Get instance type arguments | 1838 // Get instance type arguments |
| 1839 if (n > 1) { | 1839 if (n > 1) { |
| 1840 // Compute instance type arguments into EBX. | 1840 // Compute instance type arguments into EBX. |
| 1841 Label has_no_type_arguments; | 1841 Label has_no_type_arguments; |
| 1842 __ movl(EBX, raw_null); | 1842 __ movl(EBX, raw_null); |
| 1843 __ movl(EDI, FieldAddress(ECX, | 1843 __ movl(EDI, FieldAddress(ECX, |
| 1844 Class::type_arguments_instance_field_offset_offset())); | 1844 Class::type_arguments_instance_field_offset_offset())); |
| 1845 __ cmpl(EDI, Immediate(Class::kNoTypeArguments)); | 1845 __ cmpl(EDI, Immediate(Class::kNoTypeArguments)); |
| 1846 __ j(EQUAL, &has_no_type_arguments, Assembler::kNearJump); | 1846 __ j(EQUAL, &has_no_type_arguments, Assembler::kNearJump); |
| 1847 __ movl(EBX, FieldAddress(EAX, EDI, TIMES_1, 0)); | 1847 __ movl(EBX, FieldAddress(EAX, EDI, TIMES_1, 0)); |
| 1848 __ Bind(&has_no_type_arguments); | 1848 __ Bind(&has_no_type_arguments); |
| 1849 } | 1849 } |
| 1850 // EBX: instance type arguments (null if none). | 1850 // EBX: instance type arguments (null if none). |
| 1851 __ movl(EDX, Address(ESP, kCacheArrayOffsetInBytes)); | 1851 __ movl(EDX, Address(ESP, kCacheOffsetInBytes)); |
| 1852 // EDX: cache. | 1852 // EDX: SubtypeTestCache. |
| 1853 __ movl(EDX, FieldAddress(EDX, SubtypeTestCache::cache_offset())); |
| 1853 __ addl(EDX, Immediate(Array::data_offset() - kHeapObjectTag)); | 1854 __ addl(EDX, Immediate(Array::data_offset() - kHeapObjectTag)); |
| 1854 | 1855 |
| 1855 Label loop, found, next_iteration; | 1856 Label loop, found, next_iteration; |
| 1856 // EDX: Entry start. | 1857 // EDX: Entry start. |
| 1857 // ECX: instance class. | 1858 // ECX: instance class. |
| 1858 // EBX: instance type arguments | 1859 // EBX: instance type arguments |
| 1859 __ Bind(&loop); | 1860 __ Bind(&loop); |
| 1860 __ movl(EDI, Address(EDX, kWordSize * SubTypeTestCache::kInstanceClass)); | 1861 __ movl(EDI, Address(EDX, kWordSize * SubtypeTestCache::kInstanceClass)); |
| 1861 __ cmpl(EDI, raw_null); | 1862 __ cmpl(EDI, raw_null); |
| 1862 __ j(EQUAL, ¬_found, Assembler::kNearJump); | 1863 __ j(EQUAL, ¬_found, Assembler::kNearJump); |
| 1863 __ cmpl(EDI, ECX); | 1864 __ cmpl(EDI, ECX); |
| 1864 if (n == 1) { | 1865 if (n == 1) { |
| 1865 __ j(EQUAL, &found, Assembler::kNearJump); | 1866 __ j(EQUAL, &found, Assembler::kNearJump); |
| 1866 } else { | 1867 } else { |
| 1867 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); | 1868 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); |
| 1868 __ movl(EDI, | 1869 __ movl(EDI, |
| 1869 Address(EDX, kWordSize * SubTypeTestCache::kInstanceTypeArguments)); | 1870 Address(EDX, kWordSize * SubtypeTestCache::kInstanceTypeArguments)); |
| 1870 __ cmpl(EDI, EBX); | 1871 __ cmpl(EDI, EBX); |
| 1871 if (n == 2) { | 1872 if (n == 2) { |
| 1872 __ j(EQUAL, &found, Assembler::kNearJump); | 1873 __ j(EQUAL, &found, Assembler::kNearJump); |
| 1873 } else { | 1874 } else { |
| 1874 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); | 1875 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); |
| 1875 __ movl(EDI, | 1876 __ movl(EDI, |
| 1876 Address(EDX, kWordSize * | 1877 Address(EDX, kWordSize * |
| 1877 SubTypeTestCache::kInstantiatorTypeArguments)); | 1878 SubtypeTestCache::kInstantiatorTypeArguments)); |
| 1878 __ cmpl(EDI, Address(ESP, kInstantiatorTypeArgumentsInBytes)); | 1879 __ cmpl(EDI, Address(ESP, kInstantiatorTypeArgumentsInBytes)); |
| 1879 __ j(EQUAL, &found, Assembler::kNearJump); | 1880 __ j(EQUAL, &found, Assembler::kNearJump); |
| 1880 } | 1881 } |
| 1881 } | 1882 } |
| 1882 __ Bind(&next_iteration); | 1883 __ Bind(&next_iteration); |
| 1883 __ addl(EDX, Immediate(kWordSize * SubTypeTestCache::kNumEntries)); | 1884 __ addl(EDX, Immediate(kWordSize * SubtypeTestCache::kTestEntryLength)); |
| 1884 __ jmp(&loop, Assembler::kNearJump); | 1885 __ jmp(&loop, Assembler::kNearJump); |
| 1885 // Fall through to not found. | 1886 // Fall through to not found. |
| 1886 __ Bind(¬_found); | 1887 __ Bind(¬_found); |
| 1887 __ movl(ECX, raw_null); | 1888 __ movl(ECX, raw_null); |
| 1888 __ ret(); | 1889 __ ret(); |
| 1889 | 1890 |
| 1890 __ Bind(&found); | 1891 __ Bind(&found); |
| 1891 __ movl(ECX, Address(EDX, kWordSize * SubTypeTestCache::kTestResult)); | 1892 __ movl(ECX, Address(EDX, kWordSize * SubtypeTestCache::kTestResult)); |
| 1892 __ ret(); | 1893 __ ret(); |
| 1893 } | 1894 } |
| 1894 | 1895 |
| 1895 | 1896 |
| 1896 // Used to check class and type arguments. Arguments passed on stack: | 1897 // Used to check class and type arguments. Arguments passed on stack: |
| 1897 // TOS + 0: return address. | 1898 // TOS + 0: return address. |
| 1898 // TOS + 1: instantiator type arguments or NULL. | 1899 // TOS + 1: instantiator type arguments or NULL. |
| 1899 // TOS + 2: instance. | 1900 // TOS + 2: instance. |
| 1900 // TOS + 3: cache array. | 1901 // TOS + 3: cache array. |
| 1901 // Result in ECX: null -> not found, otherwise result (true or false). | 1902 // Result in ECX: null -> not found, otherwise result (true or false). |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1921 // TOS + 2: instance. | 1922 // TOS + 2: instance. |
| 1922 // TOS + 3: cache array. | 1923 // TOS + 3: cache array. |
| 1923 // Result in ECX: null -> not found, otherwise result (true or false). | 1924 // Result in ECX: null -> not found, otherwise result (true or false). |
| 1924 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { | 1925 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { |
| 1925 GenerateSubtypeNTestCacheStub(assembler, 3); | 1926 GenerateSubtypeNTestCacheStub(assembler, 3); |
| 1926 } | 1927 } |
| 1927 | 1928 |
| 1928 } // namespace dart | 1929 } // namespace dart |
| 1929 | 1930 |
| 1930 #endif // defined TARGET_ARCH_IA32 | 1931 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |