diff --git a/src/hotspot/share/gc/shared/barrierSetNMethod.cpp b/src/hotspot/share/gc/shared/barrierSetNMethod.cpp index cf481959bd6f3..f6a8f34888746 100644 --- a/src/hotspot/share/gc/shared/barrierSetNMethod.cpp +++ b/src/hotspot/share/gc/shared/barrierSetNMethod.cpp @@ -105,8 +105,14 @@ class BarrierSetNMethodArmClosure : public ThreadClosure { 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);