8292194: G1 nmethod entry barrier disarm value wraps around too early

Reviewed-by: ayang, tschatzl
This commit is contained in:
Erik Österlund 2022-08-24 13:11:23 +00:00
parent d3fed12867
commit a45a4b9465

@ -117,8 +117,14 @@ public:
void BarrierSetNMethod::arm_all_nmethods() {
// Change to a new global GC phase. Doing this requires changing the thread-local
// disarm value for all threads, to reflect the new GC phase.
// We wrap around at INT_MAX. That means that we assume nmethods won't have ABA
// problems in their nmethod disarm values after INT_MAX - 1 GCs. Every time a GC
// completes, ABA problems are removed, but if a concurrent GC is started and then
// aborted N times, that is when there could be ABA problems. If there are anything
// close to INT_MAX - 1 GCs starting without being able to finish, something is
// seriously wrong.
++_current_phase;
if (_current_phase == 4) {
if (_current_phase == INT_MAX) {
_current_phase = 1;
}
BarrierSetNMethodArmClosure cl(_current_phase);