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

[mips][wasm-c-api] Save PC to the stack.

port https://crrev.com/c/1627539 to mips.

Change-Id: I18029495b6793fa1b981e28505a7c42842dacc97
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1634629Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Yu Yin <xwafish@gmail.com>
Cr-Commit-Position: refs/heads/master@{#61926}
parent 348cc6f1
......@@ -4111,6 +4111,11 @@ void MacroAssembler::Swap(Register reg1, Register reg2, Register scratch) {
void TurboAssembler::Call(Label* target) { BranchAndLink(target); }
void TurboAssembler::LoadAddress(Register dst, Label* target) {
uint32_t address = jump_address(target);
li(dst, address);
}
void TurboAssembler::Push(Handle<HeapObject> handle) {
UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire();
......
......@@ -212,6 +212,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void Call(Handle<Code> code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET,
COND_ARGS);
void Call(Label* target);
void LoadAddress(Register dst, Label* target);
void CallBuiltinPointer(Register builtin_pointer) override;
......
......@@ -4433,6 +4433,11 @@ void MacroAssembler::Swap(Register reg1, Register reg2, Register scratch) {
void TurboAssembler::Call(Label* target) { BranchAndLink(target); }
void TurboAssembler::LoadAddress(Register dst, Label* target) {
uint64_t address = jump_address(target);
li(dst, address);
}
void TurboAssembler::Push(Smi smi) {
UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire();
......
......@@ -234,6 +234,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void Call(Handle<Code> code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET,
COND_ARGS);
void Call(Label* target);
void LoadAddress(Register dst, Label* target);
void CallBuiltinPointer(Register builtin_pointer) override;
......
......@@ -778,6 +778,13 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
case kArchCallCFunction: {
int const num_parameters = MiscField::decode(instr->opcode());
Label return_location;
if (linkage()->GetIncomingDescriptor()->kind() ==
CallDescriptor::kCallWasmImportWrapper) {
__ LoadAddress(kScratchReg, &return_location);
__ sw(kScratchReg,
MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset));
}
if (instr->InputAt(0)->IsImmediate()) {
ExternalReference ref = i.InputExternalReference(0);
__ CallCFunction(ref, num_parameters);
......@@ -785,6 +792,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
Register func = i.InputRegister(0);
__ CallCFunction(func, num_parameters);
}
__ bind(&return_location);
RecordSafepoint(instr->reference_map(), Safepoint::kNoLazyDeopt);
frame_access_state()->SetFrameAccessToDefault();
// Ideally, we should decrement SP delta to match the change of stack
// pointer in CallCFunction. However, for certain architectures (e.g.
......@@ -3397,6 +3406,7 @@ void CodeGenerator::AssembleConstructFrame() {
__ lw(kWasmInstanceRegister,
FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset));
__ Push(kWasmInstanceRegister);
__ Subu(sp, sp, Operand(kSystemPointerSize));
}
}
}
......
......@@ -756,6 +756,13 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
case kArchCallCFunction: {
int const num_parameters = MiscField::decode(instr->opcode());
Label return_location;
if (linkage()->GetIncomingDescriptor()->kind() ==
CallDescriptor::kCallWasmImportWrapper) {
__ LoadAddress(kScratchReg, &return_location);
__ sd(kScratchReg,
MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset));
}
if (instr->InputAt(0)->IsImmediate()) {
ExternalReference ref = i.InputExternalReference(0);
__ CallCFunction(ref, num_parameters);
......@@ -763,6 +770,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
Register func = i.InputRegister(0);
__ CallCFunction(func, num_parameters);
}
__ bind(&return_location);
RecordSafepoint(instr->reference_map(), Safepoint::kNoLazyDeopt);
frame_access_state()->SetFrameAccessToDefault();
// Ideally, we should decrement SP delta to match the change of stack
// pointer in CallCFunction. However, for certain architectures (e.g.
......@@ -3556,6 +3565,7 @@ void CodeGenerator::AssembleConstructFrame() {
__ ld(kWasmInstanceRegister,
FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset));
__ Push(kWasmInstanceRegister);
__ Dsubu(sp, sp, Operand(kSystemPointerSize));
}
}
}
......
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