Primitive boolean array packing

Andrew Haley aph at redhat.com
Mon Oct 8 08:53:17 UTC 2018


On 10/07/2018 08:54 PM, Aleksey Shipilev wrote:

> You need to specify what do you mean by "it". Current prototype sure
> does break the provisions of JLS 17.6 "Word Tearing":
>  https://docs.oracle.com/javase/specs/jls/se11/html/jls-17.html#jls-17.6

Oh, sure, of course.

> My comment was about generic thing: we cannot break the Java spec
> even if we have the JVM flag that makes it right again. I thought
> that what B. was suggesting as the escape hatch.

And I thought it was a switch between bit arrays and byte arrays.

> 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.

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


More information about the jdk-dev mailing list