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) { ...@@ -4111,6 +4111,11 @@ void MacroAssembler::Swap(Register reg1, Register reg2, Register scratch) {
void TurboAssembler::Call(Label* target) { BranchAndLink(target); } 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) { void TurboAssembler::Push(Handle<HeapObject> handle) {
UseScratchRegisterScope temps(this); UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire(); Register scratch = temps.Acquire();
......
...@@ -212,6 +212,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -212,6 +212,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void Call(Handle<Code> code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, void Call(Handle<Code> code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET,
COND_ARGS); COND_ARGS);
void Call(Label* target); void Call(Label* target);
void LoadAddress(Register dst, Label* target);
void CallBuiltinPointer(Register builtin_pointer) override; void CallBuiltinPointer(Register builtin_pointer) override;
......
...@@ -4433,6 +4433,11 @@ void MacroAssembler::Swap(Register reg1, Register reg2, Register scratch) { ...@@ -4433,6 +4433,11 @@ void MacroAssembler::Swap(Register reg1, Register reg2, Register scratch) {
void TurboAssembler::Call(Label* target) { BranchAndLink(target); } 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) { void TurboAssembler::Push(Smi smi) {
UseScratchRegisterScope temps(this); UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire(); Register scratch = temps.Acquire();
......
...@@ -234,6 +234,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -234,6 +234,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void Call(Handle<Code> code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, void Call(Handle<Code> code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET,
COND_ARGS); COND_ARGS);
void Call(Label* target); void Call(Label* target);
void LoadAddress(Register dst, Label* target);
void CallBuiltinPointer(Register builtin_pointer) override; void CallBuiltinPointer(Register builtin_pointer) override;
......
...@@ -778,6 +778,13 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -778,6 +778,13 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break; break;
case kArchCallCFunction: { case kArchCallCFunction: {
int const num_parameters = MiscField::decode(instr->opcode()); 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()) { if (instr->InputAt(0)->IsImmediate()) {
ExternalReference ref = i.InputExternalReference(0); ExternalReference ref = i.InputExternalReference(0);
__ CallCFunction(ref, num_parameters); __ CallCFunction(ref, num_parameters);
...@@ -785,6 +792,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -785,6 +792,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
Register func = i.InputRegister(0); Register func = i.InputRegister(0);
__ CallCFunction(func, num_parameters); __ CallCFunction(func, num_parameters);
} }
__ bind(&return_location);
RecordSafepoint(instr->reference_map(), Safepoint::kNoLazyDeopt);
frame_access_state()->SetFrameAccessToDefault(); frame_access_state()->SetFrameAccessToDefault();
// Ideally, we should decrement SP delta to match the change of stack // Ideally, we should decrement SP delta to match the change of stack
// pointer in CallCFunction. However, for certain architectures (e.g. // pointer in CallCFunction. However, for certain architectures (e.g.
...@@ -3397,6 +3406,7 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3397,6 +3406,7 @@ void CodeGenerator::AssembleConstructFrame() {
__ lw(kWasmInstanceRegister, __ lw(kWasmInstanceRegister,
FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset)); FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset));
__ Push(kWasmInstanceRegister); __ Push(kWasmInstanceRegister);
__ Subu(sp, sp, Operand(kSystemPointerSize));
} }
} }
} }
......
...@@ -756,6 +756,13 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -756,6 +756,13 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break; break;
case kArchCallCFunction: { case kArchCallCFunction: {
int const num_parameters = MiscField::decode(instr->opcode()); 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()) { if (instr->InputAt(0)->IsImmediate()) {
ExternalReference ref = i.InputExternalReference(0); ExternalReference ref = i.InputExternalReference(0);
__ CallCFunction(ref, num_parameters); __ CallCFunction(ref, num_parameters);
...@@ -763,6 +770,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -763,6 +770,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
Register func = i.InputRegister(0); Register func = i.InputRegister(0);
__ CallCFunction(func, num_parameters); __ CallCFunction(func, num_parameters);
} }
__ bind(&return_location);
RecordSafepoint(instr->reference_map(), Safepoint::kNoLazyDeopt);
frame_access_state()->SetFrameAccessToDefault(); frame_access_state()->SetFrameAccessToDefault();
// Ideally, we should decrement SP delta to match the change of stack // Ideally, we should decrement SP delta to match the change of stack
// pointer in CallCFunction. However, for certain architectures (e.g. // pointer in CallCFunction. However, for certain architectures (e.g.
...@@ -3556,6 +3565,7 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3556,6 +3565,7 @@ void CodeGenerator::AssembleConstructFrame() {
__ ld(kWasmInstanceRegister, __ ld(kWasmInstanceRegister,
FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset)); FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset));
__ Push(kWasmInstanceRegister); __ 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