Title: [236652] trunk
Revision
236652
Author
[email protected]
Date
2018-10-01 04:26:08 -0700 (Mon, 01 Oct 2018)

Log Message

Unreviewed, rolling out r236647.
https://bugs.webkit.org/show_bug.cgi?id=190124

Breaking test stress/big-int-to-string.js (Requested by
caiolima_ on #webkit).

Reverted changeset:

"[BigInt] BigInt.proptotype.toString is broken when radix is
power of 2"
https://bugs.webkit.org/show_bug.cgi?id=190033
https://trac.webkit.org/changeset/236647

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (236651 => 236652)


--- trunk/JSTests/ChangeLog	2018-10-01 09:25:41 UTC (rev 236651)
+++ trunk/JSTests/ChangeLog	2018-10-01 11:26:08 UTC (rev 236652)
@@ -1,3 +1,18 @@
+2018-10-01  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r236647.
+        https://bugs.webkit.org/show_bug.cgi?id=190124
+
+        Breaking test stress/big-int-to-string.js (Requested by
+        caiolima_ on #webkit).
+
+        Reverted changeset:
+
+        "[BigInt] BigInt.proptotype.toString is broken when radix is
+        power of 2"
+        https://bugs.webkit.org/show_bug.cgi?id=190033
+        https://trac.webkit.org/changeset/236647
+
 2018-09-30  Caio Lima  <[email protected]>
 
         [BigInt] BigInt.proptotype.toString is broken when radix is power of 2

Modified: trunk/JSTests/stress/big-int-to-string.js (236651 => 236652)


--- trunk/JSTests/stress/big-int-to-string.js	2018-10-01 09:25:41 UTC (rev 236651)
+++ trunk/JSTests/stress/big-int-to-string.js	2018-10-01 11:26:08 UTC (rev 236652)
@@ -13,30 +13,6 @@
 assert(v.toString(16) === "a");
 assert(v.toString(32) === "a");
 
-v = 191561942608236107294793378393788647952342390272950271n;
-assert(v.toString() === "191561942608236107294793378393788647952342390272950271");
-assert(v.toString(2) === "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111");
-assert(v.toString(3) === "2002122121011101220102010210020102000210011100122221002112102021022221102202020101221000021200201121121100121121");
-assert(v.toString(8) === "77777777777777777777777777777777777777777777777777777777777");
-assert(v.toString(16) === "1ffffffffffffffffffffffffffffffffffffffffffff");
-assert(v.toString(32) === "3vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
-
-v = -10n;
-assert(v.toString() === "-10");
-assert(v.toString(2) === "-1010");
-assert(v.toString(3) === "-101");
-assert(v.toString(8) === "-12");
-assert(v.toString(16) === "-a");
-assert(v.toString(32) === "-a");
-
-v = -191561942608236107294793378393788647952342390272950271n;
-assert(v.toString() === "-191561942608236107294793378393788647952342390272950271");
-assert(v.toString(2) === "-111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111");
-assert(v.toString(3) === "-2002122121011101220102010210020102000210011100122221002112102021022221102202020101221000021200201121121100121121");
-assert(v.toString(8) === "-77777777777777777777777777777777777777777777777777777777777");
-assert(v.toString(16) === "-1ffffffffffffffffffffffffffffffffffffffffffff");
-assert(v.toString(32) === "-3vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
-
 // Invaid radix
 
 function testInvalidRadix(radix) {

Modified: trunk/Source/_javascript_Core/ChangeLog (236651 => 236652)


--- trunk/Source/_javascript_Core/ChangeLog	2018-10-01 09:25:41 UTC (rev 236651)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-10-01 11:26:08 UTC (rev 236652)
@@ -1,3 +1,18 @@
+2018-10-01  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r236647.
+        https://bugs.webkit.org/show_bug.cgi?id=190124
+
+        Breaking test stress/big-int-to-string.js (Requested by
+        caiolima_ on #webkit).
+
+        Reverted changeset:
+
+        "[BigInt] BigInt.proptotype.toString is broken when radix is
+        power of 2"
+        https://bugs.webkit.org/show_bug.cgi?id=190033
+        https://trac.webkit.org/changeset/236647
+
 2018-10-01  Yusuke Suzuki  <[email protected]>
 
         [WebAssembly] Move type conversion code of JSToWasm return type to JS wasm wrapper

Modified: trunk/Source/_javascript_Core/runtime/JSBigInt.cpp (236651 => 236652)


--- trunk/Source/_javascript_Core/runtime/JSBigInt.cpp	2018-10-01 09:25:41 UTC (rev 236651)
+++ trunk/Source/_javascript_Core/runtime/JSBigInt.cpp	2018-10-01 11:26:08 UTC (rev 236652)
@@ -53,7 +53,6 @@
 #include "MathCommon.h"
 #include "ParseInt.h"
 #include <algorithm>
-#include <wtf/MathExtras.h>
 
 #define STATIC_ASSERT(cond) static_assert(cond, "JSBigInt assumes " #cond)
 
@@ -213,9 +212,6 @@
     if (this->isZero())
         return exec->vm().smallStrings.singleCharacterStringRep('0');
 
-    if (hasOneBitSet(radix))
-        return toStringBasePowerOfTwo(exec, this, radix);
-
     return toStringGeneric(exec, this, radix);
 }
 
@@ -1184,71 +1180,6 @@
     return maximumCharactersRequired;
 }
 
-String JSBigInt::toStringBasePowerOfTwo(ExecState* exec, JSBigInt* x, unsigned radix)
-{
-    ASSERT(hasOneBitSet(radix));
-    ASSERT(radix >= 2 && radix <= 32);
-    ASSERT(!x->isZero());
-    VM& vm = exec->vm();
-
-    const unsigned length = x->length();
-    const bool sign = x->sign();
-    const unsigned bitsPerChar = ctz32(radix);
-    const unsigned charMask = radix - 1;
-    // Compute the length of the resulting string: divide the bit length of the
-    // BigInt by the number of bits representable per character (rounding up).
-    const Digit msd = x->digit(length - 1);
-
-#if USE(JSVALUE64)
-    const unsigned msdLeadingZeros = clz64(msd);
-#else
-    const unsigned msdLeadingZeros = clz32(msd);
-#endif
-    
-    const size_t bitLength = length * digitBits - msdLeadingZeros;
-    const size_t charsRequired = (bitLength + bitsPerChar - 1) / bitsPerChar + sign;
-
-    if (charsRequired > JSString::MaxLength) {
-        auto scope = DECLARE_THROW_SCOPE(vm);
-        throwOutOfMemoryError(exec, scope);
-        return String();
-    }
-
-    Vector<LChar> resultString(charsRequired);
-    Digit digit = 0;
-    // Keeps track of how many unprocessed bits there are in {digit}.
-    unsigned availableBits = 0;
-    int pos = static_cast<int>(charsRequired - 1);
-    for (unsigned i = 0; i < length - 1; i++) {
-        Digit newDigit = x->digit(i);
-        // Take any leftover bits from the last iteration into account.
-        int current = (digit | (newDigit << availableBits)) & charMask;
-        resultString[pos--] = radixDigits[current];
-        int consumedBits = bitsPerChar - availableBits;
-        digit = newDigit >> consumedBits;
-        availableBits = digitBits - consumedBits;
-        while (availableBits >= bitsPerChar) {
-            resultString[pos--] = radixDigits[digit & charMask];
-            digit >>= bitsPerChar;
-            availableBits -= bitsPerChar;
-        }
-    }
-    // Take any leftover bits from the last iteration into account.
-    int current = (digit | (msd << availableBits)) & charMask;
-    resultString[pos--] = radixDigits[current];
-    digit = msd >> (bitsPerChar - availableBits);
-    while (digit) {
-        resultString[pos--] = radixDigits[digit & charMask];
-        digit >>= bitsPerChar;
-    }
-
-    if (sign)
-        resultString[pos--] = '-';
-
-    ASSERT(pos == -1);
-    return StringImpl::adopt(WTFMove(resultString));
-}
-
 String JSBigInt::toStringGeneric(ExecState* exec, JSBigInt* x, unsigned radix)
 {
     // FIXME: [JSC] Revisit usage of Vector into JSBigInt::toString

Modified: trunk/Source/_javascript_Core/runtime/JSBigInt.h (236651 => 236652)


--- trunk/Source/_javascript_Core/runtime/JSBigInt.h	2018-10-01 09:25:41 UTC (rev 236651)
+++ trunk/Source/_javascript_Core/runtime/JSBigInt.h	2018-10-01 11:26:08 UTC (rev 236652)
@@ -175,7 +175,6 @@
     static Digit digitDiv(Digit high, Digit low, Digit divisor, Digit& remainder);
     static Digit digitPow(Digit base, Digit exponent);
 
-    static String toStringBasePowerOfTwo(ExecState*, JSBigInt*, unsigned radix);
     static String toStringGeneric(ExecState*, JSBigInt*, unsigned radix);
 
     bool isZero();

Modified: trunk/Source/WTF/ChangeLog (236651 => 236652)


--- trunk/Source/WTF/ChangeLog	2018-10-01 09:25:41 UTC (rev 236651)
+++ trunk/Source/WTF/ChangeLog	2018-10-01 11:26:08 UTC (rev 236652)
@@ -1,3 +1,18 @@
+2018-10-01  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r236647.
+        https://bugs.webkit.org/show_bug.cgi?id=190124
+
+        Breaking test stress/big-int-to-string.js (Requested by
+        caiolima_ on #webkit).
+
+        Reverted changeset:
+
+        "[BigInt] BigInt.proptotype.toString is broken when radix is
+        power of 2"
+        https://bugs.webkit.org/show_bug.cgi?id=190033
+        https://trac.webkit.org/changeset/236647
+
 2018-09-30  Caio Lima  <[email protected]>
 
         [BigInt] BigInt.proptotype.toString is broken when radix is power of 2

Modified: trunk/Source/WTF/wtf/MathExtras.h (236651 => 236652)


--- trunk/Source/WTF/wtf/MathExtras.h	2018-10-01 09:25:41 UTC (rev 236651)
+++ trunk/Source/WTF/wtf/MathExtras.h	2018-10-01 11:26:08 UTC (rev 236652)
@@ -575,30 +575,6 @@
 #endif
 }
 
-inline unsigned ctz32(uint32_t number)
-{
-#if COMPILER(GCC_COMPATIBLE)
-    if (!number)
-        return __builtin_ctz(number);
-    return 32;
-#elif COMPILER(MSVC) && !CPU(X86)
-    unsigned long ret = 0;
-    if (_BitScanForward(&ret, number))
-        return ret;
-    return 32;
-#else
-    unsigned zeroCount = 0;
-    for (unsigned i = 0; i < 32; i++) {
-        if (number & 1)
-            break;
-
-        zeroCount++;
-        number >>= 1;
-    }
-    return zeroCount;
-#endif
-}
-
 } // namespace WTF
 
 using WTF::opaque;
@@ -608,6 +584,5 @@
 using WTF::shuffleVector;
 using WTF::clz32;
 using WTF::clz64;
-using WTF::ctz32;
 
 #endif // #ifndef WTF_MathExtras_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to