Commit 0e7379e0 authored by balazs.kilvady's avatar balazs.kilvady Committed by Commit bot

MIPS: Refactoring after 'MIPS: split api call stubs into accessor and function call stubs'.

Change stack handling to clarify the usage of reserved MIPS argument slots for mips32.

BUG=

Review URL: https://codereview.chromium.org/867183003

Cr-Commit-Position: refs/heads/master@{#26279}
parent 54bbbdd3
......@@ -4845,13 +4845,10 @@ static int AddressOffset(ExternalReference ref0, ExternalReference ref1) {
// 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);
......@@ -4945,13 +4942,15 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
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);
{
......@@ -5082,15 +5081,13 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm,
}
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);
}
......@@ -5139,7 +5136,7 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) {
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);
}
......
......@@ -924,6 +924,7 @@ class Instruction {
// 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.
......
......@@ -4887,13 +4887,10 @@ static int AddressOffset(ExternalReference ref0, ExternalReference ref1) {
// 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);
......@@ -4987,13 +4984,14 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
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);
......@@ -5123,14 +5121,13 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm,
}
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);
}
......@@ -5179,7 +5176,7 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) {
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);
}
......
......@@ -942,6 +942,7 @@ const int kCArgSlotCount = (kMipsAbi == kN64) ? 0 : 4;
// 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment