8379260: C2: Separate volatile barrier and full barrier#30106
8379260: C2: Separate volatile barrier and full barrier#30106merykitty wants to merge 4 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back qamai! A progress list of the required criteria for merging this PR into |
|
@merykitty 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 112 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 |
|
@merykitty 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
|
| access_store_at(nullptr, jt_addr, _gvn.type(jt_addr)->is_ptr(), ideal.ConI(1), TypeInt::BOOL, T_BOOLEAN, IN_NATIVE | MO_UNORDERED); | ||
| access_store_at(nullptr, vt_addr, _gvn.type(vt_addr)->is_ptr(), ideal.ConI(1), TypeInt::BOOL, T_BOOLEAN, IN_NATIVE | MO_UNORDERED); | ||
| insert_mem_bar(Op_MemBarVolatile); | ||
| insert_mem_bar(Op_MemBarFull); |
There was a problem hiding this comment.
The comment says this code needs OrderAccess::storeload(), which can be weaker than a full fence on PPC and RISC-V. Should we also introduce a new Op_MemBarStoreLoad to support this?
There was a problem hiding this comment.
That's a valid point, I have updated the PR.
|
I see that on RISC-V, |
|
MemBarVolatile may be obsolete now if we have MemBarStoreLoad. My understanding is that MemBarVolatile is needed between a volatile store and a volatile load, and the old JSR-133 cookbook says that requires only MacroAssembler::StoreLoad, not the stronger MacroAssembler::AnyAny. |
|
@dean-long A |
But |
That's not right. In addition to obeying Acquire and Release properties, all Volatile operations are totally ordered with respect to each other. So, a |
I suppose it is a bug, yes. |
A volatile load is a load followed by a
Thanks, I changed it to a bug. |
Oh, ISWYM. |
| format %{ "membar_full" %} | ||
| ins_encode %{ | ||
| __ block_comment("membar_full"); | ||
| __ membar(Assembler::AnyAny); |
There was a problem hiding this comment.
This code is making a distinction without a real difference between StoreLoad and AnyAny: it's dmb ish in both cases.
There was a problem hiding this comment.
Yes, that's right, so there is no difference functional-wise on Aarch64. If you want to ask me why having a separate match block for MemBarFull and MemBarStoreLoad, I think the difference in the comment is useful.
So, what is |
Co-authored-by: Andrew Haley <aph-open@littlepinkcloud.com>
|
A |
Yes, VarHandle::fullFence was using MemBarVolatile, but it should be using MemBarFull now.
Both are really StoreLoad now, if we consitently use MemBarFull when a full fence is needed, and MemBarStoreLoad only when a StoreLoad is needed. StoreLoad != full fence even though they both might get translated to the same thing depending on the hardware. |
|
For example, if we have a volatile store in a loop and no other store or memory barrier in that loop, a |
|
Thanks, I hope I got it now :-). MemBarVolatile semantics are more at the Java level, while MemBarStoreLoad is closer to the memory level, I guess you could say? |
That makes sense, so a |
RealFYang
left a comment
There was a problem hiding this comment.
Hi, I have two minor comments about the instruct format for RISC-V.
| ins_cost(VOLATILE_REF_COST); | ||
|
|
||
| format %{ "#@membar_full_rvtso\n\t" | ||
| "fence a, a"%} |
There was a problem hiding this comment.
Thanks a lot for your review, I have made the change.
| ins_cost(VOLATILE_REF_COST); | ||
|
|
||
| format %{ "#@membar_full_rvwmo\n\t" | ||
| "fence a, a"%} |
RealFYang
left a comment
There was a problem hiding this comment.
Thanks for the update. The RISC-V part looks good.
|
@theRealAph @dean-long @RealFYang Thanks a lot for your reviews and suggestions. Can I integrate now or should I wait for approval for the ppc and s390 parts? |
|
Yes, wait for ppc and s390 and maybe ping the port maintainers. |
|
@TheRealMDoerr Could you take a look? Thanks in advance. |
TheRealMDoerr
left a comment
There was a problem hiding this comment.
LGTM. Also tested jtreg:test/hotspot/jtreg/compiler/c2 on linux ppc64le. Thanks!
|
@offamitkumar Could you review the s390 part, please? |
offamitkumar
left a comment
There was a problem hiding this comment.
s390 looks fine, tier1 tests are also clean.
|
Thanks very much for your reviews! /integrate |
|
Going to push as commit fd80329.
Your commit was automatically rebased without conflicts. |
|
@merykitty Pushed as commit fd80329. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi,
MemBarVolatileNodeis described as:This is incorrect, as
MemBarVolatileNodeis used inVarHandle::fullFenceintrinsics, which means it must act as a full fence. In addition, sinceMemBarVolatileNodemust act as a full fence, it prevents most optimizations with volatile accesses.This PR extracts
MemBarFullout ofMemBarVolatileas a proper full fence. This removes the confusion in the description ofMemBarVolatileNode, as well as allows us to have a better chance optimizing memory accesses around volatile accesses.Testing:
Please kindly review, thanks a lot.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30106/head:pull/30106$ git checkout pull/30106Update a local copy of the PR:
$ git checkout pull/30106$ git pull https://git.openjdk.org/jdk.git pull/30106/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 30106View PR using the GUI difftool:
$ git pr show -t 30106Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30106.diff
Using Webrev
Link to Webrev Comment