Re: RFR: 8330595: Invoke ObjectMethods::bootstrap method exactly [v3]

2024-04-22 Thread Claes Redestad
On Fri, 19 Apr 2024 07:42:19 GMT, Claes Redestad  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.
>
> Claes Redestad has updated the pull request incrementally with two additional 
> commits since the last revision:
> 
>  - Copyright
>  - Formatting

Thanks for the reviews, Mandy!

-

PR Comment: https://git.openjdk.org/jdk/pull/18845#issuecomment-2068853277


Re: RFR: 8330595: Invoke ObjectMethods::bootstrap method exactly [v3]

2024-04-19 Thread Mandy Chung
On Fri, 19 Apr 2024 07:42:19 GMT, Claes Redestad  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.
>
> Claes Redestad has updated the pull request incrementally with two additional 
> commits since the last revision:
> 
>  - Copyright
>  - Formatting

LGTM

-

Marked as reviewed by mchung (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/18845#pullrequestreview-2011967709


Re: RFR: 8330595: Invoke ObjectMethods::bootstrap method exactly [v3]

2024-04-19 Thread Claes Redestad
> 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.

Claes Redestad has updated the pull request incrementally with two additional 
commits since the last revision:

 - Copyright
 - Formatting

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/18845/files
  - new: https://git.openjdk.org/jdk/pull/18845/files/86ccbbba..b67ee397

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=18845&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=18845&range=01-02

  Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/18845.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/18845/head:pull/18845

PR: https://git.openjdk.org/jdk/pull/18845


Re: RFR: 8330595: Invoke ObjectMethods::bootstrap method exactly [v2]

2024-04-19 Thread Claes Redestad
On Fri, 19 Apr 2024 04:45:56 GMT, Chen Liang  wrote:

>> Claes Redestad has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Use Arrays.copyOfRange
>
> 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.

No, I actually reached for the appropriate `copyOfRange` method, but my IDE hid 
it from view in favor of `copyOfRange(T[], int, int)` and all the others.

-

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


Re: RFR: 8330595: Invoke ObjectMethods::bootstrap method exactly [v2]

2024-04-19 Thread Claes Redestad
> 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.

Claes Redestad has updated the pull request incrementally with one additional 
commit since the last revision:

  Use Arrays.copyOfRange

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/18845/files
  - new: https://git.openjdk.org/jdk/pull/18845/files/31752237..86ccbbba

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=18845&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=18845&range=00-01

  Stats: 2 lines in 1 file changed: 0 ins; 1 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/18845.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/18845/head:pull/18845

PR: https://git.openjdk.org/jdk/pull/18845


Re: RFR: 8330595: Invoke ObjectMethods::bootstrap method exactly

2024-04-18 Thread Chen Liang
On Thu, 18 Apr 2024 20:11:15 GMT, Claes Redestad  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


RFR: 8330595: Invoke ObjectMethods::bootstrap method exactly

2024-04-18 Thread Claes Redestad
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.

-

Commit messages:
 - 8330595: Invoke ObjectMethods::bootstrap method exactly

Changes: https://git.openjdk.org/jdk/pull/18845/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=18845&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8330595
  Stats: 17 lines in 1 file changed: 16 ins; 1 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/18845.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/18845/head:pull/18845

PR: https://git.openjdk.org/jdk/pull/18845