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

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

Issue 10227006: (Redoing the change 6946) Progress toward inlined type checks for classes with type arguments: fact… (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/object.h ('k') | no next file » | 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 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump); 1726 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump);
1727 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel()); 1727 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel());
1728 __ Bind(&ic_cache_one_arg); 1728 __ Bind(&ic_cache_one_arg);
1729 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); 1729 __ jmp(&StubCode::OneArgCheckInlineCacheLabel());
1730 } 1730 }
1731 1731
1732 1732
1733 // Check if an instance class is a subtype of class/interface using simple 1733 // Check if an instance class is a subtype of class/interface using simple
1734 // superchain and interface array traversal. Does not take type parameters into 1734 // superchain and interface array traversal. Does not take type parameters into
1735 // account. 1735 // account.
1736 // EAX: instance (preserved) 1736 // Cannot handle Smi instances (must be tested beforehand).
1737 // EAX: instance (to be preserved).
1738 // ECX: class to test.
1737 // EDX: class/interface to test against (is class of instance a subtype of it). 1739 // EDX: class/interface to test against (is class of instance a subtype of it).
1738 // (preserved). 1740 // (preserved).
1739 // Result in EBX: 1 is subtype, 0 maybe not. 1741 // Result in EBX: 1 is subtype, 0 maybe not.
1740 // Destroys EBX, EDI, ECX. 1742 // Destroys EBX, EDI, ECX.
1741 void StubCode::GenerateIsRawSubTypeStub(Assembler* assembler) { 1743 void StubCode::GenerateIsRawSubTypeStub(Assembler* assembler) {
1742 const Immediate raw_null = 1744 const Immediate raw_null =
1743 Immediate(reinterpret_cast<intptr_t>(Object::null())); 1745 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1744 Label test_class, not_found, found, class_loaded_in_ECX, smi_value; 1746 Label test_class, not_found, found;
1745 __ EnterFrame(0);
1746 __ testl(EAX, Immediate(kSmiTagMask));
1747 __ j(ZERO, &smi_value, Assembler::kNearJump);
1748 __ movl(ECX, FieldAddress(EAX, Object::class_offset()));
1749 __ jmp(&class_loaded_in_ECX, Assembler::kNearJump);
1750 __ Bind(&smi_value);
1751 __ movl(ECX, FieldAddress(CTX, Context::isolate_offset()));
1752 __ movl(ECX, Address(ECX, Isolate::object_store_offset()));
1753 __ movl(ECX, Address(ECX, ObjectStore::smi_class_offset()));
1754 __ Bind(&class_loaded_in_ECX);
1755 1747
1756 __ movzxb(EBX, FieldAddress(EDX, Class::is_interface_offset())); 1748 __ movzxb(EBX, FieldAddress(EDX, Class::is_interface_offset()));
1757 // Check if we are comparing against class or interface. 1749 // Check if we are comparing against class or interface.
1758 __ cmpl(EBX, Immediate(0)); 1750 __ cmpl(EBX, Immediate(0));
1759 __ j(EQUAL, &test_class, Assembler::kNearJump); 1751 __ j(EQUAL, &test_class, Assembler::kNearJump);
1760 1752
1761 // Get interfaces array from instance class. 1753 // Get interfaces array from instance class.
1762 __ movl(EBX, FieldAddress(ECX, Class::interfaces_offset())); 1754 __ movl(EBX, FieldAddress(ECX, Class::interfaces_offset()));
1763 __ cmpl(EBX, raw_null); 1755 __ cmpl(EBX, raw_null);
1764 __ j(EQUAL, &not_found, Assembler::kNearJump); 1756 __ j(EQUAL, &not_found, Assembler::kNearJump);
1765 __ movl(EDI, FieldAddress(EBX, Array::length_offset())); 1757 __ movl(EDI, FieldAddress(EBX, Array::length_offset()));
1766 // EDI: array index. 1758 // EDI: array index.
1767 // EBX: interface array. 1759 // EBX: interface array.
1768 // EDX: interface searched 1760 // EDX: interface searched
1769 Label array_loop; 1761 Label array_loop;
1770 __ Bind(&array_loop); 1762 __ Bind(&array_loop);
1771 __ subl(EDI, Immediate(Smi::RawValue(1))); 1763 __ subl(EDI, Immediate(Smi::RawValue(1)));
1772 // __ cmpl(EDI, Immediate(0));
1773 __ j(LESS, &not_found, Assembler::kNearJump); 1764 __ j(LESS, &not_found, Assembler::kNearJump);
1774 // EDI is Smi therefore TIMES_2 instead of TIMES_4. 1765 // EDI is Smi therefore TIMES_2 instead of TIMES_4.
1775 // Get type from array. 1766 // Get type from array.
1776 __ movl(ECX, FieldAddress(EBX, EDI, TIMES_2, Array::data_offset())); 1767 __ movl(ECX, FieldAddress(EBX, EDI, TIMES_2, Array::data_offset()));
1777 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); 1768 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset()));
1778 __ cmpl(ECX, EDX); 1769 __ cmpl(ECX, EDX);
1779 __ j(EQUAL, &found, Assembler::kNearJump); 1770 __ j(EQUAL, &found, Assembler::kNearJump);
1780 __ jmp(&array_loop, Assembler::kNearJump); 1771 __ jmp(&array_loop, Assembler::kNearJump);
1781 1772
1782 __ Bind(&not_found); 1773 __ Bind(&not_found);
1783 __ xorl(EBX, EBX); 1774 __ xorl(EBX, EBX);
1784 __ LeaveFrame();
1785 __ ret(); 1775 __ ret();
1786 1776
1787 __ Bind(&found); 1777 __ Bind(&found);
1788 __ movl(EBX, Immediate(1)); 1778 __ movl(EBX, Immediate(1));
1789 __ LeaveFrame();
1790 __ ret(); 1779 __ ret();
1791 1780
1792 __ Bind(&test_class); 1781 __ Bind(&test_class);
1793 // EDX: test class. 1782 // EDX: test class.
1794 __ cmpl(ECX, EDX); 1783 __ cmpl(ECX, EDX);
1795 __ j(EQUAL, &found, Assembler::kNearJump); 1784 __ j(EQUAL, &found, Assembler::kNearJump);
1796 1785
1797 // Check superclasses using a loop (faster than runtime call). 1786 // Check superclasses using a loop (faster than runtime call).
1798 Label super_loop; 1787 Label super_loop;
1799 __ Bind(&super_loop); 1788 __ Bind(&super_loop);
1800 // ECX: class -> super. 1789 // ECX: class -> super.
1801 __ movl(ECX, FieldAddress(ECX, Class::super_type_offset())); 1790 __ movl(ECX, FieldAddress(ECX, Class::super_type_offset()));
1802 // The supertype of Object is a null object. 1791 // The supertype of Object is a null object.
1803 __ cmpl(ECX, raw_null); 1792 __ cmpl(ECX, raw_null);
1804 __ j(EQUAL, &not_found, Assembler::kNearJump); 1793 __ j(EQUAL, &not_found, Assembler::kNearJump);
1805 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); 1794 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset()));
1806 __ cmpl(EDX, ECX); 1795 __ cmpl(EDX, ECX);
1807 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); 1796 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump);
1808 __ jmp(&found, Assembler::kNearJump); 1797 __ jmp(&found, Assembler::kNearJump);
1809 } 1798 }
1810 1799
1811 } // namespace dart 1800 } // namespace dart
1812 1801
1813 #endif // defined TARGET_ARCH_IA32 1802 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698