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

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/typed_data.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_javascript_int_overflow);
DECLARE_FLAG(bool, trace_intrinsified_natives);
DEFINE_NATIVE_ENTRY(Double_doubleFromInteger, 2) {
@@ -81,7 +82,12 @@
}
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_javascript_int_overflow && !i.FitsIn53Bits()) {
siva 2013/05/23 17:38:57 just if (FLAG_throw_on_javascript_int_overflow) {
+ Integer::CheckForFiftyThreeBitOverflow(i, "DoubleToInteger");
+ }
+ return i.raw();
} else {
return big.raw();
}
« no previous file with comments | « no previous file | runtime/lib/integers.cc » ('j') | runtime/lib/typed_data.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698