Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: runtime/vm/stub_code_ia32.cc

Issue 10243013: Simpler and better inlined type checks as discussed. Changed inline type test cache arrays to conta… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/stub_code_arm.cc ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, &not_found, Assembler::kNearJump); 1793 __ j(EQUAL, &not_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(&not_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
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_arm.cc ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698