Skip to content
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

8292638: x86: Improve scratch register handling in VM stubs #9932

Closed
wants to merge 16 commits into from

Conversation

iwanowww
Copy link
Contributor

@iwanowww iwanowww commented Aug 18, 2022

(PR depends on #9923.)

Constants which reside outside code cache are not guaranteed to be reachable in
RIP-relative addressing mode from stub code, but absolute addressing mode requires a
scratch register.

Provide a scratch register to ensure constants are reachable irrespective of
process memory layout.

Make scratch register usage explicit to make possible conflicts with surrounding stub code explicit.

Testing:

  • hs-tier1 - hs-tier4
  • x86_32 hotspot build
    /cc hotspot

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-8292638: x86: Improve scratch register handling in VM stubs

Reviewers

Contributors

  • Aleksey Shipilev <shade@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9932

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 18, 2022

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

@iwanowww iwanowww marked this pull request as ready for review August 18, 2022 21:58
@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Aug 18, 2022
@openjdk
Copy link

openjdk bot commented Aug 18, 2022

@iwanowww
The hotspot label was successfully added.

@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 18, 2022
@mlbridge
Copy link

mlbridge bot commented Aug 18, 2022

@openjdk-notifier
Copy link

@iwanowww Please do not rebase or force-push to an active PR as it invalidates existing review comments. All changes will be squashed into a single commit automatically when integrating. See OpenJDK Developers’ Guide for more information.

@openjdk
Copy link

openjdk bot commented Aug 19, 2022

@iwanowww this pull request can not be integrated into pr/9923 due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout trig_rscratch
git fetch https://git.openjdk.org/jdk pr/9923
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge pr/9923"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Aug 19, 2022
Copy link
Contributor

@vnkozlov vnkozlov 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.

I would suggest to run full tier1-4 mach5 testing (instead of only hs-tier*) which will run java/lang/math tests too. And tier4 runs with -Xcomp.

@openjdk-notifier openjdk-notifier bot changed the base branch from pr/9923 to master August 20, 2022 00:41
@openjdk-notifier
Copy link

The dependent pull request has now been integrated, and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork:

git checkout trig_rscratch
git fetch https://git.openjdk.org/jdk master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Aug 20, 2022
Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Some review comments. Let me run x86_32 tests real quick.

src/hotspot/cpu/x86/assembler_x86.cpp Outdated Show resolved Hide resolved
return is_reachable;
}

bool Assembler::always_reachable(AddressLiteral adr) {
Copy link
Member

Choose a reason for hiding this comment

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

So, there is a similar block in Assembler::is_reachable_from -- does it make sense to reuse it then? They also are subtly different on the use of ForceUnreachable, would this method return different result compared to Assembler::is_reachable_from, and thus fail the assert in Assembler::reachable?

Copy link
Contributor Author

@iwanowww iwanowww Aug 22, 2022

Choose a reason for hiding this comment

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

As it is now, ForceUnreachable works fine.

There's one implicit assumption which makes it work though: temporary code buffer has to reside in code cache which is always the case now. Otherwise, always_reachable would have to take pc into account as well.

I propose to make it a requirement for the code buffer to be placed in the code cache and simplify the reachability checks based on that. (Latest version reflects the proposal.)

src/hotspot/cpu/x86/macroAssembler_x86.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/x86/macroAssembler_x86.hpp Outdated Show resolved Hide resolved
Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

x86_32 tier1 is good. Here is the patch that does the symmetric changes in stubGenerator_x86_64.cpp: https://cr.openjdk.java.net/~shade/8292638/x86-add-1.patch

@openjdk
Copy link

openjdk bot commented Aug 22, 2022

⚠️ @iwanowww This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@iwanowww
Copy link
Contributor Author

x86_32 tier1 is good. Here is the patch that does the symmetric changes in stubGenerator_x86_64.cpp

Thank you. Incorporated.

/contributor add shade

@openjdk
Copy link

openjdk bot commented Aug 22, 2022

@iwanowww
Contributor Aleksey Shipilev <shade@openjdk.org> successfully added.

@iwanowww
Copy link
Contributor Author

I would suggest to run full tier1-4 mach5 testing (instead of only hs-tier*) which will run java/lang/math tests too. And tier4 runs with -Xcomp.

I ran it through tier1 - tier4 and the results look fine.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Good. Thank you for running additional testing.

@openjdk
Copy link

openjdk bot commented Aug 23, 2022

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

8292638: x86: Improve scratch register handling in VM stubs

Co-authored-by: Aleksey Shipilev <shade@openjdk.org>
Reviewed-by: kvn, shade

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

  • d24b7b7: 8276651: java/lang/ProcessHandle tests fail with "RuntimeException: Input/output error" in java.lang.ProcessHandleImpl$Info.info0
  • 8a45abd: 8292654: G1 remembered set memory footprint regression after JDK-8286115
  • cc28783: 8292777: Remove hashtable.hpp from dependencies.hpp
  • cf00677: 8292368: [ppc64] internal error g1BarrierSet.inline.hpp assert(oopDesc::is_oop(pre_val, true)) failed: Error
  • d92e00a: 8292763: JDK-8292716 breaks configure without jtreg
  • 486f90c: 8292716: Configure should check that jtreg is of the required version
  • b4e1aa8: 8289658: Avoid redundant LinkedHashMap.get call in TagletManager.addNewSimpleCustomTag
  • 84936e9: 8292586: simplify cleanups in NTLMAuthSequence getCredentialsHandle
  • 259ba86: 8290075: [JVMCI] only blessed methods can link against EventWriterFactory.getEventWriter
  • a85a723: 8292351: tty should always live
  • ... and 30 more: https://git.openjdk.org/jdk/compare/44532009fff11884aa6f16a997b771c41cb01d2f...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 openjdk bot added the ready Pull request is ready to be integrated label Aug 23, 2022
Copy link
Member

@shipilev shipilev 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, a few nits:

is_reachable_from vs is_always_reachable: these look like siblings, so they probably should both either have _from, or both skip it.

I don't see why would we need to do tmp /* rscratch */ comments everywhere, looks like noise.

@iwanowww
Copy link
Contributor Author

is_reachable_from vs is_always_reachable: these look like siblings, so they probably should both either have _from, or both skip it.

Agree. Once I removed current location argument, _from doesn't make any sense anymore.

I don't see why would we need to do tmp /* rscratch */ comments everywhere, looks like noise.

I prefer to keep it for documentary purposes. IMO it clearly points at rip-relative addressing being at play here and hints that the address is not always reachable (which can be acted upon to eliminate the usage).

@openjdk
Copy link

openjdk bot commented Aug 23, 2022

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

  • d24b7b7: 8276651: java/lang/ProcessHandle tests fail with "RuntimeException: Input/output error" in java.lang.ProcessHandleImpl$Info.info0
  • 8a45abd: 8292654: G1 remembered set memory footprint regression after JDK-8286115
  • cc28783: 8292777: Remove hashtable.hpp from dependencies.hpp
  • cf00677: 8292368: [ppc64] internal error g1BarrierSet.inline.hpp assert(oopDesc::is_oop(pre_val, true)) failed: Error
  • d92e00a: 8292763: JDK-8292716 breaks configure without jtreg
  • 486f90c: 8292716: Configure should check that jtreg is of the required version
  • b4e1aa8: 8289658: Avoid redundant LinkedHashMap.get call in TagletManager.addNewSimpleCustomTag
  • 84936e9: 8292586: simplify cleanups in NTLMAuthSequence getCredentialsHandle
  • 259ba86: 8290075: [JVMCI] only blessed methods can link against EventWriterFactory.getEventWriter
  • a85a723: 8292351: tty should always live
  • ... and 30 more: https://git.openjdk.org/jdk/compare/44532009fff11884aa6f16a997b771c41cb01d2f...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Aug 23, 2022

@iwanowww Pushed as commit f3be673.

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

@iwanowww
Copy link
Contributor Author

Thanks for the reviews, Vladimir and Aleksey.

@iwanowww iwanowww deleted the trig_rscratch branch August 23, 2022 19:34
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
3 participants