RFR: 8357689: Refactor JVMCI to enable replay compilation in Graal

Doug Simon dnsimon at openjdk.org
Mon Jul 7 13:07:56 UTC 2025


On Sat, 24 May 2025 16:49:23 GMT, Andrej Pečimúth <duke at openjdk.org> wrote:

> This PR introduces a few minor JVMCI refactorings to make replay compilation possible in the Graal compiler.

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BytecodeFrame.java line 397:

> 395:      * @return a copy of the slot kinds array
> 396:      */
> 397:     public JavaKind[] getSlotKinds() {

Keep in mind that `slotKinds` is being [converted](https://github.com/openjdk/jdk/pull/25442/files#diff-43834727ed7dcd5128c10238ba56963c7d8feb66578b036c75dcf734bfa2ec92R80) to a List. In that context, can we return the list without making a copy? Or is the caller expected to be able to mutate the return value?

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/VirtualObject.java line 293:

> 291:             return true;
> 292:         }
> 293:         if (o instanceof VirtualObject) {

Rename `l` to `that` and use pattern instanceof:
Suggestion:

        if (o instanceof VirtualObject that) {

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/VirtualObject.java line 325:

> 323:      *         values have not been initialized.
> 324:      */
> 325:     public JavaKind[] getSlotKinds() {

Same comments as for BytecodeFrame.getSlotKinds. This applies to all other non-primitive array return values added by this PR.

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCode.java line 225:

> 223:      * Returns a copy of the array of {@link ResolvedJavaMethod} objects representing the methods
> 224:      * whose bytecodes were used as input to the compilation. If the compilation did not record
> 225:      * method dependencies, this method returns {@code null}. Otherwise, the first element of the

null -> empty list?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25433#discussion_r2109017920
PR Review Comment: https://git.openjdk.org/jdk/pull/25433#discussion_r2109025913
PR Review Comment: https://git.openjdk.org/jdk/pull/25433#discussion_r2109034172
PR Review Comment: https://git.openjdk.org/jdk/pull/25433#discussion_r2109040017


More information about the graal-dev mailing list