Commit b18bc221 authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[compiler][linkage] No allocation of slots after aligning a frame

- Adds DCHECKs to make sure no stack slots are allocated after
  aligning a frame.
- Changes Arm64 CodeGenerator::FinishFrame to align the frame after
  allocating callee-saved registers, and relaxes the constraints on
  the number of callee-saved registers.

Bug: v8:9198
Change-Id: Iacb0518b57fa3ea2ff801eda69719f4c32733850
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2694104Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72781}
parent 321f2d31
......@@ -3050,7 +3050,6 @@ void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) {
}
void CodeGenerator::FinishFrame(Frame* frame) {
frame->AlignFrame(16);
auto call_descriptor = linkage()->GetIncomingDescriptor();
// Save FP registers.
......@@ -3059,7 +3058,6 @@ void CodeGenerator::FinishFrame(Frame* frame) {
int saved_count = saves_fp.Count();
if (saved_count != 0) {
DCHECK(saves_fp.list() == CPURegList::GetCalleeSavedV().list());
DCHECK_EQ(saved_count % 2, 0);
frame->AllocateSavedCalleeRegisterSlots(saved_count *
(kDoubleSize / kSystemPointerSize));
}
......@@ -3068,9 +3066,9 @@ void CodeGenerator::FinishFrame(Frame* frame) {
call_descriptor->CalleeSavedRegisters());
saved_count = saves.Count();
if (saved_count != 0) {
DCHECK_EQ(saved_count % 2, 0);
frame->AllocateSavedCalleeRegisterSlots(saved_count);
}
frame->AlignFrame(16);
}
void CodeGenerator::AssembleConstructFrame() {
......
......@@ -20,6 +20,7 @@ Frame::Frame(int fixed_frame_size_in_slots)
void Frame::AlignFrame(int alignment) {
#if DEBUG
spill_slots_finished_ = true;
frame_aligned_ = true;
#endif
// In the calculations below we assume that alignment is a power of 2.
DCHECK(base::bits::IsPowerOfTwo(alignment));
......
......@@ -116,6 +116,7 @@ class V8_EXPORT_PRIVATE Frame : public ZoneObject {
}
void AlignSavedCalleeRegisterSlots(int alignment = kDoubleSize) {
DCHECK(!frame_aligned_);
#if DEBUG
spill_slots_finished_ = true;
#endif
......@@ -127,6 +128,7 @@ class V8_EXPORT_PRIVATE Frame : public ZoneObject {
}
void AllocateSavedCalleeRegisterSlots(int count) {
DCHECK(!frame_aligned_);
#if DEBUG
spill_slots_finished_ = true;
#endif
......@@ -138,6 +140,7 @@ class V8_EXPORT_PRIVATE Frame : public ZoneObject {
fixed_slot_count_ + spill_slot_count_ + return_slot_count_);
// Never allocate spill slots after the callee-saved slots are defined.
DCHECK(!spill_slots_finished_);
DCHECK(!frame_aligned_);
int actual_width = std::max({width, AlignedSlotAllocator::kSlotSize});
int actual_alignment =
std::max({alignment, AlignedSlotAllocator::kSlotSize});
......@@ -164,6 +167,7 @@ class V8_EXPORT_PRIVATE Frame : public ZoneObject {
}
void EnsureReturnSlots(int count) {
DCHECK(!frame_aligned_);
return_slot_count_ = std::max(return_slot_count_, count);
}
......@@ -171,6 +175,7 @@ class V8_EXPORT_PRIVATE Frame : public ZoneObject {
int ReserveSpillSlots(size_t slot_count) {
DCHECK_EQ(0, spill_slot_count_);
DCHECK(!frame_aligned_);
spill_slot_count_ += static_cast<int>(slot_count);
slot_allocator_.AllocateUnaligned(static_cast<int>(slot_count));
return slot_allocator_.Size() - 1;
......@@ -187,6 +192,7 @@ class V8_EXPORT_PRIVATE Frame : public ZoneObject {
BitVector* allocated_double_registers_;
#if DEBUG
bool spill_slots_finished_ = false;
bool frame_aligned_ = false;
#endif
};
......
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