Commit e8ec743b authored by Yu Yin's avatar Yu Yin Committed by Commit Bot

[mips][wasm-c-api] New call descriptor and stackframe kind.

port https://crrev.com/c/1632235 (65f3861e) to mips.
Original Commit Message:
    So far, calls to Wasm C/C++ API functions reused the call descriptors
    of WasmImportWrappers, and the stack frame type of regular Wasm
    functions. This CL cleans that up by introducing separate implementations
    for both. No change in functionality or performance is expected.

Change-Id: I1d068e9baab403d714ddb31c26f97fa4e5becb41
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1635275
Commit-Queue: Yu Yin <xwafish@gmail.com>
Auto-Submit: Yu Yin <xwafish@gmail.com>
Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61933}
parent 73ad21b1
......@@ -779,8 +779,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchCallCFunction: {
int const num_parameters = MiscField::decode(instr->opcode());
Label return_location;
if (linkage()->GetIncomingDescriptor()->kind() ==
CallDescriptor::kCallWasmImportWrapper) {
if (linkage()->GetIncomingDescriptor()->IsWasmCapiFunction()) {
// Put the return address in a stack slot.
__ LoadAddress(kScratchReg, &return_location);
__ sw(kScratchReg,
MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset));
......@@ -3396,7 +3396,8 @@ void CodeGenerator::AssembleConstructFrame() {
__ StubPrologue(info()->GetOutputStackFrameType());
if (call_descriptor->IsWasmFunctionCall()) {
__ Push(kWasmInstanceRegister);
} else if (call_descriptor->IsWasmImportWrapper()) {
} else if (call_descriptor->IsWasmImportWrapper() ||
call_descriptor->IsWasmCapiFunction()) {
// WASM import wrappers are passed a tuple in the place of the instance.
// Unpack the tuple into the instance and the target callable.
// This must be done here in the codegen because it cannot be expressed
......@@ -3406,10 +3407,13 @@ void CodeGenerator::AssembleConstructFrame() {
__ lw(kWasmInstanceRegister,
FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset));
__ Push(kWasmInstanceRegister);
if (call_descriptor->IsWasmCapiFunction()) {
// Reserve space for saving the PC later.
__ Subu(sp, sp, Operand(kSystemPointerSize));
}
}
}
}
int required_slots = frame()->GetTotalFrameSlotCount() -
call_descriptor->CalculateFixedFrameSize();
......
......@@ -757,8 +757,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchCallCFunction: {
int const num_parameters = MiscField::decode(instr->opcode());
Label return_location;
if (linkage()->GetIncomingDescriptor()->kind() ==
CallDescriptor::kCallWasmImportWrapper) {
if (linkage()->GetIncomingDescriptor()->IsWasmCapiFunction()) {
// Put the return address in a stack slot.
__ LoadAddress(kScratchReg, &return_location);
__ sd(kScratchReg,
MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset));
......@@ -3555,7 +3555,8 @@ void CodeGenerator::AssembleConstructFrame() {
__ StubPrologue(info()->GetOutputStackFrameType());
if (call_descriptor->IsWasmFunctionCall()) {
__ Push(kWasmInstanceRegister);
} else if (call_descriptor->IsWasmImportWrapper()) {
} else if (call_descriptor->IsWasmImportWrapper() ||
call_descriptor->IsWasmCapiFunction()) {
// WASM import wrappers are passed a tuple in the place of the instance.
// Unpack the tuple into the instance and the target callable.
// This must be done here in the codegen because it cannot be expressed
......@@ -3565,10 +3566,13 @@ void CodeGenerator::AssembleConstructFrame() {
__ ld(kWasmInstanceRegister,
FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset));
__ Push(kWasmInstanceRegister);
if (call_descriptor->IsWasmCapiFunction()) {
// Reserve space for saving the PC later.
__ Dsubu(sp, sp, Operand(kSystemPointerSize));
}
}
}
}
int required_slots = frame()->GetTotalFrameSlotCount() -
call_descriptor->CalculateFixedFrameSize();
......
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