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/ic_data.h" | 10 #include "vm/ic_data.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // Remove the stub frame as we are about to jump to the dart function. | 222 // Remove the stub frame as we are about to jump to the dart function. |
223 __ LeaveFrame(); | 223 __ LeaveFrame(); |
224 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); | 224 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); |
225 | 225 |
226 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset())); | 226 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset())); |
227 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 227 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
228 __ jmp(ECX); | 228 __ jmp(ECX); |
229 } | 229 } |
230 | 230 |
231 | 231 |
232 // Stub is entered after a call but before the callee's frame has been | |
233 // constructed. | |
234 // Handle stack overflow by calling the runtime routine and preserving | |
235 // the argument descriptor (EDX) and the ic-data array/function object of | |
236 // the call (ECX). | |
237 // The stub must be able to return to callee in case the stack overflow | |
238 // exception is not thrown. | |
239 void StubCode::GenerateStackOverflowStub(Assembler* assembler) { | |
240 __ EnterFrame(0); | |
241 // Stack at this point: | |
242 // TOS + 0: Saved EBP of previous frame. <== EBP | |
243 // TOS + 1: Dart code return address | |
244 // TOS + 2: Last argument of caller. | |
245 // .... | |
246 __ pushl(EDX); // Preserve arguments descriptor array. | |
247 __ pushl(ECX); // Preserve object (ic-data array or function object). | |
248 __ CallRuntimeFromStub(kStackOverflowRuntimeEntry); | |
249 __ popl(ECX); // Restore object (ic-data array or function object). | |
250 __ popl(EDX); // Restore arguments descriptor array. | |
251 __ LeaveFrame(); | |
252 __ int3(); | |
253 } | |
254 | |
255 | |
256 // Called when number of invocations exceeds | 232 // Called when number of invocations exceeds |
257 // --optimization_invocation_threshold. | 233 // --optimization_invocation_threshold. |
258 // EAX: target function. | 234 // EAX: target function. |
259 // EDX: arguments descriptor array (num_args is first Smi element). | 235 // EDX: arguments descriptor array (num_args is first Smi element). |
260 void StubCode::GenerateOptimizeInvokedFunctionStub(Assembler* assembler) { | 236 void StubCode::GenerateOptimizeInvokedFunctionStub(Assembler* assembler) { |
261 __ EnterFrame(0); | 237 __ EnterFrame(0); |
262 __ pushl(EDX); // Preserve arguments descriptor array. | 238 __ pushl(EDX); // Preserve arguments descriptor array. |
263 __ pushl(EAX); // Preserve target function. | 239 __ pushl(EAX); // Preserve target function. |
264 __ pushl(EAX); // Target function. | 240 __ pushl(EAX); // Target function. |
265 __ CallRuntimeFromStub(kOptimizeInvokedFunctionRuntimeEntry); | 241 __ CallRuntimeFromStub(kOptimizeInvokedFunctionRuntimeEntry); |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 __ popl(EDX); | 1634 __ popl(EDX); |
1659 __ popl(ECX); | 1635 __ popl(ECX); |
1660 __ LeaveFrame(); | 1636 __ LeaveFrame(); |
1661 // Now call the dynamic function. | 1637 // Now call the dynamic function. |
1662 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); | 1638 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); |
1663 } | 1639 } |
1664 | 1640 |
1665 } // namespace dart | 1641 } // namespace dart |
1666 | 1642 |
1667 #endif // defined TARGET_ARCH_IA32 | 1643 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |