tor-browser

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

commit 0f52219f177675dc84be3d2670755f3461c21fba
parent 5314ded4677bfe72b0a9e15916c5a35f4ae34c34
Author: André Bargull <andre.bargull@gmail.com>
Date:   Fri, 14 Nov 2025 13:38:06 +0000

Bug 1999492 - Part 2: Add more constructors to Int128. r=iain

These are needed for `ReciprocalMulConstants`.

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

Diffstat:
Mjs/src/vm/Int128.h | 28+++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/js/src/vm/Int128.h b/js/src/vm/Int128.h @@ -203,7 +203,18 @@ class alignas(16) Uint128 final { constexpr Uint128() = default; constexpr Uint128(const Uint128&) = default; - explicit constexpr Uint128(uint64_t value) + explicit constexpr Uint128(int value) + : Uint128(uint64_t(value), uint64_t(value < 0 ? -1 : 0)) {} + explicit constexpr Uint128(long value) + : Uint128(uint64_t(value), uint64_t(value < 0 ? -1 : 0)) {} + explicit constexpr Uint128(long long value) + : Uint128(uint64_t(value), uint64_t(value < 0 ? -1 : 0)) {} + + explicit constexpr Uint128(unsigned int value) + : Uint128(uint64_t(value), uint64_t(0)) {} + explicit constexpr Uint128(unsigned long value) + : Uint128(uint64_t(value), uint64_t(0)) {} + explicit constexpr Uint128(unsigned long long value) : Uint128(uint64_t(value), uint64_t(0)) {} constexpr bool operator==(const Uint128& other) const { @@ -456,8 +467,19 @@ class alignas(16) Int128 final { constexpr Int128() = default; constexpr Int128(const Int128&) = default; - explicit constexpr Int128(int64_t value) - : Int128(uint64_t(value), uint64_t(value >> 63)) {} + explicit constexpr Int128(int value) + : Int128(uint64_t(value), uint64_t(value < 0 ? -1 : 0)) {} + explicit constexpr Int128(long value) + : Int128(uint64_t(value), uint64_t(value < 0 ? -1 : 0)) {} + explicit constexpr Int128(long long value) + : Int128(uint64_t(value), uint64_t(value < 0 ? -1 : 0)) {} + + explicit constexpr Int128(unsigned int value) + : Int128(uint64_t(value), uint64_t(0)) {} + explicit constexpr Int128(unsigned long value) + : Int128(uint64_t(value), uint64_t(0)) {} + explicit constexpr Int128(unsigned long long value) + : Int128(uint64_t(value), uint64_t(0)) {} /** * Return the quotient and remainder of the division.