tor-browser

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

commit 19d3fc64145c543ce42f73957f532d179660262e
parent 881b2dd3dc1f85f7a5f20cdea442dcb3271d35e0
Author: André Bargull <andre.bargull@gmail.com>
Date:   Tue, 11 Nov 2025 12:29:35 +0000

Bug 1998452: Avoid REX prefix for And with unsigned 32-bit immediate. r=spidermonkey-reviewers,iain

Not emitting the REX prefix saves a byte.

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

Diffstat:
Mjs/src/jit/x64/MacroAssembler-x64-inl.h | 16+++++++++++++---
Mjs/src/jit/x64/MacroAssembler-x64.cpp | 4++--
2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/js/src/jit/x64/MacroAssembler-x64-inl.h b/js/src/jit/x64/MacroAssembler-x64-inl.h @@ -84,18 +84,28 @@ void MacroAssembler::notPtr(Register reg) { notq(reg); } void MacroAssembler::andPtr(Register src, Register dest) { andq(src, dest); } -void MacroAssembler::andPtr(Imm32 imm, Register dest) { andq(imm, dest); } +void MacroAssembler::andPtr(Imm32 imm, Register dest) { + if (imm.value >= 0) { + andl(imm, dest); + } else { + andq(imm, dest); + } +} void MacroAssembler::andPtr(Imm32 imm, Register src, Register dest) { if (src != dest) { movq(src, dest); } - andq(imm, dest); + andPtr(imm, dest); } void MacroAssembler::and64(Imm64 imm, Register64 dest) { if (INT32_MIN <= int64_t(imm.value) && int64_t(imm.value) <= INT32_MAX) { - andq(Imm32(imm.value), dest.reg); + if (int32_t(imm.value) >= 0) { + andl(Imm32(imm.value), dest.reg); + } else { + andq(Imm32(imm.value), dest.reg); + } } else { ScratchRegisterScope scratch(*this); movq(ImmWord(uintptr_t(imm.value)), scratch); diff --git a/js/src/jit/x64/MacroAssembler-x64.cpp b/js/src/jit/x64/MacroAssembler-x64.cpp @@ -1578,7 +1578,7 @@ void MacroAssembler::convertUInt64ToDouble(Register64 input, mov(input.reg, scratch); mov(input.reg, temp); shrq(Imm32(1), scratch); - andq(Imm32(1), temp); + andl(Imm32(1), temp); orq(temp, scratch); vcvtsq2sd(scratch, output, output); @@ -1608,7 +1608,7 @@ void MacroAssembler::convertUInt64ToFloat32(Register64 input, mov(input.reg, scratch); mov(input.reg, temp); shrq(Imm32(1), scratch); - andq(Imm32(1), temp); + andl(Imm32(1), temp); orq(temp, scratch); vcvtsq2ss(scratch, output, output);