-
Notifications
You must be signed in to change notification settings - Fork 5.9k
8299074: nmethod marked for deoptimization is not deoptimized #12012
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
Conversation
👋 Welcome back thartmann! A progress list of the required criteria for merging this PR into |
@TobiHartmann 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
|
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.
@TobiHartmann 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 34 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 |
compiler/jsr292/ContinuousCallSiteTargetChange.java in GHA testing failed with:
I don't see such failure in other recent PRs. |
Thanks for the reviews! I hit this assert in my testing now as well, will investigate. |
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! (- assertion :) )
Thanks for the review Robbin. Regarding the failure with |
nm->print_dependencies(); | ||
} | ||
changes.mark_for_deoptimization(nm); | ||
found++; | ||
} |
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.
A minor suggestion is to move the found++ from the individual branches to here, so there is only one.
Looks good!
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.
But that would increment found
also in the cases where no method was marked for deoptimization, right?
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.
Yes, sorry, please ignore :)
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.
Thanks again for the reviews, Vladimir and Robbin. |
/integrate |
Going to push as commit 66f7387.
Your commit was automatically rebased without conflicts. |
@TobiHartmann Pushed as commit 66f7387. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
In the failing
UnexpectedDeoptimizationAllTest
there is a race condition between one thread repeatedly callingWB_DeoptimizeAll()
and the main thread checking nmethod dependencies on class loading and also attempting marking/deoptimization of nmethods due to dependency violations. The problem is that already (concurrently) marked nmethods are not counted and if no new nmethods are marked, we then wrongly assume that there is no need to calldeoptimize_all_marked
:jdk/src/hotspot/share/code/codeCache.cpp
Lines 1438 to 1440 in 0800813
Details:
Thread 1: Method
useNativeAccessor(Executable member)
is compiled under the assumption that its argument typejava.lang.reflect.Executable
has only one implementerjava.lang.reflect.Method
. A corresponding dependency is registered in the nmethod and a virtual call tomember.getParameterCount()
is inlined tojava.lang.reflect.Method::getParameterCount()
.Thread 2: Calls Whitebox API method
WB_DeoptimizeAll
->CodeCache::mark_all_nmethods_for_deoptimization()
that marksuseNativeAccessor
for deoptimization.Thread 1: Triggers class loading of
java.lang.reflect.Constructor
andCodeCache::flush_dependents_on
->CodeCache::mark_for_deoptimization
-> ... ->DependencyContext::mark_dependent_nmethods
detects thatuseNativeAccessor
needs to be deoptimized now thatjava.lang.reflect.Executable
has more than one implementer. However, the nmethod is already marked for deoptimization (most nmethods are) and therefore ignored. The marked counter is 0 and thereforeDeoptimization::deoptimize_all_marked()
is not executed either. The thread continues execution and ends up crashing because ajava.lang.reflect.Constructor
object is passed to compileduseNativeAccessor
which can not handle it (we call the wronggetParameterCount
on it).Thread 2: Is still in
WB_DeoptimizeAll
, marking nmethods for deoptimization but didn't get a chance to callDeoptimization::deoptimize_all_marked()
yet.Before JDK-8221734 in JDK 13,
WB_DeoptimizeAll
acquired theCompile_lock
but it got removed. Instead of re-adding the lock, I modified the code to also count nmethods that were already marked for deoptimization, as suggested by @robehn in the bug comments.Thanks,
Tobias
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12012/head:pull/12012
$ git checkout pull/12012
Update a local copy of the PR:
$ git checkout pull/12012
$ git pull https://git.openjdk.org/jdk pull/12012/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12012
View PR using the GUI difftool:
$ git pr show -t 12012
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12012.diff