On Sat, 8 Jun 2024 00:19:55 GMT, Shaojin Wen <d...@openjdk.org> wrote:

> After PR #16245, C2 optimizes stores into primitive arrays by combining 
> values ​​into larger stores. In the UUID.toString method, 
> ByteArrayLittleEndian can be removed, making the code more elegant and faster.

I think you mean bug ID 8333833, right?

src/java.base/share/classes/jdk/internal/util/HexDigits.java line 123:

> 121:      */
> 122:     public static void putHex(byte[] buffer, int off, int i) {
> 123:         int v = (DIGITS[i & 0xff] << 16) | DIGITS[(i >> 8) & 0xff];

Looking at the comments in #16245, it's said that the int must be computed 
beforehand so it will be a write of a 4-byte instead of 2 write of 2-bytes. Is 
that understanding correct?

If my understanding is correct, I recommend to leave a comment explaining why 
we compact the value into an int, like

// Prepare an int value so C2 generates a 4-byte write instead of two 2-byte 
writes

-------------

PR Review: https://git.openjdk.org/jdk/pull/19610#pullrequestreview-2105776831
PR Review Comment: https://git.openjdk.org/jdk/pull/19610#discussion_r1631885732

Reply via email to