RFR: 8312235: [JVMCI] ConstantPool should not force eager resolution [v3]

Doug Simon dnsimon at openjdk.org
Wed Jul 26 16:00:20 UTC 2023


> The existing `jdk.vm.ci.meta.ConstantPool.lookupConstant(int cpi)` method forces eager resolving of constants. For `DynamicConstant`, `MethodHandle` and `MethodType`, this can mean invoking bootstrap methods, something that should not be done during JIT compilation. To avoid this, this PR adds the following to `jdk.vm.ci.meta.ConstantPool`:
> 
> 
> /**
>  * Looks up a constant at the specified index.
>  *
>  * If {@code resolve == false} and the denoted constant is of type
>  * {@code JVM_CONSTANT_Dynamic}, {@code JVM_CONSTANT_MethodHandle} or
>  * {@code JVM_CONSTANT_MethodType} and it's not yet resolved then
>  * {@code null} is returned.
>  *
>  * @param cpi the constant pool index
>  * @return the {@code Constant} or {@code JavaType} instance representing the constant pool
>  *         entry
>  */
> Object lookupConstant(int cpi, boolean resolve);
> 
> 
> Likewise, `jdk.vm.ci.meta.ConstantPool.lookupBootstrapMethodInvocation` has been fixed to no longer invoke the associated bootstrap method.
> 
> ---------
> ### Progress
> - [ ] Change must be properly reviewed (1 review required, with at least 1 [Reviewer](https://openjdk.org/bylaws#reviewer))
> - [x] Change must not contain extraneous whitespace
> - [x] Commit message must refer to an issue
> 
> 
> 
> ### Reviewing
> <details><summary>Using <code>git</code></summary>
> 
> Checkout this PR locally: \
> `$ git fetch https://git.openjdk.org/jdk.git pull/14927/head:pull/14927` \
> `$ git checkout pull/14927`
> 
> Update a local copy of the PR: \
> `$ git checkout pull/14927` \
> `$ git pull https://git.openjdk.org/jdk.git pull/14927/head`
> 
> </details>
> <details><summary>Using Skara CLI tools</summary>
> 
> Checkout this PR locally: \
> `$ git pr checkout 14927`
> 
> View PR using the GUI difftool: \
> `$ git pr show -t 14927`
> 
> </details>
> <details><summary>Using diff file</summary>
> 
> Download this PR as a diff file: \
> <a href="https://git.openjdk.org/jdk/pull/14927.diff">https://git.openjdk.org/jdk/pull/14927.diff</a>
> 
> </details>

Doug Simon has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:

 - clarified when null is returned by lookupConstantInPool
 - clarified naming around decoding an encoded indy index to a constant pool index
 - Merge remote-tracking branch 'openjdk-jdk/master' into JDK-8312235
 - avoid bootstrap method invocation by lookupBootstrapMethodInfo
 - update TestDynamicConstant to test new ConstantPool.lookupConstant method
 - add ConstantPool.lookupConstant(int cpi, boolean resolve)

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/14927/files
  - new: https://git.openjdk.org/jdk/pull/14927/files/4621c13a..5ada646c

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

  Stats: 30527 lines in 565 files changed: 16752 ins; 11706 del; 2069 mod
  Patch: https://git.openjdk.org/jdk/pull/14927.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14927/head:pull/14927

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


More information about the hotspot-compiler-dev mailing list