From 13a37bf0236c2edbee031704bdfdbc1a9ae4e0c7 Mon Sep 17 00:00:00 2001 From: Basilisk-Dev Date: Wed, 22 Apr 2026 23:13:21 -0400 Subject: [PATCH] Issue #3049 - Fix LoongArch minimal JIT return path --- js/src/jit-test/tests/basic/loongarch-minimal-jit.js | 10 ++++++++++ js/src/jit/LoongArchMinimalJit.cpp | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/js/src/jit-test/tests/basic/loongarch-minimal-jit.js b/js/src/jit-test/tests/basic/loongarch-minimal-jit.js index 9c307ef9df..3e4a3afd7c 100644 --- a/js/src/jit-test/tests/basic/loongarch-minimal-jit.js +++ b/js/src/jit-test/tests/basic/loongarch-minimal-jit.js @@ -16,6 +16,14 @@ function unsupported(a, b) { return a + (b + 0.5); } +function largeResult(a) { + return a + 300; +} + +function negativeResult(a) { + return a - 300; +} + for (var i = 0; i < 100; i++) { assertEq(add(i, i + 1), (i + i + 1)); assertEq(withLocal(i, 7), i + 7); @@ -23,6 +31,8 @@ for (var i = 0; i < 100; i++) { assertEq(overflow(2147483647, 1), 2147483648); assertEq(unsupported(2, 3), 5.5); +assertEq(largeResult(7), 307); +assertEq(negativeResult(7), -293); (function testPropertyWrappers() { function getX(obj) { return obj.x; } diff --git a/js/src/jit/LoongArchMinimalJit.cpp b/js/src/jit/LoongArchMinimalJit.cpp index 1b5e84f173..32a93225b5 100644 --- a/js/src/jit/LoongArchMinimalJit.cpp +++ b/js/src/jit/LoongArchMinimalJit.cpp @@ -261,7 +261,8 @@ class MinimalLoongArchCompiler } bool emitReturn(LoongArchReg result) { - if (!emit(EncodeUnsignedImm12(0x29000000, result, a2, 0))) + // Write the full int32 result back to the out-parameter. + if (!emit(EncodeUnsignedImm12(0x29800000, result, a2, 0))) return false; if (!emit(EncodeImm12(0x02800000, a0, zero, 1))) return false; @@ -801,4 +802,11 @@ js::jit::TryEnterLoongArchMinimalJit(JSContext*, RunState&) return false; } +bool +js::jit::TryCallLoongArchMinimalJit(JSContext*, HandleFunction, const CallArgs&, bool* handled) +{ + *handled = false; + return true; +} + #endif