Chromium Code Reviews| 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 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1812 __ cmpl(ECX, raw_null); | 1812 __ cmpl(ECX, raw_null); |
| 1813 __ j(EQUAL, ¬_found, Assembler::kNearJump); | 1813 __ j(EQUAL, ¬_found, Assembler::kNearJump); |
| 1814 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); | 1814 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); |
| 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 | 1823 // TOS + 1: instantiator type arguments (can be NULL). |
| 1824 // TOS + 2: instance | 1824 // TOS + 1: instance. |
| 1825 // TOS + 3: cache array. | 1825 // TOS + 2: cache array. |
| 1826 // Result in ECX: null -> not found, otherwise result. | 1826 // Result in ECX: null -> not found, otherwise result (true or false). |
| 1827 void StubCode::GenerateSubtypeTestCacheStub(Assembler* assembler) { | 1827 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) { |
| 1828 ASSERT((1 <= n) && (n <= 3)); | |
| 1828 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; | 1829 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; |
| 1829 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; | 1830 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; |
| 1830 const intptr_t kCacheArrayOffsetInBytes = 3 * kWordSize; | 1831 const intptr_t kCacheArrayOffsetInBytes = 3 * kWordSize; |
| 1831 const Immediate raw_null = | 1832 const Immediate raw_null = |
| 1832 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1833 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1833 | 1834 Label not_found; |
| 1834 __ movl(EAX, Address(ESP, kInstanceOffsetInBytes)); | 1835 __ movl(EAX, Address(ESP, kInstanceOffsetInBytes)); |
| 1835 __ movl(ECX, FieldAddress(EAX, Object::class_offset())); | 1836 __ movl(ECX, FieldAddress(EAX, Object::class_offset())); |
| 1836 // EAX: instance, ECX: instance-class. | 1837 // EAX: instance, ECX: instance-class. |
| 1837 // Get instance type arguments | 1838 // Get instance type arguments |
| 1838 Label has_no_type_arguments; | 1839 if (n > 1) { |
| 1839 __ movl(EBX, raw_null); | 1840 // Compute instance type arguments into EBX. |
| 1840 __ movl(EDI, FieldAddress(ECX, | 1841 Label has_no_type_arguments; |
| 1841 Class::type_arguments_instance_field_offset_offset())); | 1842 __ movl(EBX, raw_null); |
| 1842 __ cmpl(EDI, Immediate(Class::kNoTypeArguments)); | 1843 __ movl(EDI, FieldAddress(ECX, |
| 1843 __ j(EQUAL, &has_no_type_arguments, Assembler::kNearJump); | 1844 Class::type_arguments_instance_field_offset_offset())); |
| 1844 __ movl(EBX, FieldAddress(EAX, EDI, TIMES_1, 0)); | 1845 __ cmpl(EDI, Immediate(Class::kNoTypeArguments)); |
| 1845 __ Bind(&has_no_type_arguments); | 1846 __ j(EQUAL, &has_no_type_arguments, Assembler::kNearJump); |
| 1847 __ movl(EBX, FieldAddress(EAX, EDI, TIMES_1, 0)); | |
| 1848 __ Bind(&has_no_type_arguments); | |
| 1849 } | |
| 1846 // EBX: instance type arguments (null if none). | 1850 // EBX: instance type arguments (null if none). |
| 1847 __ movl(EDX, Address(ESP, kCacheArrayOffsetInBytes)); | 1851 __ movl(EDX, Address(ESP, kCacheArrayOffsetInBytes)); |
| 1848 // EDX: cache. | 1852 // EDX: cache. |
| 1849 __ addl(EDX, Immediate(Array::data_offset() - kHeapObjectTag)); | 1853 __ addl(EDX, Immediate(Array::data_offset() - kHeapObjectTag)); |
| 1850 Label loop, found, not_found, next_iteration; | 1854 |
| 1855 Label loop, found, next_iteration; | |
| 1851 // EDX: Entry start. | 1856 // EDX: Entry start. |
| 1852 // ECX: instance class. | 1857 // ECX: instance class. |
| 1853 // EBX: instance type arguments | 1858 // EBX: instance type arguments |
| 1854 // TOS + 2: test-type-class. | |
| 1855 // TOS + 1: test-type-arguments. | |
| 1856 __ Bind(&loop); | 1859 __ Bind(&loop); |
| 1857 __ movl(EDI, Address(EDX, kWordSize * SubTypeTestCache::kInstanceClass)); | 1860 __ movl(EDI, Address(EDX, kWordSize * SubTypeTestCache::kInstanceClass)); |
| 1861 __ cmpl(EDI, raw_null); | |
| 1862 __ j(EQUAL, ¬_found, Assembler::kNearJump); | |
| 1858 __ cmpl(EDI, ECX); | 1863 __ cmpl(EDI, ECX); |
| 1859 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); | 1864 if (n == 1) { |
| 1860 __ movl(EDI, | 1865 __ j(EQUAL, &found, Assembler::kNearJump); |
| 1866 } else { | |
| 1867 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); | |
| 1868 __ movl(EDI, | |
| 1861 Address(EDX, kWordSize * SubTypeTestCache::kInstanceTypeArguments)); | 1869 Address(EDX, kWordSize * SubTypeTestCache::kInstanceTypeArguments)); |
| 1862 __ cmpl(EDI, EBX); | 1870 __ cmpl(EDI, EBX); |
| 1863 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); | 1871 if (n == 2) { |
| 1864 __ movl(EDI, | 1872 __ j(EQUAL, &found, Assembler::kNearJump); |
| 1865 Address(EDX, kWordSize * | 1873 } else { |
| 1866 SubTypeTestCache::kInstantiatorTypeArguments)); | 1874 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); |
| 1867 __ cmpl(EDI, Address(ESP, kInstantiatorTypeArgumentsInBytes)); | 1875 __ movl(EDI, |
| 1868 __ j(EQUAL, &found, Assembler::kNearJump); | 1876 Address(EDX, kWordSize * |
| 1869 | 1877 SubTypeTestCache::kInstantiatorTypeArguments)); |
| 1878 __ cmpl(EDI, Address(ESP, kInstantiatorTypeArgumentsInBytes)); | |
| 1879 __ j(EQUAL, &found, Assembler::kNearJump); | |
| 1880 } | |
| 1881 } | |
| 1870 __ Bind(&next_iteration); | 1882 __ Bind(&next_iteration); |
| 1871 __ addl(EDX, Immediate(kWordSize * SubTypeTestCache::kNumEntries)); | 1883 __ addl(EDX, Immediate(kWordSize * SubTypeTestCache::kNumEntries)); |
| 1872 // Is loop done? | 1884 __ jmp(&loop, Assembler::kNearJump); |
| 1873 __ cmpl(EDI, raw_null); | |
| 1874 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); | |
| 1875 // Fall through to not found. | 1885 // Fall through to not found. |
| 1876 __ Bind(¬_found); | 1886 __ Bind(¬_found); |
| 1877 __ movl(ECX, raw_null); | 1887 __ movl(ECX, raw_null); |
| 1878 __ ret(); | 1888 __ ret(); |
| 1879 | 1889 |
| 1880 __ Bind(&found); | 1890 __ Bind(&found); |
| 1881 __ movl(ECX, Address(EDX, kWordSize * SubTypeTestCache::kTestResult)); | 1891 __ movl(ECX, Address(EDX, kWordSize * SubTypeTestCache::kTestResult)); |
| 1882 __ ret(); | 1892 __ ret(); |
| 1883 } | 1893 } |
| 1884 | 1894 |
| 1895 | |
| 1896 // Used to check class and type arguments. Arguments passed on stack: | |
| 1897 // TOS + 0: return address. | |
| 1898 // TOS + 1: instantiator type arguments or NULL. | |
| 1899 // TOS + 1: instance. | |
|
regis
2012/05/02 20:05:27
TOS + 1.5?
srdjan
2012/05/02 20:44:00
Done.
| |
| 1900 // TOS + 2: cache array. | |
| 1901 // Result in ECX: null -> not found, otherwise result (true or false). | |
| 1902 void StubCode::GenerateSubtype1TestCacheStub(Assembler* assembler) { | |
| 1903 GenerateSubtypeNTestCacheStub(assembler, 1); | |
| 1904 } | |
| 1905 | |
| 1906 | |
| 1907 // Used to check class and type arguments. Arguments passed on stack: | |
| 1908 // TOS + 0: return address. | |
| 1909 // TOS + 1: instantiator type arguments or NULL. | |
| 1910 // TOS + 2: instance. | |
| 1911 // TOS + 3: cache array. | |
| 1912 // Result in ECX: null -> not found, otherwise result (true or false). | |
| 1913 void StubCode::GenerateSubtype2TestCacheStub(Assembler* assembler) { | |
| 1914 GenerateSubtypeNTestCacheStub(assembler, 2); | |
| 1915 } | |
| 1916 | |
| 1917 | |
| 1918 // Used to check class and type arguments. Arguments passed on stack: | |
| 1919 // TOS + 0: return address. | |
| 1920 // TOS + 1: instantiator type arguments. | |
| 1921 // TOS + 2: instance. | |
| 1922 // TOS + 3: cache array. | |
| 1923 // Result in ECX: null -> not found, otherwise result (true or false). | |
| 1924 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { | |
| 1925 GenerateSubtypeNTestCacheStub(assembler, 3); | |
| 1926 } | |
| 1927 | |
| 1885 } // namespace dart | 1928 } // namespace dart |
| 1886 | 1929 |
| 1887 #endif // defined TARGET_ARCH_IA32 | 1930 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |