Commit 65ea58c8 authored by Liu Yu's avatar Liu Yu Committed by Commit Bot

[mips][wasm][liftoff] Respect CallDescriptor linkage

Port: c2a1d633

Bug: v8:9198
Change-Id: I5b448fec800b0db2860f415dd3ddcfe98728b501
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2738791
Auto-Submit: Liu yu <liuyu@loongson.cn>
Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Cr-Commit-Position: refs/heads/master@{#73244}
parent 84409f08
......@@ -83,6 +83,13 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
}
void LeaveFrame(StackFrame::Type type);
void AllocateStackSpace(Register bytes) { Subu(sp, sp, bytes); }
void AllocateStackSpace(int bytes) {
DCHECK_GE(bytes, 0);
if (bytes == 0) return;
Subu(sp, sp, Operand(bytes));
}
// Generates function and stub prologue code.
void StubPrologue(StackFrame::Type type);
void Prologue();
......
......@@ -103,6 +103,14 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
}
void LeaveFrame(StackFrame::Type type);
void AllocateStackSpace(Register bytes) { Dsubu(sp, sp, bytes); }
void AllocateStackSpace(int bytes) {
DCHECK_GE(bytes, 0);
if (bytes == 0) return;
Dsubu(sp, sp, Operand(bytes));
}
// Generates function and stub prologue code.
void StubPrologue(StackFrame::Type type);
void Prologue();
......
......@@ -1349,7 +1349,7 @@ void InstructionSelector::EmitPrepareArguments(
}
} else {
// Possibly align stack here for functions.
int push_count = static_cast<int>(call_descriptor->StackParameterCount());
int push_count = static_cast<int>(call_descriptor->ParameterSlotCount());
if (push_count > 0) {
// Calculate needed space
int stack_size = 0;
......
......@@ -1768,7 +1768,7 @@ void InstructionSelector::EmitPrepareArguments(
++slot;
}
} else {
int push_count = static_cast<int>(call_descriptor->StackParameterCount());
int push_count = static_cast<int>(call_descriptor->ParameterSlotCount());
if (push_count > 0) {
// Calculate needed space
int stack_size = 0;
......
......@@ -2992,23 +2992,35 @@ void LiftoffAssembler::DeallocateStackSlot(uint32_t size) {
addiu(sp, sp, size);
}
void LiftoffStackSlots::Construct() {
void LiftoffStackSlots::Construct(int param_slots) {
DCHECK_LT(0, slots_.size());
SortInPushOrder();
int last_stack_slot = param_slots;
for (auto& slot : slots_) {
const int stack_slot = slot.dst_slot_;
int stack_decrement = (last_stack_slot - stack_slot) * kSystemPointerSize;
DCHECK_LT(0, stack_decrement);
last_stack_slot = stack_slot;
const LiftoffAssembler::VarState& src = slot.src_;
switch (src.loc()) {
case LiftoffAssembler::VarState::kStack: {
if (src.kind() == kF64) {
asm_->AllocateStackSpace(stack_decrement - kDoubleSize);
DCHECK_EQ(kLowWord, slot.half_);
asm_->lw(kScratchReg,
liftoff::GetHalfStackSlot(slot.src_offset_, kHighWord));
asm_->push(kScratchReg);
} else {
asm_->AllocateStackSpace(stack_decrement - kSystemPointerSize);
}
asm_->lw(kScratchReg,
liftoff::GetHalfStackSlot(slot.src_offset_, slot.half_));
asm_->push(kScratchReg);
break;
}
case LiftoffAssembler::VarState::kRegister:
case LiftoffAssembler::VarState::kRegister: {
int pushed_bytes = SlotSizeInBytes(slot);
asm_->AllocateStackSpace(stack_decrement - pushed_bytes);
if (src.kind() == kI64) {
liftoff::push(
asm_, slot.half_ == kLowWord ? src.reg().low() : src.reg().high(),
......@@ -3017,8 +3029,10 @@ void LiftoffStackSlots::Construct() {
liftoff::push(asm_, src.reg(), src.kind());
}
break;
}
case LiftoffAssembler::VarState::kIntConst: {
// The high word is the sign extension of the low word.
asm_->AllocateStackSpace(stack_decrement - kSystemPointerSize);
asm_->li(kScratchReg,
Operand(slot.half_ == kLowWord ? src.i32_const()
: src.i32_const() >> 31));
......
......@@ -3160,25 +3160,38 @@ void LiftoffAssembler::DeallocateStackSlot(uint32_t size) {
Daddu(sp, sp, size);
}
void LiftoffStackSlots::Construct() {
void LiftoffStackSlots::Construct(int param_slots) {
DCHECK_LT(0, slots_.size());
SortInPushOrder();
int last_stack_slot = param_slots;
for (auto& slot : slots_) {
const int stack_slot = slot.dst_slot_;
int stack_decrement = (last_stack_slot - stack_slot) * kSystemPointerSize;
DCHECK_LT(0, stack_decrement);
last_stack_slot = stack_slot;
const LiftoffAssembler::VarState& src = slot.src_;
switch (src.loc()) {
case LiftoffAssembler::VarState::kStack:
if (src.kind() != kS128) {
asm_->AllocateStackSpace(stack_decrement - kSystemPointerSize);
asm_->Ld(kScratchReg, liftoff::GetStackSlot(slot.src_offset_));
asm_->push(kScratchReg);
} else {
asm_->AllocateStackSpace(stack_decrement - kSimd128Size);
asm_->Ld(kScratchReg, liftoff::GetStackSlot(slot.src_offset_ - 8));
asm_->push(kScratchReg);
asm_->Ld(kScratchReg, liftoff::GetStackSlot(slot.src_offset_));
asm_->push(kScratchReg);
}
break;
case LiftoffAssembler::VarState::kRegister:
case LiftoffAssembler::VarState::kRegister: {
int pushed_bytes = SlotSizeInBytes(slot);
asm_->AllocateStackSpace(stack_decrement - pushed_bytes);
liftoff::push(asm_, src.reg(), src.kind());
break;
}
case LiftoffAssembler::VarState::kIntConst: {
asm_->AllocateStackSpace(stack_decrement - kSystemPointerSize);
asm_->li(kScratchReg, Operand(src.i32_const()));
asm_->push(kScratchReg);
break;
......
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