-
Notifications
You must be signed in to change notification settings - Fork 39
Demote re-registered nmethods #336
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
Demote re-registered nmethods #336
Conversation
|
Closes #331 |
|
Could you (Edit: It turned out that there is a way to set the base branch without re-opening the PR. I have made the change already.) |
wks
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.
LGTM
Let's merge this obvious fix for now, and I'll refactor the mutex later, as I mentioned in the other comment.
| NMETHOD_SLOTS.with_borrow_mut(|slots| { | ||
| if !slots.is_empty() { | ||
| let mut roots = crate::NURSERY_CODE_CACHE_ROOTS.lock().unwrap(); | ||
| let mut mature_roots = crate::MATURE_CODE_CACHE_ROOTS.lock().unwrap(); |
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.
Holding two locks at the same time is prone to dead-locking, especially when ScanCodeCacheRoots::do_work acquires the two locks in the opposite order. One way to fix it is putting the two hash maps under the same lock. I refactored this part of code locally when trying to address the "fix relocation" thing, but haven't merged it yet because it is somewhat unrelated to the "fix relocation" itself. I'll make another pull request later for the refactoring.
If an nmethod is in the mature roots and the nmethod is re-registered due to code patching, the nmethod will appear in both the nursery roots and the mature roots for one collection, causing some roots to be scanned twice. This PR removes an nmethod from the mature roots, when the nmethod is re-registered, so that the nmethod will only be present in the nursery.
If an nmethod is in the mature roots and the nmethod is re-registered due to code patching, the nmethod will appear in both the nursery roots and the mature roots for one collection, causing some roots to be scanned twice. This PR removes an nmethod from the mature roots, when the nmethod is re-registered, so that the nmethod will only be present in the nursery. This PR is ported from #336 for the `jdk-21` branch. Co-authored-by: Hayley Patton <[email protected]>
If an nmethod is in the mature roots and the nmethod is re-registered due to code patching, the nmethod will appear in both the nursery roots and the mature roots for one collection, causing some roots to be scanned twice. This PR removes an nmethod from the mature roots, when the nmethod is re-registered, so that the nmethod will only be present in the nursery.