< prev index next >

src/hotspot/share/runtime/serviceThread.cpp

Print this page
rev 59376 : 8153224.v2.10.patch merged with 8153224.v2.11.patch.


  93 
  94 static void cleanup_oopstorages() {
  95   OopStorageSet::Iterator it = OopStorageSet::all_iterator();
  96   for ( ; !it.is_end(); ++it) {
  97     it->delete_empty_blocks();
  98   }
  99 }
 100 
 101 void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) {
 102   while (true) {
 103     bool sensors_changed = false;
 104     bool has_jvmti_events = false;
 105     bool has_gc_notification_event = false;
 106     bool has_dcmd_notification_event = false;
 107     bool stringtable_work = false;
 108     bool symboltable_work = false;
 109     bool resolved_method_table_work = false;
 110     bool thread_id_table_work = false;
 111     bool protection_domain_table_work = false;
 112     bool oopstorage_work = false;

 113     JvmtiDeferredEvent jvmti_event;
 114     {
 115       // Need state transition ThreadBlockInVM so that this thread
 116       // will be handled by safepoint correctly when this thread is
 117       // notified at a safepoint.
 118 
 119       // This ThreadBlockInVM object is not also considered to be
 120       // suspend-equivalent because ServiceThread is not visible to
 121       // external suspension.
 122 
 123       ThreadBlockInVM tbivm(jt);
 124 
 125       MonitorLocker ml(Service_lock, Mutex::_no_safepoint_check_flag);
 126       // Process all available work on each (outer) iteration, rather than
 127       // only the first recognized bit of work, to avoid frequently true early
 128       // tests from potentially starving later work.  Hence the use of
 129       // arithmetic-or to combine results; we don't want short-circuiting.
 130       while (((sensors_changed = (!UseNotificationThread && LowMemoryDetector::has_pending_requests())) |
 131               (has_jvmti_events = _jvmti_service_queue.has_events()) |
 132               (has_gc_notification_event = (!UseNotificationThread && GCNotifier::has_event())) |
 133               (has_dcmd_notification_event = (!UseNotificationThread && DCmdFactory::has_pending_jmx_notification())) |
 134               (stringtable_work = StringTable::has_work()) |
 135               (symboltable_work = SymbolTable::has_work()) |
 136               (resolved_method_table_work = ResolvedMethodTable::has_work()) |
 137               (thread_id_table_work = ThreadIdTable::has_work()) |
 138               (protection_domain_table_work = SystemDictionary::pd_cache_table()->has_work()) |
 139               (oopstorage_work = OopStorage::has_cleanup_work_and_reset())

 140              ) == 0) {
 141         // Wait until notified that there is some work to do.
 142         ml.wait();



 143       }
 144 
 145       if (has_jvmti_events) {
 146         // Get the event under the Service_lock
 147         jvmti_event = _jvmti_service_queue.dequeue();
 148         _jvmti_event = &jvmti_event;
 149       }
 150     }
 151 
 152     if (stringtable_work) {
 153       StringTable::do_concurrent_work(jt);
 154     }
 155 
 156     if (symboltable_work) {
 157       SymbolTable::do_concurrent_work(jt);
 158     }
 159 
 160     if (has_jvmti_events) {
 161       _jvmti_event->post();
 162       _jvmti_event = NULL;  // reset


 174       if(has_dcmd_notification_event) {
 175         DCmdFactory::send_notification(CHECK);
 176       }
 177     }
 178 
 179     if (resolved_method_table_work) {
 180       ResolvedMethodTable::do_concurrent_work(jt);
 181     }
 182 
 183     if (thread_id_table_work) {
 184       ThreadIdTable::do_concurrent_work(jt);
 185     }
 186 
 187     if (protection_domain_table_work) {
 188       SystemDictionary::pd_cache_table()->unlink();
 189     }
 190 
 191     if (oopstorage_work) {
 192       cleanup_oopstorages();
 193     }




 194   }
 195 }
 196 
 197 void ServiceThread::enqueue_deferred_event(JvmtiDeferredEvent* event) {
 198   MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag);
 199   // If you enqueue events before the service thread runs, gc and the sweeper
 200   // cannot keep the nmethod alive.  This could be restricted to compiled method
 201   // load and unload events, if we wanted to be picky.
 202   assert(_instance != NULL, "cannot enqueue events before the service thread runs");
 203   _jvmti_service_queue.enqueue(*event);
 204   Service_lock->notify_all();
 205  }
 206 
 207 void ServiceThread::oops_do(OopClosure* f, CodeBlobClosure* cf) {
 208   JavaThread::oops_do(f, cf);
 209   // The ServiceThread "owns" the JVMTI Deferred events, scan them here
 210   // to keep them alive until they are processed.
 211   if (cf != NULL) {
 212     if (_jvmti_event != NULL) {
 213       _jvmti_event->oops_do(f, cf);


  93 
  94 static void cleanup_oopstorages() {
  95   OopStorageSet::Iterator it = OopStorageSet::all_iterator();
  96   for ( ; !it.is_end(); ++it) {
  97     it->delete_empty_blocks();
  98   }
  99 }
 100 
 101 void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) {
 102   while (true) {
 103     bool sensors_changed = false;
 104     bool has_jvmti_events = false;
 105     bool has_gc_notification_event = false;
 106     bool has_dcmd_notification_event = false;
 107     bool stringtable_work = false;
 108     bool symboltable_work = false;
 109     bool resolved_method_table_work = false;
 110     bool thread_id_table_work = false;
 111     bool protection_domain_table_work = false;
 112     bool oopstorage_work = false;
 113     bool deflate_idle_monitors = false;
 114     JvmtiDeferredEvent jvmti_event;
 115     {
 116       // Need state transition ThreadBlockInVM so that this thread
 117       // will be handled by safepoint correctly when this thread is
 118       // notified at a safepoint.
 119 
 120       // This ThreadBlockInVM object is not also considered to be
 121       // suspend-equivalent because ServiceThread is not visible to
 122       // external suspension.
 123 
 124       ThreadBlockInVM tbivm(jt);
 125 
 126       MonitorLocker ml(Service_lock, Mutex::_no_safepoint_check_flag);
 127       // Process all available work on each (outer) iteration, rather than
 128       // only the first recognized bit of work, to avoid frequently true early
 129       // tests from potentially starving later work.  Hence the use of
 130       // arithmetic-or to combine results; we don't want short-circuiting.
 131       while (((sensors_changed = (!UseNotificationThread && LowMemoryDetector::has_pending_requests())) |
 132               (has_jvmti_events = _jvmti_service_queue.has_events()) |
 133               (has_gc_notification_event = (!UseNotificationThread && GCNotifier::has_event())) |
 134               (has_dcmd_notification_event = (!UseNotificationThread && DCmdFactory::has_pending_jmx_notification())) |
 135               (stringtable_work = StringTable::has_work()) |
 136               (symboltable_work = SymbolTable::has_work()) |
 137               (resolved_method_table_work = ResolvedMethodTable::has_work()) |
 138               (thread_id_table_work = ThreadIdTable::has_work()) |
 139               (protection_domain_table_work = SystemDictionary::pd_cache_table()->has_work()) |
 140               (oopstorage_work = OopStorage::has_cleanup_work_and_reset()) |
 141               (deflate_idle_monitors = ObjectSynchronizer::is_async_deflation_needed())
 142              ) == 0) {
 143         // Wait until notified that there is some work to do.
 144         // If AsyncDeflateIdleMonitors, then we wait for
 145         // GuaranteedSafepointInterval so that is_async_deflation_needed()
 146         // is checked at the same interval.
 147         ml.wait(AsyncDeflateIdleMonitors ? GuaranteedSafepointInterval : 0);
 148       }
 149 
 150       if (has_jvmti_events) {
 151         // Get the event under the Service_lock
 152         jvmti_event = _jvmti_service_queue.dequeue();
 153         _jvmti_event = &jvmti_event;
 154       }
 155     }
 156 
 157     if (stringtable_work) {
 158       StringTable::do_concurrent_work(jt);
 159     }
 160 
 161     if (symboltable_work) {
 162       SymbolTable::do_concurrent_work(jt);
 163     }
 164 
 165     if (has_jvmti_events) {
 166       _jvmti_event->post();
 167       _jvmti_event = NULL;  // reset


 179       if(has_dcmd_notification_event) {
 180         DCmdFactory::send_notification(CHECK);
 181       }
 182     }
 183 
 184     if (resolved_method_table_work) {
 185       ResolvedMethodTable::do_concurrent_work(jt);
 186     }
 187 
 188     if (thread_id_table_work) {
 189       ThreadIdTable::do_concurrent_work(jt);
 190     }
 191 
 192     if (protection_domain_table_work) {
 193       SystemDictionary::pd_cache_table()->unlink();
 194     }
 195 
 196     if (oopstorage_work) {
 197       cleanup_oopstorages();
 198     }
 199 
 200     if (deflate_idle_monitors) {
 201       ObjectSynchronizer::deflate_idle_monitors_using_JT();
 202     }
 203   }
 204 }
 205 
 206 void ServiceThread::enqueue_deferred_event(JvmtiDeferredEvent* event) {
 207   MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag);
 208   // If you enqueue events before the service thread runs, gc and the sweeper
 209   // cannot keep the nmethod alive.  This could be restricted to compiled method
 210   // load and unload events, if we wanted to be picky.
 211   assert(_instance != NULL, "cannot enqueue events before the service thread runs");
 212   _jvmti_service_queue.enqueue(*event);
 213   Service_lock->notify_all();
 214  }
 215 
 216 void ServiceThread::oops_do(OopClosure* f, CodeBlobClosure* cf) {
 217   JavaThread::oops_do(f, cf);
 218   // The ServiceThread "owns" the JVMTI Deferred events, scan them here
 219   // to keep them alive until they are processed.
 220   if (cf != NULL) {
 221     if (_jvmti_event != NULL) {
 222       _jvmti_event->oops_do(f, cf);
< prev index next >