diff options
Diffstat (limited to 'chromium/v8/src/builtins/arm64/builtins-arm64.cc')
-rw-r--r-- | chromium/v8/src/builtins/arm64/builtins-arm64.cc | 81 |
1 files changed, 48 insertions, 33 deletions
diff --git a/chromium/v8/src/builtins/arm64/builtins-arm64.cc b/chromium/v8/src/builtins/arm64/builtins-arm64.cc index 7bfd4f81906..c281c93ff63 100644 --- a/chromium/v8/src/builtins/arm64/builtins-arm64.cc +++ b/chromium/v8/src/builtins/arm64/builtins-arm64.cc @@ -3018,41 +3018,50 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) { // Sign extend and convert to Smi for the runtime call. __ sxtw(kWasmCompileLazyFuncIndexRegister, kWasmCompileLazyFuncIndexRegister.W()); - __ SmiTag(kWasmCompileLazyFuncIndexRegister, - kWasmCompileLazyFuncIndexRegister); - - UseScratchRegisterScope temps(masm); - { - HardAbortScope hard_abort(masm); // Avoid calls to Abort. - FrameScope scope(masm, StackFrame::WASM_COMPILE_LAZY); - - // Save all parameter registers (see wasm-linkage.h). They might be - // overwritten in the runtime call below. We don't have any callee-saved - // registers in wasm, so no need to store anything else. - RegList gp_regs; + __ SmiTag(kWasmCompileLazyFuncIndexRegister); + + // Compute register lists for parameters to be saved. We save all parameter + // registers (see wasm-linkage.h). They might be overwritten in the runtime + // call below. We don't have any callee-saved registers in wasm, so no need to + // store anything else. + constexpr RegList kSavedGpRegs = ([]() constexpr { + RegList saved_gp_regs; for (Register gp_param_reg : wasm::kGpParamRegisters) { - gp_regs.set(gp_param_reg); + saved_gp_regs.set(gp_param_reg); } // Also push x1, because we must push multiples of 16 bytes (see // {TurboAssembler::PushCPURegList}. - CHECK_EQ(1, gp_regs.Count() % 2); - gp_regs.set(x1); - CHECK_EQ(0, gp_regs.Count() % 2); + saved_gp_regs.set(x1); + // All set registers were unique. + CHECK_EQ(saved_gp_regs.Count(), arraysize(wasm::kGpParamRegisters) + 1); + // We push a multiple of 16 bytes. + CHECK_EQ(0, saved_gp_regs.Count() % 2); + // The Wasm instance must be part of the saved registers. + CHECK(saved_gp_regs.has(kWasmInstanceRegister)); + CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs, + saved_gp_regs.Count()); + return saved_gp_regs; + })(); - DoubleRegList fp_regs; + constexpr DoubleRegList kSavedFpRegs = ([]() constexpr { + DoubleRegList saved_fp_regs; for (DoubleRegister fp_param_reg : wasm::kFpParamRegisters) { - fp_regs.set(fp_param_reg); + saved_fp_regs.set(fp_param_reg); } - CHECK_EQ(gp_regs.Count(), arraysize(wasm::kGpParamRegisters) + 1); - CHECK_EQ(fp_regs.Count(), arraysize(wasm::kFpParamRegisters)); - CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs, - gp_regs.Count()); + CHECK_EQ(saved_fp_regs.Count(), arraysize(wasm::kFpParamRegisters)); CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs, - fp_regs.Count()); + saved_fp_regs.Count()); + return saved_fp_regs; + })(); - __ PushXRegList(gp_regs); - __ PushQRegList(fp_regs); + { + HardAbortScope hard_abort(masm); // Avoid calls to Abort. + FrameScope scope(masm, StackFrame::WASM_COMPILE_LAZY); + + // Save registers that we need to keep alive across the runtime call. + __ PushXRegList(kSavedGpRegs); + __ PushQRegList(kSavedFpRegs); // Pass instance and function index as explicit arguments to the runtime // function. @@ -3062,17 +3071,23 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) { __ Mov(cp, Smi::zero()); __ CallRuntime(Runtime::kWasmCompileLazy, 2); - // Exclude x17 from the scope, there are hardcoded uses of it below. - temps.Exclude(x17); - - // The entrypoint address is the return value. - __ Mov(x17, kReturnRegister0); + // Untag the returned Smi into into x17, for later use. + static_assert(!kSavedGpRegs.has(x17)); + __ SmiUntag(x17, kReturnRegister0); // Restore registers. - __ PopQRegList(fp_regs); - __ PopXRegList(gp_regs); + __ PopQRegList(kSavedFpRegs); + __ PopXRegList(kSavedGpRegs); } - // Finally, jump to the entrypoint. + + // The runtime function returned the jump table slot offset as a Smi (now in + // x17). Use that to compute the jump target. + static_assert(!kSavedGpRegs.has(x18)); + __ ldr(x18, MemOperand( + kWasmInstanceRegister, + WasmInstanceObject::kJumpTableStartOffset - kHeapObjectTag)); + __ add(x17, x18, Operand(x17)); + // Finally, jump to the jump table slot for the function. __ Jump(x17); } |