Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index 7482015638326648d80173606445df517d1fcd6b..b9521e685f9797e196d6920253283e7dd1bff946 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -19168,6 +19168,8 @@ RawBigint* Bigint::New(bool neg, |
RawBigint* Bigint::NewFromInt64(int64_t value, Heap::Space space) { |
+ // Currently only used to convert Smi or Mint to hex String, therefore do |
+ // not throw RangeError if --limit-ints-to-64-bits. |
const TypedData& digits = TypedData::Handle(NewDigits(2, space)); |
bool neg; |
uint64_t abs_value; |
@@ -19185,6 +19187,10 @@ RawBigint* Bigint::NewFromInt64(int64_t value, Heap::Space space) { |
RawBigint* Bigint::NewFromUint64(uint64_t value, Heap::Space space) { |
+ if (FLAG_limit_ints_to_64_bits) { |
+ Exceptions::ThrowRangeErrorMsg( |
+ "Integer operand requires conversion to Bigint"); |
+ } |
const TypedData& digits = TypedData::Handle(NewDigits(2, space)); |
SetDigitAt(digits, 0, static_cast<uint32_t>(value)); |
SetDigitAt(digits, 1, static_cast<uint32_t>(value >> 32)); |
@@ -19195,6 +19201,12 @@ RawBigint* Bigint::NewFromUint64(uint64_t value, Heap::Space space) { |
RawBigint* Bigint::NewFromShiftedInt64(int64_t value, |
intptr_t shift, |
Heap::Space space) { |
+ if (FLAG_limit_ints_to_64_bits) { |
+ // The allocated Bigint value is not necessarily out of range, but it may |
+ // be used as an operand in an operation resulting in a Bigint. |
+ Exceptions::ThrowRangeErrorMsg( |
+ "Integer operand requires conversion to Bigint"); |
+ } |
ASSERT(kBitsPerDigit == 32); |
ASSERT(shift >= 0); |
const intptr_t digit_shift = shift / kBitsPerDigit; |
@@ -19225,6 +19237,7 @@ RawBigint* Bigint::NewFromShiftedInt64(int64_t value, |
RawBigint* Bigint::NewFromCString(const char* str, Heap::Space space) { |
+ // Allow parser to scan Bigint literal, even with --limit-ints-to-64-bits. |
ASSERT(str != NULL); |
bool neg = false; |
TypedData& digits = TypedData::Handle(); |
@@ -19246,6 +19259,7 @@ RawBigint* Bigint::NewFromCString(const char* str, Heap::Space space) { |
RawBigint* Bigint::NewCanonical(const String& str) { |
+ // Allow parser to scan Bigint literal, even with --limit-ints-to-64-bits. |
Thread* thread = Thread::Current(); |
Zone* zone = thread->zone(); |
Isolate* isolate = thread->isolate(); |