Commit 2180e20f authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm][liftoff] Don't reserve space for the stack marker twice

The total frame size returned by GetTotalFrameSize includes the frame
marker. However, the frame marker is pushed on the stack with a push
instruction. Therefore it is not needed to allocate memory for it again
on the stack. This CL therefore reduces the memory allocated on the
stack by the size of the frame marker.

R=clemensb@chromium.org

Bug: v8:11074
Change-Id: Ie04508a57a2c641a2ee5d89d72dd22ec0572b5e5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2557510Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71373}
parent 7b6b216f
......@@ -446,7 +446,12 @@ void LiftoffAssembler::PrepareTailCall(int num_callee_stack_params,
Pop(lr, fp);
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset, int frame_size) {
void LiftoffAssembler::PatchPrepareStackFrame(int offset) {
// The frame_size includes the frame marker. The frame marker has already been
// pushed on the stack though, so we don't need to allocate memory for it
// anymore.
int frame_size = GetTotalFrameSize() - kSystemPointerSize;
#ifdef USE_SIMULATOR
// When using the simulator, deal with Liftoff which allocates the stack
// before checking it.
......
......@@ -225,7 +225,12 @@ void LiftoffAssembler::PrepareTailCall(int num_callee_stack_params,
Sub(sp, x16, stack_param_delta * 8);
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset, int frame_size) {
void LiftoffAssembler::PatchPrepareStackFrame(int offset) {
// The frame_size includes the frame marker. The frame marker has already been
// pushed on the stack though, so we don't need to allocate memory for it
// anymore.
int frame_size = GetTotalFrameSize() - kSystemPointerSize;
static_assert(kStackSlotSize == kXRegSize,
"kStackSlotSize must equal kXRegSize");
// The stack pointer is required to be quadword aligned.
......
......@@ -189,7 +189,11 @@ void LiftoffAssembler::PrepareTailCall(int num_callee_stack_params,
pop(ebp);
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset, int frame_size) {
void LiftoffAssembler::PatchPrepareStackFrame(int offset) {
// The frame_size includes the frame marker. The frame marker has already been
// pushed on the stack though, so we don't need to allocate memory for it
// anymore.
int frame_size = GetTotalFrameSize() - kSystemPointerSize;
DCHECK_EQ(frame_size % kSystemPointerSize, 0);
// We can't run out of space, just pass anything big enough to not cause the
// assembler to try to grow the buffer.
......
......@@ -469,7 +469,7 @@ class LiftoffAssembler : public TurboAssembler {
inline int PrepareStackFrame();
inline void PrepareTailCall(int num_callee_stack_params,
int stack_param_delta);
inline void PatchPrepareStackFrame(int offset, int frame_size);
inline void PatchPrepareStackFrame(int offset);
inline void FinishCode();
inline void AbortCompilation();
inline static constexpr int StaticStackFrameSize();
......
......@@ -760,8 +760,7 @@ class LiftoffCompiler {
for (OutOfLineCode& ool : out_of_line_code_) {
GenerateOutOfLineCode(&ool);
}
__ PatchPrepareStackFrame(pc_offset_stack_frame_construction_,
__ GetTotalFrameSize());
__ PatchPrepareStackFrame(pc_offset_stack_frame_construction_);
__ FinishCode();
safepoint_table_builder_.Emit(&asm_, __ GetTotalFrameSlotCountForGC());
__ MaybeEmitOutOfLineConstantPool();
......
......@@ -300,7 +300,12 @@ void LiftoffAssembler::PrepareTailCall(int num_callee_stack_params,
Pop(ra, fp);
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset, int frame_size) {
void LiftoffAssembler::PatchPrepareStackFrame(int offset) {
// The frame_size includes the frame marker. The frame marker has already been
// pushed on the stack though, so we don't need to allocate memory for it
// anymore.
int frame_size = GetTotalFrameSize() - kSystemPointerSize;
// We can't run out of space, just pass anything big enough to not cause the
// assembler to try to grow the buffer.
constexpr int kAvailableSpace = 256;
......
......@@ -287,7 +287,12 @@ void LiftoffAssembler::PrepareTailCall(int num_callee_stack_params,
Pop(ra, fp);
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset, int frame_size) {
void LiftoffAssembler::PatchPrepareStackFrame(int offset) {
// The frame_size includes the frame marker. The frame marker has already been
// pushed on the stack though, so we don't need to allocate memory for it
// anymore.
int frame_size = GetTotalFrameSize() - kSystemPointerSize;
// We can't run out of space, just pass anything big enough to not cause the
// assembler to try to grow the buffer.
constexpr int kAvailableSpace = 256;
......
......@@ -160,7 +160,11 @@ void LiftoffAssembler::PrepareTailCall(int num_callee_stack_params,
popq(rbp);
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset, int frame_size) {
void LiftoffAssembler::PatchPrepareStackFrame(int offset) {
// The frame_size includes the frame marker. The frame marker has already been
// pushed on the stack though, so we don't need to allocate memory for it
// anymore.
int frame_size = GetTotalFrameSize() - kSystemPointerSize;
// Need to align sp to system pointer size.
frame_size = RoundUp(frame_size, kSystemPointerSize);
// We can't run out of space, just pass anything big enough to not cause the
......
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