summaryrefslogtreecommitdiff
path: root/deps/v8/src/objects/bigint.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/objects/bigint.cc')
-rw-r--r--deps/v8/src/objects/bigint.cc42
1 files changed, 26 insertions, 16 deletions
diff --git a/deps/v8/src/objects/bigint.cc b/deps/v8/src/objects/bigint.cc
index 458aa7c1eb..dcf99e2f29 100644
--- a/deps/v8/src/objects/bigint.cc
+++ b/deps/v8/src/objects/bigint.cc
@@ -36,9 +36,6 @@ namespace internal {
class MutableBigInt : public FreshlyAllocatedBigInt,
public NeverReadOnlySpaceObject {
public:
- using NeverReadOnlySpaceObject::GetHeap;
- using NeverReadOnlySpaceObject::GetIsolate;
-
// Bottleneck for converting MutableBigInts to BigInts.
static MaybeHandle<BigInt> MakeImmutable(MaybeHandle<MutableBigInt> maybe);
static Handle<BigInt> MakeImmutable(Handle<MutableBigInt> result);
@@ -96,7 +93,8 @@ class MutableBigInt : public FreshlyAllocatedBigInt,
static inline Handle<MutableBigInt> AbsoluteBitwiseOp(
Isolate* isolate, Handle<BigIntBase> x, Handle<BigIntBase> y,
MutableBigInt* result_storage, ExtraDigitsHandling extra_digits,
- SymmetricOp symmetric, std::function<digit_t(digit_t, digit_t)> op);
+ SymmetricOp symmetric,
+ const std::function<digit_t(digit_t, digit_t)>& op);
static Handle<MutableBigInt> AbsoluteAnd(
Isolate* isolate, Handle<BigIntBase> x, Handle<BigIntBase> y,
MutableBigInt* result_storage = nullptr);
@@ -155,9 +153,11 @@ class MutableBigInt : public FreshlyAllocatedBigInt,
static MaybeHandle<String> ToStringBasePowerOfTwo(Isolate* isolate,
Handle<BigIntBase> x,
- int radix);
+ int radix,
+ ShouldThrow should_throw);
static MaybeHandle<String> ToStringGeneric(Isolate* isolate,
- Handle<BigIntBase> x, int radix);
+ Handle<BigIntBase> x, int radix,
+ ShouldThrow should_throw);
static double ToDouble(Handle<BigIntBase> x);
enum Rounding { kRoundDown, kTie, kRoundUp };
@@ -924,14 +924,15 @@ ComparisonResult BigInt::CompareToDouble(Handle<BigInt> x, double y) {
}
MaybeHandle<String> BigInt::ToString(Isolate* isolate, Handle<BigInt> bigint,
- int radix) {
+ int radix, ShouldThrow should_throw) {
if (bigint->is_zero()) {
return isolate->factory()->NewStringFromStaticChars("0");
}
if (base::bits::IsPowerOfTwo(radix)) {
- return MutableBigInt::ToStringBasePowerOfTwo(isolate, bigint, radix);
+ return MutableBigInt::ToStringBasePowerOfTwo(isolate, bigint, radix,
+ should_throw);
}
- return MutableBigInt::ToStringGeneric(isolate, bigint, radix);
+ return MutableBigInt::ToStringGeneric(isolate, bigint, radix, should_throw);
}
MaybeHandle<BigInt> BigInt::FromNumber(Isolate* isolate,
@@ -1255,7 +1256,7 @@ MaybeHandle<MutableBigInt> MutableBigInt::AbsoluteSubOne(Isolate* isolate,
inline Handle<MutableBigInt> MutableBigInt::AbsoluteBitwiseOp(
Isolate* isolate, Handle<BigIntBase> x, Handle<BigIntBase> y,
MutableBigInt* result_storage, ExtraDigitsHandling extra_digits,
- SymmetricOp symmetric, std::function<digit_t(digit_t, digit_t)> op) {
+ SymmetricOp symmetric, const std::function<digit_t(digit_t, digit_t)>& op) {
int x_length = x->length();
int y_length = y->length();
int num_pairs = y_length;
@@ -1924,9 +1925,9 @@ MaybeHandle<BigInt> BigInt::FromSerializedDigits(
static const char kConversionChars[] = "0123456789abcdefghijklmnopqrstuvwxyz";
-MaybeHandle<String> MutableBigInt::ToStringBasePowerOfTwo(Isolate* isolate,
- Handle<BigIntBase> x,
- int radix) {
+MaybeHandle<String> MutableBigInt::ToStringBasePowerOfTwo(
+ Isolate* isolate, Handle<BigIntBase> x, int radix,
+ ShouldThrow should_throw) {
STATIC_ASSERT(base::bits::IsPowerOfTwo(kDigitBits));
DCHECK(base::bits::IsPowerOfTwo(radix));
DCHECK(radix >= 2 && radix <= 32);
@@ -1945,7 +1946,11 @@ MaybeHandle<String> MutableBigInt::ToStringBasePowerOfTwo(Isolate* isolate,
(bit_length + bits_per_char - 1) / bits_per_char + sign;
if (chars_required > String::kMaxLength) {
- THROW_NEW_ERROR(isolate, NewInvalidStringLengthError(), String);
+ if (should_throw == kThrowOnError) {
+ THROW_NEW_ERROR(isolate, NewInvalidStringLengthError(), String);
+ } else {
+ return MaybeHandle<String>();
+ }
}
Handle<SeqOneByteString> result =
@@ -1988,7 +1993,8 @@ MaybeHandle<String> MutableBigInt::ToStringBasePowerOfTwo(Isolate* isolate,
MaybeHandle<String> MutableBigInt::ToStringGeneric(Isolate* isolate,
Handle<BigIntBase> x,
- int radix) {
+ int radix,
+ ShouldThrow should_throw) {
DCHECK(radix >= 2 && radix <= 36);
DCHECK(!x->is_zero());
Heap* heap = isolate->heap();
@@ -2014,7 +2020,11 @@ MaybeHandle<String> MutableBigInt::ToStringGeneric(Isolate* isolate,
chars_required += sign;
if (chars_required > String::kMaxLength) {
- THROW_NEW_ERROR(isolate, NewInvalidStringLengthError(), String);
+ if (should_throw == kThrowOnError) {
+ THROW_NEW_ERROR(isolate, NewInvalidStringLengthError(), String);
+ } else {
+ return MaybeHandle<String>();
+ }
}
Handle<SeqOneByteString> result =
isolate->factory()