-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8316746: Top of lock-stack does not match the unlocked object #16406
Conversation
👋 Welcome back mdoerr! A progress list of the required criteria for merging this PR into |
@TheRealMDoerr 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
|
Mystery solved! |
Yeah! Thanks again for your help! I hope I didn't steal too much of your time and that it was at least interesting for everybody. |
/label add hotspot-runtime |
@TobiHartmann |
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 Martin,
the order of BasicObjectLocks
in the interpreter is specified if the locking operations are well-formed.
the comment on the PPC implementation of frame::interpreter_frame_monitor_end
is wrong. It should be removed.
You're right! Removed the comment from all platforms which still had it. |
Thanks. I wasn't even aware that other implementations have it as well :) |
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 code in this PR is a lot easier to follow than the baseline version and it looks correct to me.
I tried to understand what's actually wrong with the baseline but gave up. Do you know where precisely the bug is?
Anyway, thanks for fixing this!
Richard.
ConditionRegister found_free_slot = CCR0, | ||
found_same_obj = CCR1, | ||
reached_limit = CCR6; | ||
// Note: The order of the monitors is important for C2 OSR which derives the |
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 should refer to the decl. of the interpreter_frame_monitor_*
where the expected order is specified.
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.
Done.
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.
@TheRealMDoerr 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 136 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 |
Thanks for the review! The old code simply reuses the first empty slot it finds (from top to bottom). That causes the order to be reversed if e.g. 2 slots are free and we lock 2 objects. The new code uses the free slot which is closer to the bottom first. |
@TobiHartmann: You were also interested in a test. I have included one which reproduces the issue on PPC64 without this fix. |
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.
Changes look good to me.
I added one minor optimization suggestion you may want to consider. It is not relevant for approval.
__ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, - frame::interpreter_frame_monitor_size_in_bytes()); | ||
__ cmpdi(CCR0, Rfree_slot, 0); | ||
__ beq(CCR0, Lallocate_new); | ||
__ mr(Rcurrent_monitor, Rfree_slot); | ||
__ b(Lfound); |
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.
Wouldn't it be nice to use Rfree_slot
from here on and save the move to Rcurrent_monitor
and the unconditional branch?
__ cmpdi(CCR0, Rfree_slot, 0);
__ bne(CCR0, Lfound);
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.
Good idea. Changed.
__ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, - frame::interpreter_frame_monitor_size_in_bytes()); | ||
__ cmpdi(CCR0, Rfree_slot, 0); | ||
__ beq(CCR0, Lallocate_new); | ||
__ mr(Rcurrent_monitor, Rfree_slot); | ||
__ b(Lfound); | ||
|
||
// We didn't find a free BasicObjLock => allocate one. | ||
__ align(32, 12); | ||
__ bind(Lallocate_new); | ||
__ add_monitor_to_stack(false, Rscratch1, Rscratch2); | ||
__ mr(Rcurrent_monitor, R26_monitor); |
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 do the above optimization, this instruction would need to change to
__ mr(Rfree_slot, R26_monitor);
@@ -4241,7 +4232,7 @@ void TemplateTable::monitorenter() { | |||
// The object has already been popped from the stack, so the expression stack looks correct. | |||
__ addi(R14_bcp, R14_bcp, 1); | |||
|
|||
__ std(Robj_to_lock, 0, Rcurrent_obj_addr); | |||
__ std(Robj_to_lock, in_bytes(BasicObjectLock::obj_offset()), Rcurrent_monitor); | |||
__ lock_object(Rcurrent_monitor, Robj_to_lock); |
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.
Rcurrent_monitor
would need to be replaced by Rfree_slot
in the above two lines as well.
Thanks for the review! I'm rerunning tests and will probably integrate tomorrow if everything is fine and there are no further comments. |
Tests are green. |
Going to push as commit 7d8adfa.
Your commit was automatically rebased without conflicts. |
@TheRealMDoerr Pushed as commit 7d8adfa. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
It took me quite a long journey to figure out that C2 OSR goes wrong only in the test "vmTestbase/nsk/jdi/StepEvent" because the interpreter fills the slots in a different order as expected by C2. (Interpreter and C1 don't care about it.)
I've reimplemented the search loop in
monitorenter
, improved comments and cleaned up the related code a bit. The test is passing with this change.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16406/head:pull/16406
$ git checkout pull/16406
Update a local copy of the PR:
$ git checkout pull/16406
$ git pull https://git.openjdk.org/jdk.git pull/16406/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16406
View PR using the GUI difftool:
$ git pr show -t 16406
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16406.diff
Webrev
Link to Webrev Comment