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 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1751 __ cmpl(EBX, Immediate(1)); | 1751 __ cmpl(EBX, Immediate(1)); |
| 1752 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump); | 1752 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump); |
| 1753 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel()); | 1753 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel()); |
| 1754 __ Bind(&ic_cache_one_arg); | 1754 __ Bind(&ic_cache_one_arg); |
| 1755 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); | 1755 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); |
| 1756 } | 1756 } |
| 1757 | 1757 |
| 1758 | 1758 |
| 1759 // Check if an instance class is a subtype of class/interface using simple | 1759 // Check if an instance class is a subtype of class/interface using simple |
| 1760 // superchain and interface array traversal. Does not take type parameters into | 1760 // superchain and interface array traversal. Does not take type parameters into |
| 1761 // account. | 1761 // account. |
|
regis
2012/04/25 01:53:53
Should you mention that instances of type Smi cann
srdjan
2012/04/25 16:38:01
Done.
| |
| 1762 // EAX: instance (preserved) | 1762 // EAX: instance (to be preserved). |
| 1763 // ECX: class to test. | |
| 1763 // EDX: class/interface to test against (is class of instance a subtype of it). | 1764 // EDX: class/interface to test against (is class of instance a subtype of it). |
| 1764 // (preserved). | 1765 // (preserved). |
| 1765 // Result in EBX: 1 is subtype, 0 maybe not. | 1766 // Result in EBX: 1 is subtype, 0 maybe not. |
| 1766 // Destroys EBX, EDI, ECX. | 1767 // Destroys EBX, EDI, ECX. |
| 1767 void StubCode::GenerateIsRawSubTypeStub(Assembler* assembler) { | 1768 void StubCode::GenerateIsRawSubTypeStub(Assembler* assembler) { |
| 1768 const Immediate raw_null = | 1769 const Immediate raw_null = |
| 1769 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1770 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1770 Label test_class, not_found, found, class_loaded_in_ECX, smi_value; | 1771 Label test_class, not_found, found; |
| 1771 __ EnterFrame(0); | |
| 1772 __ testl(EAX, Immediate(kSmiTagMask)); | |
| 1773 __ j(ZERO, &smi_value, Assembler::kNearJump); | |
| 1774 __ movl(ECX, FieldAddress(EAX, Object::class_offset())); | |
| 1775 __ jmp(&class_loaded_in_ECX, Assembler::kNearJump); | |
| 1776 __ Bind(&smi_value); | |
| 1777 __ movl(ECX, FieldAddress(CTX, Context::isolate_offset())); | |
| 1778 __ movl(ECX, Address(ECX, Isolate::object_store_offset())); | |
| 1779 __ movl(ECX, Address(ECX, ObjectStore::smi_class_offset())); | |
| 1780 __ Bind(&class_loaded_in_ECX); | |
| 1781 | 1772 |
| 1782 __ movzxb(EBX, FieldAddress(EDX, Class::is_interface_offset())); | 1773 __ movzxb(EBX, FieldAddress(EDX, Class::is_interface_offset())); |
| 1783 // Check if we are comparing against class or interface. | 1774 // Check if we are comparing against class or interface. |
| 1784 __ cmpl(EBX, Immediate(0)); | 1775 __ cmpl(EBX, Immediate(0)); |
| 1785 __ j(EQUAL, &test_class, Assembler::kNearJump); | 1776 __ j(EQUAL, &test_class, Assembler::kNearJump); |
| 1786 | 1777 |
| 1787 // Get interfaces array from instance class. | 1778 // Get interfaces array from instance class. |
| 1788 __ movl(EBX, FieldAddress(ECX, Class::interfaces_offset())); | 1779 __ movl(EBX, FieldAddress(ECX, Class::interfaces_offset())); |
| 1789 __ cmpl(EBX, raw_null); | 1780 __ cmpl(EBX, raw_null); |
| 1790 __ j(EQUAL, ¬_found, Assembler::kNearJump); | 1781 __ j(EQUAL, ¬_found, Assembler::kNearJump); |
| 1791 __ movl(EDI, FieldAddress(EBX, Array::length_offset())); | 1782 __ movl(EDI, FieldAddress(EBX, Array::length_offset())); |
| 1792 // EDI: array index. | 1783 // EDI: array index. |
| 1793 // EBX: interface array. | 1784 // EBX: interface array. |
| 1794 // EDX: interface searched | 1785 // EDX: interface searched |
| 1795 Label array_loop; | 1786 Label array_loop; |
| 1796 __ Bind(&array_loop); | 1787 __ Bind(&array_loop); |
| 1797 __ subl(EDI, Immediate(Smi::RawValue(1))); | 1788 __ subl(EDI, Immediate(Smi::RawValue(1))); |
| 1798 // __ cmpl(EDI, Immediate(0)); | |
| 1799 __ j(LESS, ¬_found, Assembler::kNearJump); | 1789 __ j(LESS, ¬_found, Assembler::kNearJump); |
| 1800 // EDI is Smi therefore TIMES_2 instead of TIMES_4. | 1790 // EDI is Smi therefore TIMES_2 instead of TIMES_4. |
| 1801 // Get type from array. | 1791 // Get type from array. |
| 1802 __ movl(ECX, FieldAddress(EBX, EDI, TIMES_2, Array::data_offset())); | 1792 __ movl(ECX, FieldAddress(EBX, EDI, TIMES_2, Array::data_offset())); |
| 1803 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); | 1793 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); |
| 1804 __ cmpl(ECX, EDX); | 1794 __ cmpl(ECX, EDX); |
| 1805 __ j(EQUAL, &found, Assembler::kNearJump); | 1795 __ j(EQUAL, &found, Assembler::kNearJump); |
| 1806 __ jmp(&array_loop, Assembler::kNearJump); | 1796 __ jmp(&array_loop, Assembler::kNearJump); |
| 1807 | 1797 |
| 1808 __ Bind(¬_found); | 1798 __ Bind(¬_found); |
| 1809 __ xorl(EBX, EBX); | 1799 __ xorl(EBX, EBX); |
| 1810 __ LeaveFrame(); | |
| 1811 __ ret(); | 1800 __ ret(); |
| 1812 | 1801 |
| 1813 __ Bind(&found); | 1802 __ Bind(&found); |
| 1814 __ movl(EBX, Immediate(1)); | 1803 __ movl(EBX, Immediate(1)); |
| 1815 __ LeaveFrame(); | |
| 1816 __ ret(); | 1804 __ ret(); |
| 1817 | 1805 |
| 1818 __ Bind(&test_class); | 1806 __ Bind(&test_class); |
| 1819 // EDX: test class. | 1807 // EDX: test class. |
| 1820 __ cmpl(ECX, EDX); | 1808 __ cmpl(ECX, EDX); |
| 1821 __ j(EQUAL, &found, Assembler::kNearJump); | 1809 __ j(EQUAL, &found, Assembler::kNearJump); |
| 1822 | 1810 |
| 1823 // Check superclasses using a loop (faster than runtime call). | 1811 // Check superclasses using a loop (faster than runtime call). |
| 1824 Label super_loop; | 1812 Label super_loop; |
| 1825 __ Bind(&super_loop); | 1813 __ Bind(&super_loop); |
| 1826 // ECX: class -> super. | 1814 // ECX: class -> super. |
| 1827 __ movl(ECX, FieldAddress(ECX, Class::super_type_offset())); | 1815 __ movl(ECX, FieldAddress(ECX, Class::super_type_offset())); |
| 1828 // The supertype of Object is a null object. | 1816 // The supertype of Object is a null object. |
| 1829 __ cmpl(ECX, raw_null); | 1817 __ cmpl(ECX, raw_null); |
| 1830 __ j(EQUAL, ¬_found, Assembler::kNearJump); | 1818 __ j(EQUAL, ¬_found, Assembler::kNearJump); |
| 1831 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); | 1819 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); |
| 1832 __ cmpl(EDX, ECX); | 1820 __ cmpl(EDX, ECX); |
| 1833 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); | 1821 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); |
| 1834 __ jmp(&found, Assembler::kNearJump); | 1822 __ jmp(&found, Assembler::kNearJump); |
| 1835 } | 1823 } |
|
regis
2012/04/25 01:53:53
Will you fix the 64-bit stub in a different cl?
| |
| 1836 | 1824 |
| 1837 } // namespace dart | 1825 } // namespace dart |
| 1838 | 1826 |
| 1839 #endif // defined TARGET_ARCH_IA32 | 1827 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |