56 template <
typename Isolate = v8::
internal::Isolate>
62 template <
typename IsolateT>
64 IsolateT* isolate, uint32_t length,
71 template <
typename IsolateT>
76 New(isolate, 0, allocation).ToHandleChecked());
84 DirectHandle<BigIntBase>
x);
99 int mantissa_bits_unset,
int digit_index,
100 uint64_t current_digit);
107 return static_cast<digit_t>(~x) == 0;
115 std::memory_order_relaxed);
120 std::memory_order_relaxed);
124 std::memory_order_relaxed);
128 raw_digits()[
n].set_value(value);
135 static_assert(std::is_same_v<bigint::digit_t, BigIntBase::digit_t>,
136 "We must be able to call BigInt library functions");
155template <
typename T,
typename Isolate>
163 if (
v8_flags.correctness_fuzzer_suppressions) {
164 FATAL(
"Aborting on invalid BigInt length");
166 THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kBigIntTooBig));
169template <
typename IsolateT>
178 result->initialize_bitfield(
false, length);
180 result->InitializeDigits(length, 0xBF);
186 if (value == 0)
return Zero(isolate);
189 bool sign = value < 0;
192 result->set_digit(0, value);
198 result->set_digit(0, -value);
206 if (value == 0)
return Zero(isolate);
208 bool sign = value < 0;
210 int32_t raw_exponent =
211 static_cast<int32_t
>(double_bits >>
216 uint32_t exponent = raw_exponent - 0x3FF;
234 const uint32_t kMantissaTopBit =
240 uint32_t remaining_mantissa_bits = 0;
245 if (msd_topbit < kMantissaTopBit) {
246 remaining_mantissa_bits = kMantissaTopBit - msd_topbit;
247 digit = mantissa >> remaining_mantissa_bits;
248 mantissa = mantissa << (64 - remaining_mantissa_bits);
251 digit = mantissa << (msd_topbit - kMantissaTopBit);
257 for (int32_t digit_index =
digits - 2; digit_index >= 0; digit_index--) {
258 if (remaining_mantissa_bits > 0) {
260 if (
sizeof(
digit) == 4) {
261 digit = mantissa >> 32;
262 mantissa = mantissa << 32;
278 uint32_t length = source->length();
286 memset(raw_digits(), value, length *
kDigitSize);
296template <
typename IsolateT>
304 uint32_t old_length =
result->length();
315 heap->NotifyObjectSizeChange(
result, old_size, new_size,
332template <
typename IsolateT>
366 if (exponent->sign()) {
367 THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kMustBePositive));
370 if (exponent->is_zero()) {
376 if (
base->length() == 1 &&
base->digit(0) == 1) {
378 if (
base->sign() && (exponent->digit(0) & 1) == 0) {
386 static_assert(kMaxLengthBits < std::numeric_limits<digit_t>::max());
387 if (exponent->length() > 1) {
390 digit_t exp_value = exponent->digit(0);
391 if (exp_value == 1)
return base;
396 int n =
static_cast<int>(exp_value);
397 if (
base->length() == 1 &&
base->digit(0) == 2) {
403 result->InitializeDigits(needed_digits);
406 result->set_digit(needed_digits - 1, msd);
408 if (
base->sign())
result->set_sign((n & 1) != 0);
416 for (; n != 0; n >>= 1) {
418 Multiply(isolate, running_square, running_square);
419 if (!maybe_result.
ToHandle(&running_square))
return maybe_result;
436 uint32_t result_length =
444 result->rw_digits(),
x->digits(),
y->digits());
447 isolate->TerminateExecution();
450 result->set_sign(
x->sign() !=
y->sign());
458 THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kBigIntDivZero));
464 return Zero(isolate);
466 bool result_sign =
x->sign() !=
y->sign();
467 if (
y->length() == 1 &&
y->digit(0) == 1) {
478 quotient->rw_digits(),
x->digits(),
y->digits());
481 isolate->TerminateExecution();
484 quotient->set_sign(result_sign);
492 THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kBigIntDivZero));
498 if (
y->length() == 1 &&
y->digit(0) == 1)
return Zero(isolate);
509 isolate->TerminateExecution();
520 bool xsign =
x->sign();
521 bool ysign =
y->sign();
522 uint32_t result_length =
532 result->set_sign(result_sign);
540 bool xsign =
x->sign();
541 bool ysign =
y->sign();
543 x->length(),
y->length(), xsign == ysign);
551 xsign,
y->digits(), ysign);
552 result->set_sign(result_sign);
581 bool x_sign =
x->sign();
582 if (x_sign !=
y->sign())
return UnequalSign(x_sign);
585 if (
result > 0)
return AbsoluteGreater(x_sign);
586 if (
result < 0)
return AbsoluteLess(x_sign);
591 if (
x->sign() !=
y->sign())
return false;
592 if (
x->length() !=
y->length())
return false;
594 if (
x->digit(
i) !=
y->digit(
i))
return false;
616 }
else if (
x->is_zero()) {
633 if (isolate->has_exception()) {
650 if (isolate->has_exception()) {
667 if (value == 0)
return x->is_zero();
670 return (
x->length() == 1) && (
x->sign() == (value < 0)) &&
672 static_cast<digit_t>(std::abs(
static_cast<int64_t
>(value))));
683 bool x_sign =
x->sign();
685 bool y_sign = (y_value < 0);
686 if (x_sign != y_sign)
return UnequalSign(x_sign);
694 static_assert(
sizeof(
digit_t) >=
sizeof(y_value));
695 if (
x->length() > 1)
return AbsoluteGreater(x_sign);
697 digit_t abs_value = std::abs(
static_cast<int64_t
>(y_value));
699 if (x_digit > abs_value)
return AbsoluteGreater(x_sign);
700 if (x_digit < abs_value)
return AbsoluteLess(x_sign);
712 bool x_sign =
x->sign();
715 bool y_sign = (
y < 0);
716 if (x_sign != y_sign)
return UnequalSign(x_sign);
727 int32_t raw_exponent =
728 static_cast<int32_t
>(double_bits >>
734 int32_t exponent = raw_exponent - 0x3FF;
739 return AbsoluteGreater(x_sign);
741 uint32_t x_length =
x->length();
742 digit_t x_msd =
x->digit(x_length - 1);
744 uint32_t x_bitlength = x_length *
kDigitBits - msd_leading_zeros;
745 uint32_t y_bitlength = exponent + 1;
746 if (x_bitlength < y_bitlength)
return AbsoluteLess(x_sign);
747 if (x_bitlength > y_bitlength)
return AbsoluteGreater(x_sign);
763 const uint32_t kMantissaTopBit = 52;
765 uint32_t msd_topbit =
kDigitBits - 1 - msd_leading_zeros;
771 uint32_t remaining_mantissa_bits = 0;
775 if (msd_topbit < kMantissaTopBit) {
776 remaining_mantissa_bits = (kMantissaTopBit - msd_topbit);
777 compare_mantissa = mantissa >> remaining_mantissa_bits;
778 mantissa = mantissa << (64 - remaining_mantissa_bits);
781 compare_mantissa = mantissa << (msd_topbit - kMantissaTopBit);
784 if (x_msd > compare_mantissa)
return AbsoluteGreater(x_sign);
785 if (x_msd < compare_mantissa)
return AbsoluteLess(x_sign);
789 for (int32_t digit_index = x_length - 2; digit_index >= 0; digit_index--) {
790 if (remaining_mantissa_bits > 0) {
792 if (
sizeof(mantissa) !=
sizeof(x_msd)) {
793 compare_mantissa = mantissa >> (64 -
kDigitBits);
797 compare_mantissa = mantissa;
801 compare_mantissa = 0;
804 if (
digit > compare_mantissa)
return AbsoluteGreater(x_sign);
805 if (
digit < compare_mantissa)
return AbsoluteLess(x_sign);
811 return AbsoluteLess(x_sign);
819 int chars_allocated,
int chars_written) {
820 DCHECK_LE(chars_written, chars_allocated);
821 if (chars_written == chars_allocated)
return;
826 if (needed_size < string_size && !isolate->
heap()->IsLargeObject(*
string)) {
827 isolate->heap()->NotifyObjectSizeChange(*
string, string_size, needed_size,
838 if (bigint->is_zero()) {
839 return isolate->factory()->zero_string();
841 const bool sign = bigint->sign();
842 uint32_t chars_allocated;
843 uint32_t chars_written;
845 if (bigint->length() == 1 && radix == 10) {
852 constexpr uint32_t kShift = 7;
855 constexpr uint32_t kShiftedBitsPerChar = 425;
856 chars_allocated = (bit_length << kShift) / kShiftedBitsPerChar + 1 +
sign;
857 result = isolate->factory()
858 ->NewRawOneByteString(chars_allocated)
862 uint8_t* out =
start + chars_allocated;
864 *(--out) =
'0' + (
digit % 10);
867 if (
sign) *(--out) =
'-';
869 chars_written = chars_allocated;
876 chars_written = chars_allocated -
static_cast<uint32_t
>(out -
start);
877 std::memmove(
start, out, chars_written);
878 memset(
start + chars_written, 0, chars_allocated - chars_written);
882 DCHECK(radix >= 2 && radix <= 36);
892 result = isolate->factory()
893 ->NewRawOneByteString(chars_allocated)
895 chars_written = chars_allocated;
897 char* characters =
reinterpret_cast<char*
>(
result->GetChars(no_gc));
899 characters, &chars_written, bigint->digits(), radix,
sign);
902 isolate->TerminateExecution();
909 RightTrimString(isolate,
result, chars_allocated, chars_written);
914 uint8_t* chars =
result->GetChars(no_gc);
915 for (uint32_t
i = 0;
i < chars_written;
i++) {
924 if (bigint->is_zero()) {
925 return isolate->factory()->zero_string();
930 if (bigint->length() > 100) {
931 return isolate->factory()->NewStringFromStaticChars(
932 "<a very large BigInt>");
935 uint32_t chars_allocated =
940 ->NewRawOneByteString(chars_allocated)
942 uint32_t chars_written = chars_allocated;
944 char* characters =
reinterpret_cast<char*
>(
result->GetChars(no_gc));
945 std::unique_ptr<bigint::Processor, bigint::Processor::Destroyer>
946 non_interruptible_processor(
948 non_interruptible_processor->ToString(characters, &chars_written,
949 bigint->digits(), 10, bigint->sign());
950 RightTrimString(isolate,
result, chars_allocated, chars_written);
957 if (
IsSmi(*number)) {
963 NewRangeError(MessageTemplate::kBigIntFromNumber, number));
968template <
template <
typename>
typename HandleType>
970typename HandleType<BigInt>::MaybeType BigInt::FromObject(
971 Isolate* isolate, HandleType<Object> obj) {
972 if (IsJSReceiver(*obj)) {
979 if (IsBoolean(*obj)) {
983 if (IsBigInt(*obj)) {
986 if (IsString(*obj)) {
987 HandleType<BigInt>
n;
989 if (isolate->has_exception()) {
993 constexpr uint32_t kMaxRenderedLength = 1000;
994 if (str->length() > kMaxRenderedLength) {
995 Factory* factory = isolate->factory();
996 DirectHandle<String> prefix =
997 factory->NewProperSubString(str, 0, kMaxRenderedLength);
998 DirectHandle<SeqTwoByteString> ellipsis =
999 factory->NewRawTwoByteString(1).ToHandleChecked();
1000 ellipsis->SeqTwoByteStringSet(0, 0x2026);
1004 str = factory->NewConsString(prefix,
Cast<String>(ellipsis))
1008 isolate, NewSyntaxError(MessageTemplate::kBigIntFromObject, str));
1015 NewTypeError(MessageTemplate::kBigIntFromObject, obj));
1019 Isolate* isolate, DirectHandle<Object> obj);
1027 int value =
static_cast<int>(
x->digit(0));
1028 if (
x->sign()) value = -
value;
1032 return isolate->factory()->NewHeapNumber(
result);
1036 if (
x->is_zero())
return 0.0;
1037 uint32_t x_length =
x->length();
1038 digit_t x_msd =
x->digit(x_length - 1);
1040 uint32_t x_bitlength = x_length *
kDigitBits - msd_leading_zeros;
1042 uint64_t exponent = x_bitlength - 1;
1045 uint64_t current_digit = x_msd;
1046 uint32_t digit_index = x_length - 1;
1047 uint32_t shift = msd_leading_zeros + 1 + (64 -
kDigitBits);
1050 uint64_t mantissa = (shift == 64) ? 0 : current_digit << shift;
1052 int32_t mantissa_bits_unset = shift - 12;
1054 if (mantissa_bits_unset >=
static_cast<int32_t
>(
kDigitBits) &&
1057 current_digit =
static_cast<uint64_t
>(
x->digit(digit_index));
1058 mantissa |= (current_digit << (mantissa_bits_unset -
kDigitBits));
1061 if (mantissa_bits_unset > 0 && digit_index > 0) {
1064 current_digit =
static_cast<uint64_t
>(
x->digit(digit_index));
1065 mantissa |= (current_digit >> (
kDigitBits - mantissa_bits_unset));
1071 if (rounding ==
kRoundUp || (rounding ==
kTie && (mantissa & 1) == 1)) {
1079 if (exponent > 1023) {
1085 uint64_t sign_bit =
x->sign() ? (
static_cast<uint64_t
>(1) << 63) : 0;
1087 uint64_t double_bits = sign_bit | exponent | mantissa;
1095 uint64_t current_digit) {
1096 if (mantissa_bits_unset > 0)
return kRoundDown;
1097 int top_unconsumed_bit;
1098 if (mantissa_bits_unset < 0) {
1100 top_unconsumed_bit = -mantissa_bits_unset - 1;
1106 current_digit =
static_cast<uint64_t
>(
x->digit(digit_index));
1110 uint64_t bitmask =
static_cast<uint64_t
>(1) << top_unconsumed_bit;
1111 if ((current_digit & bitmask) == 0) {
1116 if ((current_digit & bitmask) != 0)
return kRoundUp;
1117 while (digit_index > 0) {
1119 if (
x->digit(digit_index) != 0)
return kRoundUp;
1125 if (
sign()) os <<
"-";
1131 if (len > 1) os <<
"...";
1145 uint32_t input_length =
x->length();
1148 bool will_overflow =
true;
1149 for (uint32_t
i = 0;
i < input_length;
i++) {
1151 will_overflow =
false;
1155 uint32_t result_length = input_length + will_overflow;
1157 if (result_storage.
is_null()) {
1158 if (!
New(isolate, result_length).ToHandle(&
result))
return {};
1162 if (input_length == 0) {
1164 }
else if (input_length == 1 && !will_overflow) {
1165 result->set_digit(0,
x->digit(0) + 1);
1177 uint32_t length =
x->length();
1180 result->set_digit(0,
x->digit(0) - 1);
1191template <
typename IsolateT>
1200 isolate->bigint_processor()->FromString(
result->rw_digits(), accumulator);
1233 size_t num_digits_to_write = storage_length /
kDigitSize;
1236#if defined(V8_TARGET_LITTLE_ENDIAN)
1237 memcpy(storage, raw_digits(), num_digits_to_write *
kDigitSize);
1238#elif defined(V8_TARGET_BIG_ENDIAN)
1241 for (
size_t i = 0;
i < num_digits_to_write;
i++) {
1252 Isolate* isolate, uint32_t bitfield,
1255 DCHECK_EQ(
static_cast<uint32_t
>(digits_storage.
length()), bytelength);
1259 if (length == 0 &&
sign ==
true)
return {};
1264#if defined(V8_TARGET_LITTLE_ENDIAN)
1265 memcpy(
digits, digits_storage.
begin(), bytelength);
1266 void* padding_start =
1267 reinterpret_cast<void*
>(
reinterpret_cast<Address>(
digits) + bytelength);
1268 memset(padding_start, 0, length *
kDigitSize - bytelength);
1269#elif defined(V8_TARGET_BIG_ENDIAN)
1271 const digit_t* digit_storage =
1272 reinterpret_cast<const digit_t*
>(digits_storage.
begin());
1280 uint8_t* digit_byte =
reinterpret_cast<uint8_t*
>(
digit);
1281 digit_byte +=
sizeof(*digit) - 1;
1282 const uint8_t* digit_storage_byte =
1283 reinterpret_cast<const uint8_t*
>(digit_storage);
1285 *digit_byte = *digit_storage_byte;
1287 digit_storage_byte++;
1300 if (needed_length == -1)
return x;
1304 static_cast<int>(n));
1311 if (
x->is_zero())
return x;
1325 if (result_length < 0)
return x;
1343 absolute =
static_cast<uint64_t
>(
n);
1345 if (n == std::numeric_limits<int64_t>::min()) {
1346 absolute =
static_cast<uint64_t
>(std::numeric_limits<int64_t>::max()) + 1;
1348 absolute =
static_cast<uint64_t
>(-
n);
1351 result->set_64_bits(absolute);
1361 result->initialize_bitfield(
false, length);
1367 uint32_t words64_count,
1368 const uint64_t* words) {
1374 uint32_t length = (64 /
kDigitBits) * words64_count;
1376 if (
kDigitBits == 32 && words[words64_count - 1] < (1ULL << 32)) length--;
1381 result->set_sign(sign_bit);
1387 for (uint32_t
i = 0;
i <
length;
i += 2) {
1391 if (
i + 1 < length)
result->set_digit(
i + 1,
hi);
1409 uint32_t available_words = *words64_count;
1411 if (available_words == 0)
return;
1416 for (uint32_t
i = 0;
i < len &&
i < available_words; ++
i)
1419 for (uint32_t
i = 0; i < len && available_words > 0;
i += 2) {
1421 uint64_t
hi = (
i + 1) < len ?
digit(
i + 1) : 0;
1422 words[
i / 2] =
lo | (
hi << 32);
1429 if (lossless !=
nullptr) *lossless =
true;
1430 if (
x->is_zero())
return 0;
1431 uint32_t len =
x->length();
1433 if (lossless !=
nullptr && len > 64 /
kDigitBits) *lossless =
false;
1434 uint64_t raw =
static_cast<uint64_t
>(
x->digit(0));
1436 raw |=
static_cast<uint64_t
>(
x->digit(1)) << 32;
1439 return x->sign() ? ((~raw) + 1u) : raw;
1444 int64_t
result =
static_cast<int64_t
>(raw);
1445 if (lossless !=
nullptr && (
result < 0) !=
sign()) *lossless =
false;
1451 if (lossless !=
nullptr &&
sign()) *lossless =
false;
1466void BigIntBase::BigIntBasePrint(std::ostream& os) {
1468 PrintHeader(os,
"BigInt");
1470 os <<
"\n- length: " << len;
1471 os <<
"\n- sign: " <<
sign();
1473 os <<
"\n- digits:";
1474 for (uint32_t
i = 0;
i < len;
i++) {
1475 os <<
"\n 0x" << std::hex <<
digit(
i);
1478 os << std::dec <<
"\n";
1528 result->rw_digits(),
x->digits(),
y->digits());
1554 result->rw_digits(),
x->digits(),
y->digits());
1578 result->rw_digits(),
x->digits(),
y->digits());
1713 return (
static_cast<uint32_t
>(state.must_round_down)
1719 Address x_addr, intptr_t shift,
1720 uint32_t must_round_down) {
#define SLOW_DCHECK(condition)
static constexpr T decode(U value)
static constexpr U encode(T value)
static V8_NODISCARD constexpr U update(U previous, T value)
static constexpr int kSignificandSize
static constexpr uint64_t kSignificandMask
static constexpr int kPhysicalSignificandSize
static constexpr uint64_t kHiddenBit
constexpr T * begin() const
Status Modulo(RWDigits R, Digits A, Digits B)
Status Divide(RWDigits Q, Digits A, Digits B)
static Processor * New(Platform *platform)
Status Multiply(RWDigits Z, Digits X, Digits Y)
bigint::Digits digits() const
static const uint32_t kDigitBits
static const uint32_t kDigitSize
static const uint32_t kLengthFieldBits
digit_t digit(uint32_t n) const
std::atomic_uint32_t bitfield_
static const uint32_t kMaxLength
static const uint32_t kMaxLengthBits
V8_EXPORT_PRIVATE int64_t AsInt64(bool *lossless=nullptr)
uint32_t GetBitfieldForSerialization() const
static Maybe< ComparisonResult > CompareToString(Isolate *isolate, DirectHandle< BigInt > x, DirectHandle< String > y)
static MaybeHandle< BigInt > Remainder(Isolate *isolate, DirectHandle< BigInt > x, DirectHandle< BigInt > y)
static Maybe< bool > EqualToString(Isolate *isolate, DirectHandle< BigInt > x, DirectHandle< String > y)
static ComparisonResult CompareToBigInt(DirectHandle< BigInt > x, DirectHandle< BigInt > y)
static MaybeHandle< BigInt > Multiply(Isolate *isolate, DirectHandle< BigInt > x, DirectHandle< BigInt > y)
static uint32_t SizeFor(uint32_t length)
static DirectHandle< Number > ToNumber(Isolate *isolate, DirectHandle< BigInt > x)
void ToWordsArray64(int *sign_bit, uint32_t *words64_count, uint64_t *words)
static MaybeDirectHandle< BigInt > Exponentiate(Isolate *isolate, DirectHandle< BigInt > base, DirectHandle< BigInt > exponent)
void SerializeDigits(uint8_t *storage, size_t storage_length)
static MaybeDirectHandle< BigInt > AsUintN(Isolate *isolate, uint64_t n, DirectHandle< BigInt > x)
static MaybeHandle< BigInt > Divide(Isolate *isolate, DirectHandle< BigInt > x, DirectHandle< BigInt > y)
static MaybeHandle< String > ToString(Isolate *isolate, DirectHandle< BigInt > bigint, int radix=10, ShouldThrow should_throw=kThrowOnError)
static MaybeHandle< BigInt > Increment(Isolate *isolate, DirectHandle< BigInt > x)
static bool EqualToBigInt(Tagged< BigInt > x, Tagged< BigInt > y)
static Handle< BigInt > Zero(IsolateT *isolate, AllocationType allocation=AllocationType::kYoung)
static bool EqualToNumber(DirectHandle< BigInt > x, DirectHandle< Object > y)
static V8_EXPORT_PRIVATE Handle< BigInt > FromUint64(Isolate *isolate, uint64_t n)
static MaybeDirectHandle< BigInt > FromWords64(Isolate *isolate, int sign_bit, uint32_t words64_count, const uint64_t *words)
static MaybeHandle< BigInt > Decrement(Isolate *isolate, DirectHandle< BigInt > x)
static MaybeHandle< BigInt > Allocate(IsolateT *isolate, bigint::FromStringAccumulator *accumulator, bool negative, AllocationType allocation)
static Handle< BigInt > UnaryMinus(Isolate *isolate, DirectHandle< BigInt > x)
static DirectHandle< String > NoSideEffectsToString(Isolate *isolate, DirectHandle< BigInt > bigint)
static V8_EXPORT_PRIVATE ComparisonResult CompareToDouble(DirectHandle< BigInt > x, double y)
static V8_EXPORT_PRIVATE Handle< BigInt > FromInt64(Isolate *isolate, int64_t n)
void BigIntShortPrint(std::ostream &os)
static MaybeDirectHandle< BigInt > BitwiseNot(Isolate *isolate, DirectHandle< BigInt > x)
static MaybeHandle< BigInt > Add(Isolate *isolate, DirectHandle< BigInt > x, DirectHandle< BigInt > y)
static ComparisonResult CompareToNumber(DirectHandle< BigInt > x, DirectHandle< Object > y)
static DirectHandle< BigInt > AsIntN(Isolate *isolate, uint64_t n, DirectHandle< BigInt > x)
static size_t DigitsByteLengthForBitfield(uint32_t bitfield)
uint64_t AsUint64(bool *lossless=nullptr)
static MaybeHandle< BigInt > Subtract(Isolate *isolate, DirectHandle< BigInt > x, DirectHandle< BigInt > y)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< BigInt > FromSerializedDigits(Isolate *isolate, uint32_t bitfield, base::Vector< const uint8_t > digits_storage)
static V8_EXPORT_PRIVATE MaybeHandle< BigInt > FromNumber(Isolate *isolate, DirectHandle< Object > number)
bigint::Processor * bigint_processor()
static V8_WARN_UNUSED_RESULT HandleType< Object >::MaybeType ToPrimitive(Isolate *isolate, HandleType< JSReceiver > receiver, ToPrimitiveHint hint=ToPrimitiveHint::kDefault)
V8_WARN_UNUSED_RESULT V8_INLINE bool ToHandle(DirectHandle< S > *out) const
V8_WARN_UNUSED_RESULT V8_INLINE bool ToHandle(Handle< S > *out) const
static bool IsMutableBigInt(Tagged< MutableBigInt > o)
static MaybeHandle< BigInt > MakeImmutable(MaybeHandle< MutableBigInt > maybe)
static Handle< BigInt > NewFromInt(Isolate *isolate, int value)
static DirectHandle< BigInt > RightShiftByAbsolute(Isolate *isolate, Handle< BigIntBase > x, Handle< BigIntBase > y)
static bool digit_ismax(digit_t x)
static Handle< MutableBigInt > Copy(Isolate *isolate, DirectHandle< BigIntBase > source)
static DirectHandle< BigInt > RightShiftByMaximum(Isolate *isolate, bool sign)
void set_sign(bool new_sign)
static MaybeHandle< MutableBigInt > New(IsolateT *isolate, uint32_t length, AllocationType allocation=AllocationType::kYoung)
static MaybeDirectHandle< BigInt > LeftShiftByAbsolute(Isolate *isolate, Handle< BigIntBase > x, Handle< BigIntBase > y)
void InitializeDigits(uint32_t length, uint8_t value=0)
void set_64_bits(uint64_t bits)
static Maybe< digit_t > ToShiftAmount(Handle< BigIntBase > x)
bigint::RWDigits rw_digits()
static void Canonicalize(Tagged< MutableBigInt > result)
void set_length(uint32_t new_length, ReleaseStoreTag)
static Handle< BigInt > NewFromDouble(Isolate *isolate, double value)
static Handle< BigInt > Zero(IsolateT *isolate, AllocationType allocation=AllocationType::kYoung)
static Handle< MutableBigInt > AbsoluteSubOne(Isolate *isolate, DirectHandle< BigIntBase > x)
static double ToDouble(DirectHandle< BigIntBase > x)
void set_digit(uint32_t n, digit_t value)
static uint64_t GetRawBits(BigIntBase *x, bool *lossless)
static MaybeHandle< MutableBigInt > AbsoluteAddOne(Isolate *isolate, DirectHandle< BigIntBase > x, bool sign, Tagged< MutableBigInt > result_storage={})
static Rounding DecideRounding(DirectHandle< BigIntBase > x, int mantissa_bits_unset, int digit_index, uint64_t current_digit)
void initialize_bitfield(bool sign, uint32_t length)
static V8_EXPORT_PRIVATE bool BooleanValue(Tagged< Object > obj, IsolateT *isolate)
static V8_INLINE constexpr int32_t SizeFor(int32_t length)
static constexpr int ToInt(const Tagged< Object > object)
static constexpr Tagged< Smi > FromInt(int value)
static constexpr Tagged< Smi > zero()
static constexpr int kMaxValue
static const uint32_t kMaxLength
V8_INLINE constexpr bool is_null() const
#define ALIGN_TO_ALLOCATION_ALIGNMENT(value)
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call)
#define THROW_NEW_ERROR(isolate, call)
ZoneVector< RpoNumber > & result
LiftoffAssembler::CacheState state
constexpr unsigned CountLeadingZeros(T value)
V8_INLINE Dest bit_cast(Source const &source)
uint32_t ToStringResultLength(Digits X, int radix, bool sign)
int SubtractSignedResultLength(int x_length, int y_length, bool same_sign)
void BitwiseXor_NegNeg(RWDigits Z, Digits X, Digits Y)
bool AsIntN(RWDigits Z, Digits X, bool x_negative, int n)
void BitwiseAnd_PosPos(RWDigits Z, Digits X, Digits Y)
void SubtractOne(RWDigits Z, Digits X)
void BitwiseOr_PosNeg(RWDigits Z, Digits X, Digits Y)
int RightShift_ResultLength(Digits X, bool x_sign, digit_t shift, RightShiftState *state)
void AddOne(RWDigits Z, Digits X)
void BitwiseXor_PosPos(RWDigits Z, Digits X, Digits Y)
void LeftShift(RWDigits Z, Digits X, digit_t shift)
int Compare(Digits A, Digits B)
void BitwiseOr_PosPos(RWDigits Z, Digits X, Digits Y)
int ModuloResultLength(Digits B)
void BitwiseAnd_NegNeg(RWDigits Z, Digits X, Digits Y)
constexpr char kStringZapValue
int AsIntNResultLength(Digits X, bool x_negative, int n)
void Add(RWDigits Z, Digits X, Digits Y)
int AddSignedResultLength(int x_length, int y_length, bool same_sign)
bool SubtractSigned(RWDigits Z, Digits X, bool x_negative, Digits Y, bool y_negative)
bool AddSigned(RWDigits Z, Digits X, bool x_negative, Digits Y, bool y_negative)
void AsUintN_Neg(RWDigits Z, Digits X, int n)
void Subtract(RWDigits Z, Digits X, Digits Y)
void BitwiseOr_NegNeg(RWDigits Z, Digits X, Digits Y)
void RightShift(RWDigits Z, Digits X, digit_t shift, const RightShiftState &state)
int AsUintN_Neg_ResultLength(int n)
int DivideResultLength(Digits A, Digits B)
int MultiplyResultLength(Digits X, Digits Y)
void BitwiseXor_PosNeg(RWDigits Z, Digits X, Digits Y)
int AsUintN_Pos_ResultLength(Digits X, int n)
void BitwiseAnd_PosNeg(RWDigits Z, Digits X, Digits Y)
void AsUintN_Pos(RWDigits Z, Digits X, int n)
uint32_t RightShiftResultLength(Address x_addr, uint32_t x_sign, intptr_t shift)
void MutableBigInt_BitwiseAndNegNegAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
void MutableBigInt_BitwiseXorNegNegAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
bool IsNumber(Tagged< Object > obj)
void MutableBigInt_RightShiftAndCanonicalize(Address result_addr, Address x_addr, intptr_t shift, uint32_t must_round_down)
double DoubleToInteger(double x)
MaybeHandle< T > MaybeIndirectHandle
V8_INLINE bool GetIsolateFromHeapObject(Tagged< HeapObject > object, Isolate **isolate)
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
V8_INLINE IndirectHandle< T > indirect_handle(DirectHandle< T > handle)
void MutableBigInt_BitwiseOrNegNegAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
int32_t MutableBigInt_AbsoluteMulAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
V8_INLINE DirectHandle< T > direct_handle(Tagged< T > object, Isolate *isolate)
void MutableBigInt_BitwiseOrPosPosAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
v8::internal::LoadHandler V8_OBJECT_END
void Terminate(Isolate *isolate)
int32_t MutableBigInt_AbsoluteCompare(Address x_addr, Address y_addr)
void MutableBigInt_BitwiseXorPosNegAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
void MutableBigInt_BitwiseAndPosNegAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
Handle< T > IndirectHandle
MaybeHandle< T > ThrowBigIntTooBig(Isolate *isolate)
void MutableBigInt_BitwiseOrPosNegAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
void MutableBigInt_BitwiseAndPosPosAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
void MutableBigInt_AbsoluteSubAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
V8_EXPORT_PRIVATE FlagValues v8_flags
void MutableBigInt_AbsoluteAddAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
void MutableBigInt_LeftShiftAndCanonicalize(Address result_addr, Address x_addr, intptr_t shift)
int32_t MutableBigInt_AbsoluteModAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
int32_t MutableBigInt_AbsoluteDivAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
static V ByteReverse(V value)
void MutableBigInt_BitwiseXorPosPosAndCanonicalize(Address result_addr, Address x_addr, Address y_addr)
MaybeHandle< BigInt > StringToBigInt(Isolate *isolate, DirectHandle< String > string)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
static constexpr ReleaseStoreTag kReleaseStore
Maybe< T > Just(const T &t)
#define NEVER_READ_ONLY_SPACE
#define NEVER_READ_ONLY_SPACE_IMPL(Type)
#define DCHECK_LE(v1, v2)
#define DCHECK_IMPLIES(v1, v2)
#define DCHECK_NE(v1, v2)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)
#define V8_EXPORT_PRIVATE