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
8266746: C1: Replace UnsafeGetRaw with UnsafeGet when setting up OSR entry block #3917
Conversation
|
@kelthuzadx 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
|
Hi Yang. If the OptimizeUnsafes feature was ever useful for UnsafeGetRaw, then maybe we should apply that optimization to the UnsafeGetObject-with-null-object case rather than removing the feature. Could you try it? |
Also, I can't find where the UnsafeGetObject implementation handles the unaligned/wide flags of UnsafeGetRaw. It would be good to get this change reviewed by someone from GC, since UnsafeGetRaw uses the GC barrier interface to do its work. |
/cc hotspot-gc |
@dean-long |
Hi Dean, Thanks for noticing this PR.
Yes, I will investigate this and file an issue if it's possible to canonicalize UnsafeGetObject as well.
I think access_load already handles the wide flag
Internally, move_wide will check the type and decide whether to execute the "wide" semantics according to the type, so using access_load for all types is ok. As for the unaligned flag, I found that it only affects PPC and s390 (which is why the pre-submit test passed), and access_load is not aware of this flag, I think they should really need to be handled.
Yes, I'm looking forward to hearing suggestions from GC folks! |
PING: May I ask your help to review this patch? |
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.
Looks good to me but this should be tested on all platforms.
LIR_Opr offset = new_register(T_LONG); | ||
__ convert(Bytecodes::_i2l, off.result(), offset); | ||
#else | ||
LIR_Opr offset = off.result(); |
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.
The indentation is wrong in the else branch.
true /*unaligned*/, true /*wide*/)); | ||
Value off_val = append(new Constant(new IntConstant(offset))); | ||
get = append(new UnsafeGetObject(as_BasicType(local->type()), e, | ||
off_val, |
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.
Indentation is wrong.
} | ||
|
||
// accessors | ||
bool is_raw_get() { return _is_raw_get; } |
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.
I would rename this to _is_raw
because we already know it's a get.
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 Tobias for the review! All fixed. I will test it on Linux(already tested)/Mac/Windows(aarch64+x86_64) later. But I don't have ppc and s390 machines so I'm not sure how to test it on them...
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.
Looks good. Maybe someone from the OpenJDK community can run some sanity testing on ppc/s390.
@kelthuzadx This change now passes all automated pre-integration checks. 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 861 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.
|
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.
It looks like when JDK-8150921 was done, some micro-benchmarks were run, and @shipilev noticed a regression in C1 with constant null handling:
http://cr.openjdk.java.net/~shade/8150921/notes.txt
Looking over the code review:
https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2016-May/022767.html
I don't see any references to benchmark testing that would check for any regressions in the InlineUnsafeOps + OptimizeUnsafes optimization that 8150921 mostly bypassed. @vidmik
Now this PR proposes to remove this mostly dead code. I'm OK with that, since blindly reviving it risks hitting bitrot, but for compleness, perhaps we should file 2 followup RFEs:
- investigate constant null C1 regression
- measure if the dead InlineUnsafeOps + OptimizeUnsafes optimization is worth reviving in a later release (with sufficient bake time)
They are indeed necessary. Thanks for sharing more information about JDK-8150921. I've filed JDK-8267783 and JDK-8267782 and assign them to me, I would investigate and check if it's worth doing later. |
Tests are passed on both aarch64 and x64. Can someone help running sanity checks on s390/ppc machines? Thanks a lot. |
@TobiHartmann @dean-long It seems that there is no easy way to test this PR on all architectures. Can I merge this PR in this case? If not, do you have a general solution for changes that should be tested on all architectures while the author can not cover all architectures for PR that they made? Thanks in advance! |
@TheRealMDoerr, could someone at SAP test this change on s390 and ppc, please? |
Thanks for checking with us! I've given it a quick spin and it seems to work on s390. However, I got the following error on ppc64: V [libjvm.so+0x64703c] LIR_Assembler::mem2reg(LIR_OprDesc*, LIR_OprDesc*, BasicType, LIR_PatchCode, CodeEmitInfo*, b |
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.
If you want to use unaligned_move, please remove the assertions (the derived PPC64 instructions do support unaligned access):
--- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
+++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
@@ -1172,7 +1172,6 @@ void LIR_Assembler::mem2reg(LIR_Opr src_opr, LIR_Opr dest, BasicType type,
assert(Assembler::is_simm16(disp_value), "should have set this up");
offset = load(src, disp_value, to_reg, type, wide, unaligned);
} else {
- assert(!unaligned, "unexpected");
offset = load(src, disp_reg, to_reg, type, wide);
}
@@ -1301,7 +1300,6 @@ void LIR_Assembler::reg2mem(LIR_Opr from_reg, LIR_Opr dest, BasicType type,
assert(Assembler::is_simm16(disp_value), "should have set this up");
offset = store(from_reg, src, disp_value, type, wide, unaligned);
} else {
- assert(!unaligned, "unexpected");
offset = store(from_reg, src, disp_reg, type, wide);
}
#endif | ||
LIR_Address* addr = new LIR_Address(src.result(), offset, type); | ||
if (type == T_LONG || type == T_DOUBLE) { | ||
__ unaligned_move(addr, result); |
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.
You're always using unaligned_move. Old code checks x->may_be_unaligned(). May be ok, though.
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.
Thank you Martin for running these tests!
In this case, may_be_unaligned is must-be-unaligned since setup_osr_entry_block always creates unaligned UnsafeGetRaw before.
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 for taking care of PPC64. I haven't seen errors with this version. But I have some remarks:
- I think the name UnsafeGetObject is confusing, now. It's no longer used for objects only.
- The "unaligned" parameter is unused on all platforms, now. Note that PPC64 and s390 support unaligned accesses, too. I believe it was used by SPARC which has been removed.
I don't see any reason that we need the "Object" suffix.
|
|
/summary Replace UnsafeGetRaw with UnsafeGetObject when setting up OSR entry block, and rename Unsafe{Get,Put}Object to Unsafe{Get,Put} |
@kelthuzadx Setting summary to |
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 for cleaning this up!
/integrate |
Going to push as commit d89e630.
Your commit was automatically rebased without conflicts. |
@kelthuzadx Pushed as commit d89e630. |
After JDK-8150921, most Unsafe{Get,Put}Raw intrinsic methods can be replaced by Unsafe{Get,Put}Object.
There is the only one occurrence where c1 refers UnsafeGetRaw among GraphBuilder::setup_osr_entry_block()
jdk/src/hotspot/share/c1/c1_GraphBuilder.cpp
Lines 3143 to 3157 in 74fecc0
We can replace UnsafeGetRaw with UnsafeGetObject when setting up OSR entry block. After that, Unsafe{Get,Put}Raw can be completely removed because no one refers to them.
(This patch actually does two things:
Replace UnsafeGetRaw with UnsafeGetObject when setting up OSR entry block
This is the only occurrence where c1 refers UnsafeGetRawCleanup unused Unsafe{Get,Put}Raw code
They are related so I put it together, but I still want to hear your suggestions, I will separate them into two patches if you think it is more reasonable)
Thanks!
Yang
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3917/head:pull/3917
$ git checkout pull/3917
Update a local copy of the PR:
$ git checkout pull/3917
$ git pull https://git.openjdk.java.net/jdk pull/3917/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3917
View PR using the GUI difftool:
$ git pr show -t 3917
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3917.diff