Aligned long views over byte arrays and heap ByteBuffers
paul.sandoz at oracle.com
Mon Jan 18 13:44:51 UTC 2016
> On 18 Jan 2016, at 12:38, Paul Sandoz <Paul.Sandoz at oracle.com> wrote:
> Hi Vitaly,
> I had a quick chat with John and we think may be able to avoid the aligned vs. unaligned distinction in the API and any split in terms of platform implementations.
> We can add some new alignment methods to ByteBuffer:
> 1) query if an index is aligned
> 2) slice to aligned
> Then we can provide a singular view over a ByteBuffer for source-based indexes, where for enhanced atomic operations an ISE is thrown if the index is not aligned. Thus a user can set up the alignment with 1)/2) to avoid ISEs.
> If a user wants enhanced atomic operations on byte they could first wrap that in a ByteBuffer, although we could provide some static methods on ByteBuffer to avoid such wrapping.
Since GC can move the byte i presume we cannot guarantee alignment stability e.g. on a 32-bit system a query at one point might report true for alignment of index 0 with a long-based unit value, and later on might report false if the underlying byte has been moved between the two queries.
Thus such proposed methods would reliably work only for DBBs and as such they would be rather awkward on BB.
More information about the valhalla-dev