Bug 1846936 - [loong64][mips64] Port wasm return calls implementation. r=yury

Differential Revision: https://phabricator.services.mozilla.com/D185392
This commit is contained in:
Zhao Jiazhong 2023-08-04 17:17:17 +00:00
Родитель 20819d2182
Коммит 38bc24b98f
6 изменённых файлов: 44 добавлений и 3 удалений

Просмотреть файл

@ -693,7 +693,7 @@ def wasm_tail_calls(value, target):
if not value:
return
if target.cpu in ("x86", "x86_64", "arm", "aarch64"):
if target.cpu in ("x86", "x86_64", "arm", "aarch64", "loongarch64", "mips64"):
return True

Просмотреть файл

@ -4621,6 +4621,8 @@ static void MoveDataBlock(MacroAssembler& masm, Register base, int32_t from,
# elif defined(JS_CODEGEN_ARM) || defined(JS_CODEGEN_X86)
static constexpr Register scratch = ABINonArgReg0;
masm.push(scratch);
# elif defined(JS_CODEGEN_LOONG64) || defined(JS_CODEGEN_MIPS64)
ScratchRegisterScope scratch(masm);
# elif !defined(JS_CODEGEN_NONE)
const Register scratch = ScratchReg;
# else
@ -4746,7 +4748,11 @@ static void CollapseWasmFrameFast(MacroAssembler& masm,
static constexpr Register tempForFP = ABINonArgReg3;
# ifdef JS_USE_LINK_REGISTER
# if defined(JS_CODEGEN_LOONG64) || defined(JS_CODEGEN_MIPS64)
static constexpr Register tempForRA = ra;
# else
static constexpr Register tempForRA = lr;
# endif
# else
static constexpr Register tempForRA = ABINonArgReg2;
masm.push(tempForRA);
@ -4852,7 +4858,11 @@ static void CollapseWasmFrameSlow(MacroAssembler& masm,
masm.reserveStack(reserved);
# ifdef JS_USE_LINK_REGISTER
# if defined(JS_CODEGEN_LOONG64) || defined(JS_CODEGEN_MIPS64)
static constexpr Register tempForRA = ra;
# else
static constexpr Register tempForRA = lr;
# endif
# else
static constexpr Register tempForRA = ABINonArgReg2;
masm.push(tempForRA);

Просмотреть файл

@ -3829,9 +3829,10 @@ class MacroAssembler : public MacroAssemblerSpecific {
void wasmCollapseFrameFast(const ReturnCallAdjustmentInfo& retCallInfo);
void wasmCheckSlowCallsite(Register ra, Label* notSlow, Register temp1,
Register temp2) DEFINED_ON(x86, x64, arm, arm64);
Register temp2)
DEFINED_ON(x86, x64, arm, arm64, loong64, mips64);
void wasmMarkSlowCall() DEFINED_ON(x86, x64, arm, arm64);
void wasmMarkSlowCall() DEFINED_ON(x86, x64, arm, arm64, loong64, mips64);
#endif
// WasmTableCallIndexReg must contain the index of the indirect call. This is

Просмотреть файл

@ -5400,6 +5400,19 @@ void MacroAssembler::shiftIndex32AndAdd(Register indexTemp32, int shift,
addPtr(indexTemp32, pointer);
}
#ifdef ENABLE_WASM_TAIL_CALLS
void MacroAssembler::wasmMarkSlowCall() { mov(ra, ra); }
const int32_t SlowCallMarker = 0x03800021; // ori ra, ra, 0
void MacroAssembler::wasmCheckSlowCallsite(Register ra_, Label* notSlow,
Register temp1, Register temp2) {
MOZ_ASSERT(ra_ != temp2);
load32(Address(ra_, 0), temp2);
branch32(Assembler::NotEqual, temp2, Imm32(SlowCallMarker), notSlow);
}
#endif // ENABLE_WASM_TAIL_CALLS
//}}} check_macroassembler_style
} // namespace jit

Просмотреть файл

@ -2856,4 +2856,17 @@ void MacroAssembler::convertUInt64ToFloat32(Register64 src_, FloatRegister dest,
bind(&done);
}
#ifdef ENABLE_WASM_TAIL_CALLS
void MacroAssembler::wasmMarkSlowCall() { mov(ra, ra); }
const int32_t SlowCallMarker = 0x37ff0000; // ori ra, ra, 0
void MacroAssembler::wasmCheckSlowCallsite(Register ra_, Label* notSlow,
Register temp1, Register temp2) {
MOZ_ASSERT(ra_ != temp2);
load32(Address(ra_, 0), temp2);
branch32(Assembler::NotEqual, temp2, Imm32(SlowCallMarker), notSlow);
}
#endif // ENABLE_WASM_TAIL_CALLS
//}}} check_macroassembler_style

Просмотреть файл

@ -35,7 +35,9 @@ BEGIN_TEST(testWasmCheckSlowCallMarkerHit) {
masm.bind(&check);
# ifdef JS_USE_LINK_REGISTER
# if !defined(JS_CODEGEN_LOONG64) && !defined(JS_CODEGEN_MIPS64)
static constexpr Register ra = lr;
# endif
# else
static constexpr Register ra = ABINonArgReg2;
masm.loadPtr(Address(StackPointer, 0), ra);
@ -70,7 +72,9 @@ BEGIN_TEST(testWasmCheckSlowCallMarkerMiss) {
masm.bind(&check);
# ifdef JS_USE_LINK_REGISTER
# if !defined(JS_CODEGEN_LOONG64) && !defined(JS_CODEGEN_MIPS64)
static constexpr Register ra = lr;
# endif
# else
static constexpr Register ra = ABINonArgReg2;
masm.loadPtr(Address(StackPointer, 0), ra);