[mips][wasm-c-api] Correct the saved return address.
port f5ab7d3
https://crrev.com/c/1627539.
Change-Id: Ibe721144301bff6d843b6d1861b5a20890a057bb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1818004
Commit-Queue: Yu Yin <xwafish@gmail.com>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63937}
This commit is contained in:
parent
b12a07c29c
commit
663c7251a5
@ -779,12 +779,24 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
|
||||
break;
|
||||
case kArchCallCFunction: {
|
||||
int const num_parameters = MiscField::decode(instr->opcode());
|
||||
Label return_location;
|
||||
if (linkage()->GetIncomingDescriptor()->IsWasmCapiFunction()) {
|
||||
Label start_call;
|
||||
bool isWasmCapiFunction =
|
||||
linkage()->GetIncomingDescriptor()->IsWasmCapiFunction();
|
||||
int offset = 48;
|
||||
#if V8_HOST_ARCH_MIPS
|
||||
if (__ emit_debug_code()) {
|
||||
offset += 16;
|
||||
}
|
||||
#endif
|
||||
if (isWasmCapiFunction) {
|
||||
// Put the return address in a stack slot.
|
||||
__ LoadAddress(kScratchReg, &return_location);
|
||||
__ sw(kScratchReg,
|
||||
MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset));
|
||||
__ mov(kScratchReg, ra);
|
||||
__ bind(&start_call);
|
||||
__ nal();
|
||||
__ nop();
|
||||
__ Addu(ra, ra, offset);
|
||||
__ sw(ra, MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset));
|
||||
__ mov(ra, kScratchReg);
|
||||
}
|
||||
if (instr->InputAt(0)->IsImmediate()) {
|
||||
ExternalReference ref = i.InputExternalReference(0);
|
||||
@ -793,7 +805,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
|
||||
Register func = i.InputRegister(0);
|
||||
__ CallCFunction(func, num_parameters);
|
||||
}
|
||||
__ bind(&return_location);
|
||||
if (isWasmCapiFunction) {
|
||||
CHECK_EQ(offset, __ SizeOfCodeGeneratedSince(&start_call));
|
||||
}
|
||||
|
||||
RecordSafepoint(instr->reference_map(), Safepoint::kNoLazyDeopt);
|
||||
frame_access_state()->SetFrameAccessToDefault();
|
||||
// Ideally, we should decrement SP delta to match the change of stack
|
||||
|
@ -757,12 +757,24 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
|
||||
break;
|
||||
case kArchCallCFunction: {
|
||||
int const num_parameters = MiscField::decode(instr->opcode());
|
||||
Label return_location;
|
||||
if (linkage()->GetIncomingDescriptor()->IsWasmCapiFunction()) {
|
||||
Label start_call;
|
||||
bool isWasmCapiFunction =
|
||||
linkage()->GetIncomingDescriptor()->IsWasmCapiFunction();
|
||||
int offset = 48;
|
||||
#if V8_HOST_ARCH_MIPS64
|
||||
if (__ emit_debug_code()) {
|
||||
offset += 16;
|
||||
}
|
||||
#endif
|
||||
if (isWasmCapiFunction) {
|
||||
// Put the return address in a stack slot.
|
||||
__ LoadAddress(kScratchReg, &return_location);
|
||||
__ sd(kScratchReg,
|
||||
MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset));
|
||||
__ mov(kScratchReg, ra);
|
||||
__ bind(&start_call);
|
||||
__ nal();
|
||||
__ nop();
|
||||
__ Daddu(ra, ra, offset);
|
||||
__ sd(ra, MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset));
|
||||
__ mov(ra, kScratchReg);
|
||||
}
|
||||
if (instr->InputAt(0)->IsImmediate()) {
|
||||
ExternalReference ref = i.InputExternalReference(0);
|
||||
@ -771,7 +783,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
|
||||
Register func = i.InputRegister(0);
|
||||
__ CallCFunction(func, num_parameters);
|
||||
}
|
||||
__ bind(&return_location);
|
||||
if (isWasmCapiFunction) {
|
||||
CHECK_EQ(offset, __ SizeOfCodeGeneratedSince(&start_call));
|
||||
}
|
||||
|
||||
RecordSafepoint(instr->reference_map(), Safepoint::kNoLazyDeopt);
|
||||
frame_access_state()->SetFrameAccessToDefault();
|
||||
// Ideally, we should decrement SP delta to match the change of stack
|
||||
|
Loading…
Reference in New Issue
Block a user