RFR: 8299576: Reimplement java.io.Bits using VarHandle access [v6]

Raffaello Giulietti rgiulietti at openjdk.org
Thu Jan 5 13:24:51 UTC 2023


On Thu, 5 Jan 2023 12:18:58 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> Currently, `java.io.Bits` is using explicit logic to read/write various primitive types to/from byte arrays. Switching to the use of `VarHandle` access would provide better performance and less code. 
>> 
>> Also, using a standard API for these conversions means future `VarHandle` improvements will benefit `Bits` too. 
>> 
>> Improvements in `Bits` will propagate to `ObjectInputStream`, `ObjectOutputStream` and `RandomAccessFile`.
>> 
>> Initial benchmarks and performance discussions can be found here: https://github.com/openjdk/panama-foreign/pull/762
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Use canonical NaN values also for read

The point, I think, is not whether the result is normalized (this is not specified in detail in the Javadoc of `Double::longBitsToDouble` and `Float::intBitsToFloat`, so it's open to the implementation) but to use the same basic conversions as the original code, just to avoid any ever so slight difference.

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

PR: https://git.openjdk.org/jdk/pull/11840


More information about the core-libs-dev mailing list