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

Unified Diff: runtime/lib/double.cc

Issue 15743017: Adds a flag to the standalone vm to throw an exception on 53-bit integer overflow. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « no previous file | runtime/lib/integers.cc » ('j') | runtime/lib/integers.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « no previous file | runtime/lib/integers.cc » ('j') | runtime/lib/integers.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698