[BigInt] BigInt.proptotype.toString is broken when radix is power of 2
authorticaiolima@gmail.com <ticaiolima@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 30 Sep 2018 18:18:55 +0000 (18:18 +0000)
committerticaiolima@gmail.com <ticaiolima@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 30 Sep 2018 18:18:55 +0000 (18:18 +0000)
commit7c05edf998e7918dbdd0652f2da8d19a4bdbd515
treed0d5e48048a8f9fc7b764f9854eca98e239b6b6d
parent0716618143d31236f2fb795d82db4684d28fb2a0
[BigInt] BigInt.proptotype.toString is broken when radix is power of 2
https://bugs.webkit.org/show_bug.cgi?id=190033

Reviewed by Yusuke Suzuki.

JSTests:

* stress/big-int-to-string.js:

Source/JavaScriptCore:

The implementation of JSBigInt::toStringToGeneric doesn't handle power
of 2 radix when JSBigInt length is >= 2. To handle such cases, we
implemented JSBigInt::toStringBasePowerOfTwo that follows the
algorithm that groups bits using mask of (2 ^ n) - 1 to extract every
digit.

* runtime/JSBigInt.cpp:
(JSC::JSBigInt::toString):
(JSC::JSBigInt::toStringBasePowerOfTwo):
* runtime/JSBigInt.h:

Source/WTF:

* wtf/MathExtras.h:
(WTF::ctz32):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236647 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JSTests/ChangeLog
JSTests/stress/big-int-to-string.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSBigInt.cpp
Source/JavaScriptCore/runtime/JSBigInt.h
Source/WTF/ChangeLog
Source/WTF/wtf/MathExtras.h