71 class CompileThread;
72 class CompileLog;
73 class CompileTask;
74 class CompileQueue;
75 class CompilerCounters;
76 class vframeArray;
77
78 class DeoptResourceMark;
79 class jvmtiDeferredLocalVariableSet;
80
81 class GCTaskQueue;
82 class ThreadClosure;
83 class IdealGraphPrinter;
84
85 class Metadata;
86 template <class T, MEMFLAGS F> class ChunkedList;
87 typedef ChunkedList<Metadata*, mtInternal> MetadataOnStackBuffer;
88
89 DEBUG_ONLY(class ResourceMark;)
90
91 class WorkerThread;
92
93 // Class hierarchy
94 // - Thread
95 // - NamedThread
96 // - VMThread
97 // - ConcurrentGCThread
98 // - WorkerThread
99 // - GangWorker
100 // - GCTaskThread
101 // - JavaThread
102 // - WatcherThread
103
104 class Thread: public ThreadShadow {
105 friend class VMStructs;
106 private:
107 // Exception handling
108 // (Note: _pending_exception and friends are in ThreadShadow)
109 //oop _pending_exception; // pending exception for current thread
110 // const char* _exception_file; // file information for exception (debugging only)
245 //
246 NOT_PRODUCT(int _allow_safepoint_count;) // If 0, thread allow a safepoint to happen
247 debug_only (int _allow_allocation_count;) // If 0, the thread is allowed to allocate oops.
248
249 // Used by SkipGCALot class.
250 NOT_PRODUCT(bool _skip_gcalot;) // Should we elide gc-a-lot?
251
252 friend class No_Alloc_Verifier;
253 friend class No_Safepoint_Verifier;
254 friend class Pause_No_Safepoint_Verifier;
255 friend class ThreadLocalStorage;
256 friend class GC_locker;
257
258 ThreadLocalAllocBuffer _tlab; // Thread-local eden
259 jlong _allocated_bytes; // Cumulative number of bytes allocated on
260 // the Java heap
261
262 // Thread-local buffer used by MetadataOnStackMark.
263 MetadataOnStackBuffer* _metadata_on_stack_buffer;
264
265 TRACE_DATA _trace_data; // Thread-local data for tracing
266
267 ThreadExt _ext;
268
269 int _vm_operation_started_count; // VM_Operation support
270 int _vm_operation_completed_count; // VM_Operation support
271
272 ObjectMonitor* _current_pending_monitor; // ObjectMonitor this thread
273 // is waiting to lock
274 bool _current_pending_monitor_is_from_java; // locking is from Java code
275
276 // ObjectMonitor on which this thread called Object.wait()
277 ObjectMonitor* _current_waiting_monitor;
278
279 // Private thread-local objectmonitor list - a simple cache organized as a SLL.
280 public:
281 ObjectMonitor* omFreeList;
282 int omFreeCount; // length of omFreeList
283 int omFreeProvision; // reload chunk size
284 ObjectMonitor* omInUseList; // SLL to track monitors in circulation
295
296 public:
297 enum {
298 is_definitely_current_thread = true
299 };
300
301 // Constructor
302 Thread();
303 virtual ~Thread();
304
305 // initializtion
306 void initialize_thread_local_storage();
307
308 // thread entry point
309 virtual void run();
310
311 // Testers
312 virtual bool is_VM_thread() const { return false; }
313 virtual bool is_Java_thread() const { return false; }
314 virtual bool is_Compiler_thread() const { return false; }
315 virtual bool is_hidden_from_external_view() const { return false; }
316 virtual bool is_jvmti_agent_thread() const { return false; }
317 // True iff the thread can perform GC operations at a safepoint.
318 // Generally will be true only of VM thread and parallel GC WorkGang
319 // threads.
320 virtual bool is_GC_task_thread() const { return false; }
321 virtual bool is_Watcher_thread() const { return false; }
322 virtual bool is_ConcurrentGC_thread() const { return false; }
323 virtual bool is_Named_thread() const { return false; }
324 virtual bool is_Worker_thread() const { return false; }
325
326 // Casts
327 virtual WorkerThread* as_Worker_thread() const { return NULL; }
328
329 virtual char* name() const { return (char*)"Unknown thread"; }
330
331 // Returns the current thread
332 static inline Thread* current();
333
334 // Common thread operations
425
426 // Internal handle support
427 HandleArea* handle_area() const { return _handle_area; }
428 void set_handle_area(HandleArea* area) { _handle_area = area; }
429
430 GrowableArray<Metadata*>* metadata_handles() const { return _metadata_handles; }
431 void set_metadata_handles(GrowableArray<Metadata*>* handles){ _metadata_handles = handles; }
432
433 // Thread-Local Allocation Buffer (TLAB) support
434 ThreadLocalAllocBuffer& tlab() { return _tlab; }
435 void initialize_tlab() {
436 if (UseTLAB) {
437 tlab().initialize();
438 }
439 }
440
441 jlong allocated_bytes() { return _allocated_bytes; }
442 void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
443 void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
444 inline jlong cooked_allocated_bytes();
445
446 TRACE_DATA* trace_data() { return &_trace_data; }
447
448 const ThreadExt& ext() const { return _ext; }
449 ThreadExt& ext() { return _ext; }
450
451 // VM operation support
452 int vm_operation_ticket() { return ++_vm_operation_started_count; }
453 int vm_operation_completed_count() { return _vm_operation_completed_count; }
454 void increment_vm_operation_completed_count() { _vm_operation_completed_count++; }
455
456 // For tracking the heavyweight monitor the thread is pending on.
457 ObjectMonitor* current_pending_monitor() {
458 return _current_pending_monitor;
459 }
460 void set_current_pending_monitor(ObjectMonitor* monitor) {
461 _current_pending_monitor = monitor;
462 }
463 void set_current_pending_monitor_is_from_java(bool from_java) {
464 _current_pending_monitor_is_from_java = from_java;
|
71 class CompileThread;
72 class CompileLog;
73 class CompileTask;
74 class CompileQueue;
75 class CompilerCounters;
76 class vframeArray;
77
78 class DeoptResourceMark;
79 class jvmtiDeferredLocalVariableSet;
80
81 class GCTaskQueue;
82 class ThreadClosure;
83 class IdealGraphPrinter;
84
85 class Metadata;
86 template <class T, MEMFLAGS F> class ChunkedList;
87 typedef ChunkedList<Metadata*, mtInternal> MetadataOnStackBuffer;
88
89 DEBUG_ONLY(class ResourceMark;)
90
91 class TraceBuffer;
92 class CachedTraceStack;
93
94 class WorkerThread;
95
96 // Class hierarchy
97 // - Thread
98 // - NamedThread
99 // - VMThread
100 // - ConcurrentGCThread
101 // - WorkerThread
102 // - GangWorker
103 // - GCTaskThread
104 // - JavaThread
105 // - WatcherThread
106
107 class Thread: public ThreadShadow {
108 friend class VMStructs;
109 private:
110 // Exception handling
111 // (Note: _pending_exception and friends are in ThreadShadow)
112 //oop _pending_exception; // pending exception for current thread
113 // const char* _exception_file; // file information for exception (debugging only)
248 //
249 NOT_PRODUCT(int _allow_safepoint_count;) // If 0, thread allow a safepoint to happen
250 debug_only (int _allow_allocation_count;) // If 0, the thread is allowed to allocate oops.
251
252 // Used by SkipGCALot class.
253 NOT_PRODUCT(bool _skip_gcalot;) // Should we elide gc-a-lot?
254
255 friend class No_Alloc_Verifier;
256 friend class No_Safepoint_Verifier;
257 friend class Pause_No_Safepoint_Verifier;
258 friend class ThreadLocalStorage;
259 friend class GC_locker;
260
261 ThreadLocalAllocBuffer _tlab; // Thread-local eden
262 jlong _allocated_bytes; // Cumulative number of bytes allocated on
263 // the Java heap
264
265 // Thread-local buffer used by MetadataOnStackMark.
266 MetadataOnStackBuffer* _metadata_on_stack_buffer;
267
268 TraceBuffer *_trace_buffer;
269 debug_only(bool _trace_active;)
270 intptr_t _park_last_global_seq;
271 int _park_priority;
272 int _nesting_level;
273 address _memento_original_return_address;
274 const CachedTraceStack* _memento_stack_trace;
275
276 TRACE_DATA _trace_data; // Thread-local data for tracing
277
278 ThreadExt _ext;
279
280 int _vm_operation_started_count; // VM_Operation support
281 int _vm_operation_completed_count; // VM_Operation support
282
283 ObjectMonitor* _current_pending_monitor; // ObjectMonitor this thread
284 // is waiting to lock
285 bool _current_pending_monitor_is_from_java; // locking is from Java code
286
287 // ObjectMonitor on which this thread called Object.wait()
288 ObjectMonitor* _current_waiting_monitor;
289
290 // Private thread-local objectmonitor list - a simple cache organized as a SLL.
291 public:
292 ObjectMonitor* omFreeList;
293 int omFreeCount; // length of omFreeList
294 int omFreeProvision; // reload chunk size
295 ObjectMonitor* omInUseList; // SLL to track monitors in circulation
306
307 public:
308 enum {
309 is_definitely_current_thread = true
310 };
311
312 // Constructor
313 Thread();
314 virtual ~Thread();
315
316 // initializtion
317 void initialize_thread_local_storage();
318
319 // thread entry point
320 virtual void run();
321
322 // Testers
323 virtual bool is_VM_thread() const { return false; }
324 virtual bool is_Java_thread() const { return false; }
325 virtual bool is_Compiler_thread() const { return false; }
326 virtual bool is_TraceReader_thread() const { return false; }
327 virtual bool is_hidden_from_external_view() const { return false; }
328 virtual bool is_jvmti_agent_thread() const { return false; }
329 // True iff the thread can perform GC operations at a safepoint.
330 // Generally will be true only of VM thread and parallel GC WorkGang
331 // threads.
332 virtual bool is_GC_task_thread() const { return false; }
333 virtual bool is_Watcher_thread() const { return false; }
334 virtual bool is_ConcurrentGC_thread() const { return false; }
335 virtual bool is_Named_thread() const { return false; }
336 virtual bool is_Worker_thread() const { return false; }
337
338 // Casts
339 virtual WorkerThread* as_Worker_thread() const { return NULL; }
340
341 virtual char* name() const { return (char*)"Unknown thread"; }
342
343 // Returns the current thread
344 static inline Thread* current();
345
346 // Common thread operations
437
438 // Internal handle support
439 HandleArea* handle_area() const { return _handle_area; }
440 void set_handle_area(HandleArea* area) { _handle_area = area; }
441
442 GrowableArray<Metadata*>* metadata_handles() const { return _metadata_handles; }
443 void set_metadata_handles(GrowableArray<Metadata*>* handles){ _metadata_handles = handles; }
444
445 // Thread-Local Allocation Buffer (TLAB) support
446 ThreadLocalAllocBuffer& tlab() { return _tlab; }
447 void initialize_tlab() {
448 if (UseTLAB) {
449 tlab().initialize();
450 }
451 }
452
453 jlong allocated_bytes() { return _allocated_bytes; }
454 void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
455 void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
456 inline jlong cooked_allocated_bytes();
457
458 TraceBuffer *trace_buffer() { return _trace_buffer; }
459 void set_trace_buffer(TraceBuffer *b) { _trace_buffer = b; }
460 DEBUG_ONLY(bool trace_active() { return _trace_active; })
461 DEBUG_ONLY(void toggle_trace_active() { _trace_active = !_trace_active; })
462 void set_park_last_global_seq(intptr_t seq) { _park_last_global_seq = seq; }
463 static ByteSize park_last_global_seq_offset() { return byte_offset_of(Thread, _park_last_global_seq); }
464 int park_priority() { return _park_priority; }
465 static ByteSize park_priority_offset() { return byte_offset_of(Thread, _park_priority); }
466 int nesting_level() { return _nesting_level; }
467 static ByteSize nesting_level_offset() { return byte_offset_of(Thread, _nesting_level); }
468 address& memento_original_return_address() { return _memento_original_return_address; }
469 static ByteSize memento_original_return_address_offset() { return byte_offset_of(Thread, _memento_original_return_address); }
470 const CachedTraceStack *memento_stack_trace() { return _memento_stack_trace; }
471 void set_memento_stack_trace(const CachedTraceStack *ts) { _memento_stack_trace = ts; }
472
473 TRACE_DATA* trace_data() { return &_trace_data; }
474
475 const ThreadExt& ext() const { return _ext; }
476 ThreadExt& ext() { return _ext; }
477
478 // VM operation support
479 int vm_operation_ticket() { return ++_vm_operation_started_count; }
480 int vm_operation_completed_count() { return _vm_operation_completed_count; }
481 void increment_vm_operation_completed_count() { _vm_operation_completed_count++; }
482
483 // For tracking the heavyweight monitor the thread is pending on.
484 ObjectMonitor* current_pending_monitor() {
485 return _current_pending_monitor;
486 }
487 void set_current_pending_monitor(ObjectMonitor* monitor) {
488 _current_pending_monitor = monitor;
489 }
490 void set_current_pending_monitor_is_from_java(bool from_java) {
491 _current_pending_monitor_is_from_java = from_java;
|