Aligned long views over byte arrays and heap ByteBuffers

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon Jan 18 14:17:01 UTC 2016


On 18.01.2016 16:44, Paul Sandoz wrote:
> Critiquing myself…
> 
> 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.

Hotspot uses 8-byte alignments for Java objects universally, so the
absolute 8-byte alignment of byte[] base (and consequently, any i-th
element) stays the same: it it failed/passed the alignment check once,
it will fail/pass always.

That being said, there probably are VMs that implement multiple
alignments, like I proposed here:
https://bugs.openjdk.java.net/browse/JDK-8025677 -- where this invariant
indeed is not stable.

Thanks,
-Aleksey




More information about the valhalla-dev mailing list