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