RFR: 8310843: Reimplement ByteArray and ByteArrayLittleEndian with Unsafe [v6]

Glavo duke at openjdk.org
Mon Jun 26 07:12:06 UTC 2023


On Mon, 26 Jun 2023 07:03:22 GMT, Glavo <duke at openjdk.org> wrote:

>> `ByteArray` and `ByteArrayLittleEndian` are very useful tool classes that can be used in many places to performance tuning.
>> 
>> Currently they are implemented by `VarHandle`, so using them may have some impact on startup time.
>> 
>> This PR reimplements them using `Unsafe`, which reduces the impact on startup time.
>
> Glavo has updated the pull request incrementally with one additional commit since the last revision:
> 
>   delete incorrect comments

I deleted some incorrect comments.

The original author of these two classes misunderstood the behavior of `intBitsToFloat` and `longBitsToDouble`. These two methods never collapse NaN values to a "canonical" NaN value, so the comments is incorrect.

I deleted those comments because conversions from `int`/`long` to `float`/`double` don't need to differentiate that behavior, their difference only exists when converting from `float`/`double` to `int`/`long`.

The conversion methods in the `Float`/`Double` class also exhibits this: there is only one method for converting from `int`/`long` to `float`/`double` , but there are two methods for converting from `float`/`double` to `int`/`long`.

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

PR Comment: https://git.openjdk.org/jdk/pull/14636#issuecomment-1606840551


More information about the core-libs-dev mailing list