RFR 8149469: ByteBuffer API and implementation enhancements for VarHandles

Paul Sandoz paul.sandoz at oracle.com
Tue Feb 9 15:05:28 UTC 2016


This patch contains API and internal enhancements to ByteBuffer:


I am CC’ing hotspot-compiler because i want to push to hs-comp to reduce time delays for reviewing/pushing dependent VarHandle patches (which also depends on the Unsafe enhancements currently under review that are also to be pushed to hs-comp).

The API enhancements provide support for querying misalignment of an index and unit size, and also slicing a buffer to align for a unit size. Such functionality enables one to set up for aligned access for unit sizes bytes, if supported by the platform.

The internal enhancements enable consistent use of fields readOnly and address. For the moment i have only enabled consistent use of address for ByteBuffers.

A primary motivation for these enhancements is too support VarHandles access to ByteBuffer contents. The API enhancement enables access to values at known aligned indexes and therefore provides stronger atomicity guarantees and enhanced atomic accesses that follow from that. The internal enhancement allows VarHandle implementations to uniformly access buffers using the Unsafe double addressing mode [*].

I believe these enhancements are also valuable independently of the VarHandles work. Furthermore, the internal enhancements are a stepping stone to potentially consolidating many aspects of heap and direct buffers.


For heap buffers
  Buffer.address == Unsafe.ARRAY_BYTE_BASE_OFFSET + offset;
  ByteBuffer.hb != null,

For direct buffers
  Buffer.address == <base address of region>;
  ByteBuffer.hb == null,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20160209/7d64cacf/signature-0001.asc>

More information about the hotspot-compiler-dev mailing list