Chromium Code Reviews| Index: runtime/lib/typed_data.cc |
| =================================================================== |
| --- runtime/lib/typed_data.cc (revision 23032) |
| +++ runtime/lib/typed_data.cc (working copy) |
| @@ -13,6 +13,8 @@ |
| namespace dart { |
| +DECLARE_FLAG(bool, throw_on_javascript_int_overflow); |
| + |
| // TypedData. |
| // Checks to see if offset_in_bytes is in the range. |
| @@ -261,6 +263,9 @@ |
| } else { \ |
| result = Integer::New(value); \ |
| } \ |
| + if (FLAG_throw_on_javascript_int_overflow && !result.FitsIn53Bits()) { \ |
|
siva
2013/05/23 17:38:57
Ditto comment about the FitsIn53Bits check here.
|
| + Integer::CheckForFiftyThreeBitOverflow(result, "TypedData_getter"); \ |
| + } \ |
| return result.raw(); \ |
| } \ |
| @@ -384,7 +389,11 @@ |
| } else { |
| value = Utils::HostToBigEndian64(value); |
| } |
| - return Integer::New(value); |
| + const Integer& i = Integer::Handle(Integer::New(value)); |
| + if (FLAG_throw_on_javascript_int_overflow && !i.FitsIn53Bits()) { |
|
siva
2013/05/23 17:38:57
Ditto comment about the FitsIn53Bits check here.
|
| + Integer::CheckForFiftyThreeBitOverflow(i, "ByteData_ToEndianInt64"); |
| + } |
| + return i.raw(); |
| } |
| @@ -406,9 +415,19 @@ |
| value = Utils::HostToBigEndian64(value); |
| } |
| if (value > static_cast<uint64_t>(Mint::kMaxValue)) { |
| - return BigintOperations::NewFromUint64(value); |
| + if (FLAG_throw_on_javascript_int_overflow) { |
| + const Array& arg = Array::Handle(Array::New(1)); |
| + arg.SetAt(0, Object::Handle(String::New("ByteData_ToEndianUint64"))); |
| + Exceptions::ThrowByType(Exceptions::kFiftyThreeBitOverflowError, arg); |
| + } else { |
| + return BigintOperations::NewFromUint64(value); |
| + } |
| } |
| - return Integer::New(value); |
| + const Integer& i = Integer::Handle(Integer::New(value)); |
| + if (FLAG_throw_on_javascript_int_overflow && !i.FitsIn53Bits()) { |
|
siva
2013/05/23 17:38:57
Ditto comment about FitsIn53Bits check here.
|
| + Integer::CheckForFiftyThreeBitOverflow(i, "ByteData_ToEndianUint64"); |
| + } |
| + return i.raw(); |
| } |