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,
158 ObjectMonitor** free_head_p,
159 ObjectMonitor** free_tail_p);
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 needs_monitor_scavenge();
165 static bool is_safepoint_deflation_needed();
166 static bool is_async_deflation_requested() { return _is_async_deflation_requested; }
167 static bool is_special_deflation_requested() { return _is_special_deflation_requested; }
168 static void set_is_async_deflation_requested(bool new_value) { _is_async_deflation_requested = new_value; }
169 static void set_is_special_deflation_requested(bool new_value) { _is_special_deflation_requested = new_value; }
170 static jlong time_since_last_async_deflation_ms();
171 static void oops_do(OopClosure* f);
172 // Process oops in thread local used monitors
173 static void thread_local_used_oops_do(Thread* thread, OopClosure* f);
184 int *error_cnt_p);
185 static void chk_in_use_entry(JavaThread* jt, ObjectMonitor* n,
186 outputStream * out, int *error_cnt_p);
187 static void chk_per_thread_in_use_list_and_count(JavaThread *jt,
188 outputStream * out,
189 int *error_cnt_p);
190 static void chk_per_thread_free_list_and_count(JavaThread *jt,
191 outputStream * out,
192 int *error_cnt_p);
193 static void log_in_use_monitor_details(outputStream * out);
194 static int log_monitor_list_counts(outputStream * out);
195 static int verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
196
197 static void do_safepoint_work(DeflateMonitorCounters* counters);
198
199 private:
200 friend class SynchronizerTest;
201
202 enum { _BLOCKSIZE = 128 };
203 // global list of blocks of monitors
204 static PaddedObjectMonitor* volatile g_block_list;
205 static volatile bool _is_async_deflation_requested;
206 static volatile bool _is_special_deflation_requested;
207 static jlong _last_async_deflation_time_ns;
208
209 // Function to prepend new blocks to the appropriate lists:
210 static void prepend_block_to_lists(PaddedObjectMonitor* new_blk);
211
212 // Process oops in all global used monitors (i.e. moribund thread's monitors)
213 static void global_used_oops_do(OopClosure* f);
214 // Process oops in monitors on the given list
215 static void list_oops_do(ObjectMonitor* list, int count, OopClosure* f);
216
217 // Support for SynchronizerTest access to GVars fields:
218 static u_char* get_gvars_addr();
219 static u_char* get_gvars_hc_sequence_addr();
220 static size_t get_gvars_size();
221 static u_char* get_gvars_stw_random_addr();
222 };
223
224 // ObjectLocker enforces balanced locking and can never throw an
|
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** list_p,
147 int* 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** list_p,
153 int* 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,
158 ObjectMonitor** free_head_p,
159 ObjectMonitor** free_tail_p);
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 needs_monitor_scavenge();
165 static bool is_safepoint_deflation_needed();
166 static bool is_async_deflation_requested() { return _is_async_deflation_requested; }
167 static bool is_special_deflation_requested() { return _is_special_deflation_requested; }
168 static void set_is_async_deflation_requested(bool new_value) { _is_async_deflation_requested = new_value; }
169 static void set_is_special_deflation_requested(bool new_value) { _is_special_deflation_requested = new_value; }
170 static jlong time_since_last_async_deflation_ms();
171 static void oops_do(OopClosure* f);
172 // Process oops in thread local used monitors
173 static void thread_local_used_oops_do(Thread* thread, OopClosure* f);
184 int *error_cnt_p);
185 static void chk_in_use_entry(JavaThread* jt, ObjectMonitor* n,
186 outputStream * out, int *error_cnt_p);
187 static void chk_per_thread_in_use_list_and_count(JavaThread *jt,
188 outputStream * out,
189 int *error_cnt_p);
190 static void chk_per_thread_free_list_and_count(JavaThread *jt,
191 outputStream * out,
192 int *error_cnt_p);
193 static void log_in_use_monitor_details(outputStream * out);
194 static int log_monitor_list_counts(outputStream * out);
195 static int verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
196
197 static void do_safepoint_work(DeflateMonitorCounters* counters);
198
199 private:
200 friend class SynchronizerTest;
201
202 enum { _BLOCKSIZE = 128 };
203 // global list of blocks of monitors
204 static PaddedObjectMonitor* g_block_list;
205 static volatile bool _is_async_deflation_requested;
206 static volatile bool _is_special_deflation_requested;
207 static jlong _last_async_deflation_time_ns;
208
209 // Function to prepend new blocks to the appropriate lists:
210 static void prepend_block_to_lists(PaddedObjectMonitor* new_blk);
211
212 // Process oops in all global used monitors (i.e. moribund thread's monitors)
213 static void global_used_oops_do(OopClosure* f);
214 // Process oops in monitors on the given list
215 static void list_oops_do(ObjectMonitor* list, int count, OopClosure* f);
216
217 // Support for SynchronizerTest access to GVars fields:
218 static u_char* get_gvars_addr();
219 static u_char* get_gvars_hc_sequence_addr();
220 static size_t get_gvars_size();
221 static u_char* get_gvars_stw_random_addr();
222 };
223
224 // ObjectLocker enforces balanced locking and can never throw an
|