On Wed, 21 Jun 2023 14:31:20 GMT, Chen Liang <li...@openjdk.org> wrote:

>> Not sure if this can be applied but some months ago, I optimized Bits to use 
>> VarHandles rather than explicitly shifting bits around. This gave us a 
>> significant performance increase:
>> 
>> https://github.com/openjdk/jdk/pull/11840/files
>
> The key to the optimization was MethodHandles.byteArrayViewVarHandle. Don't 
> know if StringUTF16.putChar and StringUTF16.getChar can benefit from such an 
> update.

CDS can initialize arrays efficiently.  The Long class already uses CDS to 
initialize the cache of Long values.
See the LongCache code for an example of initializing from CDS with a fallback 
to direct initialization.
You could move the HEX256 array to the LongCache holder class and avoid any 
performance hit on startup.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14578#discussion_r1237189484

Reply via email to