Primitive boolean array packing

B. Blaser bsrbnd at
Mon Oct 8 11:16:28 UTC 2018

On Mon, 8 Oct 2018 at 10:53, Andrew Haley <aph at> wrote:
> On 10/07/2018 08:54 PM, Aleksey Shipilev wrote:
> > Of course, if you do packed boolean[] with locked/CAS-ed writes or
> > otherwise guarantee the absence of word tearing, it does not break
> > the spec.
> Exactly. it's an interesting idea for large bit vectors, and it could
> well generate good code. However, it probably makes more sense to
> implement it as a bit vector class with suitable helper intrinsics.

The current prototype was intended to scrupulously implement what the
JVMS explicitly allows for baload/bastore instructions.
But helper intrinsics might be good alternatives too, we could try both.

Note that the existing BitSet needs external sync (most probably on
the whole set) when used in multi-threaded environments.
With packed baload/bastore instructions or dedicated intrinsics, the
sync would be on smaller 8-bit blocks or no sync at all on some arch
as Roman mentioned (AArch64).


More information about the compiler-dev mailing list