OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize; | 1606 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize; |
1607 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; | 1607 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; |
1608 __ movl(EAX, Address(EBX, target_offset)); | 1608 __ movl(EAX, Address(EBX, target_offset)); |
1609 __ addl(Address(EBX, count_offset), Immediate(Smi::RawValue(1))); | 1609 __ addl(Address(EBX, count_offset), Immediate(Smi::RawValue(1))); |
1610 __ j(NO_OVERFLOW, &call_target_function, Assembler::kNearJump); | 1610 __ j(NO_OVERFLOW, &call_target_function, Assembler::kNearJump); |
1611 __ movl(Address(EBX, count_offset), | 1611 __ movl(Address(EBX, count_offset), |
1612 Immediate(Smi::RawValue(Smi::kMaxValue))); | 1612 Immediate(Smi::RawValue(Smi::kMaxValue))); |
1613 | 1613 |
1614 __ Bind(&call_target_function); | 1614 __ Bind(&call_target_function); |
1615 // EAX: Target function. | 1615 // EAX: Target function. |
1616 __ movl(EAX, FieldAddress(EAX, Function::code_offset())); | 1616 Label is_compiled; |
1617 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); | 1617 __ movl(EBX, FieldAddress(EAX, Function::code_offset())); |
| 1618 if (FLAG_collect_code) { |
| 1619 // If code might be GC'd, then EBX might be null. If it is, recompile. |
| 1620 __ cmpl(EBX, raw_null); |
| 1621 __ j(NOT_EQUAL, &is_compiled, Assembler::kNearJump); |
| 1622 __ EnterStubFrame(); |
| 1623 __ pushl(EDX); // Preserve arguments descriptor array. |
| 1624 __ pushl(ECX); // Preserve IC data object. |
| 1625 __ pushl(EAX); // Pass function. |
| 1626 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); |
| 1627 __ popl(EAX); // Restore function. |
| 1628 __ popl(ECX); // Restore IC data array. |
| 1629 __ popl(EDX); // Restore arguments descriptor array. |
| 1630 __ LeaveFrame(); |
| 1631 __ movl(EBX, FieldAddress(EAX, Function::code_offset())); |
| 1632 __ Bind(&is_compiled); |
| 1633 } |
| 1634 __ movl(EAX, FieldAddress(EBX, Code::instructions_offset())); |
1618 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1635 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
1619 __ jmp(EAX); | 1636 __ jmp(EAX); |
1620 | 1637 |
1621 // Instance in EAX, return its class-id in EAX as Smi. | 1638 // Instance in EAX, return its class-id in EAX as Smi. |
1622 __ Bind(&get_class_id_as_smi); | 1639 __ Bind(&get_class_id_as_smi); |
1623 Label not_smi; | 1640 Label not_smi; |
1624 // Test if Smi -> load Smi class for comparison. | 1641 // Test if Smi -> load Smi class for comparison. |
1625 __ testl(EAX, Immediate(kSmiTagMask)); | 1642 __ testl(EAX, Immediate(kSmiTagMask)); |
1626 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); | 1643 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); |
1627 __ movl(EAX, Immediate(Smi::RawValue(kSmiCid))); | 1644 __ movl(EAX, Immediate(Smi::RawValue(kSmiCid))); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1789 } | 1806 } |
1790 | 1807 |
1791 | 1808 |
1792 void StubCode::GenerateTwoArgsUnoptimizedStaticCallStub(Assembler* assembler) { | 1809 void StubCode::GenerateTwoArgsUnoptimizedStaticCallStub(Assembler* assembler) { |
1793 GenerateUsageCounterIncrement(assembler, EBX); | 1810 GenerateUsageCounterIncrement(assembler, EBX); |
1794 GenerateNArgsCheckInlineCacheStub( | 1811 GenerateNArgsCheckInlineCacheStub( |
1795 assembler, 2, kStaticCallMissHandlerTwoArgsRuntimeEntry); | 1812 assembler, 2, kStaticCallMissHandlerTwoArgsRuntimeEntry); |
1796 } | 1813 } |
1797 | 1814 |
1798 | 1815 |
| 1816 // Stub for calling the CompileFunction runtime call. |
| 1817 // ECX: IC-Data. |
| 1818 // EDX: Arguments descriptor. |
| 1819 // EAX: Function. |
| 1820 void StubCode::GenerateCompileFunctionRuntimeCallStub(Assembler* assembler) { |
| 1821 __ EnterStubFrame(); |
| 1822 __ pushl(EDX); // Preserve arguments descriptor array. |
| 1823 __ pushl(ECX); // Preserve IC data object. |
| 1824 __ pushl(EAX); // Pass function. |
| 1825 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); |
| 1826 __ popl(EAX); // Restore function. |
| 1827 __ popl(ECX); // Restore IC data array. |
| 1828 __ popl(EDX); // Restore arguments descriptor array. |
| 1829 __ LeaveFrame(); |
| 1830 __ ret(); |
| 1831 } |
| 1832 |
| 1833 |
1799 // EDX, ECX: May contain arguments to runtime stub. | 1834 // EDX, ECX: May contain arguments to runtime stub. |
1800 void StubCode::GenerateBreakpointRuntimeStub(Assembler* assembler) { | 1835 void StubCode::GenerateBreakpointRuntimeStub(Assembler* assembler) { |
1801 __ EnterStubFrame(); | 1836 __ EnterStubFrame(); |
1802 // Save runtime args. | 1837 // Save runtime args. |
1803 __ pushl(ECX); | 1838 __ pushl(ECX); |
1804 __ pushl(EDX); | 1839 __ pushl(EDX); |
1805 // Room for result. Debugger stub returns address of the | 1840 // Room for result. Debugger stub returns address of the |
1806 // unpatched runtime stub. | 1841 // unpatched runtime stub. |
1807 const Immediate& raw_null = | 1842 const Immediate& raw_null = |
1808 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1843 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2173 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); | 2208 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); |
2174 __ popl(temp); | 2209 __ popl(temp); |
2175 __ popl(right); | 2210 __ popl(right); |
2176 __ popl(left); | 2211 __ popl(left); |
2177 __ ret(); | 2212 __ ret(); |
2178 } | 2213 } |
2179 | 2214 |
2180 } // namespace dart | 2215 } // namespace dart |
2181 | 2216 |
2182 #endif // defined TARGET_ARCH_IA32 | 2217 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |