Commit 45ee6f40 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[liftoff] Change PatchPrepareStackFrame to use bytes

Calculate the number of bytes of the stack frame used in
PatchPrepareStackFrame using the size of the spill instead of the number
of slots.

We only need the number of bytes spilled (without adding the number of
locals) because whenever we spill, we already track the largest offset,
with RecordUsedSpillSlot. GetTotalFrameSlotCount can also be changed to
remove the num_locals, in a future patch.

Change-Id: I08fe3e81eaebf5f2cf1e11292645663474483447
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1945944
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65303}
parent 73a1a844
......@@ -242,10 +242,9 @@ int LiftoffAssembler::PrepareStackFrame() {
return offset;
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset,
uint32_t stack_slots) {
void LiftoffAssembler::PatchPrepareStackFrame(int offset, uint32_t spill_size) {
// Allocate space for instance plus what is needed for the frame slots.
uint32_t bytes = liftoff::kConstantStackSpace + kStackSlotSize * stack_slots;
uint32_t bytes = liftoff::kConstantStackSpace + spill_size;
#ifdef USE_SIMULATOR
// When using the simulator, deal with Liftoff which allocates the stack
// before checking it.
......
......@@ -120,11 +120,10 @@ int LiftoffAssembler::PrepareStackFrame() {
return offset;
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset,
uint32_t stack_slots) {
void LiftoffAssembler::PatchPrepareStackFrame(int offset, uint32_t spill_size) {
static_assert(kStackSlotSize == kXRegSize,
"kStackSlotSize must equal kXRegSize");
uint32_t bytes = liftoff::kConstantStackSpace + kStackSlotSize * stack_slots;
uint32_t bytes = liftoff::kConstantStackSpace + spill_size;
// The stack pointer is required to be quadword aligned.
// Misalignment will cause a stack alignment fault.
bytes = RoundUp(bytes, kQuadWordSizeInBytes);
......
......@@ -153,9 +153,8 @@ int LiftoffAssembler::PrepareStackFrame() {
return offset;
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset,
uint32_t stack_slots) {
uint32_t bytes = liftoff::kConstantStackSpace + kStackSlotSize * stack_slots;
void LiftoffAssembler::PatchPrepareStackFrame(int offset, uint32_t spill_size) {
uint32_t bytes = liftoff::kConstantStackSpace + spill_size;
DCHECK_LE(bytes, kMaxInt);
// We can't run out of space, just pass anything big enough to not cause the
// assembler to try to grow the buffer.
......
......@@ -404,7 +404,7 @@ class LiftoffAssembler : public TurboAssembler {
// which can later be patched (via {PatchPrepareStackFrame)} when the size of
// the frame is known.
inline int PrepareStackFrame();
inline void PatchPrepareStackFrame(int offset, uint32_t stack_slots);
inline void PatchPrepareStackFrame(int offset, uint32_t spill_size);
inline void FinishCode();
inline void AbortCompilation();
......@@ -683,6 +683,8 @@ class LiftoffAssembler : public TurboAssembler {
((num_used_spill_bytes_ + kStackSlotSize - 1) / kStackSlotSize);
}
uint32_t GetTotalFrameSlotSize() const { return num_used_spill_bytes_; }
ValueType local_type(uint32_t index) {
DCHECK_GT(num_locals_, index);
ValueType* locals =
......
......@@ -349,7 +349,8 @@ class LiftoffCompiler {
int num_locals = decoder->num_locals();
__ set_num_locals(num_locals);
for (int i = 0; i < num_locals; ++i) {
__ set_local_type(i, decoder->GetLocalType(i));
ValueType type = decoder->GetLocalType(i);
__ set_local_type(i, type);
}
}
......@@ -549,7 +550,7 @@ class LiftoffCompiler {
GenerateOutOfLineCode(&ool);
}
__ PatchPrepareStackFrame(pc_offset_stack_frame_construction_,
__ GetTotalFrameSlotCount());
__ GetTotalFrameSlotSize());
__ FinishCode();
safepoint_table_builder_.Emit(&asm_, __ GetTotalFrameSlotCount());
__ MaybeEmitOutOfLineConstantPool();
......
......@@ -282,9 +282,8 @@ int LiftoffAssembler::PrepareStackFrame() {
return offset;
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset,
uint32_t stack_slots) {
uint32_t bytes = liftoff::kConstantStackSpace + kStackSlotSize * stack_slots;
void LiftoffAssembler::PatchPrepareStackFrame(int offset, uint32_t spill_size) {
uint32_t bytes = liftoff::kConstantStackSpace + spill_size;
DCHECK_LE(bytes, kMaxInt);
// We can't run out of space, just pass anything big enough to not cause the
// assembler to try to grow the buffer.
......
......@@ -240,9 +240,8 @@ int LiftoffAssembler::PrepareStackFrame() {
return offset;
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset,
uint32_t stack_slots) {
uint64_t bytes = liftoff::kConstantStackSpace + kStackSlotSize * stack_slots;
void LiftoffAssembler::PatchPrepareStackFrame(int offset, uint32_t spill_size) {
uint64_t bytes = liftoff::kConstantStackSpace + spill_size;
DCHECK_LE(bytes, kMaxInt);
// We can't run out of space, just pass anything big enough to not cause the
// assembler to try to grow the buffer.
......
......@@ -56,8 +56,7 @@ int LiftoffAssembler::PrepareStackFrame() {
return 0;
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset,
uint32_t stack_slots) {
void LiftoffAssembler::PatchPrepareStackFrame(int offset, uint32_t spill_size) {
bailout(kUnsupportedArchitecture, "PatchPrepareStackFrame");
}
......
......@@ -55,8 +55,7 @@ int LiftoffAssembler::PrepareStackFrame() {
return 0;
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset,
uint32_t stack_slots) {
void LiftoffAssembler::PatchPrepareStackFrame(int offset, uint32_t spill_size) {
bailout(kUnsupportedArchitecture, "PatchPrepareStackFrame");
}
......
......@@ -136,9 +136,8 @@ int LiftoffAssembler::PrepareStackFrame() {
return offset;
}
void LiftoffAssembler::PatchPrepareStackFrame(int offset,
uint32_t stack_slots) {
uint32_t bytes = liftoff::kConstantStackSpace + kStackSlotSize * stack_slots;
void LiftoffAssembler::PatchPrepareStackFrame(int offset, uint32_t spill_size) {
uint32_t bytes = liftoff::kConstantStackSpace + spill_size;
DCHECK_LE(bytes, kMaxInt);
// We can't run out of space, just pass anything big enough to not cause the
// assembler to try to grow the buffer.
......
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