Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2722)

Unified Diff: runtime/vm/object.cc

Issue 2708213004: Introduce a flag --limit-ints-to-64-bits in the VM in order to investigate the (Closed)
Patch Set: work in progress Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/flag_list.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « runtime/vm/flag_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698