From: yangguo@chromium.org Date: Mon, 8 Apr 2013 15:13:57 +0000 (+0000) Subject: Fix bug in bignum implementation. X-Git-Tag: upstream/4.7.83~14674 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=26ef04fa9cd265d8f10cd46dcf2712100af4da88;p=platform%2Fupstream%2Fv8.git Fix bug in bignum implementation. R=mstarzinger@chromium.org BUG= Review URL: https://chromiumcodereview.appspot.com/13454019 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14167 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/bignum.cc b/src/bignum.cc index 9436322..c8b61ee 100644 --- a/src/bignum.cc +++ b/src/bignum.cc @@ -735,6 +735,13 @@ void Bignum::BigitsShiftLeft(int shift_amount) { void Bignum::SubtractTimes(const Bignum& other, int factor) { +#ifdef DEBUG + Bignum a, b; + a.AssignBignum(*this); + b.AssignBignum(other); + b.MultiplyByUInt32(factor); + a.SubtractBignum(b); +#endif ASSERT(exponent_ <= other.exponent_); if (factor < 3) { for (int i = 0; i < factor; ++i) { @@ -758,9 +765,9 @@ void Bignum::SubtractTimes(const Bignum& other, int factor) { Chunk difference = bigits_[i] - borrow; bigits_[i] = difference & kBigitMask; borrow = difference >> (kChunkSize - 1); - ++i; } Clamp(); + ASSERT(Bignum::Equal(a, *this)); }