Mercurial > hg > truffle
comparison src/share/vm/runtime/thread.cpp @ 7212:291ffc492eb6
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 14 Dec 2012 14:35:13 +0100 |
parents | 1baf7f1e3f23 d2f8c38e543d |
children | 989155e2d07a |
comparison
equal
deleted
inserted
replaced
7163:2ed8d74e5984 | 7212:291ffc492eb6 |
---|---|
66 #include "runtime/safepoint.hpp" | 66 #include "runtime/safepoint.hpp" |
67 #include "runtime/sharedRuntime.hpp" | 67 #include "runtime/sharedRuntime.hpp" |
68 #include "runtime/statSampler.hpp" | 68 #include "runtime/statSampler.hpp" |
69 #include "runtime/stubRoutines.hpp" | 69 #include "runtime/stubRoutines.hpp" |
70 #include "runtime/task.hpp" | 70 #include "runtime/task.hpp" |
71 #include "runtime/thread.inline.hpp" | |
71 #include "runtime/threadCritical.hpp" | 72 #include "runtime/threadCritical.hpp" |
72 #include "runtime/threadLocalStorage.hpp" | 73 #include "runtime/threadLocalStorage.hpp" |
73 #include "runtime/vframe.hpp" | 74 #include "runtime/vframe.hpp" |
74 #include "runtime/vframeArray.hpp" | 75 #include "runtime/vframeArray.hpp" |
75 #include "runtime/vframe_hp.hpp" | 76 #include "runtime/vframe_hp.hpp" |
84 #include "utilities/dtrace.hpp" | 85 #include "utilities/dtrace.hpp" |
85 #include "utilities/events.hpp" | 86 #include "utilities/events.hpp" |
86 #include "utilities/preserveException.hpp" | 87 #include "utilities/preserveException.hpp" |
87 #ifdef TARGET_OS_FAMILY_linux | 88 #ifdef TARGET_OS_FAMILY_linux |
88 # include "os_linux.inline.hpp" | 89 # include "os_linux.inline.hpp" |
89 # include "thread_linux.inline.hpp" | |
90 #endif | 90 #endif |
91 #ifdef TARGET_OS_FAMILY_solaris | 91 #ifdef TARGET_OS_FAMILY_solaris |
92 # include "os_solaris.inline.hpp" | 92 # include "os_solaris.inline.hpp" |
93 # include "thread_solaris.inline.hpp" | |
94 #endif | 93 #endif |
95 #ifdef TARGET_OS_FAMILY_windows | 94 #ifdef TARGET_OS_FAMILY_windows |
96 # include "os_windows.inline.hpp" | 95 # include "os_windows.inline.hpp" |
97 # include "thread_windows.inline.hpp" | |
98 #endif | 96 #endif |
99 #ifdef TARGET_OS_FAMILY_bsd | 97 #ifdef TARGET_OS_FAMILY_bsd |
100 # include "os_bsd.inline.hpp" | 98 # include "os_bsd.inline.hpp" |
101 # include "thread_bsd.inline.hpp" | |
102 #endif | 99 #endif |
103 #ifndef SERIALGC | 100 #ifndef SERIALGC |
104 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp" | 101 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp" |
105 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp" | 102 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp" |
106 #include "gc_implementation/parallelScavenge/pcTasks.hpp" | 103 #include "gc_implementation/parallelScavenge/pcTasks.hpp" |
827 assert(SharedHeap::heap()->workers()->active_workers() > 0, | 824 assert(SharedHeap::heap()->workers()->active_workers() > 0, |
828 "Should only fail when parallel."); | 825 "Should only fail when parallel."); |
829 return false; | 826 return false; |
830 } | 827 } |
831 | 828 |
832 void Thread::oops_do(OopClosure* f, CodeBlobClosure* cf) { | 829 void Thread::oops_do(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf) { |
833 active_handles()->oops_do(f); | 830 active_handles()->oops_do(f); |
834 // Do oop for ThreadShadow | 831 // Do oop for ThreadShadow |
835 f->do_oop((oop*)&_pending_exception); | 832 f->do_oop((oop*)&_pending_exception); |
836 handle_area()->oops_do(f); | 833 handle_area()->oops_do(f); |
837 } | 834 } |
2719 _cur_thr->set_processed_thread(NULL); | 2716 _cur_thr->set_processed_thread(NULL); |
2720 } | 2717 } |
2721 } | 2718 } |
2722 }; | 2719 }; |
2723 | 2720 |
2724 void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { | 2721 void JavaThread::oops_do(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf) { |
2725 // Verify that the deferred card marks have been flushed. | 2722 // Verify that the deferred card marks have been flushed. |
2726 assert(deferred_card_mark().is_empty(), "Should be empty during GC"); | 2723 assert(deferred_card_mark().is_empty(), "Should be empty during GC"); |
2727 | 2724 |
2728 // The ThreadProfiler oops_do is done from FlatProfiler::oops_do | 2725 // The ThreadProfiler oops_do is done from FlatProfiler::oops_do |
2729 // since there may be more than one thread using each ThreadProfiler. | 2726 // since there may be more than one thread using each ThreadProfiler. |
2730 | 2727 |
2731 // Traverse the GCHandles | 2728 // Traverse the GCHandles |
2732 Thread::oops_do(f, cf); | 2729 Thread::oops_do(f, cld_f, cf); |
2733 | 2730 |
2734 assert( (!has_last_Java_frame() && java_call_counter() == 0) || | 2731 assert( (!has_last_Java_frame() && java_call_counter() == 0) || |
2735 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); | 2732 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); |
2736 | 2733 |
2737 if (has_last_Java_frame()) { | 2734 if (has_last_Java_frame()) { |
2755 chunk->oops_do(f); | 2752 chunk->oops_do(f); |
2756 } | 2753 } |
2757 | 2754 |
2758 // Traverse the execution stack | 2755 // Traverse the execution stack |
2759 for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { | 2756 for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { |
2760 fst.current()->oops_do(f, cf, fst.register_map()); | 2757 fst.current()->oops_do(f, cld_f, cf, fst.register_map()); |
2761 } | 2758 } |
2762 } | 2759 } |
2763 | 2760 |
2764 // callee_target is never live across a gc point so NULL it here should | 2761 // callee_target is never live across a gc point so NULL it here should |
2765 // it still contain a methdOop. | 2762 // it still contain a methdOop. |
2789 if (jvmti_thread_state() != NULL) { | 2786 if (jvmti_thread_state() != NULL) { |
2790 jvmti_thread_state()->oops_do(f); | 2787 jvmti_thread_state()->oops_do(f); |
2791 } | 2788 } |
2792 | 2789 |
2793 if (_scanned_nmethod != NULL && cf != NULL) { | 2790 if (_scanned_nmethod != NULL && cf != NULL) { |
2794 // Safepoints can occur when the sweeper is scanning an nmethod so | 2791 // Safepoints can occur when the sweeper is scanning an nmethod so |
2795 // process it here to make sure it isn't unloaded in the middle of | 2792 // process it here to make sure it isn't unloaded in the middle of |
2796 // a scan. | 2793 // a scan. |
2797 cf->do_code_blob(_scanned_nmethod); | 2794 cf->do_code_blob(_scanned_nmethod); |
2798 } | 2795 } |
2799 } | 2796 } |
2800 | 2797 |
2801 void JavaThread::nmethods_do(CodeBlobClosure* cf) { | 2798 void JavaThread::nmethods_do(CodeBlobClosure* cf) { |
2802 Thread::nmethods_do(cf); // (super method is a no-op) | 2799 Thread::nmethods_do(cf); // (super method is a no-op) |
2803 | 2800 |
2899 | 2896 |
2900 static void frame_verify(frame* f, const RegisterMap *map) { f->verify(map); } | 2897 static void frame_verify(frame* f, const RegisterMap *map) { f->verify(map); } |
2901 | 2898 |
2902 void JavaThread::verify() { | 2899 void JavaThread::verify() { |
2903 // Verify oops in the thread. | 2900 // Verify oops in the thread. |
2904 oops_do(&VerifyOopClosure::verify_oop, NULL); | 2901 oops_do(&VerifyOopClosure::verify_oop, NULL, NULL); |
2905 | 2902 |
2906 // Verify the stack frames. | 2903 // Verify the stack frames. |
2907 frames_do(frame_verify); | 2904 frames_do(frame_verify); |
2908 } | 2905 } |
2909 | 2906 |
3149 | 3146 |
3150 | 3147 |
3151 static void oops_print(frame* f, const RegisterMap *map) { | 3148 static void oops_print(frame* f, const RegisterMap *map) { |
3152 PrintAndVerifyOopClosure print; | 3149 PrintAndVerifyOopClosure print; |
3153 f->print_value(); | 3150 f->print_value(); |
3154 f->oops_do(&print, NULL, (RegisterMap*)map); | 3151 f->oops_do(&print, NULL, NULL, (RegisterMap*)map); |
3155 } | 3152 } |
3156 | 3153 |
3157 // Print our all the locations that contain oops and whether they are | 3154 // Print our all the locations that contain oops and whether they are |
3158 // valid or not. This useful when trying to find the oldest frame | 3155 // valid or not. This useful when trying to find the oldest frame |
3159 // where an oop has gone bad since the frame walk is from youngest to | 3156 // where an oop has gone bad since the frame walk is from youngest to |
3344 TraceTime timer("Create VM", TraceStartupTime); | 3341 TraceTime timer("Create VM", TraceStartupTime); |
3345 | 3342 |
3346 // Initialize the os module after parsing the args | 3343 // Initialize the os module after parsing the args |
3347 jint os_init_2_result = os::init_2(); | 3344 jint os_init_2_result = os::init_2(); |
3348 if (os_init_2_result != JNI_OK) return os_init_2_result; | 3345 if (os_init_2_result != JNI_OK) return os_init_2_result; |
3346 | |
3347 jint adjust_after_os_result = Arguments::adjust_after_os(); | |
3348 if (adjust_after_os_result != JNI_OK) return adjust_after_os_result; | |
3349 | 3349 |
3350 // intialize TLS | 3350 // intialize TLS |
3351 ThreadLocalStorage::init(); | 3351 ThreadLocalStorage::init(); |
3352 | 3352 |
3353 // Bootstrap native memory tracking, so it can start recording memory | 3353 // Bootstrap native memory tracking, so it can start recording memory |
3678 if (CleanChunkPoolAsync) { | 3678 if (CleanChunkPoolAsync) { |
3679 Chunk::start_chunk_pool_cleaner_task(); | 3679 Chunk::start_chunk_pool_cleaner_task(); |
3680 } | 3680 } |
3681 | 3681 |
3682 // initialize compiler(s) | 3682 // initialize compiler(s) |
3683 #if defined(COMPILER1) || defined(COMPILER2) || defined(GRAAL) | 3683 #if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) || defined(GRAALVM) |
3684 CompileBroker::compilation_init(); | 3684 CompileBroker::compilation_init(); |
3685 #endif | 3685 #endif |
3686 | 3686 |
3687 #if INCLUDE_MANAGEMENT | 3687 #if INCLUDE_MANAGEMENT |
3688 Management::initialize(THREAD); | 3688 Management::initialize(THREAD); |
4209 // In particular, these things should never be called when the Threads_lock | 4209 // In particular, these things should never be called when the Threads_lock |
4210 // is held by some other thread. (Note: the Safepoint abstraction also | 4210 // is held by some other thread. (Note: the Safepoint abstraction also |
4211 // uses the Threads_lock to gurantee this property. It also makes sure that | 4211 // uses the Threads_lock to gurantee this property. It also makes sure that |
4212 // all threads gets blocked when exiting or starting). | 4212 // all threads gets blocked when exiting or starting). |
4213 | 4213 |
4214 void Threads::oops_do(OopClosure* f, CodeBlobClosure* cf) { | 4214 void Threads::oops_do(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf) { |
4215 ALL_JAVA_THREADS(p) { | 4215 ALL_JAVA_THREADS(p) { |
4216 p->oops_do(f, cf); | 4216 p->oops_do(f, cld_f, cf); |
4217 } | 4217 } |
4218 VMThread::vm_thread()->oops_do(f, cf); | 4218 VMThread::vm_thread()->oops_do(f, cld_f, cf); |
4219 } | 4219 } |
4220 | 4220 |
4221 void Threads::possibly_parallel_oops_do(OopClosure* f, CodeBlobClosure* cf) { | 4221 void Threads::possibly_parallel_oops_do(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf) { |
4222 // Introduce a mechanism allowing parallel threads to claim threads as | 4222 // Introduce a mechanism allowing parallel threads to claim threads as |
4223 // root groups. Overhead should be small enough to use all the time, | 4223 // root groups. Overhead should be small enough to use all the time, |
4224 // even in sequential code. | 4224 // even in sequential code. |
4225 SharedHeap* sh = SharedHeap::heap(); | 4225 SharedHeap* sh = SharedHeap::heap(); |
4226 // Cannot yet substitute active_workers for n_par_threads | 4226 // Cannot yet substitute active_workers for n_par_threads |
4233 (SharedHeap::heap()->n_par_threads() == | 4233 (SharedHeap::heap()->n_par_threads() == |
4234 SharedHeap::heap()->workers()->active_workers()), "Mismatch"); | 4234 SharedHeap::heap()->workers()->active_workers()), "Mismatch"); |
4235 int cp = SharedHeap::heap()->strong_roots_parity(); | 4235 int cp = SharedHeap::heap()->strong_roots_parity(); |
4236 ALL_JAVA_THREADS(p) { | 4236 ALL_JAVA_THREADS(p) { |
4237 if (p->claim_oops_do(is_par, cp)) { | 4237 if (p->claim_oops_do(is_par, cp)) { |
4238 p->oops_do(f, cf); | 4238 p->oops_do(f, cld_f, cf); |
4239 } | 4239 } |
4240 } | 4240 } |
4241 VMThread* vmt = VMThread::vm_thread(); | 4241 VMThread* vmt = VMThread::vm_thread(); |
4242 if (vmt->claim_oops_do(is_par, cp)) { | 4242 if (vmt->claim_oops_do(is_par, cp)) { |
4243 vmt->oops_do(f, cf); | 4243 vmt->oops_do(f, cld_f, cf); |
4244 } | 4244 } |
4245 } | 4245 } |
4246 | 4246 |
4247 #ifndef SERIALGC | 4247 #ifndef SERIALGC |
4248 // Used by ParallelScavenge | 4248 // Used by ParallelScavenge |