RFR: 8310929: Optimization for Integer.toString [v20]

温绍锦 duke at openjdk.org
Wed Sep 6 15:21:47 UTC 2023


On Wed, 6 Sep 2023 10:20:17 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> 温绍锦 has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   update copyright date info
>
> We can consolidate the implementation of `Integer::toString` and `Integer::toUnsignedString` by taking the absolute value of the signed integer and move the later operation to unsigned domain. This helps remove the need of relying on much more expensive `BigInteger` when invoking `Long::toUnsignedString` and may improve the performance of `Integer::toUnsignedString` a little bit. Computing in unsigned domain is also faster (`x s/ 100 = (x * 1374389535) >> 37 - (x >> 31)` while `x u/ 100 = (x * 1374389535) >>> 37`). Folding of unsigned division is still in review but we can use `(int)(((long)x * 1374389535) >>> 37)` for `int` and `mulhi(x >>> 2, 2951479051793528259) >>> 2` for `long` directly.
> 
> Thanks.

@merykitty This PR has been more than 2 months, 19 commits, 55 conversations, the optimization of this PR is mainly to merge two caches into one cache and use unsafe.setShort to write two numbers at a time. Can we finish merging this PR first, and then open a new PR to implement your suggestion?

-------------

PR Comment: https://git.openjdk.org/jdk/pull/14699#issuecomment-1708586068


More information about the core-libs-dev mailing list