On Thu, 18 Apr 2024 20:11:15 GMT, Claes Redestad <redes...@openjdk.org> wrote:

> Investigating a recent regression in mainline I realized we have an 
> opportunity to improve the bootstrap overheads of ObjectMethods::bootstrap by 
> using `invokeExact` in a way similar to what we already do for LMF and SCF 
> BSMs. This avoids generating type checking adapters and equates to a one-off 
> startup win of around 5ms in any app that ever has the need to spin up a 
> toString, equals or hashCode method on a record.

src/java.base/share/classes/java/lang/invoke/BootstrapMethodInvoker.java line 
150:

> 148:                 } else if (isObjectMethodsBootstrapBSM(bsmType)) {
> 149:                     MethodHandle[] methodHandles = new 
> MethodHandle[argv.length - 2];
> 150:                     System.arraycopy(argv, 2, methodHandles, 0, 
> argv.length - 2);

Are we avoiding `Arrays.copyOfRange(argv, 2, argv.length, MethodHandle.class)` 
because of the JIT? If JIT compiler can recognize `MethodHandle.class` constant 
and inline I recommend using copyOfRange like for string concat above.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18845#discussion_r1571783566

Reply via email to