mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 08:48:39 +09:00
Issue #1240 - Part 3b - Implement WrappingOperations.h for wraparound math operations & conversions. https://bugzilla.mozilla.org/show_bug.cgi?id=1441657 Implement mozilla::WrappingMultiply. Prerequisite for our V8 fast forward.
This commit is contained in:
parent
ddd49121a6
commit
d42d5ce138
7 changed files with 328 additions and 10 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/WrappingOperations.h"
|
||||
|
||||
#include <algorithm> // for std::max
|
||||
#include <fcntl.h>
|
||||
|
|
@ -103,6 +104,7 @@ using mozilla::IsNegative;
|
|||
using mozilla::IsNegativeZero;
|
||||
using mozilla::PositiveInfinity;
|
||||
using mozilla::NegativeInfinity;
|
||||
using mozilla::WrappingMultiply;
|
||||
using JS::ToNumber;
|
||||
using JS::GenericNaN;
|
||||
|
||||
|
|
@ -458,16 +460,13 @@ js::math_floor(JSContext* cx, unsigned argc, Value* vp)
|
|||
bool
|
||||
js::math_imul_handle(JSContext* cx, HandleValue lhs, HandleValue rhs, MutableHandleValue res)
|
||||
{
|
||||
uint32_t a = 0, b = 0;
|
||||
if (!lhs.isUndefined() && !ToUint32(cx, lhs, &a))
|
||||
int32_t a = 0, b = 0;
|
||||
if (!lhs.isUndefined() && !ToInt32(cx, lhs, &a))
|
||||
return false;
|
||||
if (!rhs.isUndefined() && !ToUint32(cx, rhs, &b))
|
||||
if (!rhs.isUndefined() && !ToInt32(cx, rhs, &b))
|
||||
return false;
|
||||
|
||||
uint32_t product = a * b;
|
||||
res.setInt32(product > INT32_MAX
|
||||
? int32_t(INT32_MIN + (product - INT32_MAX - 1))
|
||||
: int32_t(product));
|
||||
res.setInt32(WrappingMultiply(a, b));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue