Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/thread.cpp @ 8002:8391fdd36e1f
Merge
author | dlong |
---|---|
date | Sun, 27 Jan 2013 01:07:09 -0800 |
parents | db9981fd3124 |
children | 3c9bc17b9403 |
comparison
equal
deleted
inserted
replaced
7946:6fbe8a57549d | 8002:8391fdd36e1f |
---|---|
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; |
1962 | 1963 |
1963 if (UseTLAB) { | 1964 if (UseTLAB) { |
1964 tlab().make_parsable(true); // retire TLAB, if any | 1965 tlab().make_parsable(true); // retire TLAB, if any |
1965 } | 1966 } |
1966 | 1967 |
1967 #ifndef SERIALGC | 1968 #if INCLUDE_ALL_GCS |
1968 if (UseG1GC) { | 1969 if (UseG1GC) { |
1969 flush_barrier_queues(); | 1970 flush_barrier_queues(); |
1970 } | 1971 } |
1971 #endif | 1972 #endif // INCLUDE_ALL_GCS |
1972 | 1973 |
1973 Threads::remove(this); | 1974 Threads::remove(this); |
1974 delete this; | 1975 delete this; |
1975 } | 1976 } |
1976 | 1977 |
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 |
4207 if (vmt->claim_oops_do(is_par, cp)) { | 4208 if (vmt->claim_oops_do(is_par, cp)) { |
4208 vmt->oops_do(f, cld_f, cf); | 4209 vmt->oops_do(f, cld_f, cf); |
4209 } | 4210 } |
4210 } | 4211 } |
4211 | 4212 |
4212 #ifndef SERIALGC | 4213 #if INCLUDE_ALL_GCS |
4213 // Used by ParallelScavenge | 4214 // Used by ParallelScavenge |
4214 void Threads::create_thread_roots_tasks(GCTaskQueue* q) { | 4215 void Threads::create_thread_roots_tasks(GCTaskQueue* q) { |
4215 ALL_JAVA_THREADS(p) { | 4216 ALL_JAVA_THREADS(p) { |
4216 q->enqueue(new ThreadRootsTask(p)); | 4217 q->enqueue(new ThreadRootsTask(p)); |
4217 } | 4218 } |
4223 ALL_JAVA_THREADS(p) { | 4224 ALL_JAVA_THREADS(p) { |
4224 q->enqueue(new ThreadRootsMarkingTask(p)); | 4225 q->enqueue(new ThreadRootsMarkingTask(p)); |
4225 } | 4226 } |
4226 q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread())); | 4227 q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread())); |
4227 } | 4228 } |
4228 #endif // SERIALGC | 4229 #endif // INCLUDE_ALL_GCS |
4229 | 4230 |
4230 void Threads::nmethods_do(CodeBlobClosure* cf) { | 4231 void Threads::nmethods_do(CodeBlobClosure* cf) { |
4231 ALL_JAVA_THREADS(p) { | 4232 ALL_JAVA_THREADS(p) { |
4232 p->nmethods_do(cf); | 4233 p->nmethods_do(cf); |
4233 } | 4234 } |
4331 Abstract_VM_Version::vm_release(), | 4332 Abstract_VM_Version::vm_release(), |
4332 Abstract_VM_Version::vm_info_string() | 4333 Abstract_VM_Version::vm_info_string() |
4333 ); | 4334 ); |
4334 st->cr(); | 4335 st->cr(); |
4335 | 4336 |
4336 #ifndef SERIALGC | 4337 #if INCLUDE_ALL_GCS |
4337 // Dump concurrent locks | 4338 // Dump concurrent locks |
4338 ConcurrentLocksDump concurrent_locks; | 4339 ConcurrentLocksDump concurrent_locks; |
4339 if (print_concurrent_locks) { | 4340 if (print_concurrent_locks) { |
4340 concurrent_locks.dump_at_safepoint(); | 4341 concurrent_locks.dump_at_safepoint(); |
4341 } | 4342 } |
4342 #endif // SERIALGC | 4343 #endif // INCLUDE_ALL_GCS |
4343 | 4344 |
4344 ALL_JAVA_THREADS(p) { | 4345 ALL_JAVA_THREADS(p) { |
4345 ResourceMark rm; | 4346 ResourceMark rm; |
4346 p->print_on(st); | 4347 p->print_on(st); |
4347 if (print_stacks) { | 4348 if (print_stacks) { |
4350 } else { | 4351 } else { |
4351 p->print_stack_on(st); | 4352 p->print_stack_on(st); |
4352 } | 4353 } |
4353 } | 4354 } |
4354 st->cr(); | 4355 st->cr(); |
4355 #ifndef SERIALGC | 4356 #if INCLUDE_ALL_GCS |
4356 if (print_concurrent_locks) { | 4357 if (print_concurrent_locks) { |
4357 concurrent_locks.print_locks_on(p, st); | 4358 concurrent_locks.print_locks_on(p, st); |
4358 } | 4359 } |
4359 #endif // SERIALGC | 4360 #endif // INCLUDE_ALL_GCS |
4360 } | 4361 } |
4361 | 4362 |
4362 VMThread::vm_thread()->print_on(st); | 4363 VMThread::vm_thread()->print_on(st); |
4363 st->cr(); | 4364 st->cr(); |
4364 Universe::heap()->print_gc_threads_on(st); | 4365 Universe::heap()->print_gc_threads_on(st); |