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

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

Issue 10381045: Improve type checking, remove unused stub (removed also in x64 in preparation of porting the better… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 Label ic_cache_one_arg; 1743 Label ic_cache_one_arg;
1744 __ movl(EBX, FieldAddress(ECX, ICData::num_args_tested_offset())); 1744 __ movl(EBX, FieldAddress(ECX, ICData::num_args_tested_offset()));
1745 __ cmpl(EBX, Immediate(1)); 1745 __ cmpl(EBX, Immediate(1));
1746 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump); 1746 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump);
1747 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel()); 1747 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel());
1748 __ Bind(&ic_cache_one_arg); 1748 __ Bind(&ic_cache_one_arg);
1749 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); 1749 __ jmp(&StubCode::OneArgCheckInlineCacheLabel());
1750 } 1750 }
1751 1751
1752 1752
1753 // Check if an instance class is a subtype of class/interface using simple
1754 // superchain and interface array traversal. Does not take type parameters into
1755 // account.
1756 // Cannot handle Smi instances (must be tested beforehand).
1757 // EAX: instance (to be preserved).
1758 // ECX: class to test.
1759 // EDX: class/interface to test against (is class of instance a subtype of it).
1760 // (preserved).
1761 // Result in EBX: 1 is subtype, 0 maybe not.
1762 // Destroys EBX, EDI, ECX.
1763 void StubCode::GenerateIsRawSubTypeStub(Assembler* assembler) {
1764 const Immediate raw_null =
1765 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1766 Label test_class, not_found, found;
1767
1768 __ movzxb(EBX, FieldAddress(EDX, Class::is_interface_offset()));
1769 // Check if we are comparing against class or interface.
1770 __ cmpl(EBX, Immediate(0));
1771 __ j(EQUAL, &test_class, Assembler::kNearJump);
1772
1773 // Get interfaces array from instance class.
1774 __ movl(EBX, FieldAddress(ECX, Class::interfaces_offset()));
1775 __ cmpl(EBX, raw_null);
1776 __ j(EQUAL, &not_found, Assembler::kNearJump);
1777 __ movl(EDI, FieldAddress(EBX, Array::length_offset()));
1778 // EDI: array index.
1779 // EBX: interface array.
1780 // EDX: interface searched
1781 Label array_loop;
1782 __ Bind(&array_loop);
1783 __ subl(EDI, Immediate(Smi::RawValue(1)));
1784 __ j(LESS, &not_found, Assembler::kNearJump);
1785 // EDI is Smi therefore TIMES_2 instead of TIMES_4.
1786 // Get type from array.
1787 __ movl(ECX, FieldAddress(EBX, EDI, TIMES_2, Array::data_offset()));
1788 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset()));
1789 __ cmpl(ECX, EDX);
1790 __ j(EQUAL, &found, Assembler::kNearJump);
1791 __ jmp(&array_loop, Assembler::kNearJump);
1792
1793 __ Bind(&not_found);
1794 __ xorl(EBX, EBX);
1795 __ ret();
1796
1797 __ Bind(&found);
1798 __ movl(EBX, Immediate(1));
1799 __ ret();
1800
1801 __ Bind(&test_class);
1802 // EDX: test class.
1803 __ cmpl(ECX, EDX);
1804 __ j(EQUAL, &found, Assembler::kNearJump);
1805
1806 // Check superclasses using a loop (faster than runtime call).
1807 Label super_loop;
1808 __ Bind(&super_loop);
1809 // ECX: class -> super.
1810 __ movl(ECX, FieldAddress(ECX, Class::super_type_offset()));
1811 // The supertype of Object is a null object.
1812 __ cmpl(ECX, raw_null);
1813 __ j(EQUAL, &not_found, Assembler::kNearJump);
1814 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset()));
1815 __ cmpl(EDX, ECX);
1816 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump);
1817 __ jmp(&found, Assembler::kNearJump);
1818 }
1819
1820
1821 // Used to check class and type arguments. Arguments passed on stack: 1753 // Used to check class and type arguments. Arguments passed on stack:
1822 // TOS + 0: return address. 1754 // TOS + 0: return address.
1823 // TOS + 1: instantiator type arguments (can be NULL). 1755 // TOS + 1: instantiator type arguments (can be NULL).
1824 // TOS + 2: instance. 1756 // TOS + 2: instance.
1825 // TOS + 3: SubtypeTestCache. 1757 // TOS + 3: SubtypeTestCache.
1826 // Result in ECX: null -> not found, otherwise result (true or false). 1758 // Result in ECX: null -> not found, otherwise result (true or false).
1827 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) { 1759 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) {
1828 ASSERT((1 <= n) && (n <= 3)); 1760 ASSERT((1 <= n) && (n <= 3));
1829 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; 1761 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize;
1830 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; 1762 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 // TOS + 2: instance. 1854 // TOS + 2: instance.
1923 // TOS + 3: cache array. 1855 // TOS + 3: cache array.
1924 // Result in ECX: null -> not found, otherwise result (true or false). 1856 // Result in ECX: null -> not found, otherwise result (true or false).
1925 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { 1857 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) {
1926 GenerateSubtypeNTestCacheStub(assembler, 3); 1858 GenerateSubtypeNTestCacheStub(assembler, 3);
1927 } 1859 }
1928 1860
1929 } // namespace dart 1861 } // namespace dart
1930 1862
1931 #endif // defined TARGET_ARCH_IA32 1863 #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