Chromium Code Reviews| Index: runtime/lib/double.cc |
| =================================================================== |
| --- runtime/lib/double.cc (revision 23032) |
| +++ runtime/lib/double.cc (working copy) |
| @@ -16,6 +16,7 @@ |
| namespace dart { |
| +DECLARE_FLAG(bool, throw_on_53bit_overflow); |
|
siva
2013/05/23 01:28:22
I wonder if the flag needs to be:
throw_on_javascr
zra
2013/05/23 15:59:07
Done.
|
| DECLARE_FLAG(bool, trace_intrinsified_natives); |
| DEFINE_NATIVE_ENTRY(Double_doubleFromInteger, 2) { |
| @@ -81,7 +82,15 @@ |
| } |
| const Bigint& big = Bigint::Handle(BigintOperations::NewFromDouble(val)); |
| if (BigintOperations::FitsIntoInt64(big)) { |
| - return Integer::New(BigintOperations::ToInt64(big)); |
| + const Integer& i = Integer::Handle( |
| + Integer::New(BigintOperations::ToInt64(big))); |
| + if (FLAG_throw_on_53bit_overflow && !i.FitsIn53Bits()) { |
| + const Array& exc_args = Array::Handle(Array::New(1)); |
| + exc_args.SetAt(0, Object::Handle(String::New("DoubleToInteger"))); |
| + Exceptions::ThrowByType(Exceptions::kFiftyThreeBitOverflowError, |
| + exc_args); |
| + } |
| + return i.AsValidInteger(); |
|
siva
2013/05/23 01:28:22
Integer::New(...) above has already done the Smi/M
zra
2013/05/23 15:59:07
Done.
|
| } else { |
| return big.raw(); |
| } |