Commit 8c7a29b2 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[nojit] Consistently use DCHECKs in CallApi helper

This addresses follow-up comments to https://crrev.com/c/1354887/.

Use DCHECKs instead of CHECKs and make the branch order consistent
across architectures.

Bug: v8:7777
Change-Id: I5c3f8f5ac97b55fa80662bc211aff7833ff12bfa
Reviewed-on: https://chromium-review.googlesource.com/c/1362912
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58063}
parent 0c25d512
......@@ -2746,10 +2746,12 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
// Leave the API exit frame.
__ bind(&leave_exit_frame);
// LeaveExitFrame expects unwind space to be in a register.
if (stack_space_operand != nullptr) {
__ ldr(r4, *stack_space_operand);
} else {
if (stack_space_operand == nullptr) {
DCHECK_NE(stack_space, 0);
__ mov(r4, Operand(stack_space));
} else {
DCHECK_EQ(stack_space, 0);
__ ldr(r4, *stack_space_operand);
}
__ LeaveExitFrame(false, r4, stack_space_operand != nullptr);
......
......@@ -3328,7 +3328,7 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
__ Peek(x22, (spill_offset + 3) * kXRegSize);
if (stack_space_operand != nullptr) {
CHECK_EQ(stack_space, 0);
DCHECK_EQ(stack_space, 0);
// Load the number of stack slots to drop before LeaveExitFrame modifies sp.
__ Ldr(x19, *stack_space_operand);
}
......@@ -3341,10 +3341,10 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
__ JumpIfNotRoot(x5, RootIndex::kTheHoleValue, &promote_scheduled_exception);
if (stack_space_operand == nullptr) {
CHECK_NE(stack_space, 0);
DCHECK_NE(stack_space, 0);
__ DropSlots(stack_space);
} else {
CHECK_EQ(stack_space, 0);
DCHECK_EQ(stack_space, 0);
__ DropArguments(x19);
}
......
......@@ -3065,6 +3065,7 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
// Leave the API exit frame.
__ bind(&leave_exit_frame);
if (stack_space_operand != nullptr) {
DCHECK_EQ(stack_space, 0);
__ mov(edx, *stack_space_operand);
}
__ LeaveApiExitFrame();
......@@ -3111,13 +3112,14 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
__ bind(&ok);
#endif
if (stack_space_operand != nullptr) {
if (stack_space_operand == nullptr) {
DCHECK_NE(stack_space, 0);
__ ret(stack_space * kPointerSize);
} else {
DCHECK_EQ(0, stack_space);
__ pop(ecx);
__ add(esp, edx);
__ jmp(ecx);
} else {
__ ret(stack_space * kPointerSize);
}
// Re-throw by promoting a scheduled exception.
......
......@@ -2834,10 +2834,10 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
__ bind(&leave_exit_frame);
if (stack_space_operand == nullptr) {
CHECK_NE(stack_space, 0);
DCHECK_NE(stack_space, 0);
__ li(s0, Operand(stack_space));
} else {
CHECK_EQ(stack_space, 0);
DCHECK_EQ(stack_space, 0);
// The ExitFrame contains four MIPS argument slots after the call so this
// must be accounted for.
// TODO(jgruber): Investigate if this is needed by the direct call.
......
......@@ -2856,10 +2856,10 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
__ bind(&leave_exit_frame);
if (stack_space_operand == nullptr) {
CHECK_NE(stack_space, 0);
DCHECK_NE(stack_space, 0);
__ li(s0, Operand(stack_space));
} else {
CHECK_EQ(stack_space, 0);
DCHECK_EQ(stack_space, 0);
STATIC_ASSERT(kCArgSlotCount == 0);
__ Ld(s0, *stack_space_operand);
}
......
......@@ -2945,6 +2945,7 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
// Leave the API exit frame.
__ bind(&leave_exit_frame);
if (stack_space_operand != nullptr) {
DCHECK_EQ(stack_space, 0);
__ movp(rbx, *stack_space_operand);
}
__ LeaveApiExitFrame();
......@@ -2989,13 +2990,14 @@ void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address,
__ bind(&ok);
#endif
if (stack_space_operand != nullptr) {
if (stack_space_operand == nullptr) {
DCHECK_NE(stack_space, 0);
__ ret(stack_space * kPointerSize);
} else {
DCHECK_EQ(stack_space, 0);
__ PopReturnAddressTo(rcx);
__ addq(rsp, rbx);
__ jmp(rcx);
} else {
__ ret(stack_space * kPointerSize);
}
// Re-throw by promoting a scheduled exception.
......
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