tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 675a32185473a4c617fce0f6bf4e568fb97f23e3
parent 7a3f53369269d48cb64697322f23e4c9fa00cb4b
Author: André Bargull <andre.bargull@gmail.com>
Date:   Fri, 17 Oct 2025 11:25:42 +0000

Bug 1992993 - Part 6: Fix out of range detection for rounding on MIPS. r=spidermonkey-reviewers,iain

MIPS rounding functions return `INT32_MAX` for out-of-range values.

Differential Revision: https://phabricator.services.mozilla.com/D267794

Diffstat:
Mjs/src/jit/mips-shared/MacroAssembler-mips-shared.cpp | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared.cpp b/js/src/jit/mips-shared/MacroAssembler-mips-shared.cpp @@ -3316,8 +3316,7 @@ void MacroAssembler::roundFloat32ToInt32(FloatRegister src, Register dest, moveFromFloat32(fscratch, dest); - branchTest32(Assembler::Equal, dest, Imm32(INT_MIN), fail); - branchTest32(Assembler::Equal, dest, Imm32(INT_MAX), fail); + branch32(Assembler::Equal, dest, Imm32(INT_MAX), fail); jump(&end); @@ -3343,7 +3342,11 @@ void MacroAssembler::roundFloat32ToInt32(FloatRegister src, Register dest, as_floorws(fscratch, temp); moveFromFloat32(fscratch, dest); + // Need to test for both INT_MIN and INT_MAX: + // If NAN2008=0, out-of-range (negative) values return INT_MAX. + // If NAN2008=1, out-of-range negative values return INT_MIN. branch32(Assembler::Equal, dest, Imm32(INT_MIN), fail); + branch32(Assembler::Equal, dest, Imm32(INT_MAX), fail); bind(&end); } @@ -3380,7 +3383,6 @@ void MacroAssembler::roundDoubleToInt32(FloatRegister src, Register dest, moveFromDoubleLo(dscratch, dest); - branch32(Assembler::Equal, dest, Imm32(INT_MIN), fail); branch32(Assembler::Equal, dest, Imm32(INT_MAX), fail); jump(&end); @@ -3407,7 +3409,11 @@ void MacroAssembler::roundDoubleToInt32(FloatRegister src, Register dest, as_floorwd(dscratch, temp); moveFromDoubleLo(dscratch, dest); + // Need to test for both INT_MIN and INT_MAX: + // If NAN2008=0, out-of-range (negative) values return INT_MAX. + // If NAN2008=1, out-of-range negative values return INT_MIN. branch32(Assembler::Equal, dest, Imm32(INT_MIN), fail); + branch32(Assembler::Equal, dest, Imm32(INT_MAX), fail); bind(&end); }