Primitive boolean array packing

Andrew Haley aph at
Sun Oct 7 17:51:20 UTC 2018

On 10/07/2018 04:13 PM, Aleksey Shipilev wrote:
> On 10/07/2018 02:38 PM, B. Blaser wrote:
>> Thanks Aleksey, you're absolutely right but a programmer can still
>> disable this feature and use regular boolean arrays if necessary.
> I fully expect the JVM feature/flag what optionally breaks the Java
> specification will be flat out rejected.

It doesn't break the Java specification:


    The baload instruction is used to load values from both byte and
    boolean arrays. In Oracle's Java Virtual Machine implementation,
    boolean arrays - that is, arrays of type T_BOOLEAN (§2.2,
    §newarray) - are implemented as arrays of 8-bit values. Other
    implementations may implement packed boolean arrays; the baload
    instruction of such implementations must be used to access those

> My educated guess from the subword atomic operations over
> VarHandles: the local latency of uncontended CAS would still be too
> significant to ignore. Over years, we hoped CAS overhead would
> become negligible, but it still isn't

Probably so. Numbers would be nice.

Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671

More information about the compiler-dev mailing list