[liftoff][arm64] Remove frame size padding to 4k
Before https://crrev.com/c/3054114 we needed to pad the frame size to 4k so that it fits into a 'sub' instruction as an immediate. Since frame sizes larger than 4k use special OOL code now, this is not required any more. We thus remove the padding to save stack space. R=ahaas@chromium.org Bug: chromium:1379364 Change-Id: I155628141d2c0438415ccff36a4de8f7d1ad4fd3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3991050 Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/main@{#83999}
This commit is contained in:
parent
01a368bb49
commit
2f5fbb1381
@ -298,27 +298,18 @@ void LiftoffAssembler::AlignFrameSize() {
|
||||
// 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 initial_frame_size = GetTotalFrameSize() - 2 * kSystemPointerSize;
|
||||
int frame_size = initial_frame_size;
|
||||
int frame_size = GetTotalFrameSize() - 2 * kSystemPointerSize;
|
||||
|
||||
static_assert(kStackSlotSize == kXRegSize,
|
||||
"kStackSlotSize must equal kXRegSize");
|
||||
|
||||
// The stack pointer is required to be quadword aligned.
|
||||
// Misalignment will cause a stack alignment fault.
|
||||
frame_size = RoundUp(frame_size, kQuadWordSizeInBytes);
|
||||
if (!IsImmAddSub(frame_size)) {
|
||||
// Round the stack to a page to try to fit a add/sub immediate.
|
||||
frame_size = RoundUp(frame_size, 0x1000);
|
||||
if (!IsImmAddSub(frame_size)) {
|
||||
// Stack greater than 4M! Because this is a quite improbable case, we
|
||||
// just fallback to TurboFan.
|
||||
bailout(kOtherReason, "Stack too big");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (frame_size > initial_frame_size) {
|
||||
// Record the padding, as it is needed for GC offsets later.
|
||||
max_used_spill_offset_ += (frame_size - initial_frame_size);
|
||||
int misalignment = frame_size % kQuadWordSizeInBytes;
|
||||
if (misalignment) {
|
||||
int padding = kQuadWordSizeInBytes - misalignment;
|
||||
frame_size += padding;
|
||||
max_used_spill_offset_ += padding;
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,7 +328,6 @@ void LiftoffAssembler::PatchPrepareStackFrame(
|
||||
// The stack pointer is required to be quadword aligned.
|
||||
// Misalignment will cause a stack alignment fault.
|
||||
DCHECK_EQ(frame_size, RoundUp(frame_size, kQuadWordSizeInBytes));
|
||||
DCHECK(IsImmAddSub(frame_size));
|
||||
|
||||
PatchingAssembler patching_assembler(AssemblerOptions{},
|
||||
buffer_start_ + offset, 1);
|
||||
@ -345,6 +335,7 @@ void LiftoffAssembler::PatchPrepareStackFrame(
|
||||
if (V8_LIKELY(frame_size < 4 * KB)) {
|
||||
// This is the standard case for small frames: just subtract from SP and be
|
||||
// done with it.
|
||||
DCHECK(IsImmAddSub(frame_size));
|
||||
patching_assembler.PatchSubSp(frame_size);
|
||||
return;
|
||||
}
|
||||
|
11
test/mjsunit/regress/wasm/regress-1379364.js
Normal file
11
test/mjsunit/regress/wasm/regress-1379364.js
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright 2022 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
const builder = new WasmModuleBuilder();
|
||||
builder.addFunction(undefined, kSig_d_v)
|
||||
.addLocals(kWasmExternRef, 16000)
|
||||
.addBody([kExprUnreachable]);
|
||||
builder.toModule();
|
Loading…
Reference in New Issue
Block a user