8076325: java hangs with -XX:ParallelGCThreads=0 -XX:+ExplicitGCInvokesConcurrent options

Added a guard of gc workers > 0 to execute logic.

Reviewed-by: stefank, mgerdin
This commit is contained in:
Sangheon Kim 2015-04-09 10:16:45 -07:00
parent d86a561fe4
commit 2dff1df5da

View File

@ -93,11 +93,13 @@ void G1RootProcessor::worker_has_discovered_all_strong_classes() {
uint n_workers = _g1h->n_par_threads();
assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
uint new_value = (uint)Atomic::add(1, &_n_workers_discovered_strong_classes);
if (new_value == n_workers) {
// This thread is last. Notify the others.
MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
_lock.notify_all();
if (n_workers > 0) {
uint new_value = (uint)Atomic::add(1, &_n_workers_discovered_strong_classes);
if (new_value == n_workers) {
// This thread is last. Notify the others.
MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
_lock.notify_all();
}
}
}
@ -105,7 +107,7 @@ void G1RootProcessor::wait_until_all_strong_classes_discovered() {
uint n_workers = _g1h->n_par_threads();
assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
if ((uint)_n_workers_discovered_strong_classes != n_workers) {
if (n_workers > 0 && (uint)_n_workers_discovered_strong_classes != n_workers) {
MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
while ((uint)_n_workers_discovered_strong_classes != n_workers) {
_lock.wait(Mutex::_no_safepoint_check_flag, 0, false);