// from handle and propagates exceptions. Restores context. stack_space
// - space to be unwound on exit (includes the call JS arguments space and
// the additional space allocated for the fast call).
-static void CallApiFunctionAndReturn(MacroAssembler* masm,
- Register function_address,
- ExternalReference thunk_ref,
- int stack_space,
- MemOperand* stack_space_operand,
- MemOperand return_value_operand,
- MemOperand* context_restore_operand) {
+static void CallApiFunctionAndReturn(
+ MacroAssembler* masm, Register function_address,
+ ExternalReference thunk_ref, int stack_space, int32_t stack_space_offset,
+ MemOperand return_value_operand, MemOperand* context_restore_operand) {
Isolate* isolate = masm->isolate();
ExternalReference next_address =
ExternalReference::handle_scope_next_address(isolate);
if (restore_context) {
__ lw(cp, *context_restore_operand);
}
- if (stack_space_operand != NULL) {
- __ lw(s0, *stack_space_operand);
+ if (stack_space_offset != kInvalidStackOffset) {
+ // ExitFrame contains four MIPS argument slots after DirectCEntryStub call
+ // so this must be accounted for.
+ __ lw(s0, MemOperand(sp, stack_space_offset + kCArgsSlotsSize));
} else {
__ li(s0, Operand(stack_space));
}
__ LeaveExitFrame(false, s0, !restore_context, EMIT_RETURN,
- stack_space_operand != NULL);
+ stack_space_offset != kInvalidStackOffset);
__ bind(&promote_scheduled_exception);
{
}
MemOperand return_value_operand(fp, return_value_offset * kPointerSize);
int stack_space = 0;
- MemOperand is_construct_call_operand =
- MemOperand(sp, 4 * kPointerSize + kCArgsSlotsSize);
- MemOperand* stack_space_operand = &is_construct_call_operand;
+ int32_t stack_space_offset = 4 * kPointerSize;
if (argc.is_immediate()) {
stack_space = argc.immediate() + FCA::kArgsLength + 1;
- stack_space_operand = NULL;
+ stack_space_offset = kInvalidStackOffset;
}
CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space,
- stack_space_operand, return_value_operand,
+ stack_space_offset, return_value_operand,
&context_restore_operand);
}
ExternalReference thunk_ref =
ExternalReference::invoke_accessor_getter_callback(isolate());
CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
- kStackUnwindSpace, NULL,
+ kStackUnwindSpace, kInvalidStackOffset,
MemOperand(fp, 6 * kPointerSize), NULL);
}
// C/C++ argument slots size.
const int kCArgSlotCount = 4;
const int kCArgsSlotsSize = kCArgSlotCount * Instruction::kInstrSize;
+const int kInvalidStackOffset = -1;
// JS argument slots size.
const int kJSArgsSlotsSize = 0 * Instruction::kInstrSize;
// Assembly builtins argument slots size.
// from handle and propagates exceptions. Restores context. stack_space
// - space to be unwound on exit (includes the call JS arguments space and
// the additional space allocated for the fast call).
-static void CallApiFunctionAndReturn(MacroAssembler* masm,
- Register function_address,
- ExternalReference thunk_ref,
- int stack_space,
- MemOperand* stack_space_operand,
- MemOperand return_value_operand,
- MemOperand* context_restore_operand) {
+static void CallApiFunctionAndReturn(
+ MacroAssembler* masm, Register function_address,
+ ExternalReference thunk_ref, int stack_space, int32_t stack_space_offset,
+ MemOperand return_value_operand, MemOperand* context_restore_operand) {
Isolate* isolate = masm->isolate();
ExternalReference next_address =
ExternalReference::handle_scope_next_address(isolate);
if (restore_context) {
__ ld(cp, *context_restore_operand);
}
- if (stack_space_operand != NULL) {
- __ lw(s0, *stack_space_operand);
+ if (stack_space_offset != kInvalidStackOffset) {
+ DCHECK(kCArgsSlotsSize == 0);
+ __ ld(s0, MemOperand(sp, stack_space_offset));
} else {
__ li(s0, Operand(stack_space));
}
__ LeaveExitFrame(false, s0, !restore_context, EMIT_RETURN,
- stack_space_operand != NULL);
+ stack_space_offset != kInvalidStackOffset);
__ bind(&promote_scheduled_exception);
{
FrameScope frame(masm, StackFrame::INTERNAL);
}
MemOperand return_value_operand(fp, return_value_offset * kPointerSize);
int stack_space = 0;
- MemOperand is_construct_call_operand = MemOperand(sp, 4 * kPointerSize);
- MemOperand* stack_space_operand = &is_construct_call_operand;
+ int32_t stack_space_offset = 4 * kPointerSize;
if (argc.is_immediate()) {
stack_space = argc.immediate() + FCA::kArgsLength + 1;
- stack_space_operand = NULL;
+ stack_space_offset = kInvalidStackOffset;
}
CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space,
- stack_space_operand, return_value_operand,
+ stack_space_offset, return_value_operand,
&context_restore_operand);
}
ExternalReference thunk_ref =
ExternalReference::invoke_accessor_getter_callback(isolate());
CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
- kStackUnwindSpace, NULL,
+ kStackUnwindSpace, kInvalidStackOffset,
MemOperand(fp, 6 * kPointerSize), NULL);
}
// TODO(plind): find all usages and remove the needless instructions for n64.
const int kCArgsSlotsSize = kCArgSlotCount * Instruction::kInstrSize * 2;
+const int kInvalidStackOffset = -1;
const int kBranchReturnOffset = 2 * Instruction::kInstrSize;
} } // namespace v8::internal