valhalla icon indicating copy to clipboard operation
valhalla copied to clipboard

8348606: [lworld] Substitutability test may perform heap allocations

Open liach opened this issue 9 months ago • 5 comments

Update substitutability test to use MethodHandles that access independent primitive/pointer instead heap reallocated copies of inlined values with an object header. Need long-term solution for user MethodHandle that accesses nested values in the future; hope the intrinsics can help in the future.

Testing: test/jdk/valhalla and test/hotspot/jtreg/*/valhalla, tier 1-3 tests running.


Progress

  • [x] Change must not contain extraneous whitespace

Issue

  • JDK-8348606: [lworld] Substitutability test may perform heap allocations (Bug - P3)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1364/head:pull/1364
$ git checkout pull/1364

Update a local copy of the PR:
$ git checkout pull/1364
$ git pull https://git.openjdk.org/valhalla.git pull/1364/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1364

View PR using the GUI difftool:
$ git pr show -t 1364

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1364.diff

Using Webrev

Link to Webrev Comment

liach avatar Feb 13 '25 00:02 liach

:wave: Welcome back liach! A progress list of the required criteria for merging this PR into lworld will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

bridgekeeper[bot] avatar Feb 13 '25 00:02 bridgekeeper[bot]

@liach This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8348606: [lworld] Substitutability test may perform heap allocations

Co-authored-by: Tobias Hartmann <[email protected]>

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the lworld branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

openjdk[bot] avatar Feb 13 '25 00:02 openjdk[bot]

The reason you are seeing the failures is that you are using Unsafe incorrectly. Note this paragraph:

 * The results are undefined unless one of the following cases is true:
 * <ul>
 * <li>The offset was obtained from {@link #objectFieldOffset} on
 * the {@link java.lang.reflect.Field} of some Java field and the object
 * referred to by {@code o} is of a class compatible with that
 * field's class.
 *
 * <li>The offset and object reference {@code o} (either null or
 * non-null) were both obtained via {@link #staticFieldOffset}
 * and {@link #staticFieldBase} (respectively) from the
 * reflective {@link Field} representation of some Java field.
 *
 * <li>The object referred to by {@code o} is an array, and the offset
 * is an integer of the form {@code B+N*S}, where {@code N} is
 * a valid index into the array, and {@code B} and {@code S} are
 * the values obtained by {@link #arrayBaseOffset} and {@link
 * #arrayIndexScale} (respectively) from the array's class.  The value
 * referred to is the {@code N}<em>th</em> element of the array.
 *
 * </ul>

The wording here is albeit bad, it is not only the result that is undefined, the behaviour itself is undefined.

merykitty avatar Feb 13 '25 14:02 merykitty

Hmm, @fparain recommends this access pattern for me...

liach avatar Feb 13 '25 15:02 liach

Marking this ready - @TobiHartmann recommends me to integrate and C2 to subsequently fix up. This can fix JDK-8354122.

liach avatar Apr 09 '25 10:04 liach

/contributor add @TobiHartmann

liach avatar Apr 09 '25 13:04 liach

@liach Contributor Tobias Hartmann <[email protected]> successfully added.

openjdk[bot] avatar Apr 09 '25 13:04 openjdk[bot]

compiler/valhalla/inlinetypes/TestNullableInlineTypes.java seems to have some problem with aarch64 with -ea -esa -XX:CompileThreshold=100 -XX:+UnlockExperimentalVMOptions -server -XX:-TieredCompilation flags on mac and linux, but I don't know what exactly causes it. No other failure. Guess I am integrating for now.

/integrate

liach avatar Apr 09 '25 18:04 liach

@liach Your change (at version 921a8d59961f46b0e29f5bd08644556d0eff3360) is now ready to be sponsored by a Committer.

openjdk[bot] avatar Apr 09 '25 18:04 openjdk[bot]

Right, the TestNullableInlineTypes.java failure is a known issue.

TobiHartmann avatar Apr 10 '25 05:04 TobiHartmann

/sponsor

TobiHartmann avatar Apr 10 '25 05:04 TobiHartmann

Going to push as commit 15a064c787fe5ef7972ad7d3de8f0c42b7a0a288.

openjdk[bot] avatar Apr 10 '25 05:04 openjdk[bot]

@TobiHartmann @liach Pushed as commit 15a064c787fe5ef7972ad7d3de8f0c42b7a0a288.

:bulb: You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

openjdk[bot] avatar Apr 10 '25 05:04 openjdk[bot]