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

Unified Diff: runtime/vm/object.cc

Issue 11421064: Cleanups and added more checks for valid Integer allocation (must be Smi, Mint or Bigint for their … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 15309)
+++ runtime/vm/object.cc (working copy)
@@ -9283,7 +9283,7 @@
}
-RawInteger* Integer::AsInteger() const {
+RawInteger* Integer::AsValidInteger() const {
if (IsSmi()) return raw();
if (IsMint()) {
Mint& mint = Mint::Handle();
@@ -9402,7 +9402,7 @@
const Bigint& right_big = Bigint::Handle(other.AsBigint());
const Bigint& result =
Bigint::Handle(left_big.ArithmeticOp(operation, right_big));
- return Integer::Handle(result.AsInteger()).raw();
+ return Integer::Handle(result.AsValidInteger()).raw();
}
@@ -9873,15 +9873,13 @@
RawBigint* Bigint::New(const String& str, Heap::Space space) {
- return BigintOperations::NewFromCString(str.ToCString(), space);
+ const Bigint& result = Bigint::Handle(
+ BigintOperations::NewFromCString(str.ToCString(), space));
+ ASSERT(!BigintOperations::FitsIntoMint(result));
+ return result.raw();
}
-RawBigint* Bigint::New(int64_t value, Heap::Space space) {
- return BigintOperations::NewFromInt64(value, space);
-}
-
-
double Bigint::AsDoubleValue() const {
return Double::Handle(BigintOperations::ToDouble(*this)).value();
}
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698