80 #include "trace/traceEventTypes.hpp" |
80 #include "trace/traceEventTypes.hpp" |
81 #include "utilities/defaultStream.hpp" |
81 #include "utilities/defaultStream.hpp" |
82 #include "utilities/dtrace.hpp" |
82 #include "utilities/dtrace.hpp" |
83 #include "utilities/events.hpp" |
83 #include "utilities/events.hpp" |
84 #include "utilities/preserveException.hpp" |
84 #include "utilities/preserveException.hpp" |
|
85 #include "utilities/macros.hpp" |
85 #ifdef TARGET_OS_FAMILY_linux |
86 #ifdef TARGET_OS_FAMILY_linux |
86 # include "os_linux.inline.hpp" |
87 # include "os_linux.inline.hpp" |
87 #endif |
88 #endif |
88 #ifdef TARGET_OS_FAMILY_solaris |
89 #ifdef TARGET_OS_FAMILY_solaris |
89 # include "os_solaris.inline.hpp" |
90 # include "os_solaris.inline.hpp" |
92 # include "os_windows.inline.hpp" |
93 # include "os_windows.inline.hpp" |
93 #endif |
94 #endif |
94 #ifdef TARGET_OS_FAMILY_bsd |
95 #ifdef TARGET_OS_FAMILY_bsd |
95 # include "os_bsd.inline.hpp" |
96 # include "os_bsd.inline.hpp" |
96 #endif |
97 #endif |
97 #ifndef SERIALGC |
98 #if INCLUDE_ALL_GCS |
98 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp" |
99 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp" |
99 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp" |
100 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp" |
100 #include "gc_implementation/parallelScavenge/pcTasks.hpp" |
101 #include "gc_implementation/parallelScavenge/pcTasks.hpp" |
101 #endif |
102 #endif // INCLUDE_ALL_GCS |
102 #ifdef COMPILER1 |
103 #ifdef COMPILER1 |
103 #include "c1/c1_Compiler.hpp" |
104 #include "c1/c1_Compiler.hpp" |
104 #endif |
105 #endif |
105 #ifdef COMPILER2 |
106 #ifdef COMPILER2 |
106 #include "opto/c2compiler.hpp" |
107 #include "opto/c2compiler.hpp" |
1480 _popframe_preserved_args_size = 0; |
1481 _popframe_preserved_args_size = 0; |
1481 |
1482 |
1482 pd_initialize(); |
1483 pd_initialize(); |
1483 } |
1484 } |
1484 |
1485 |
1485 #ifndef SERIALGC |
1486 #if INCLUDE_ALL_GCS |
1486 SATBMarkQueueSet JavaThread::_satb_mark_queue_set; |
1487 SATBMarkQueueSet JavaThread::_satb_mark_queue_set; |
1487 DirtyCardQueueSet JavaThread::_dirty_card_queue_set; |
1488 DirtyCardQueueSet JavaThread::_dirty_card_queue_set; |
1488 #endif // !SERIALGC |
1489 #endif // INCLUDE_ALL_GCS |
1489 |
1490 |
1490 JavaThread::JavaThread(bool is_attaching_via_jni) : |
1491 JavaThread::JavaThread(bool is_attaching_via_jni) : |
1491 Thread() |
1492 Thread() |
1492 #ifndef SERIALGC |
1493 #if INCLUDE_ALL_GCS |
1493 , _satb_mark_queue(&_satb_mark_queue_set), |
1494 , _satb_mark_queue(&_satb_mark_queue_set), |
1494 _dirty_card_queue(&_dirty_card_queue_set) |
1495 _dirty_card_queue(&_dirty_card_queue_set) |
1495 #endif // !SERIALGC |
1496 #endif // INCLUDE_ALL_GCS |
1496 { |
1497 { |
1497 initialize(); |
1498 initialize(); |
1498 if (is_attaching_via_jni) { |
1499 if (is_attaching_via_jni) { |
1499 _jni_attach_state = _attaching_via_jni; |
1500 _jni_attach_state = _attaching_via_jni; |
1500 } else { |
1501 } else { |
1545 // Remove this ifdef when C1 is ported to the compiler interface. |
1546 // Remove this ifdef when C1 is ported to the compiler interface. |
1546 static void compiler_thread_entry(JavaThread* thread, TRAPS); |
1547 static void compiler_thread_entry(JavaThread* thread, TRAPS); |
1547 |
1548 |
1548 JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) : |
1549 JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) : |
1549 Thread() |
1550 Thread() |
1550 #ifndef SERIALGC |
1551 #if INCLUDE_ALL_GCS |
1551 , _satb_mark_queue(&_satb_mark_queue_set), |
1552 , _satb_mark_queue(&_satb_mark_queue_set), |
1552 _dirty_card_queue(&_dirty_card_queue_set) |
1553 _dirty_card_queue(&_dirty_card_queue_set) |
1553 #endif // !SERIALGC |
1554 #endif // INCLUDE_ALL_GCS |
1554 { |
1555 { |
1555 if (TraceThreadEvents) { |
1556 if (TraceThreadEvents) { |
1556 tty->print_cr("creating thread %p", this); |
1557 tty->print_cr("creating thread %p", this); |
1557 } |
1558 } |
1558 initialize(); |
1559 initialize(); |
1894 |
1895 |
1895 if (JvmtiEnv::environments_might_exist()) { |
1896 if (JvmtiEnv::environments_might_exist()) { |
1896 JvmtiExport::cleanup_thread(this); |
1897 JvmtiExport::cleanup_thread(this); |
1897 } |
1898 } |
1898 |
1899 |
1899 #ifndef SERIALGC |
1900 #if INCLUDE_ALL_GCS |
1900 // We must flush G1-related buffers before removing a thread from |
1901 // We must flush G1-related buffers before removing a thread from |
1901 // the list of active threads. |
1902 // the list of active threads. |
1902 if (UseG1GC) { |
1903 if (UseG1GC) { |
1903 flush_barrier_queues(); |
1904 flush_barrier_queues(); |
1904 } |
1905 } |
1905 #endif |
1906 #endif // INCLUDE_ALL_GCS |
1906 |
1907 |
1907 // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread |
1908 // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread |
1908 Threads::remove(this); |
1909 Threads::remove(this); |
1909 } |
1910 } |
1910 |
1911 |
1911 #ifndef SERIALGC |
1912 #if INCLUDE_ALL_GCS |
1912 // Flush G1-related queues. |
1913 // Flush G1-related queues. |
1913 void JavaThread::flush_barrier_queues() { |
1914 void JavaThread::flush_barrier_queues() { |
1914 satb_mark_queue().flush(); |
1915 satb_mark_queue().flush(); |
1915 dirty_card_queue().flush(); |
1916 dirty_card_queue().flush(); |
1916 } |
1917 } |
1934 DirtyCardQueue& dirty_queue = dirty_card_queue(); |
1935 DirtyCardQueue& dirty_queue = dirty_card_queue(); |
1935 // The dirty card queue should have been constructed with its |
1936 // The dirty card queue should have been constructed with its |
1936 // active field set to true. |
1937 // active field set to true. |
1937 assert(dirty_queue.is_active(), "dirty card queue should be active"); |
1938 assert(dirty_queue.is_active(), "dirty card queue should be active"); |
1938 } |
1939 } |
1939 #endif // !SERIALGC |
1940 #endif // INCLUDE_ALL_GCS |
1940 |
1941 |
1941 void JavaThread::cleanup_failed_attach_current_thread() { |
1942 void JavaThread::cleanup_failed_attach_current_thread() { |
1942 if (get_thread_profiler() != NULL) { |
1943 if (get_thread_profiler() != NULL) { |
1943 get_thread_profiler()->disengage(); |
1944 get_thread_profiler()->disengage(); |
1944 ResourceMark rm; |
1945 ResourceMark rm; |
3598 SystemDictionary::compute_java_system_loader(THREAD); |
3599 SystemDictionary::compute_java_system_loader(THREAD); |
3599 if (HAS_PENDING_EXCEPTION) { |
3600 if (HAS_PENDING_EXCEPTION) { |
3600 vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION)); |
3601 vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION)); |
3601 } |
3602 } |
3602 |
3603 |
3603 #ifndef SERIALGC |
3604 #if INCLUDE_ALL_GCS |
3604 // Support for ConcurrentMarkSweep. This should be cleaned up |
3605 // Support for ConcurrentMarkSweep. This should be cleaned up |
3605 // and better encapsulated. The ugly nested if test would go away |
3606 // and better encapsulated. The ugly nested if test would go away |
3606 // once things are properly refactored. XXX YSR |
3607 // once things are properly refactored. XXX YSR |
3607 if (UseConcMarkSweepGC || UseG1GC) { |
3608 if (UseConcMarkSweepGC || UseG1GC) { |
3608 if (UseConcMarkSweepGC) { |
3609 if (UseConcMarkSweepGC) { |
3612 } |
3613 } |
3613 if (HAS_PENDING_EXCEPTION) { |
3614 if (HAS_PENDING_EXCEPTION) { |
3614 vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION)); |
3615 vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION)); |
3615 } |
3616 } |
3616 } |
3617 } |
3617 #endif // SERIALGC |
3618 #endif // INCLUDE_ALL_GCS |
3618 |
3619 |
3619 // Always call even when there are not JVMTI environments yet, since environments |
3620 // Always call even when there are not JVMTI environments yet, since environments |
3620 // may be attached late and JVMTI must track phases of VM execution |
3621 // may be attached late and JVMTI must track phases of VM execution |
3621 JvmtiExport::enter_live_phase(); |
3622 JvmtiExport::enter_live_phase(); |
3622 |
3623 |
4185 if (vmt->claim_oops_do(is_par, cp)) { |
4186 if (vmt->claim_oops_do(is_par, cp)) { |
4186 vmt->oops_do(f, cld_f, cf); |
4187 vmt->oops_do(f, cld_f, cf); |
4187 } |
4188 } |
4188 } |
4189 } |
4189 |
4190 |
4190 #ifndef SERIALGC |
4191 #if INCLUDE_ALL_GCS |
4191 // Used by ParallelScavenge |
4192 // Used by ParallelScavenge |
4192 void Threads::create_thread_roots_tasks(GCTaskQueue* q) { |
4193 void Threads::create_thread_roots_tasks(GCTaskQueue* q) { |
4193 ALL_JAVA_THREADS(p) { |
4194 ALL_JAVA_THREADS(p) { |
4194 q->enqueue(new ThreadRootsTask(p)); |
4195 q->enqueue(new ThreadRootsTask(p)); |
4195 } |
4196 } |
4201 ALL_JAVA_THREADS(p) { |
4202 ALL_JAVA_THREADS(p) { |
4202 q->enqueue(new ThreadRootsMarkingTask(p)); |
4203 q->enqueue(new ThreadRootsMarkingTask(p)); |
4203 } |
4204 } |
4204 q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread())); |
4205 q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread())); |
4205 } |
4206 } |
4206 #endif // SERIALGC |
4207 #endif // INCLUDE_ALL_GCS |
4207 |
4208 |
4208 void Threads::nmethods_do(CodeBlobClosure* cf) { |
4209 void Threads::nmethods_do(CodeBlobClosure* cf) { |
4209 ALL_JAVA_THREADS(p) { |
4210 ALL_JAVA_THREADS(p) { |
4210 p->nmethods_do(cf); |
4211 p->nmethods_do(cf); |
4211 } |
4212 } |
4309 Abstract_VM_Version::vm_release(), |
4310 Abstract_VM_Version::vm_release(), |
4310 Abstract_VM_Version::vm_info_string() |
4311 Abstract_VM_Version::vm_info_string() |
4311 ); |
4312 ); |
4312 st->cr(); |
4313 st->cr(); |
4313 |
4314 |
4314 #ifndef SERIALGC |
4315 #if INCLUDE_ALL_GCS |
4315 // Dump concurrent locks |
4316 // Dump concurrent locks |
4316 ConcurrentLocksDump concurrent_locks; |
4317 ConcurrentLocksDump concurrent_locks; |
4317 if (print_concurrent_locks) { |
4318 if (print_concurrent_locks) { |
4318 concurrent_locks.dump_at_safepoint(); |
4319 concurrent_locks.dump_at_safepoint(); |
4319 } |
4320 } |
4320 #endif // SERIALGC |
4321 #endif // INCLUDE_ALL_GCS |
4321 |
4322 |
4322 ALL_JAVA_THREADS(p) { |
4323 ALL_JAVA_THREADS(p) { |
4323 ResourceMark rm; |
4324 ResourceMark rm; |
4324 p->print_on(st); |
4325 p->print_on(st); |
4325 if (print_stacks) { |
4326 if (print_stacks) { |
4328 } else { |
4329 } else { |
4329 p->print_stack_on(st); |
4330 p->print_stack_on(st); |
4330 } |
4331 } |
4331 } |
4332 } |
4332 st->cr(); |
4333 st->cr(); |
4333 #ifndef SERIALGC |
4334 #if INCLUDE_ALL_GCS |
4334 if (print_concurrent_locks) { |
4335 if (print_concurrent_locks) { |
4335 concurrent_locks.print_locks_on(p, st); |
4336 concurrent_locks.print_locks_on(p, st); |
4336 } |
4337 } |
4337 #endif // SERIALGC |
4338 #endif // INCLUDE_ALL_GCS |
4338 } |
4339 } |
4339 |
4340 |
4340 VMThread::vm_thread()->print_on(st); |
4341 VMThread::vm_thread()->print_on(st); |
4341 st->cr(); |
4342 st->cr(); |
4342 Universe::heap()->print_gc_threads_on(st); |
4343 Universe::heap()->print_gc_threads_on(st); |