hotspot/src/share/vm/gc_implementation/g1/g1RootProcessor.cpp
changeset 30167 1a32e4a39680
parent 30153 596ed88949ad
child 30172 4dcc7e33e633
equal deleted inserted replaced
30165:c4ff729cb74a 30167:1a32e4a39680
    91 
    91 
    92 void G1RootProcessor::worker_has_discovered_all_strong_classes() {
    92 void G1RootProcessor::worker_has_discovered_all_strong_classes() {
    93   uint n_workers = _g1h->n_par_threads();
    93   uint n_workers = _g1h->n_par_threads();
    94   assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
    94   assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
    95 
    95 
    96   uint new_value = (uint)Atomic::add(1, &_n_workers_discovered_strong_classes);
    96   if (n_workers > 0) {
    97   if (new_value == n_workers) {
    97     uint new_value = (uint)Atomic::add(1, &_n_workers_discovered_strong_classes);
    98     // This thread is last. Notify the others.
    98     if (new_value == n_workers) {
    99     MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
    99       // This thread is last. Notify the others.
   100     _lock.notify_all();
   100       MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
       
   101       _lock.notify_all();
       
   102     }
   101   }
   103   }
   102 }
   104 }
   103 
   105 
   104 void G1RootProcessor::wait_until_all_strong_classes_discovered() {
   106 void G1RootProcessor::wait_until_all_strong_classes_discovered() {
   105   uint n_workers = _g1h->n_par_threads();
   107   uint n_workers = _g1h->n_par_threads();
   106   assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
   108   assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
   107 
   109 
   108   if ((uint)_n_workers_discovered_strong_classes != n_workers) {
   110   if (n_workers > 0 && (uint)_n_workers_discovered_strong_classes != n_workers) {
   109     MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
   111     MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
   110     while ((uint)_n_workers_discovered_strong_classes != n_workers) {
   112     while ((uint)_n_workers_discovered_strong_classes != n_workers) {
   111       _lock.wait(Mutex::_no_safepoint_check_flag, 0, false);
   113       _lock.wait(Mutex::_no_safepoint_check_flag, 0, false);
   112     }
   114     }
   113   }
   115   }