144 static int deflate_monitor_list(ObjectMonitor** list_p,
145 int* count_p,
146 ObjectMonitor** free_head_p,
147 ObjectMonitor** free_tail_p);
148 // For a given in-use monitor list: global or per-thread, deflate idle
149 // monitors using a JavaThread.
150 static int deflate_monitor_list_using_JT(ObjectMonitor** list_p,
151 int* count_p,
152 ObjectMonitor** free_head_p,
153 ObjectMonitor** free_tail_p,
154 ObjectMonitor** saved_mid_in_use_p);
155 static bool deflate_monitor(ObjectMonitor* mid, oop obj,
156 ObjectMonitor** free_head_p,
157 ObjectMonitor** free_tail_p);
158 static bool deflate_monitor_using_JT(ObjectMonitor* mid,
159 ObjectMonitor** free_head_p,
160 ObjectMonitor** free_tail_p);
161 static bool is_async_deflation_needed();
162 static bool is_safepoint_deflation_needed();
163 static bool is_async_deflation_requested() { return _is_async_deflation_requested; }
164 static bool is_special_deflation_requested() { return _is_special_deflation_requested; }
165 static void set_is_async_deflation_requested(bool new_value) { _is_async_deflation_requested = new_value; }
166 static void set_is_special_deflation_requested(bool new_value) { _is_special_deflation_requested = new_value; }
167 static jlong time_since_last_async_deflation_ms();
168 static void oops_do(OopClosure* f);
169 // Process oops in thread local used monitors
170 static void thread_local_used_oops_do(Thread* thread, OopClosure* f);
171
172 // debugging
173 static void audit_and_print_stats(bool on_exit);
174 static void chk_free_entry(JavaThread* jt, ObjectMonitor* n,
175 outputStream * out, int *error_cnt_p);
176 static void chk_global_free_list_and_count(outputStream * out,
177 int *error_cnt_p);
178 static void chk_global_wait_list_and_count(outputStream * out,
179 int *error_cnt_p);
180 static void chk_global_in_use_list_and_count(outputStream * out,
181 int *error_cnt_p);
182 static void chk_in_use_entry(JavaThread* jt, ObjectMonitor* n,
183 outputStream * out, int *error_cnt_p);
184 static void chk_per_thread_in_use_list_and_count(JavaThread *jt,
185 outputStream * out,
186 int *error_cnt_p);
187 static void chk_per_thread_free_list_and_count(JavaThread *jt,
188 outputStream * out,
189 int *error_cnt_p);
190 static void log_in_use_monitor_details(outputStream * out);
191 static int log_monitor_list_counts(outputStream * out);
192 static int verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
193
194 static void do_safepoint_work(DeflateMonitorCounters* counters);
195
196 private:
197 friend class SynchronizerTest;
198
199 enum { _BLOCKSIZE = 128 };
200 // global list of blocks of monitors
201 static PaddedObjectMonitor* g_block_list;
202 static volatile bool _is_async_deflation_requested;
203 static volatile bool _is_special_deflation_requested;
204 static jlong _last_async_deflation_time_ns;
205
206 // Function to prepend new blocks to the appropriate lists:
207 static void prepend_block_to_lists(PaddedObjectMonitor* new_blk);
208
209 // Process oops in all global used monitors (i.e. moribund thread's monitors)
210 static void global_used_oops_do(OopClosure* f);
211 // Process oops in monitors on the given list
212 static void list_oops_do(ObjectMonitor* list, OopClosure* f);
213
214 // Support for SynchronizerTest access to GVars fields:
215 static u_char* get_gvars_addr();
216 static u_char* get_gvars_hc_sequence_addr();
217 static size_t get_gvars_size();
218 static u_char* get_gvars_stw_random_addr();
219 };
220
221 // ObjectLocker enforces balanced locking and can never throw an
222 // IllegalMonitorStateException. However, a pending exception may
223 // have to pass through, and we must also be able to deal with
|
144 static int deflate_monitor_list(ObjectMonitor** list_p,
145 int* count_p,
146 ObjectMonitor** free_head_p,
147 ObjectMonitor** free_tail_p);
148 // For a given in-use monitor list: global or per-thread, deflate idle
149 // monitors using a JavaThread.
150 static int deflate_monitor_list_using_JT(ObjectMonitor** list_p,
151 int* count_p,
152 ObjectMonitor** free_head_p,
153 ObjectMonitor** free_tail_p,
154 ObjectMonitor** saved_mid_in_use_p);
155 static bool deflate_monitor(ObjectMonitor* mid, oop obj,
156 ObjectMonitor** free_head_p,
157 ObjectMonitor** free_tail_p);
158 static bool deflate_monitor_using_JT(ObjectMonitor* mid,
159 ObjectMonitor** free_head_p,
160 ObjectMonitor** free_tail_p);
161 static bool is_async_deflation_needed();
162 static bool is_safepoint_deflation_needed();
163 static bool is_async_deflation_requested() { return _is_async_deflation_requested; }
164 static jlong last_async_deflation_time_ns() { return _last_async_deflation_time_ns; }
165 static bool request_deflate_idle_monitors(); // for whitebox test support and VM exit logging
166 static void set_is_async_deflation_requested(bool new_value) { _is_async_deflation_requested = new_value; }
167 static jlong time_since_last_async_deflation_ms();
168 static void oops_do(OopClosure* f);
169 // Process oops in thread local used monitors
170 static void thread_local_used_oops_do(Thread* thread, OopClosure* f);
171
172 // debugging
173 static void audit_and_print_stats(bool on_exit);
174 static void chk_free_entry(JavaThread* jt, ObjectMonitor* n,
175 outputStream * out, int *error_cnt_p);
176 static void chk_global_free_list_and_count(outputStream * out,
177 int *error_cnt_p);
178 static void chk_global_wait_list_and_count(outputStream * out,
179 int *error_cnt_p);
180 static void chk_global_in_use_list_and_count(outputStream * out,
181 int *error_cnt_p);
182 static void chk_in_use_entry(JavaThread* jt, ObjectMonitor* n,
183 outputStream * out, int *error_cnt_p);
184 static void chk_per_thread_in_use_list_and_count(JavaThread *jt,
185 outputStream * out,
186 int *error_cnt_p);
187 static void chk_per_thread_free_list_and_count(JavaThread *jt,
188 outputStream * out,
189 int *error_cnt_p);
190 static void log_in_use_monitor_details(outputStream * out);
191 static int log_monitor_list_counts(outputStream * out);
192 static int verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
193
194 static void do_safepoint_work(DeflateMonitorCounters* counters);
195
196 private:
197 friend class SynchronizerTest;
198
199 enum { _BLOCKSIZE = 128 };
200 // global list of blocks of monitors
201 static PaddedObjectMonitor* g_block_list;
202 static volatile bool _is_async_deflation_requested;
203 static jlong _last_async_deflation_time_ns;
204
205 // Function to prepend new blocks to the appropriate lists:
206 static void prepend_block_to_lists(PaddedObjectMonitor* new_blk);
207
208 // Process oops in all global used monitors (i.e. moribund thread's monitors)
209 static void global_used_oops_do(OopClosure* f);
210 // Process oops in monitors on the given list
211 static void list_oops_do(ObjectMonitor* list, OopClosure* f);
212
213 // Support for SynchronizerTest access to GVars fields:
214 static u_char* get_gvars_addr();
215 static u_char* get_gvars_hc_sequence_addr();
216 static size_t get_gvars_size();
217 static u_char* get_gvars_stw_random_addr();
218 };
219
220 // ObjectLocker enforces balanced locking and can never throw an
221 // IllegalMonitorStateException. However, a pending exception may
222 // have to pass through, and we must also be able to deal with
|