8386292: Shenandoah: Simplify and strengthen C1 barriers - #31576
8386292: Shenandoah: Simplify and strengthen C1 barriers#31576shipilev wants to merge 13 commits into
Conversation
|
👋 Welcome back shade! A progress list of the required criteria for merging this PR into |
|
@shipilev 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 54 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 |
|
The total number of required reviews for this PR has been set to 2 based on the presence of this label: |
Webrevs
|
|
/contributor add @TheRealMDoerr |
|
@shipilev |
| __ prologue("shenandoah_keepalive_barrier", false); | ||
| const Register tmp_obj = x10; | ||
| const Register tmp1 = t1; | ||
| const Register tmp2 = t2; |
There was a problem hiding this comment.
t1 is one of the two reserved scratch registers which may be clobbered implicitly by some macro-assemblers.
Can we simply use x11 and x12 for tmp1 and tmp2 respectively? I think that should be safer.
There was a problem hiding this comment.
Right! I think the risk is low, given we immediately stash these registers here. But you are right we might conflict somewhere down the line. If you feel x11/x12 is safer, let's do that. Done in new commit.
rkennke
left a comment
There was a problem hiding this comment.
This is great! And it's the right thing to do: C1 LIR should not really get any fancy stuff/control flow inserted into its basic blocks. Checking a flag and branching to a stub is about all that C1 can realistically handle.
I have carefully checked the changes and could not find anything wrong with it. (I'm not really familiar with RISCV and PPC assembly, though.)
|
Thanks for looking! @TheRealMDoerr, @RealFYang -- do you guys want to run PPC64/RISC-V testing before I integrate? |
|
I had already run some tests on PPC64 and they were good. Thanks! |
RealFYang
left a comment
There was a problem hiding this comment.
The RISC-V part seems fine to me. My local hotspot_gc_shenandoah test using fastdebug build on linux-riscv64 is good.
|
Awesome, thanks for testing! |
kdnilsen
left a comment
There was a problem hiding this comment.
I'm not fluent in C1, but everything looks good to me. I agree that this simplification is the right direction to move.
|
Thanks for reviews! Here goes. /integrate |
|
Going to push as commit 60e4b91.
Your commit was automatically rebased without conflicts. |
For Valhalla enablement, I was chasing a few issues that reproduce under stress testing. A few of them are in C1 barriers, where we apparently clobber registers. This shows up prominently under heavy register pressure in Valhalla tests. We can and should simplify C1 barriers by delegating them to assembler barriers where possible. The whole lot of complexity would go away then.
Currently, Shenandoah C1 barriers are shaped like this:
Steps (2) and (3) are the bulk of C1 barriers, those implementations are written specifically for C1. But there is no real point in having them for baseline compiler like C1. For maintainability reasons, we can delegate to assembler barriers that are at the same efficiency ballpark.
In this change, the shape of the barriers is:
There are maintainability savings at steps (2) and (3), since we push down most of the implementation to (3); I believe I have fixed some register clobbering bugs that were showing up in Valhalla because of this simplification. We now do fairly little code in C1, which I am very happy with.
There are code density savings at step (2), because we do not generate a lot extra code that shows up in every C1 method. There are also assorted quality of life improvements along the way to make the code more straight-forward.
If you stand way back and look at it from a distance, you can think about this as LBE-shaped refactoring of C1 barriers. In contrast to LBE, this rewrite favors maintainability over peak performance. At some point in the future we might be able to coalesce the assembler, C1 and C2 barriers completely, but I am not 100% confident it is going to work for peak perf.
I am throwing more testing at this now, but would appreciate early review in case there are obvious gaps.
Additional testing:
hotspot_gc_shenandoahtier1with-XX:+UseShenandoahGC -XX:TieredStopAtLevel=1allwith-XX:+UseShenandoahGC -XX:TieredStopAtLevel=1allwith-XX:+UseShenandoahGC -XX:TieredStopAtLevel=1Progress
Issue
Reviewers
Contributors
<mdoerr@openjdk.org>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/31576/head:pull/31576$ git checkout pull/31576Update a local copy of the PR:
$ git checkout pull/31576$ git pull https://git.openjdk.org/jdk.git pull/31576/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 31576View PR using the GUI difftool:
$ git pr show -t 31576Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/31576.diff
Using Webrev
Link to Webrev Comment