Skip to content

Conversation

@rose00
Copy link
Contributor

@rose00 rose00 commented Dec 20, 2025

first cut: passes smoke tests in interpreter and C1 (aarch64)

https://bugs.openjdk.org/browse/JDK-8374169
too many intrinsics

Fold getIntAcquire and every other getFooBar into getPrimitiveBitsMO(mo, bt, base, offset).
Do similar moves for put and the various CAS operations.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Reviewers without OpenJDK IDs

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28940

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28940.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 20, 2025

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

@openjdk
Copy link

openjdk bot commented Dec 20, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Dec 20, 2025

@rose00 The following labels will be automatically applied to this pull request:

  • core-libs
  • hotspot
  • nio

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@rose00
Copy link
Contributor Author

rose00 commented Dec 21, 2025

Status:

No testing beyond looking for smoke when I run javac (in the changed VM).

I have not gone looking for inlining failures. I know they are endemic in C2.

I think the interpreter support (native methods) is stable, as are JDK code adjustments.

The vmIntrinsics.hpp declarations define a bunch of “polymorphic intrinsic wrappers” (F_PW).
I think we should eventually remove them all; there’s no value to this classification.
(But we should find a way to ensure that Unsafe wrappers never fail to inline!)

C2 support is not started yet. It should be relatively simple, as with C1.
When C2 is done, I will try to remove the old intrinsic names, and see what breaks.

The C1 support is nearly stable. Smoke test with javac passes.
The IR for CAS should be further simplified, to make it easier to consider cmpxchg.

I added some C1 canonicalization logic for back-to-back conversions.
For example, when you run javac on a small job, C1 simplifies 71 instances of l2i(i2l(x) ⇒ x.
It may be we can avoid adding those canonicalizations, but they do help the poly-intrinsics.

@rose00
Copy link
Contributor Author

rose00 commented Dec 21, 2025

Overall goal is to thin out the current Dark Forest of intrinsics, which has become overgrown.
Besides improving maintainability, my goal here is to prepare for new intrinsics in the future.
Keeping up with the hardware is too difficult, if you have to add a new intrinsic for every single instruction.
That why folding groups of single-instruction intrinsics to single polymorphic intrinsics
will help us keep up with hardware capabilities.

Copy link

@ExE-Boss ExE-Boss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the final modifier should be kept on the Unsafe methods to ease the burden on reviewing the git diff.


/** Special-access version of {@link #getInt(Object, long)} */
@ForceInline
public int getIntMO(byte memoryOrder, Object o, long offset) {
Copy link

@ExE-Boss ExE-Boss Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better to keep these parametrised memory order implementation methods private without changing the Java API by changing @IntrinsicCandidate to @ForceInline on all the [get/put/compareAnd​[Set/⁠Exchange]]​<Type>​[/Opaque/Acquire/Release/Volatile] methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants