OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/assembler_macros.h" | 9 #include "vm/assembler_macros.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 // Cache Context pointer into CTX while executing Dart code. | 177 // Cache Context pointer into CTX while executing Dart code. |
178 __ movl(CTX, EDI); | 178 __ movl(CTX, EDI); |
179 | 179 |
180 __ LeaveFrame(); | 180 __ LeaveFrame(); |
181 __ ret(); | 181 __ ret(); |
182 } | 182 } |
183 | 183 |
184 | 184 |
185 // Input parameters: | 185 // Input parameters: |
186 // ECX: function object. | |
187 // EDX: arguments descriptor array (num_args is first Smi element). | 186 // EDX: arguments descriptor array (num_args is first Smi element). |
188 void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) { | 187 void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) { |
189 const Immediate raw_null = | 188 const Immediate raw_null = |
190 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 189 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
191 | |
192 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); | |
193 __ cmpl(EAX, raw_null); | |
194 Label function_compiled; | |
195 __ j(NOT_EQUAL, &function_compiled, Assembler::kNearJump); | |
196 | |
197 // Create a stub frame as we are pushing some objects on the stack before | |
198 // calling into the runtime. | |
199 AssemblerMacros::EnterStubFrame(assembler); | 190 AssemblerMacros::EnterStubFrame(assembler); |
200 | |
201 __ pushl(EDX); // Preserve arguments descriptor array. | 191 __ pushl(EDX); // Preserve arguments descriptor array. |
202 __ pushl(ECX); | 192 __ pushl(raw_null); // Setup space on stack for return value. |
203 __ CallRuntime(kCompileFunctionRuntimeEntry); | |
204 __ popl(ECX); // Restore read-only function object argument in ECX. | |
205 __ popl(EDX); // Restore arguments descriptor array. | |
206 // Restore EAX. | |
207 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); | |
208 | |
209 // Remove the stub frame as we are about to jump to the dart function. | |
210 __ LeaveFrame(); | |
211 | |
212 __ Bind(&function_compiled); | |
213 // Patch caller. | |
214 | |
215 // Create a stub frame as we are pushing some objects on the stack before | |
216 // calling into the runtime. | |
217 AssemblerMacros::EnterStubFrame(assembler); | |
218 | |
219 __ pushl(EDX); // Preserve arguments descriptor array. | |
220 __ pushl(ECX); // Preserve function object. | |
221 __ CallRuntime(kPatchStaticCallRuntimeEntry); | 193 __ CallRuntime(kPatchStaticCallRuntimeEntry); |
222 __ popl(ECX); // Restore function object argument in ECX. | 194 __ popl(EAX); // Get Code object result. |
223 __ popl(EDX); // Restore arguments descriptor array. | 195 __ popl(EDX); // Restore arguments descriptor array. |
224 // Remove the stub frame as we are about to jump to the dart function. | 196 // Remove the stub frame as we are about to jump to the dart function. |
225 __ LeaveFrame(); | 197 __ LeaveFrame(); |
226 | 198 |
227 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); | |
228 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset())); | 199 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset())); |
229 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 200 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
230 __ jmp(ECX); | 201 __ jmp(ECX); |
231 } | 202 } |
232 | 203 |
233 | 204 |
234 // Called from a static call only when an invalid code has been entered | 205 // Called from a static call only when an invalid code has been entered |
235 // (invalid because its function was optimized or deoptimized). | 206 // (invalid because its function was optimized or deoptimized). |
236 // ECX: function object. | |
237 // EDX: arguments descriptor array (num_args is first Smi element). | 207 // EDX: arguments descriptor array (num_args is first Smi element). |
238 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { | 208 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { |
| 209 const Immediate raw_null = |
| 210 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
239 // Create a stub frame as we are pushing some objects on the stack before | 211 // Create a stub frame as we are pushing some objects on the stack before |
240 // calling into the runtime. | 212 // calling into the runtime. |
241 AssemblerMacros::EnterStubFrame(assembler); | 213 AssemblerMacros::EnterStubFrame(assembler); |
242 __ pushl(EDX); // Preserve arguments descriptor array. | 214 __ pushl(EDX); // Preserve arguments descriptor array. |
243 __ pushl(ECX); // Preserve target function. | 215 __ pushl(raw_null); // Setup space on stack for return value. |
244 __ pushl(ECX); // Target function. | |
245 __ CallRuntime(kFixCallersTargetRuntimeEntry); | 216 __ CallRuntime(kFixCallersTargetRuntimeEntry); |
246 __ popl(EAX); // discard argument. | 217 __ popl(EAX); // Get Code object. |
247 __ popl(EAX); // Restore function. | |
248 __ popl(EDX); // Restore arguments descriptor array. | 218 __ popl(EDX); // Restore arguments descriptor array. |
249 __ movl(EAX, FieldAddress(EAX, Function::code_offset())); | |
250 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); | 219 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); |
251 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 220 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
252 __ LeaveFrame(); | 221 __ LeaveFrame(); |
253 __ jmp(EAX); | 222 __ jmp(EAX); |
254 __ int3(); | 223 __ int3(); |
255 } | 224 } |
256 | 225 |
257 | 226 |
258 // Input parameters: | 227 // Input parameters: |
259 // EDI: argument count, may be zero. | 228 // EDI: argument count, may be zero. |
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 } | 1778 } |
1810 | 1779 |
1811 | 1780 |
1812 // Megamorphic call is currently implemented as IC call but through a stub | 1781 // Megamorphic call is currently implemented as IC call but through a stub |
1813 // that does not check/count function invocations. | 1782 // that does not check/count function invocations. |
1814 void StubCode::GenerateMegamorphicCallStub(Assembler* assembler) { | 1783 void StubCode::GenerateMegamorphicCallStub(Assembler* assembler) { |
1815 GenerateNArgsCheckInlineCacheStub(assembler, 1); | 1784 GenerateNArgsCheckInlineCacheStub(assembler, 1); |
1816 } | 1785 } |
1817 | 1786 |
1818 | 1787 |
1819 // ECX: Function object. | |
1820 // EDX: Arguments array. | 1788 // EDX: Arguments array. |
1821 // TOS(0): return address (Dart code). | 1789 // TOS(0): return address (Dart code). |
1822 void StubCode::GenerateBreakpointStaticStub(Assembler* assembler) { | 1790 void StubCode::GenerateBreakpointStaticStub(Assembler* assembler) { |
1823 // Create a stub frame as we are pushing some objects on the stack before | 1791 // Create a stub frame as we are pushing some objects on the stack before |
1824 // calling into the runtime. | 1792 // calling into the runtime. |
1825 AssemblerMacros::EnterStubFrame(assembler); | 1793 AssemblerMacros::EnterStubFrame(assembler); |
1826 __ pushl(EDX); | 1794 __ pushl(EDX); // Preserve arguments descriptor. |
1827 __ pushl(ECX); | 1795 const Immediate raw_null = |
| 1796 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1797 __ pushl(raw_null); // Room for result. |
1828 __ CallRuntime(kBreakpointStaticHandlerRuntimeEntry); | 1798 __ CallRuntime(kBreakpointStaticHandlerRuntimeEntry); |
1829 __ popl(ECX); | 1799 __ popl(EAX); // Code object. |
1830 __ popl(EDX); | 1800 __ popl(EDX); // Restore arguments descriptor. |
1831 __ LeaveFrame(); | 1801 __ LeaveFrame(); |
1832 | 1802 |
1833 // Now call the static function. The breakpoint handler function | 1803 // Now call the static function. The breakpoint handler function |
1834 // ensures that the call target is compiled. | 1804 // ensures that the call target is compiled. |
1835 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); | |
1836 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset())); | 1805 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset())); |
1837 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1806 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
1838 __ jmp(ECX); | 1807 __ jmp(ECX); |
1839 } | 1808 } |
1840 | 1809 |
1841 | 1810 |
1842 // TOS(0): return address (Dart code). | 1811 // TOS(0): return address (Dart code). |
1843 void StubCode::GenerateBreakpointReturnStub(Assembler* assembler) { | 1812 void StubCode::GenerateBreakpointReturnStub(Assembler* assembler) { |
1844 // Create a stub frame as we are pushing some objects on the stack before | 1813 // Create a stub frame as we are pushing some objects on the stack before |
1845 // calling into the runtime. | 1814 // calling into the runtime. |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2157 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); | 2126 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); |
2158 __ popl(EDX); | 2127 __ popl(EDX); |
2159 __ popl(EAX); | 2128 __ popl(EAX); |
2160 __ LeaveFrame(); | 2129 __ LeaveFrame(); |
2161 __ ret(); | 2130 __ ret(); |
2162 } | 2131 } |
2163 | 2132 |
2164 } // namespace dart | 2133 } // namespace dart |
2165 | 2134 |
2166 #endif // defined TARGET_ARCH_IA32 | 2135 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |