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

Unified Diff: runtime/vm/object.cc

Issue 747483002: Resubmit bigint changes of r41817 that were later reverted. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
« runtime/lib/bigint.dart ('K') | « runtime/vm/intrinsifier_x64.cc ('k') | no next file » | 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 41860)
+++ runtime/vm/object.cc (working copy)
@@ -16408,7 +16408,7 @@
RawBigint* Bigint::NewFromShiftedInt64(int64_t value, intptr_t shift,
- Heap::Space space) {
+ Heap::Space space) {
ASSERT(kBitsPerDigit == 32);
ASSERT(shift >= 0);
const Bigint& result = Bigint::Handle(New(space));
@@ -16439,17 +16439,18 @@
void Bigint::EnsureLength(intptr_t length, Heap::Space space) const {
- ASSERT(length >= 0);
+ ASSERT(length > 0);
+ length++; // Account for leading zero for 64-bit processing.
regis 2014/11/20 22:37:23 Here too.
TypedData& old_digits = TypedData::Handle(digits());
- if ((length > 0) && (length > old_digits.Length())) {
+ if (length > old_digits.Length()) {
TypedData& new_digits = TypedData::Handle(
TypedData::New(kTypedDataUint32ArrayCid, length + kExtraDigits, space));
- if (old_digits.Length() > 0) {
+ set_digits(new_digits);
+ if (Used() > 0) {
TypedData::Copy(new_digits, TypedData::data_offset(),
old_digits, TypedData::data_offset(),
- old_digits.LengthInBytes());
+ (Used() + 1)*kBytesPerDigit); // Copy leading zero.
}
- set_digits(new_digits);
}
}
@@ -16456,10 +16457,15 @@
void Bigint::Clamp() const {
intptr_t used = Used();
- while ((used > 0) && (DigitAt(used - 1) == 0)) {
- --used;
+ if (used > 0) {
+ if (DigitAt(used - 1) == 0) {
+ do {
+ --used;
+ } while ((used > 0) && (DigitAt(used - 1) == 0));
+ SetUsed(used);
+ }
+ SetDigitAt(used, 0); // Set leading zero for 64-bit processing.
}
- SetUsed(used);
}
« runtime/lib/bigint.dart ('K') | « runtime/vm/intrinsifier_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698