-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8367066: RISC-V: refine register selection in MacroAssembler:: decode_klass_not_null #27138
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
8367066: RISC-V: refine register selection in MacroAssembler:: decode_klass_not_null #27138
Conversation
|
👋 Welcome back mli! A progress list of the required criteria for merging this PR into |
|
@Hamlin-Li 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: 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 62 new commits pushed to the
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 |
|
@Hamlin-Li The following label will be automatically applied to this pull request:
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. |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, seems we can further eliminate the use of t0 replacing it with tmp. How about we go like this?
diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
index 1436bc02113..89e615b1cbb 100644
--- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
@@ -3402,6 +3402,8 @@ void MacroAssembler::decode_klass_not_null(Register r, Register tmp) {
void MacroAssembler::decode_klass_not_null(Register dst, Register src, Register tmp) {
assert(UseCompressedClassPointers, "should only be used for compressed headers");
+ assert_different_registers(src, tmp);
+ assert_different_registers(dst, tmp);
if (CompressedKlassPointers::base() == nullptr) {
if (CompressedKlassPointers::shift() != 0) {
@@ -3421,7 +3423,7 @@ void MacroAssembler::decode_klass_not_null(Register dst, Register src, Register
mv(xbase, (uintptr_t)CompressedKlassPointers::base());
if (CompressedKlassPointers::shift() != 0) {
- Register t = src == dst ? dst : t0;
+ Register t = dst == xbase ? tmp : dst;
assert_different_registers(t, xbase);
shadd(dst, src, xbase, t, CompressedKlassPointers::shift());
} else {
I applied your suggested patch, and it trigger an assert at still running tests by removing this assert only. |
|
Yes, we still need one extra change to guarantee that dst != tmp, which we can do with a TEMP_DEF effect for dst. EDIT: My local |
In this sense, we're not saving one register (t0), as we require extra register by |
|
I think we can further simplify the code in |
| assert_different_registers(t, xbase); | ||
| shadd(dst, src, xbase, t, CompressedKlassPointers::shift()); | ||
| // dst = (src << shift) + xbase | ||
| shadd(dst, src, xbase, dst /* temporary, dst != xbase */, CompressedKlassPointers::shift()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safer to turn the code comment into an assertion? It will trigger if people incorrectly sets xbase.
assert_different_registers(dst, xbase);
// dst = (src << shift) + xbase
shadd(dst, src, xbase, dst, CompressedKlassPointers::shift());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In shadd when tmp (here we use dst as tmp) is used, there is already an assert there.
Yes, the code now looks more simplified. Thanks. |
Thanks for reviewing. |
feilongjiang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thank you for reviewing! |
|
/integrate |
|
Going to push as commit 0b3a303.
Your commit was automatically rebased without conflicts. |
|
@Hamlin-Li Pushed as commit 0b3a303. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi,
Can you help to review this patch?
Previously, the register selection in MacroAssembler:: decode_klass_not_null is misleading, better to refine it to improve the readability.
Thanks!
Running runtime test tier1/2/3...
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27138/head:pull/27138$ git checkout pull/27138Update a local copy of the PR:
$ git checkout pull/27138$ git pull https://git.openjdk.org/jdk.git pull/27138/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27138View PR using the GUI difftool:
$ git pr show -t 27138Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27138.diff
Using Webrev
Link to Webrev Comment