Changeset 149609 in webkit


Ignore:
Timestamp:
May 6, 2013 10:49:52 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Cherry-pick fixes to bignum from upstream
https://bugs.webkit.org/show_bug.cgi?id=115658

Patch by Cosmin Truta <ctruta@blackberry.com> on 2013-05-06
Reviewed by Darin Adler.

Cherry-picked the following change lists:

Fix bug in bignum implementation
http://codereview.chromium.org/13454019

Make VS2005 project files compile without errors
http://codereview.chromium.org/6286135

  • wtf/dtoa/bignum.cc:
Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r149602 r149609  
     12013-05-06  Cosmin Truta  <ctruta@blackberry.com>
     2
     3        Cherry-pick fixes to bignum from upstream
     4        https://bugs.webkit.org/show_bug.cgi?id=115658
     5
     6        Reviewed by Darin Adler.
     7
     8        Cherry-picked the following change lists:
     9
     10        Fix bug in bignum implementation
     11        http://codereview.chromium.org/13454019
     12
     13        Make VS2005 project files compile without errors
     14        http://codereview.chromium.org/6286135
     15
     16        * wtf/dtoa/bignum.cc:
     17
    1182013-05-06  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
    219
  • trunk/Source/WTF/wtf/dtoa/bignum.cc

    r147976 r149609  
    6969        EnsureCapacity(needed_bigits);
    7070        for (int i = 0; i < needed_bigits; ++i) {
    71             bigits_[i] = (uint32_t)value & kBigitMask;
     71            bigits_[i] = static_cast<Chunk>(value & kBigitMask);
    7272            value = value >> kBigitSize;
    7373        }
     
    268268        while (carry != 0) {
    269269            EnsureCapacity(used_digits_ + 1);
    270             bigits_[used_digits_] = (uint32_t)carry & kBigitMask;
     270            bigits_[used_digits_] = static_cast<Chunk>(carry & kBigitMask);
    271271            used_digits_++;
    272272            carry >>= kBigitSize;
     
    289289            uint64_t product_high = high * bigits_[i];
    290290            uint64_t tmp = (carry & kBigitMask) + product_low;
    291             bigits_[i] = (uint32_t)tmp & kBigitMask;
     291            bigits_[i] = static_cast<Chunk>(tmp & kBigitMask);
    292292            carry = (carry >> kBigitSize) + (tmp >> kBigitSize) +
    293293            (product_high << (32 - kBigitSize));
     
    295295        while (carry != 0) {
    296296            EnsureCapacity(used_digits_ + 1);
    297             bigits_[used_digits_] = (uint32_t)carry & kBigitMask;
     297            bigits_[used_digits_] = static_cast<Chunk>(carry & kBigitMask);
    298298            used_digits_++;
    299299            carry >>= kBigitSize;
     
    738738   
    739739    void Bignum::SubtractTimes(const Bignum& other, int factor) {
     740#ifndef NDEBUG
     741        Bignum a, b;
     742        a.AssignBignum(*this);
     743        b.AssignBignum(other);
     744        b.MultiplyByUInt32(factor);
     745        a.SubtractBignum(b);
     746#endif
    740747        ASSERT(exponent_ <= other.exponent_);
    741748        if (factor < 3) {
     
    750757            DoubleChunk product = static_cast<DoubleChunk>(factor) * other.bigits_[i];
    751758            DoubleChunk remove = borrow + product;
    752             Chunk difference = bigits_[i + exponent_diff] - ((uint32_t)remove & kBigitMask);
     759            Chunk difference =
     760                bigits_[i + exponent_diff] - static_cast<Chunk>(remove & kBigitMask);
    753761            bigits_[i + exponent_diff] = difference & kBigitMask;
    754762            borrow = static_cast<Chunk>((difference >> (kChunkSize - 1)) +
     
    760768            bigits_[i] = difference & kBigitMask;
    761769            borrow = difference >> (kChunkSize - 1);
    762             ++i;
    763770        }
    764771        Clamp();
     772        ASSERT(Bignum::Equal(a, *this));
    765773    }
    766774   
Note: See TracChangeset for help on using the changeset viewer.