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

Unified Diff: runtime/vm/object.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
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 23032)
+++ runtime/vm/object.cc (working copy)
@@ -10386,6 +10386,17 @@
}
+// Throw kFiftyThreeBitOverflow if the result of an operation overflows
+// 53 bits.
+void Integer::CheckForFiftyThreeBitOverflow(const Integer& i, const char* msg) {
+ if (i.FitsIn53Bits()) return;
+ const Array& exc_args = Array::Handle(Array::New(1));
+ exc_args.SetAt(0, Object::Handle(String::New(msg)));
+ Exceptions::ThrowByType(Exceptions::kFiftyThreeBitOverflowError, exc_args);
+ return;
+}
+
+
double Integer::AsDoubleValue() const {
UNIMPLEMENTED();
return 0.0;
@@ -10398,6 +10409,12 @@
}
+bool Integer::FitsIn53Bits() const {
+ UNIMPLEMENTED();
+ return false;
+}
+
+
int Integer::CompareWith(const Integer& other) const {
UNIMPLEMENTED();
return 0;
@@ -10772,6 +10789,12 @@
}
+bool Mint::FitsIn53Bits() const {
+ int64_t v = AsInt64Value();
+ return Utils::IsInt(53, v);
+}
+
+
int Mint::CompareWith(const Integer& other) const {
ASSERT(!FitsIntoSmi(*this));
if (other.IsMint() || other.IsSmi()) {
« runtime/lib/typed_data.cc ('K') | « runtime/vm/object.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698