116
117 static bool quick_notify(oopDesc* obj, JavaThread* current, bool All);
118 static bool quick_enter(oop obj, BasicLock* Lock, JavaThread* current);
119
120 // Special internal-use-only method for use by JVM infrastructure
121 // that needs to wait() on a java-level object but that can't risk
122 // throwing unexpected InterruptedExecutionExceptions.
123 static void waitUninterruptibly(Handle obj, jlong Millis, TRAPS);
124
125 public:
126 static const char* inflate_cause_name(const InflateCause cause);
127
128 static ObjectMonitor* read_monitor(markWord mark);
129 static ObjectMonitor* read_monitor(Thread* current, oop obj);
130 static ObjectMonitor* read_monitor(Thread* current, oop obj, markWord mark);
131
132 // Returns the identity hash value for an oop
133 // NOTE: It may cause monitor inflation
134 static intptr_t FastHashCode(Thread* current, oop obj);
135
136 // java.lang.Thread support
137 static bool current_thread_holds_lock(JavaThread* current, Handle h_obj);
138
139 static JavaThread* get_lock_owner(ThreadsList * t_list, Handle h_obj);
140
141 // JNI detach support
142 static void release_monitors_owned_by_thread(JavaThread* current);
143
144 // Iterate over all ObjectMonitors.
145 template <typename Function>
146 static void monitors_iterate(Function function);
147
148 // Iterate ObjectMonitors owned by any thread and where the owner `filter`
149 // returns true.
150 template <typename OwnerFilter>
151 static void owned_monitors_iterate_filtered(MonitorClosure* closure, OwnerFilter filter);
152
153 // Iterate ObjectMonitors where the owner is thread; this does NOT include
154 // ObjectMonitors where the owner is anonymous.
155 static void owned_monitors_iterate(MonitorClosure* m, JavaThread* thread);
176 static void inc_in_use_list_ceiling();
177 static void set_in_use_list_ceiling(size_t new_value);
178 static bool is_async_deflation_needed();
179 static bool is_async_deflation_requested() { return _is_async_deflation_requested; }
180 static bool is_final_audit() { return _is_final_audit; }
181 static void set_is_final_audit() { _is_final_audit = true; }
182 static jlong last_async_deflation_time_ns() { return _last_async_deflation_time_ns; }
183 static void request_deflate_idle_monitors();
184 static bool request_deflate_idle_monitors_from_wb(); // for whitebox test support
185 static void set_is_async_deflation_requested(bool new_value) { _is_async_deflation_requested = new_value; }
186 static jlong time_since_last_async_deflation_ms();
187
188 // debugging
189 static void audit_and_print_stats(outputStream* out, bool on_exit);
190 static void chk_in_use_list(outputStream* out, int* error_cnt_p);
191 static void chk_in_use_entry(ObjectMonitor* n, outputStream* out,
192 int* error_cnt_p);
193 static void do_final_audit_and_print_stats();
194 static void log_in_use_monitor_details(outputStream* out, bool log_all);
195
196 private:
197 friend class SynchronizerTest;
198
199 static MonitorList _in_use_list;
200 static volatile bool _is_async_deflation_requested;
201 static volatile bool _is_final_audit;
202 static jlong _last_async_deflation_time_ns;
203
204 // Support for SynchronizerTest access to GVars fields:
205 static u_char* get_gvars_addr();
206 static u_char* get_gvars_hc_sequence_addr();
207 static size_t get_gvars_size();
208 static u_char* get_gvars_stw_random_addr();
209
210 static void handle_sync_on_value_based_class(Handle obj, JavaThread* locking_thread);
211
212 static ObjectMonitor* get_or_insert_monitor_from_table(oop object, JavaThread* current, bool* inserted);
213 static ObjectMonitor* get_or_insert_monitor(oop object, JavaThread* current, ObjectSynchronizer::InflateCause cause);
214
215 static ObjectMonitor* add_monitor(JavaThread* current, ObjectMonitor* monitor, oop obj);
|
116
117 static bool quick_notify(oopDesc* obj, JavaThread* current, bool All);
118 static bool quick_enter(oop obj, BasicLock* Lock, JavaThread* current);
119
120 // Special internal-use-only method for use by JVM infrastructure
121 // that needs to wait() on a java-level object but that can't risk
122 // throwing unexpected InterruptedExecutionExceptions.
123 static void waitUninterruptibly(Handle obj, jlong Millis, TRAPS);
124
125 public:
126 static const char* inflate_cause_name(const InflateCause cause);
127
128 static ObjectMonitor* read_monitor(markWord mark);
129 static ObjectMonitor* read_monitor(Thread* current, oop obj);
130 static ObjectMonitor* read_monitor(Thread* current, oop obj, markWord mark);
131
132 // Returns the identity hash value for an oop
133 // NOTE: It may cause monitor inflation
134 static intptr_t FastHashCode(Thread* current, oop obj);
135
136 // NOTE: May not cause monitor inflation
137 static uint32_t get_hash(markWord mark, oop obj);
138 // For CDS path.
139 static uint32_t get_hash(markWord mark, oop obj, Klass* klass);
140
141 // java.lang.Thread support
142 static bool current_thread_holds_lock(JavaThread* current, Handle h_obj);
143
144 static JavaThread* get_lock_owner(ThreadsList * t_list, Handle h_obj);
145
146 // JNI detach support
147 static void release_monitors_owned_by_thread(JavaThread* current);
148
149 // Iterate over all ObjectMonitors.
150 template <typename Function>
151 static void monitors_iterate(Function function);
152
153 // Iterate ObjectMonitors owned by any thread and where the owner `filter`
154 // returns true.
155 template <typename OwnerFilter>
156 static void owned_monitors_iterate_filtered(MonitorClosure* closure, OwnerFilter filter);
157
158 // Iterate ObjectMonitors where the owner is thread; this does NOT include
159 // ObjectMonitors where the owner is anonymous.
160 static void owned_monitors_iterate(MonitorClosure* m, JavaThread* thread);
181 static void inc_in_use_list_ceiling();
182 static void set_in_use_list_ceiling(size_t new_value);
183 static bool is_async_deflation_needed();
184 static bool is_async_deflation_requested() { return _is_async_deflation_requested; }
185 static bool is_final_audit() { return _is_final_audit; }
186 static void set_is_final_audit() { _is_final_audit = true; }
187 static jlong last_async_deflation_time_ns() { return _last_async_deflation_time_ns; }
188 static void request_deflate_idle_monitors();
189 static bool request_deflate_idle_monitors_from_wb(); // for whitebox test support
190 static void set_is_async_deflation_requested(bool new_value) { _is_async_deflation_requested = new_value; }
191 static jlong time_since_last_async_deflation_ms();
192
193 // debugging
194 static void audit_and_print_stats(outputStream* out, bool on_exit);
195 static void chk_in_use_list(outputStream* out, int* error_cnt_p);
196 static void chk_in_use_entry(ObjectMonitor* n, outputStream* out,
197 int* error_cnt_p);
198 static void do_final_audit_and_print_stats();
199 static void log_in_use_monitor_details(outputStream* out, bool log_all);
200
201 static intptr_t get_next_hash(Thread* current, oop obj);
202
203 private:
204 friend class SynchronizerTest;
205
206 static MonitorList _in_use_list;
207 static volatile bool _is_async_deflation_requested;
208 static volatile bool _is_final_audit;
209 static jlong _last_async_deflation_time_ns;
210
211 // Support for SynchronizerTest access to GVars fields:
212 static u_char* get_gvars_addr();
213 static u_char* get_gvars_hc_sequence_addr();
214 static size_t get_gvars_size();
215 static u_char* get_gvars_stw_random_addr();
216
217 static void handle_sync_on_value_based_class(Handle obj, JavaThread* locking_thread);
218
219 static ObjectMonitor* get_or_insert_monitor_from_table(oop object, JavaThread* current, bool* inserted);
220 static ObjectMonitor* get_or_insert_monitor(oop object, JavaThread* current, ObjectSynchronizer::InflateCause cause);
221
222 static ObjectMonitor* add_monitor(JavaThread* current, ObjectMonitor* monitor, oop obj);
|