Chromium Code Reviews| Index: src/ia32/macro-assembler-ia32.cc |
| =================================================================== |
| --- src/ia32/macro-assembler-ia32.cc (revision 5829) |
| +++ src/ia32/macro-assembler-ia32.cc (working copy) |
| @@ -392,13 +392,8 @@ |
| } |
| -void MacroAssembler::EnterApiExitFrame(int stack_space, |
| - int argc) { |
| +void MacroAssembler::EnterApiExitFrame(int argc) { |
| EnterExitFramePrologue(); |
| - |
| - int offset = StandardFrameConstants::kCallerSPOffset - kPointerSize; |
| - lea(esi, Operand(ebp, (stack_space * kPointerSize) + offset)); |
| - |
| EnterExitFrameEpilogue(argc); |
| } |
| @@ -427,6 +422,23 @@ |
| } |
| +void MacroAssembler::LeaveApiExitFrame() { |
| + mov(esp, Operand(ebp)); |
| + pop(ebp); |
| + |
| + // Restore current context from top and clear it in debug mode. |
|
antonm
2010/11/16 14:32:26
I'd suggest (but not insisting) to factor out comm
SeRya
2010/11/16 14:53:28
Done.
|
| + ExternalReference context_address(Top::k_context_address); |
| + mov(esi, Operand::StaticVariable(context_address)); |
| +#ifdef DEBUG |
| + mov(Operand::StaticVariable(context_address), Immediate(0)); |
| +#endif |
| + |
| + // Clear the top frame. |
| + ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); |
| + mov(Operand::StaticVariable(c_entry_fp_address), Immediate(0)); |
| +} |
| + |
| + |
| void MacroAssembler::PushTryHandler(CodeLocation try_location, |
| HandlerType type) { |
| // Adjust this code if not the case. |
| @@ -1151,21 +1163,15 @@ |
| } |
| -void MacroAssembler::PrepareCallApiFunction(int stack_space, int argc) { |
| +void MacroAssembler::PrepareCallApiFunction(int argc, Register scratch) { |
| if (kPassHandlesDirectly) { |
| - EnterApiExitFrame(stack_space, argc); |
| + EnterApiExitFrame(argc); |
| // When handles as passed directly we don't have to allocate extra |
| // space for and pass an out parameter. |
| } else { |
| // We allocate two additional slots: return value and pointer to it. |
| - EnterApiExitFrame(stack_space, argc + 2); |
| - } |
| -} |
| + EnterApiExitFrame(argc + 2); |
| - |
| -MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn(ApiFunction* function, |
| - int argc) { |
| - if (!kPassHandlesDirectly) { |
| // The argument slots are filled as follows: |
| // |
| // n + 1: output cell |
| @@ -1177,11 +1183,19 @@ |
| // Note that this is one more "argument" than the function expects |
| // so the out cell will have to be popped explicitly after returning |
| // from the function. The out cell contains Handle. |
| - lea(eax, Operand(esp, (argc + 1) * kPointerSize)); // pointer to out cell. |
| - mov(Operand(esp, 0 * kPointerSize), eax); // output. |
| - mov(Operand(esp, (argc + 1) * kPointerSize), Immediate(0)); // out cell. |
| + |
| + // pointer to out cell. |
| + lea(scratch, Operand(esp, (argc + 1) * kPointerSize)); |
| + mov(Operand(esp, 0 * kPointerSize), scratch); // output. |
| + if (FLAG_debug_code) { |
| + mov(Operand(esp, (argc + 1) * kPointerSize), Immediate(0)); // out cell. |
| + } |
| } |
| +} |
| + |
| +MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn(ApiFunction* function, |
| + int stack_space) { |
| ExternalReference next_address = |
| ExternalReference::handle_scope_next_address(); |
| ExternalReference limit_address = |
| @@ -1230,8 +1244,8 @@ |
| cmp(Operand::StaticVariable(scheduled_exception_address), |
| Immediate(Factory::the_hole_value())); |
| j(not_equal, &promote_scheduled_exception, not_taken); |
| - LeaveExitFrame(); |
| - ret(0); |
| + LeaveApiExitFrame(); |
| + ret(stack_space * kPointerSize); |
| bind(&promote_scheduled_exception); |
| MaybeObject* result = |
| TryTailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); |