@@ -1478,7 +1478,9 @@ void Generate_ContinueToBuiltinHelper(MacroAssembler* masm,
14781478 bool with_result) {
14791479 const RegisterConfiguration* config (RegisterConfiguration::Default ());
14801480 int allocatable_register_count = config->num_allocatable_general_registers ();
1481- Register scratch = t3;
1481+ UseScratchRegisterScope temps (masm);
1482+ Register scratch = temps.Acquire ();
1483+
14821484 if (with_result) {
14831485 if (java_script_builtin) {
14841486 __ mov (scratch, v0);
@@ -2363,24 +2365,41 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
23632365 // Save all parameter registers (see wasm-linkage.h). They might be
23642366 // overwritten in the runtime call below. We don't have any callee-saved
23652367 // registers in wasm, so no need to store anything else.
2366- constexpr RegList gp_regs =
2367- Register::ListOf (a0, a2, a3, a4, a5, a6, a7);
2368- constexpr RegList fp_regs =
2369- DoubleRegister::ListOf (f2, f4, f6, f8 , f10, f12, f14);
2370- constexpr int16_t num_to_push = base::bits::CountPopulation (gp_regs) +
2371- base::bits::CountPopulation (fp_regs);
2372- // The number of regs to be pushed before kWasmInstanceRegister should be
2373- // equal to kNumberOfSavedAllParamRegs.
2374- STATIC_ASSERT (num_to_push ==
2375- WasmCompileLazyFrameConstants::kNumberOfSavedAllParamRegs );
2376- __ MultiPush (gp_regs);
2377- if (CpuFeatures::IsSupported (MIPS_SIMD)) {
2378- __ MultiPushMSA (fp_regs);
2379- } else {
2380- __ MultiPushFPU (fp_regs);
2381- __ Dsubu (sp, sp, base::bits::CountPopulation (fp_regs) * kDoubleSize );
2368+ RegList gp_regs = 0 ;
2369+ for (Register gp_param_reg : wasm::kGpParamRegisters ) {
2370+ gp_regs |= gp_param_reg.bit ();
2371+ }
2372+
2373+ RegList fp_regs = 0 ;
2374+ for (DoubleRegister fp_param_reg : wasm::kFpParamRegisters ) {
2375+ fp_regs |= fp_param_reg.bit ();
23822376 }
23832377
2378+ CHECK_EQ (NumRegs (gp_regs), arraysize (wasm::kGpParamRegisters ));
2379+ CHECK_EQ (NumRegs (fp_regs), arraysize (wasm::kFpParamRegisters ));
2380+ CHECK_EQ (WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs ,
2381+ NumRegs (gp_regs));
2382+ CHECK_EQ (WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs ,
2383+ NumRegs (fp_regs));
2384+
2385+ __ MultiPush (gp_regs);
2386+ // Check if machine has simd enabled, if so push vector registers. If not
2387+ // then only push double registers.
2388+ Label push_doubles, simd_pushed;
2389+ __ li (a1, ExternalReference::supports_wasm_simd_128_address ());
2390+ // If > 0 then simd is available.
2391+ __ Lbu (a1, MemOperand (a1));
2392+ __ Branch (&push_doubles, le, a1, Operand (zero_reg));
2393+ // Save vector registers.
2394+ __ MultiPushMSA (fp_regs);
2395+ __ Branch (&simd_pushed);
2396+ __ bind (&push_doubles);
2397+ __ MultiPushFPU (fp_regs);
2398+ // kFixedFrameSizeFromFp is hard coded to include space for Simd
2399+ // registers, so we still need to allocate extra (unused) space on the stack
2400+ // as if they were saved.
2401+ __ Dsubu (sp, sp, base::bits::CountPopulation (fp_regs) * kDoubleSize );
2402+ __ bind (&simd_pushed);
23842403 // Pass instance and function index as an explicit arguments to the runtime
23852404 // function.
23862405 __ Push (kWasmInstanceRegister , kWasmCompileLazyFuncIndexRegister );
@@ -2390,12 +2409,18 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
23902409 __ CallRuntime (Runtime::kWasmCompileLazy , 2 );
23912410
23922411 // Restore registers.
2393- if (CpuFeatures::IsSupported (MIPS_SIMD)) {
2394- __ MultiPopMSA (fp_regs);
2395- } else {
2396- __ Daddu (sp, sp, base::bits::CountPopulation (fp_regs) * kDoubleSize );
2397- __ MultiPopFPU (fp_regs);
2398- }
2412+ Label pop_doubles, simd_popped;
2413+ __ li (a1, ExternalReference::supports_wasm_simd_128_address ());
2414+ // If > 0 then simd is available.
2415+ __ Lbu (a1, MemOperand (a1));
2416+ __ Branch (&pop_doubles, le, a1, Operand (zero_reg));
2417+ // Pop vector registers.
2418+ __ MultiPopMSA (fp_regs);
2419+ __ Branch (&simd_popped);
2420+ __ bind (&pop_doubles);
2421+ __ Daddu (sp, sp, base::bits::CountPopulation (fp_regs) * kDoubleSize );
2422+ __ MultiPopFPU (fp_regs);
2423+ __ bind (&simd_popped);
23992424 __ MultiPop (gp_regs);
24002425 }
24012426 // Finally, jump to the entrypoint.
0 commit comments