On 1/4/23 09:56, Per Minborg 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.

Hmh, Javadoc for MethodHandels::byteArrayViewVarHandle says the following:

* read write access modes for all T, with the exception of access modes get and set for long and double on 32-bit platforms.

Are you sure that your change will work correctly on a 32-bit platform? From what I read, it could throw an IllegalStateException when a long value is read/written.

-Michael


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

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

Commit messages:
  - Update copyright year to 2023
  - Update copyright year
  - Reimplement java.io.Bits using VarHandle access

Changes: https://git.openjdk.org/jdk/pull/11840/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11840&range=00
   Issue: https://bugs.openjdk.org/browse/JDK-8299576
   Stats: 463 lines in 2 files changed: 424 ins; 24 del; 15 mod
   Patch: https://git.openjdk.org/jdk/pull/11840.diff
   Fetch: git fetch https://git.openjdk.org/jdk pull/11840/head:pull/11840

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

Reply via email to