< prev index next >

src/hotspot/share/runtime/synchronizer.hpp

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 56637 : Add OM_CACHE_LINE_SIZE so that ObjectMonitor cache line sizes can be experimented with independently of DEFAULT_CACHE_LINE_SIZE; for SPARC and X64 configs that use 128 for DEFAULT_CACHE_LINE_SIZE, we are experimenting with 64; move _previous_owner_tid and _allocation_state fields to share the cache line with ObjectMonitor::_header; put ObjectMonitor::_ref_count on its own cache line after _owner; add 'int* count_p' parameter to deflate_monitor_list() and deflate_monitor_list_using_JT() and push counter updates down to where the ObjectMonitors are actually removed from the in-use lists; monitors_iterate() async deflation check should use negative ref_count; add 'JavaThread* target' param to deflate_per_thread_idle_monitors_using_JT() add deflate_common_idle_monitors_using_JT() to make it clear which JavaThread* is the target of the work and which is the calling JavaThread* (self); g_free_list, g_om_in_use_list and g_om_in_use_count are now static to synchronizer.cpp (reduce scope); add more diagnostic info to some assert()'s; minor code cleanups and code motion; save_om_ptr() should detect a race with a deflating thread that is bailing out and cause a retry when the ref_count field is not positive; merge with jdk-14+11; add special GC support for TestHumongousClassLoader.java; merge with 8230184.patch; merge with jdk-14+14; 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().


 117 
 118   // Returns the identity hash value for an oop
 119   // NOTE: It may cause monitor inflation
 120   static intptr_t identity_hash_value_for(Handle obj);
 121   static intptr_t FastHashCode(Thread* self, oop obj);
 122 
 123   // java.lang.Thread support
 124   static bool current_thread_holds_lock(JavaThread* thread, Handle h_obj);
 125   static LockOwnership query_lock_ownership(JavaThread* self, Handle h_obj);
 126 
 127   static JavaThread* get_lock_owner(ThreadsList * t_list, Handle h_obj);
 128 
 129   // JNI detach support
 130   static void release_monitors_owned_by_thread(TRAPS);
 131   static void monitors_iterate(MonitorClosure* m);
 132 
 133   // GC: we current use aggressive monitor deflation policy
 134   // Basically we deflate all monitors that are not busy.
 135   // An adaptive profile-based deflation policy could be used if needed
 136   static void deflate_idle_monitors(DeflateMonitorCounters* counters);

 137   static void deflate_global_idle_monitors_using_JT();
 138   static void deflate_per_thread_idle_monitors_using_JT(JavaThread* target);
 139   static void deflate_common_idle_monitors_using_JT(bool is_global, JavaThread* target);
 140   static void deflate_thread_local_monitors(Thread* thread, DeflateMonitorCounters* counters);
 141   static void prepare_deflate_idle_monitors(DeflateMonitorCounters* counters);
 142   static void finish_deflate_idle_monitors(DeflateMonitorCounters* counters);
 143 
 144   // For a given monitor list: global or per-thread, deflate idle monitors
 145   static int deflate_monitor_list(ObjectMonitor* volatile * list_p,
 146                                   int volatile * count_p,
 147                                   ObjectMonitor** free_head_p,
 148                                   ObjectMonitor** free_tail_p);
 149   // For a given in-use monitor list: global or per-thread, deflate idle
 150   // monitors using a JavaThread.
 151   static int deflate_monitor_list_using_JT(ObjectMonitor* volatile * list_p,
 152                                            int volatile * count_p,
 153                                            ObjectMonitor** free_head_p,
 154                                            ObjectMonitor** free_tail_p,
 155                                            ObjectMonitor** saved_mid_in_use_p);
 156   static bool deflate_monitor(ObjectMonitor* mid, oop obj,


 159   static bool deflate_monitor_using_JT(ObjectMonitor* mid,
 160                                        ObjectMonitor** free_head_p,
 161                                        ObjectMonitor** free_tail_p);
 162   static bool is_async_deflation_needed();
 163   static bool is_safepoint_deflation_needed();
 164   static bool is_async_deflation_requested() { return _is_async_deflation_requested; }
 165   static bool is_special_deflation_requested() { return _is_special_deflation_requested; }
 166   static void set_is_async_deflation_requested(bool new_value) { _is_async_deflation_requested = new_value; }
 167   static void set_is_special_deflation_requested(bool new_value) { _is_special_deflation_requested = new_value; }
 168   static jlong time_since_last_async_deflation_ms();
 169   static void oops_do(OopClosure* f);
 170   // Process oops in thread local used monitors
 171   static void thread_local_used_oops_do(Thread* thread, OopClosure* f);
 172 
 173   // debugging
 174   static void audit_and_print_stats(bool on_exit);
 175   static void chk_free_entry(JavaThread* jt, ObjectMonitor* n,
 176                              outputStream * out, int *error_cnt_p);
 177   static void chk_global_free_list_and_count(outputStream * out,
 178                                              int *error_cnt_p);


 179   static void chk_global_in_use_list_and_count(outputStream * out,
 180                                                int *error_cnt_p);
 181   static void chk_in_use_entry(JavaThread* jt, ObjectMonitor* n,
 182                                outputStream * out, int *error_cnt_p);
 183   static void chk_per_thread_in_use_list_and_count(JavaThread *jt,
 184                                                    outputStream * out,
 185                                                    int *error_cnt_p);
 186   static void chk_per_thread_free_list_and_count(JavaThread *jt,
 187                                                  outputStream * out,
 188                                                  int *error_cnt_p);
 189   static void log_in_use_monitor_details(outputStream * out);
 190   static int  log_monitor_list_counts(outputStream * out);
 191   static int  verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
 192 
 193   static void do_safepoint_work(DeflateMonitorCounters* counters);
 194 
 195  private:
 196   friend class SynchronizerTest;
 197 
 198   enum { _BLOCKSIZE = 128 };




 117 
 118   // Returns the identity hash value for an oop
 119   // NOTE: It may cause monitor inflation
 120   static intptr_t identity_hash_value_for(Handle obj);
 121   static intptr_t FastHashCode(Thread* self, oop obj);
 122 
 123   // java.lang.Thread support
 124   static bool current_thread_holds_lock(JavaThread* thread, Handle h_obj);
 125   static LockOwnership query_lock_ownership(JavaThread* self, Handle h_obj);
 126 
 127   static JavaThread* get_lock_owner(ThreadsList * t_list, Handle h_obj);
 128 
 129   // JNI detach support
 130   static void release_monitors_owned_by_thread(TRAPS);
 131   static void monitors_iterate(MonitorClosure* m);
 132 
 133   // GC: we current use aggressive monitor deflation policy
 134   // Basically we deflate all monitors that are not busy.
 135   // An adaptive profile-based deflation policy could be used if needed
 136   static void deflate_idle_monitors(DeflateMonitorCounters* counters);
 137   static void deflate_idle_monitors_using_JT();
 138   static void deflate_global_idle_monitors_using_JT();
 139   static void deflate_per_thread_idle_monitors_using_JT(JavaThread* target);
 140   static void deflate_common_idle_monitors_using_JT(bool is_global, JavaThread* target);
 141   static void deflate_thread_local_monitors(Thread* thread, DeflateMonitorCounters* counters);
 142   static void prepare_deflate_idle_monitors(DeflateMonitorCounters* counters);
 143   static void finish_deflate_idle_monitors(DeflateMonitorCounters* counters);
 144 
 145   // For a given monitor list: global or per-thread, deflate idle monitors
 146   static int deflate_monitor_list(ObjectMonitor* volatile * list_p,
 147                                   int volatile * count_p,
 148                                   ObjectMonitor** free_head_p,
 149                                   ObjectMonitor** free_tail_p);
 150   // For a given in-use monitor list: global or per-thread, deflate idle
 151   // monitors using a JavaThread.
 152   static int deflate_monitor_list_using_JT(ObjectMonitor* volatile * list_p,
 153                                            int volatile * count_p,
 154                                            ObjectMonitor** free_head_p,
 155                                            ObjectMonitor** free_tail_p,
 156                                            ObjectMonitor** saved_mid_in_use_p);
 157   static bool deflate_monitor(ObjectMonitor* mid, oop obj,


 160   static bool deflate_monitor_using_JT(ObjectMonitor* mid,
 161                                        ObjectMonitor** free_head_p,
 162                                        ObjectMonitor** free_tail_p);
 163   static bool is_async_deflation_needed();
 164   static bool is_safepoint_deflation_needed();
 165   static bool is_async_deflation_requested() { return _is_async_deflation_requested; }
 166   static bool is_special_deflation_requested() { return _is_special_deflation_requested; }
 167   static void set_is_async_deflation_requested(bool new_value) { _is_async_deflation_requested = new_value; }
 168   static void set_is_special_deflation_requested(bool new_value) { _is_special_deflation_requested = new_value; }
 169   static jlong time_since_last_async_deflation_ms();
 170   static void oops_do(OopClosure* f);
 171   // Process oops in thread local used monitors
 172   static void thread_local_used_oops_do(Thread* thread, OopClosure* f);
 173 
 174   // debugging
 175   static void audit_and_print_stats(bool on_exit);
 176   static void chk_free_entry(JavaThread* jt, ObjectMonitor* n,
 177                              outputStream * out, int *error_cnt_p);
 178   static void chk_global_free_list_and_count(outputStream * out,
 179                                              int *error_cnt_p);
 180   static void chk_global_wait_list_and_count(outputStream * out,
 181                                              int *error_cnt_p);
 182   static void chk_global_in_use_list_and_count(outputStream * out,
 183                                                int *error_cnt_p);
 184   static void chk_in_use_entry(JavaThread* jt, ObjectMonitor* n,
 185                                outputStream * out, int *error_cnt_p);
 186   static void chk_per_thread_in_use_list_and_count(JavaThread *jt,
 187                                                    outputStream * out,
 188                                                    int *error_cnt_p);
 189   static void chk_per_thread_free_list_and_count(JavaThread *jt,
 190                                                  outputStream * out,
 191                                                  int *error_cnt_p);
 192   static void log_in_use_monitor_details(outputStream * out);
 193   static int  log_monitor_list_counts(outputStream * out);
 194   static int  verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
 195 
 196   static void do_safepoint_work(DeflateMonitorCounters* counters);
 197 
 198  private:
 199   friend class SynchronizerTest;
 200 
 201   enum { _BLOCKSIZE = 128 };


< prev index next >