< prev index next >

src/hotspot/share/runtime/serviceThread.cpp

Print this page
rev 56635 : v2.00 -> v2.05 (CR5/v2.05/8-for-jdk13) patches combined into one; merge with 8229212.patch; merge with jdk-14+11; merge with 8230184.patch; merge with 8230876.patch; merge with jdk-14+15; merge with jdk-14+18.
rev 56638 : Merge the remainder of the lock-free monitor list changes from v2.06 with v2.06a and v2.06b after running the changes through the edit scripts; merge pieces from dcubed.monitor_deflate_conc.v2.06d in dcubed.monitor_deflate_conc.v2.06[ac]; merge pieces from dcubed.monitor_deflate_conc.v2.06e into dcubed.monitor_deflate_conc.v2.06c; merge with jdk-14+11; test work around for test/jdk/tools/jlink/multireleasejar/JLinkMultiReleaseJarTest.java should not been needed anymore; merge with jdk-14+18.
rev 56639 : loosen a couple more counter checks due to races observed in testing; simplify om_release() extraction of mid since list head or cur_mid_in_use is marked; simplify deflate_monitor_list() extraction of mid since there are no parallel deleters due to the safepoint; simplify deflate_monitor_list_using_JT() extraction of mid since list head or cur_mid_in_use is marked; prepend_block_to_lists() - simplify based on David H's comments; does not need load_acquire() or release_store() because of the cmpxchg(); prepend_to_common() - simplify to use mark_next_loop() for m and use mark_list_head() and release_store() for the non-empty list case; add more debugging for "Non-balanced monitor enter/exit" failure mode; fix race in inflate() in the "CASE: neutral" code path; install_displaced_markword_in_object() does not need to clear the header field since that is handled when the ObjectMonitor is moved from the global free list; LSuccess should clear boxReg to set ICC.ZF=1 to avoid depending on existing boxReg contents; update fast_unlock() to detect when object no longer refers to the same ObjectMonitor and take fast path exit instead; clarify fast_lock() code where we detect when object no longer refers to the same ObjectMonitor; add/update comments for movptr() calls where we move a literal into an Address; remove set_owner(); refactor setting of owner field into set_owner_from(2 versions), set_owner_from_BasicLock(), and try_set_owner_from(); the new functions include monitorinflation+owner logging; extract debug code from v2.06 and v2.07 and move to v2.07.debug; change 'jccb' -> 'jcc' and 'jmpb' -> 'jmp' as needed; checkpoint initial version of MacroAssembler::inc_om_ref_count(); update LP64 MacroAssembler::fast_lock() and fast_unlock() to use inc_om_ref_count(); fast_lock() return flag setting logic can use 'testptr(tmpReg, tmpReg)' instead of 'cmpptr(tmpReg, 0)' since that's more efficient; fast_unlock() LSuccess return flag setting logic can use 'testl (boxReg, 0)' instead of 'xorptr(boxReg, boxReg)' since that's more efficient; cleanup "fast-path" vs "fast path" and "slow-path" vs "slow path"; update MacroAssembler::rtm_inflated_locking() to use inc_om_ref_count(); update MacroAssembler::fast_lock() to preserve the flags before decrementing ref_count and restore the flags afterwards; this is more clean than depending on the contents of rax/tmpReg; coleenp CR - refactor async monitor deflation work from ServiceThread::service_thread_entry() to ObjectSynchronizer::deflate_idle_monitors_using_JT(); rehn,eosterlund CR - add support for HandshakeAfterDeflateIdleMonitors for platforms that don't have ObjectMonitor ref_count support implemented in C2 fast_lock() and fast_unlock().


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

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

 135              ) == 0) {
 136         // Wait until notified that there is some work to do.
 137         ml.wait();



 138       }
 139 
 140       if (has_jvmti_events) {
 141         jvmti_event = JvmtiDeferredEventQueue::dequeue();
 142       }
 143     }
 144 
 145     if (stringtable_work) {
 146       StringTable::do_concurrent_work(jt);
 147     }
 148 
 149     if (symboltable_work) {
 150       SymbolTable::do_concurrent_work(jt);
 151     }
 152 
 153     if (has_jvmti_events) {
 154       jvmti_event.post();
 155     }
 156 
 157     if (!UseNotificationThread) {


 166       if(has_dcmd_notification_event) {
 167         DCmdFactory::send_notification(CHECK);
 168       }
 169     }
 170 
 171     if (resolved_method_table_work) {
 172       ResolvedMethodTable::do_concurrent_work(jt);
 173     }
 174 
 175     if (thread_id_table_work) {
 176       ThreadIdTable::do_concurrent_work(jt);
 177     }
 178 
 179     if (protection_domain_table_work) {
 180       SystemDictionary::pd_cache_table()->unlink();
 181     }
 182 
 183     if (oopstorage_work) {
 184       cleanup_oopstorages();
 185     }




 186   }
 187 }
 188 
 189 bool ServiceThread::is_service_thread(Thread* thread) {
 190   return thread == _instance;
 191 }


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


 171       if(has_dcmd_notification_event) {
 172         DCmdFactory::send_notification(CHECK);
 173       }
 174     }
 175 
 176     if (resolved_method_table_work) {
 177       ResolvedMethodTable::do_concurrent_work(jt);
 178     }
 179 
 180     if (thread_id_table_work) {
 181       ThreadIdTable::do_concurrent_work(jt);
 182     }
 183 
 184     if (protection_domain_table_work) {
 185       SystemDictionary::pd_cache_table()->unlink();
 186     }
 187 
 188     if (oopstorage_work) {
 189       cleanup_oopstorages();
 190     }
 191 
 192     if (deflate_idle_monitors) {
 193       ObjectSynchronizer::deflate_idle_monitors_using_JT();
 194     }
 195   }
 196 }
 197 
 198 bool ServiceThread::is_service_thread(Thread* thread) {
 199   return thread == _instance;
 200 }
< prev index next >