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

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: 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..c3c2c3039b53c481f78f6e0828375873104ff9e9 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -19168,6 +19168,12 @@ RawBigint* Bigint::New(bool neg,
RawBigint* Bigint::NewFromInt64(int64_t value, Heap::Space space) {
siva 2017/02/22 01:48:51 This function seems to be used only as a convenien
regis 2017/02/22 17:30:48 Done.
+ 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");
+ }
const TypedData& digits = TypedData::Handle(NewDigits(2, space));
bool neg;
uint64_t abs_value;
@@ -19185,6 +19191,12 @@ 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) {
+ // 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.
siva 2017/02/22 01:48:51 Why do you say the value is not necessarily out of
regis 2017/02/22 17:30:48 You are right. I duplicated the same comment witho
+ 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 +19207,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 +19243,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 +19265,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