Skip to content

8343242: RISC-V: Refactor materialization of literal address #21777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

RealFYang
Copy link
Member

@RealFYang RealFYang commented Oct 30, 2024

Hi, please consider this refactoring work.

Currently, we have both la(address) and la(Address). They both accept and materialize literal address.
While la(Address) always emit a movptr sequence, la(address) is a bit complex: it checks whether the target is
reachable from anywhere within the code cache (is_32bit_offset_from_codecache) and emits pc-relative auipc+addi
pair or movptr sequence. This makes it not that obvious at places where we want a more accurate estimation about
the size of code emitted like when we prepare code stubs like C2SafepointPollStub or C2EntryBarrierStub (See: #21732).

I would suggest we keep la(address) simple and let it only emit auipc+addi pair, which will be consistent with the
RISC-V Assembly Programmer's Handbook. I think It's more reasonable to move the distance check to la(Address).
Furthermore, I would also suggest that we make the distance check simpler. The approach taken here is to only check
whether the target is inside the code cache. This way we will be more certain about code emitted with la(Address)
as well. This will help keep the risk of this change low as all la(Address) callsites with literal address outside of code
cache won't be affected. And I don't think the original distance check from code cache will benefit us much more.
Eyeballed all la(Address) callsites, I think we are fine.

Benefits:

  1. We have a simpler la(address) which is kind of spec compatible;
  2. We are consistent in target distance check when doing j(Address), la(Address), ld/st(Address) and rt_call;
  3. We don't need explicit use of relocate with lambda for most of the places;

Note that there are several places where we want explicit movptr sequence:

  1. In SignatureHandlerGenerator::generate() where the emitted code is simply copied without relocation [1];
  2. In movoop and mov_metadata where we want patching afterwards;

[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/interpreter/interpreterRuntime.cpp#L1313

Testing on linux-riscv64:

  • hotspot:tier1 (fastdebug)
  • tier1-tier3, hotspot:tier4 (release)
  • specjbb2015, dacapo, renaissance (release)

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

Issue

  • JDK-8343242: RISC-V: Refactor materialization of literal address (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 21777

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 30, 2024

👋 Welcome back fyang! 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 Oct 30, 2024

@RealFYang 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:

8343242: RISC-V: Refactor materialization of literal address

Reviewed-by: rehn, fjiang

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 15 new commits pushed to the master branch:

  • 00ec105: 8343412: Missing escapes for single quote marks in javac.properties
  • 8c1cf8f: 8339128: Cannot resolve user specified tool properly after JDK-8338304
  • 3c7082a: 8343419: Assertion failure in long vector unsigned min/max with -XX:+UseKNLSetting
  • c82ad84: 8342183: Update tests to use stronger algorithms and keys
  • 1eccdfc: 8343439: [JVMCI] Fix javadoc of Services.getSavedProperties
  • ea110c3: 8343236: Use @APinote and @implSpec in j.util.Currency
  • 5995786: 8343177: JFR: Remove critical section for thread id assignment
  • 751a914: 8340733: Add scope for relaxing constraint on JavaCalls from CompilerThread
  • 7e87c07: 8340116: test/jdk/sun/security/tools/jarsigner/PreserveRawManifestEntryAndDigest.java can fail due to regex
  • da0e9e3: 8343333: Parallel: Cleanup comment referring Solaris in MutableNUMASpace
  • ... and 5 more: https://git.openjdk.org/jdk/compare/cbda758010c22b0c1b9aec16004d4bfd24ab5c81...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Oct 30, 2024

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

  • graal
  • hotspot

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.

@openjdk openjdk bot added graal graal-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Oct 30, 2024
@RealFYang
Copy link
Member Author

/label remove graal

@openjdk openjdk bot removed the graal graal-dev@openjdk.org label Oct 30, 2024
@openjdk
Copy link

openjdk bot commented Oct 30, 2024

@RealFYang
The graal label was successfully removed.

@RealFYang RealFYang marked this pull request as ready for review October 30, 2024 01:33
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 30, 2024
@mlbridge
Copy link

mlbridge bot commented Oct 30, 2024

Webrevs

@robehn
Copy link
Contributor

robehn commented Oct 31, 2024

Hi, I agree with the sentiment of the CR.

Thinking about the is_32bit_offset_from_codecache vs CodeCache::contains change.

@RealFYang
Copy link
Member Author

RealFYang commented Oct 31, 2024

Hi, I agree with the sentiment of the CR.

Thinking about the is_32bit_offset_from_codecache vs CodeCache::contains change.

Thanks! Note that I didn't remove this is_32bit_offset_from_codecache routine as I am guessing that we might find a better way of using this check after this change.

@robehn
Copy link
Contributor

robehn commented Oct 31, 2024

Did you run any micro benchmarks? Maybe skynet just to check VTs.
And did you do any measurement on code cache size?

I can't find anything that would matter, but I'll look a bit more.

@RealFYang
Copy link
Member Author

Did you run any micro benchmarks? Maybe skynet just to check VTs. And did you do any measurement on code cache size?

No obvious change witnessed on Skynet JMH with this change. Let me know if there are others we might want a try.

And did you do any measurement on code cache size?

Good suggestion. I just tried dacapo and renaissance with -XX:+PrintCodeCache -XX:-TieredCompilation and compared the max_used of code cache. I didn't see a big difference with this change either.

I can't find anything that would matter, but I'll look a bit more.

Thanks. I merged master. Take your time!

Copy link
Contributor

@robehn robehn left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 1, 2024
Copy link
Member

@feilongjiang feilongjiang left a comment

Choose a reason for hiding this comment

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

It looks much cleaner now. Thank you!

@RealFYang
Copy link
Member Author

@robehn @feilongjiang : Thanks for the review! I also tried NetBeans and Eclipse. Both IDEs work fine with this change. Let's move on.
/integrate

@openjdk
Copy link

openjdk bot commented Nov 4, 2024

Going to push as commit 37a3398.
Since your change was applied there have been 18 commits pushed to the master branch:

  • d26412e: 8343433: Update net.properties and java.net.http module-info.java after 8326949
  • 29882bf: 8340311: JPackage app-image exe launches multiple exe's in JDK 22+
  • 069bb79: 8342082: Remove unused BasicProgressBarUI.Animator.interval
  • 00ec105: 8343412: Missing escapes for single quote marks in javac.properties
  • 8c1cf8f: 8339128: Cannot resolve user specified tool properly after JDK-8338304
  • 3c7082a: 8343419: Assertion failure in long vector unsigned min/max with -XX:+UseKNLSetting
  • c82ad84: 8342183: Update tests to use stronger algorithms and keys
  • 1eccdfc: 8343439: [JVMCI] Fix javadoc of Services.getSavedProperties
  • ea110c3: 8343236: Use @APinote and @implSpec in j.util.Currency
  • 5995786: 8343177: JFR: Remove critical section for thread id assignment
  • ... and 8 more: https://git.openjdk.org/jdk/compare/cbda758010c22b0c1b9aec16004d4bfd24ab5c81...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 4, 2024
@openjdk openjdk bot closed this Nov 4, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 4, 2024
@openjdk
Copy link

openjdk bot commented Nov 4, 2024

@RealFYang Pushed as commit 37a3398.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants