Commit 2f88c9b2 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[bigint] Implement Divide and Remainder

Bug: v8:6791
Change-Id: I5ab97feeb25da29bc76cd28088836b4f12d1d916
Reviewed-on: https://chromium-review.googlesource.com/678037
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarDaniel Ehrenberg <littledan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48152}
parent a32c9483
......@@ -117,6 +117,7 @@ inline unsigned CountLeadingZeros64(uint64_t value) {
#endif
}
DEFINE_32_64_OVERLOADS(CountLeadingZeros)
// ReverseBits(value) returns |value| in reverse bit order.
template <typename T>
......
......@@ -503,6 +503,7 @@ class ErrorUtils : public AllStatic {
T(SuperAlreadyCalled, "Super constructor may only be called once") \
T(UnsupportedSuper, "Unsupported reference to 'super'") \
/* RangeError */ \
T(BigIntDivZero, "Division by zero") \
T(DateRange, "Provided date is not in valid range.") \
T(ExpectedTimezoneID, \
"Expected Area/Location(/Location)* for time zone, got %") \
......
This diff is collapsed.
......@@ -103,6 +103,26 @@ class BigInt : public HeapObject {
static void MultiplyAccumulate(Handle<BigInt> multiplicand,
digit_t multiplier, Handle<BigInt> accumulator,
int accumulator_index);
static void InternalMultiplyAdd(BigInt* source, digit_t factor,
digit_t summand, int n, BigInt* result);
// Specialized helpers for Divide/Remainder.
static void AbsoluteDivSmall(Handle<BigInt> x, digit_t divisor,
Handle<BigInt>* quotient, digit_t* remainder);
static void AbsoluteDivLarge(Handle<BigInt> dividend, Handle<BigInt> divisor,
Handle<BigInt>* quotient,
Handle<BigInt>* remainder);
static bool DoubleDigitGreaterThan(digit_t x_high, digit_t x_low,
digit_t y_high, digit_t y_low);
digit_t InplaceAdd(BigInt* summand, int start_index);
digit_t InplaceSub(BigInt* subtrahend, int start_index);
void InplaceRightShift(int shift);
enum SpecialLeftShiftMode {
kSameSizeResult,
kAlwaysAddOneDigit,
};
static Handle<BigInt> SpecialLeftShift(Handle<BigInt> x, int shift,
SpecialLeftShiftMode mode);
static MaybeHandle<String> ToStringBasePowerOfTwo(Handle<BigInt> x,
int radix);
......@@ -111,6 +131,8 @@ class BigInt : public HeapObject {
static inline digit_t digit_add(digit_t a, digit_t b, digit_t* carry);
static inline digit_t digit_sub(digit_t a, digit_t b, digit_t* borrow);
static inline digit_t digit_mul(digit_t a, digit_t b, digit_t* high);
static inline digit_t digit_div(digit_t high, digit_t low, digit_t divisor,
digit_t* remainder);
class LengthBits : public BitField<int, 0, kMaxLengthBits> {};
class SignBits : public BitField<bool, LengthBits::kNext, 1> {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment