Skip to content

8307572: AArch64: Vector registers are clobbered by some macroassemblers #13895

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 1 commit into from

Conversation

nsjian
Copy link

@nsjian nsjian commented May 10, 2023

I found that MacroAssembler::arrays_equals() would call stubcode, which may use vector registers. However, the call site in match rule does not claim the use of vector registers. Since c2 will allocate v16-v31 first [1], it's rare that using of v0-v7 will cause problem, but I did create a test case to expose the bug.

Apart from arrays_equals, I also checked other macroassemblers, and found several similar issues. Fixed by claiming those vector register being killed in match rules call sites, which should have minimal performance impact compared to always saving/restoring those vector registers, since those V0-Vx registers are rarely allocated and live cross the macroassembler call.

A jtreg test case is also added to demonstrate the failure. Test will fail without this patch, and pass with this patch.

Test: I tried to update the allocation order in [1] to allocate V0-V15 first and then V16-V31, and full jtreg tests passed with the allocation order changed. (I did found some test failures with this allocation order change without this patch). I have also eyeballed and checked other macroassembler calls, and others seemed fine.

[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/aarch64.ad#L424


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-8307572: AArch64: Vector registers are clobbered by some macroassemblers

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13895

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

Using diff file

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

Webrev

Link to Webrev Comment

I found that MacroAssembler::arrays_equals() would call stubcode, which
may use vector registers. However, the call site in match rule does not
claim the use of vector registers. Since c2 will allocate v16-v31
first [1], it's rare that using of v0-v7 will cause problem, but I did
create a test case to expose the bug.

Apart from arrays_equals, I also checked other macroassemblers, and
found several similar issues. Fixed by claiming those vector register
being killed in match rules call sites, which should have minimal
performance impact compared to always saving/restoring those vector
registers, since those V0-Vx registers are rarely allocated and live
cross the macroassembler call.

A jtreg test case is also added to demonstrate the failure. Test will
fail without this patch, and pass with this patch.

Test: I tried to update the allocation order in [1] to allocate V0-V15
first and then V16-V31, and full jtreg tests passed with the allocation
order changed. I have also eyeballed and checked other macroassembler
calls, and other macroassembler calls seemed fine.

[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/aarch64.ad#L424

Change-Id: I0feb0c3f3761732a642b3080eb383e0d6ce77825
@bridgekeeper
Copy link

bridgekeeper bot commented May 10, 2023

👋 Welcome back njian! 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 openjdk bot added the rfr Pull request is ready for review label May 10, 2023
@openjdk
Copy link

openjdk bot commented May 10, 2023

@nsjian The following label will be automatically applied to this pull request:

  • hotspot

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

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label May 10, 2023
@mlbridge
Copy link

mlbridge bot commented May 10, 2023

Webrevs

Copy link
Contributor

@theRealAph theRealAph left a comment

Choose a reason for hiding this comment

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

Great catch, thanks. Does this one need backports?

@openjdk
Copy link

openjdk bot commented May 11, 2023

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

8307572: AArch64: Vector registers are clobbered by some macroassemblers

Reviewed-by: aph, adinn

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

  • 0cbfbc4: 8307813: [JVMCI] Export markWord::lock_mask_in_place to JVMCI compilers.
  • ba9714d: 8307610: Linker::nativeLinker should not be restricted (mainline)
  • ecc1d85: 8307869: Remove unnecessary log statements from arm32 fastlocking code
  • 08fa269: 8307349: Support xlc17 clang toolchain on AIX
  • 8ac7186: 8305416: runtime/Thread/TestAlwaysPreTouchStacks.java failed with "Did not find expected NMT output"
  • 984fbbb: 8307810: Consistently use LockingMode instead of UseHeavyMonitors
  • 39f4e4d: 8307758: RISC-V: Improve bit test code introduced by JDK-8291555
  • 3cb606e: 8306965: osThread allocation failures should not abort the VM
  • 4795c39: 8281103: Give example for Locale that is English and follows the ISO standards
  • 958d4a7: 8307563: make most fields final in JavacTrees
  • ... and 64 more: https://git.openjdk.org/jdk/compare/ad0e5a99ca1ad9dd04105f502985735a3536c3f4...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 May 11, 2023
@nsjian
Copy link
Author

nsjian commented May 11, 2023

Great catch, thanks. Does this one need backports?

I think so. I will handle the backports as well.

Copy link
Contributor

@adinn adinn left a comment

Choose a reason for hiding this comment

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

Nice work Ningsheng!

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed ready Pull request is ready to be integrated labels May 11, 2023
@nsjian
Copy link
Author

nsjian commented May 12, 2023

Thanks for the review! @theRealAph @adinn

@nsjian
Copy link
Author

nsjian commented May 12, 2023

/integrate

@openjdk
Copy link

openjdk bot commented May 12, 2023

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

  • 9a7b443: 8307966: ProblemList java/util/concurrent/locks/Lock/OOMEInAQS.java on linux-x64
  • 54c06d2: 8307559: Add better checking in com/sun/jdi tests for debuggee exiting unexpectedly with an exception
  • ce59077: 8307945: Build of Client VM is broken after JDK-8307058
  • a667213: 8281715: Move "base CDS archive not loaded" tests to SharedArchiveFileOption.java
  • 29b8242: 8307954: Update string template regression tests to be robust on release updates
  • 4f355c3: 8307653: Adjust delay time and gc log argument in TestAbortOnVMOperationTimeout
  • 1535863: 8307848: update for deprecated sprintf for jdk.attach
  • cbecf42: 8307850: update for deprecated sprintf for jdk.jdi
  • 7fcb0fd: 8307139: Fix signed integer overflow in compiler code, part 1
  • 5d6cce0: 8307298: JFR: Ensure jdk.jfr.internal.TypeLibrary is initialized only once
  • ... and 79 more: https://git.openjdk.org/jdk/compare/ad0e5a99ca1ad9dd04105f502985735a3536c3f4...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented May 12, 2023

@nsjian Pushed as commit 33d9a85.

💡 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