Primitive boolean array packing

Roman Kennke rkennke at redhat.com
Sun Oct 7 18:29:33 UTC 2018


IIRC, some CPUs even have instructions for directly getting/setting
bits, without explicit mask/shift. AArch64 can do that I think. Not sure
if it's more efficient though.

Roman

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20181007/02420c44/signature-0001.asc>


More information about the compiler-dev mailing list