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

温绍锦 duke at openjdk.org
Tue Jul 18 01:30:14 UTC 2023


On Mon, 17 Jul 2023 20:53:23 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> 温绍锦 has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Integer/Long toString test against compact strings
>>   
>>   Co-authored-by: liach <liach at users.noreply.github.com>
>
> src/java.base/share/classes/java/lang/Integer.java line 528:
> 
>> 526:             i = q;
>> 527:             charPos -= 2;
>> 528:             UNSAFE.putShortUnaligned(buf, Unsafe.ARRAY_BYTE_BASE_OFFSET + charPos, PACKED_DIGITS[r], false);
> 
> When switching to use Unsafe, `getChars` should do the array bounds check in the loop of the store index.

The value range of the r variable is 0-99, and the length of PACKED_DIGITS is 100, There is no need to check the array boundary here.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14699#discussion_r1266072419


More information about the core-libs-dev mailing list