From 8757293d7ed7591d01733a3bbae91d0365973b2b Mon Sep 17 00:00:00 2001 From: Lu Yahan Date: Mon, 21 Nov 2022 18:50:59 +0800 Subject: [PATCH] [riscv] Optimize ComputeCodeStartAddress func We can only use auipc + add instr to get pc address. Change-Id: I44d7dd1798c94d672bf506658c82c80de601a4af Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4039240 Reviewed-by: ji qiu Commit-Queue: ji qiu Auto-Submit: Yahan Lu Cr-Commit-Position: refs/heads/main@{#84415} --- src/codegen/riscv/macro-assembler-riscv.cc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/codegen/riscv/macro-assembler-riscv.cc b/src/codegen/riscv/macro-assembler-riscv.cc index 3deac90238..e9ac398752 100644 --- a/src/codegen/riscv/macro-assembler-riscv.cc +++ b/src/codegen/riscv/macro-assembler-riscv.cc @@ -6171,17 +6171,9 @@ Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2, Register reg3, } void TurboAssembler::ComputeCodeStartAddress(Register dst) { - // This push on ra and the pop below together ensure that we restore the - // register ra, which is needed while computing the code start address. - push(ra); - - auipc(ra, 0); - addi(ra, ra, kInstrSize * 2); // ra = address of li - int pc = pc_offset(); - li(dst, Operand(pc)); - SubWord(dst, ra, dst); - - pop(ra); // Restore ra + auto pc = -pc_offset(); + auipc(dst, 0); + if(pc != 0) SubWord(dst, dst, pc); } void TurboAssembler::CallForDeoptimization(Builtin target, int, Label* exit,