| JDK 23 | 
|---|
| 23 b20Fixed | 
| Blocks :   | |
| Causes :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | |
| Relates :   | 
[~redestad] and [~rriggs] have recently been asking if patterns like below can be improved in C2.
- Storing a sequence of byte constants:
        a[0] = 't';
        a[1] = 'r';
        a[2] = 'u';
        a[3] = 'e';
- Storing a int-value:
        a[1] = (byte)v;
        a[2] = (byte)(v >> 8 );
        a[3] = (byte)(v >> 16);
        a[4] = (byte)(v >> 24);
An alternative is to use Unsafe or "BALE":
UNSAFE.putIntUnaligned
ByteArrayLittleEndian.setInt
However, [~redestad] has pointed out that using ByteArrayLittleEndian can slow down initialization of the JVM, because of varHandle overheads. And we would like to avoid using Unsafe - or rather move away from it when possible.
| 
 |