From ff4332d6054b92d40ff0eb4656079b65847ca7ad Mon Sep 17 00:00:00 2001 From: Basilisk-Dev Date: Sat, 25 Apr 2026 13:42:00 -0400 Subject: [PATCH] Issue #3049 - loongarch64: use explicit VM wrapper tail-call contracts --- js/src/jit/loongarch64/Trampoline-loongarch64.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/js/src/jit/loongarch64/Trampoline-loongarch64.cpp b/js/src/jit/loongarch64/Trampoline-loongarch64.cpp index b6dcb07959..33185e1622 100644 --- a/js/src/jit/loongarch64/Trampoline-loongarch64.cpp +++ b/js/src/jit/loongarch64/Trampoline-loongarch64.cpp @@ -675,19 +675,10 @@ JitRuntime::generateVMWrapper(JSContext* cx, const VMFunction& f) Register cxreg = a0; regs.take(cxreg); - // LoongArch callers can arrive here in either style: - // - Non-tail calls keep the return address in |ra| and only push a descriptor. - // - Tail calls push a full CommonFrameLayout with the return address on the stack. - // Normalize both forms so the wrapper always sees a stack return address. - { - Label haveStackReturnAddress; - Register scratch = regs.getAny(); - masm.loadPtr(Address(StackPointer, 0), scratch); - masm.rshiftPtr(Imm32(32), scratch); - masm.branch32(Assembler::NotEqual, scratch, Imm32(0), &haveStackReturnAddress); + // Non-tail calls keep the return address in |ra|, while tail-call sites + // have already materialized a CommonFrameLayout on the stack. + if (f.expectTailCall == NonTailCall) masm.pushReturnAddress(); - masm.bind(&haveStackReturnAddress); - } // We're aligned to an exit frame, so link it up. masm.enterExitFrame(&f);