179 // osThread.hpp).
180 //
181 // 2. It would be more natural if set_external_suspend() is private and
182 // part of java_suspend(), but that probably would affect the suspend/query
183 // performance. Need more investigation on this.
184 //
185
186 // suspend/resume lock: used for self-suspend
187 Monitor* _SR_lock;
188
189 protected:
190 enum SuspendFlags {
191 // NOTE: avoid using the sign-bit as cc generates different test code
192 // when the sign-bit is used, and sometimes incorrectly - see CR 6398077
193
194 _external_suspend = 0x20000000U, // thread is asked to self suspend
195 _ext_suspended = 0x40000000U, // thread has self-suspended
196 _deopt_suspend = 0x10000000U, // thread needs to self suspend for deopt
197
198 _has_async_exception = 0x00000001U, // there is a pending async exception
199 _critical_native_unlock = 0x00000002U // Must call back to unlock JNI critical lock
200 };
201
202 // various suspension related flags - atomically updated
203 // overloaded for async exception checking in check_special_condition_for_native_trans.
204 volatile uint32_t _suspend_flags;
205
206 private:
207 int _num_nested_signal;
208
209 public:
210 void enter_signal_handler() { _num_nested_signal++; }
211 void leave_signal_handler() { _num_nested_signal--; }
212 bool is_inside_signal_handler() const { return _num_nested_signal > 0; }
213
214 private:
215 // Debug tracing
216 static void trace(const char* msg, const Thread* const thread) PRODUCT_RETURN;
217
218 // Active_handles points to a block of handles
219 JNIHandleBlock* _active_handles;
426 HandleArea* handle_area() const { return _handle_area; }
427 void set_handle_area(HandleArea* area) { _handle_area = area; }
428
429 GrowableArray<Metadata*>* metadata_handles() const { return _metadata_handles; }
430 void set_metadata_handles(GrowableArray<Metadata*>* handles){ _metadata_handles = handles; }
431
432 // Thread-Local Allocation Buffer (TLAB) support
433 ThreadLocalAllocBuffer& tlab() { return _tlab; }
434 void initialize_tlab() {
435 if (UseTLAB) {
436 tlab().initialize();
437 }
438 }
439
440 jlong allocated_bytes() { return _allocated_bytes; }
441 void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
442 void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
443 inline jlong cooked_allocated_bytes();
444
445 JFR_ONLY(DEFINE_THREAD_LOCAL_ACCESSOR_JFR;)
446
447 const ThreadExt& ext() const { return _ext; }
448 ThreadExt& ext() { return _ext; }
449
450 // VM operation support
451 int vm_operation_ticket() { return ++_vm_operation_started_count; }
452 int vm_operation_completed_count() { return _vm_operation_completed_count; }
453 void increment_vm_operation_completed_count() { _vm_operation_completed_count++; }
454
455 // For tracking the heavyweight monitor the thread is pending on.
456 ObjectMonitor* current_pending_monitor() {
457 return _current_pending_monitor;
458 }
459 void set_current_pending_monitor(ObjectMonitor* monitor) {
460 _current_pending_monitor = monitor;
461 }
462 void set_current_pending_monitor_is_from_java(bool from_java) {
463 _current_pending_monitor_is_from_java = from_java;
464 }
465 bool current_pending_monitor_is_from_java() {
|
179 // osThread.hpp).
180 //
181 // 2. It would be more natural if set_external_suspend() is private and
182 // part of java_suspend(), but that probably would affect the suspend/query
183 // performance. Need more investigation on this.
184 //
185
186 // suspend/resume lock: used for self-suspend
187 Monitor* _SR_lock;
188
189 protected:
190 enum SuspendFlags {
191 // NOTE: avoid using the sign-bit as cc generates different test code
192 // when the sign-bit is used, and sometimes incorrectly - see CR 6398077
193
194 _external_suspend = 0x20000000U, // thread is asked to self suspend
195 _ext_suspended = 0x40000000U, // thread has self-suspended
196 _deopt_suspend = 0x10000000U, // thread needs to self suspend for deopt
197
198 _has_async_exception = 0x00000001U, // there is a pending async exception
199 _critical_native_unlock = 0x00000002U, // Must call back to unlock JNI critical lock
200
201 JFR_ONLY(_trace_flag = 0x00000004U) // call jfr tracing
202 };
203
204 // various suspension related flags - atomically updated
205 // overloaded for async exception checking in check_special_condition_for_native_trans.
206 volatile uint32_t _suspend_flags;
207
208 private:
209 int _num_nested_signal;
210
211 public:
212 void enter_signal_handler() { _num_nested_signal++; }
213 void leave_signal_handler() { _num_nested_signal--; }
214 bool is_inside_signal_handler() const { return _num_nested_signal > 0; }
215
216 private:
217 // Debug tracing
218 static void trace(const char* msg, const Thread* const thread) PRODUCT_RETURN;
219
220 // Active_handles points to a block of handles
221 JNIHandleBlock* _active_handles;
428 HandleArea* handle_area() const { return _handle_area; }
429 void set_handle_area(HandleArea* area) { _handle_area = area; }
430
431 GrowableArray<Metadata*>* metadata_handles() const { return _metadata_handles; }
432 void set_metadata_handles(GrowableArray<Metadata*>* handles){ _metadata_handles = handles; }
433
434 // Thread-Local Allocation Buffer (TLAB) support
435 ThreadLocalAllocBuffer& tlab() { return _tlab; }
436 void initialize_tlab() {
437 if (UseTLAB) {
438 tlab().initialize();
439 }
440 }
441
442 jlong allocated_bytes() { return _allocated_bytes; }
443 void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
444 void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
445 inline jlong cooked_allocated_bytes();
446
447 JFR_ONLY(DEFINE_THREAD_LOCAL_ACCESSOR_JFR;)
448 JFR_ONLY(DEFINE_TRACE_SUSPEND_FLAG_METHODS)
449
450 const ThreadExt& ext() const { return _ext; }
451 ThreadExt& ext() { return _ext; }
452
453 // VM operation support
454 int vm_operation_ticket() { return ++_vm_operation_started_count; }
455 int vm_operation_completed_count() { return _vm_operation_completed_count; }
456 void increment_vm_operation_completed_count() { _vm_operation_completed_count++; }
457
458 // For tracking the heavyweight monitor the thread is pending on.
459 ObjectMonitor* current_pending_monitor() {
460 return _current_pending_monitor;
461 }
462 void set_current_pending_monitor(ObjectMonitor* monitor) {
463 _current_pending_monitor = monitor;
464 }
465 void set_current_pending_monitor_is_from_java(bool from_java) {
466 _current_pending_monitor_is_from_java = from_java;
467 }
468 bool current_pending_monitor_is_from_java() {
|