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 };
|