From: commit-queue@webkit.org Date: Mon, 1 Oct 2018 11:26:08 +0000 (+0000) Subject: Unreviewed, rolling out r236647. X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=b828c854d8e8509579573b35be0f54d9df51f40e;hp=6b0b86a4e0f7164dc695dcbd98856ebc9b0ddc67 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 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236652 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/JSTests/ChangeLog b/JSTests/ChangeLog index debd5ac..0d5cbab 100644 --- a/JSTests/ChangeLog +++ b/JSTests/ChangeLog @@ -1,3 +1,18 @@ +2018-10-01 Commit Queue + + 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 [BigInt] BigInt.proptotype.toString is broken when radix is power of 2 diff --git a/JSTests/stress/big-int-to-string.js b/JSTests/stress/big-int-to-string.js index d6851c9..d7878a9 100644 --- a/JSTests/stress/big-int-to-string.js +++ b/JSTests/stress/big-int-to-string.js @@ -13,30 +13,6 @@ 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"); - -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) { diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index c178af4..780997e 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,18 @@ +2018-10-01 Commit Queue + + 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 [WebAssembly] Move type conversion code of JSToWasm return type to JS wasm wrapper diff --git a/Source/JavaScriptCore/runtime/JSBigInt.cpp b/Source/JavaScriptCore/runtime/JSBigInt.cpp index 29e8bb5..d15a33c 100644 --- a/Source/JavaScriptCore/runtime/JSBigInt.cpp +++ b/Source/JavaScriptCore/runtime/JSBigInt.cpp @@ -53,7 +53,6 @@ #include "MathCommon.h" #include "ParseInt.h" #include -#include #define STATIC_ASSERT(cond) static_assert(cond, "JSBigInt assumes " #cond) @@ -213,9 +212,6 @@ String JSBigInt::toString(ExecState* exec, unsigned radix) 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 @@ uint64_t JSBigInt::calculateMaximumCharactersRequired(unsigned length, unsigned 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 resultString(charsRequired); - Digit digit = 0; - // Keeps track of how many unprocessed bits there are in {digit}. - unsigned availableBits = 0; - int pos = static_cast(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 diff --git a/Source/JavaScriptCore/runtime/JSBigInt.h b/Source/JavaScriptCore/runtime/JSBigInt.h index 52ff88c..3f9e232 100644 --- a/Source/JavaScriptCore/runtime/JSBigInt.h +++ b/Source/JavaScriptCore/runtime/JSBigInt.h @@ -175,7 +175,6 @@ private: 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(); diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog index d318fd4..d132a00 100644 --- a/Source/WTF/ChangeLog +++ b/Source/WTF/ChangeLog @@ -1,3 +1,18 @@ +2018-10-01 Commit Queue + + 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 [BigInt] BigInt.proptotype.toString is broken when radix is power of 2 diff --git a/Source/WTF/wtf/MathExtras.h b/Source/WTF/wtf/MathExtras.h index f3e0933..9118112 100644 --- a/Source/WTF/wtf/MathExtras.h +++ b/Source/WTF/wtf/MathExtras.h @@ -575,30 +575,6 @@ inline unsigned clz64(uint64_t number) #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::preciseIndexMaskShiftForSize; using WTF::shuffleVector; using WTF::clz32; using WTF::clz64; -using WTF::ctz32; #endif // #ifndef WTF_MathExtras_h