Primitive boolean array packing
bsrbnd at gmail.com
Mon Oct 8 08:30:19 UTC 2018
On Sun, 7 Oct 2018 at 21:54, Aleksey Shipilev <shade at redhat.com> wrote:
> On 10/07/2018 07:51 PM, Andrew Haley wrote:
> > 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:
> > Notes
> > 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
> > arrays.
> You need to specify what do you mean by "it". Current prototype sure does break the provisions of
> JLS 17.6 "Word Tearing":
> 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. 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.
You're undoubtedly right, I was focusing on the JVMS and I missed that
point in the JLS...
I'll try to put the prototype in sync with *all* the specs.
More information about the jdk-dev