Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/thread.cpp @ 7182:c24f778e9401
Merge
author | johnc |
---|---|
date | Thu, 29 Nov 2012 11:23:15 -0800 |
parents | f34d701e952e |
children | d2f8c38e543d |
comparison
equal
deleted
inserted
replaced
7176:59c790074993 | 7182:c24f778e9401 |
---|---|
63 #include "runtime/safepoint.hpp" | 63 #include "runtime/safepoint.hpp" |
64 #include "runtime/sharedRuntime.hpp" | 64 #include "runtime/sharedRuntime.hpp" |
65 #include "runtime/statSampler.hpp" | 65 #include "runtime/statSampler.hpp" |
66 #include "runtime/stubRoutines.hpp" | 66 #include "runtime/stubRoutines.hpp" |
67 #include "runtime/task.hpp" | 67 #include "runtime/task.hpp" |
68 #include "runtime/thread.inline.hpp" | |
68 #include "runtime/threadCritical.hpp" | 69 #include "runtime/threadCritical.hpp" |
69 #include "runtime/threadLocalStorage.hpp" | 70 #include "runtime/threadLocalStorage.hpp" |
70 #include "runtime/vframe.hpp" | 71 #include "runtime/vframe.hpp" |
71 #include "runtime/vframeArray.hpp" | 72 #include "runtime/vframeArray.hpp" |
72 #include "runtime/vframe_hp.hpp" | 73 #include "runtime/vframe_hp.hpp" |
81 #include "utilities/dtrace.hpp" | 82 #include "utilities/dtrace.hpp" |
82 #include "utilities/events.hpp" | 83 #include "utilities/events.hpp" |
83 #include "utilities/preserveException.hpp" | 84 #include "utilities/preserveException.hpp" |
84 #ifdef TARGET_OS_FAMILY_linux | 85 #ifdef TARGET_OS_FAMILY_linux |
85 # include "os_linux.inline.hpp" | 86 # include "os_linux.inline.hpp" |
86 # include "thread_linux.inline.hpp" | |
87 #endif | 87 #endif |
88 #ifdef TARGET_OS_FAMILY_solaris | 88 #ifdef TARGET_OS_FAMILY_solaris |
89 # include "os_solaris.inline.hpp" | 89 # include "os_solaris.inline.hpp" |
90 # include "thread_solaris.inline.hpp" | |
91 #endif | 90 #endif |
92 #ifdef TARGET_OS_FAMILY_windows | 91 #ifdef TARGET_OS_FAMILY_windows |
93 # include "os_windows.inline.hpp" | 92 # include "os_windows.inline.hpp" |
94 # include "thread_windows.inline.hpp" | |
95 #endif | 93 #endif |
96 #ifdef TARGET_OS_FAMILY_bsd | 94 #ifdef TARGET_OS_FAMILY_bsd |
97 # include "os_bsd.inline.hpp" | 95 # include "os_bsd.inline.hpp" |
98 # include "thread_bsd.inline.hpp" | |
99 #endif | 96 #endif |
100 #ifndef SERIALGC | 97 #ifndef SERIALGC |
101 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp" | 98 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp" |
102 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp" | 99 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp" |
103 #include "gc_implementation/parallelScavenge/pcTasks.hpp" | 100 #include "gc_implementation/parallelScavenge/pcTasks.hpp" |
824 assert(SharedHeap::heap()->workers()->active_workers() > 0, | 821 assert(SharedHeap::heap()->workers()->active_workers() > 0, |
825 "Should only fail when parallel."); | 822 "Should only fail when parallel."); |
826 return false; | 823 return false; |
827 } | 824 } |
828 | 825 |
829 void Thread::oops_do(OopClosure* f, CodeBlobClosure* cf) { | 826 void Thread::oops_do(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf) { |
830 active_handles()->oops_do(f); | 827 active_handles()->oops_do(f); |
831 // Do oop for ThreadShadow | 828 // Do oop for ThreadShadow |
832 f->do_oop((oop*)&_pending_exception); | 829 f->do_oop((oop*)&_pending_exception); |
833 handle_area()->oops_do(f); | 830 handle_area()->oops_do(f); |
834 } | 831 } |
2703 _cur_thr->set_processed_thread(NULL); | 2700 _cur_thr->set_processed_thread(NULL); |
2704 } | 2701 } |
2705 } | 2702 } |
2706 }; | 2703 }; |
2707 | 2704 |
2708 void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { | 2705 void JavaThread::oops_do(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf) { |
2709 // Verify that the deferred card marks have been flushed. | 2706 // Verify that the deferred card marks have been flushed. |
2710 assert(deferred_card_mark().is_empty(), "Should be empty during GC"); | 2707 assert(deferred_card_mark().is_empty(), "Should be empty during GC"); |
2711 | 2708 |
2712 // The ThreadProfiler oops_do is done from FlatProfiler::oops_do | 2709 // The ThreadProfiler oops_do is done from FlatProfiler::oops_do |
2713 // since there may be more than one thread using each ThreadProfiler. | 2710 // since there may be more than one thread using each ThreadProfiler. |
2714 | 2711 |
2715 // Traverse the GCHandles | 2712 // Traverse the GCHandles |
2716 Thread::oops_do(f, cf); | 2713 Thread::oops_do(f, cld_f, cf); |
2717 | 2714 |
2718 assert( (!has_last_Java_frame() && java_call_counter() == 0) || | 2715 assert( (!has_last_Java_frame() && java_call_counter() == 0) || |
2719 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); | 2716 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); |
2720 | 2717 |
2721 if (has_last_Java_frame()) { | 2718 if (has_last_Java_frame()) { |
2739 chunk->oops_do(f); | 2736 chunk->oops_do(f); |
2740 } | 2737 } |
2741 | 2738 |
2742 // Traverse the execution stack | 2739 // Traverse the execution stack |
2743 for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { | 2740 for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { |
2744 fst.current()->oops_do(f, cf, fst.register_map()); | 2741 fst.current()->oops_do(f, cld_f, cf, fst.register_map()); |
2745 } | 2742 } |
2746 } | 2743 } |
2747 | 2744 |
2748 // callee_target is never live across a gc point so NULL it here should | 2745 // callee_target is never live across a gc point so NULL it here should |
2749 // it still contain a methdOop. | 2746 // it still contain a methdOop. |
2873 | 2870 |
2874 static void frame_verify(frame* f, const RegisterMap *map) { f->verify(map); } | 2871 static void frame_verify(frame* f, const RegisterMap *map) { f->verify(map); } |
2875 | 2872 |
2876 void JavaThread::verify() { | 2873 void JavaThread::verify() { |
2877 // Verify oops in the thread. | 2874 // Verify oops in the thread. |
2878 oops_do(&VerifyOopClosure::verify_oop, NULL); | 2875 oops_do(&VerifyOopClosure::verify_oop, NULL, NULL); |
2879 | 2876 |
2880 // Verify the stack frames. | 2877 // Verify the stack frames. |
2881 frames_do(frame_verify); | 2878 frames_do(frame_verify); |
2882 } | 2879 } |
2883 | 2880 |
3123 | 3120 |
3124 | 3121 |
3125 static void oops_print(frame* f, const RegisterMap *map) { | 3122 static void oops_print(frame* f, const RegisterMap *map) { |
3126 PrintAndVerifyOopClosure print; | 3123 PrintAndVerifyOopClosure print; |
3127 f->print_value(); | 3124 f->print_value(); |
3128 f->oops_do(&print, NULL, (RegisterMap*)map); | 3125 f->oops_do(&print, NULL, NULL, (RegisterMap*)map); |
3129 } | 3126 } |
3130 | 3127 |
3131 // Print our all the locations that contain oops and whether they are | 3128 // Print our all the locations that contain oops and whether they are |
3132 // valid or not. This useful when trying to find the oldest frame | 3129 // valid or not. This useful when trying to find the oldest frame |
3133 // where an oop has gone bad since the frame walk is from youngest to | 3130 // where an oop has gone bad since the frame walk is from youngest to |
3225 #ifndef PRODUCT | 3222 #ifndef PRODUCT |
3226 _ideal_graph_printer = NULL; | 3223 _ideal_graph_printer = NULL; |
3227 #endif | 3224 #endif |
3228 } | 3225 } |
3229 | 3226 |
3230 void CompilerThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { | 3227 void CompilerThread::oops_do(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf) { |
3231 JavaThread::oops_do(f, cf); | 3228 JavaThread::oops_do(f, cld_f, cf); |
3232 if (_scanned_nmethod != NULL && cf != NULL) { | 3229 if (_scanned_nmethod != NULL && cf != NULL) { |
3233 // Safepoints can occur when the sweeper is scanning an nmethod so | 3230 // Safepoints can occur when the sweeper is scanning an nmethod so |
3234 // process it here to make sure it isn't unloaded in the middle of | 3231 // process it here to make sure it isn't unloaded in the middle of |
3235 // a scan. | 3232 // a scan. |
3236 cf->do_code_blob(_scanned_nmethod); | 3233 cf->do_code_blob(_scanned_nmethod); |
3331 TraceTime timer("Create VM", TraceStartupTime); | 3328 TraceTime timer("Create VM", TraceStartupTime); |
3332 | 3329 |
3333 // Initialize the os module after parsing the args | 3330 // Initialize the os module after parsing the args |
3334 jint os_init_2_result = os::init_2(); | 3331 jint os_init_2_result = os::init_2(); |
3335 if (os_init_2_result != JNI_OK) return os_init_2_result; | 3332 if (os_init_2_result != JNI_OK) return os_init_2_result; |
3333 | |
3334 jint adjust_after_os_result = Arguments::adjust_after_os(); | |
3335 if (adjust_after_os_result != JNI_OK) return adjust_after_os_result; | |
3336 | 3336 |
3337 // intialize TLS | 3337 // intialize TLS |
3338 ThreadLocalStorage::init(); | 3338 ThreadLocalStorage::init(); |
3339 | 3339 |
3340 // Bootstrap native memory tracking, so it can start recording memory | 3340 // Bootstrap native memory tracking, so it can start recording memory |
4196 // In particular, these things should never be called when the Threads_lock | 4196 // In particular, these things should never be called when the Threads_lock |
4197 // is held by some other thread. (Note: the Safepoint abstraction also | 4197 // is held by some other thread. (Note: the Safepoint abstraction also |
4198 // uses the Threads_lock to gurantee this property. It also makes sure that | 4198 // uses the Threads_lock to gurantee this property. It also makes sure that |
4199 // all threads gets blocked when exiting or starting). | 4199 // all threads gets blocked when exiting or starting). |
4200 | 4200 |
4201 void Threads::oops_do(OopClosure* f, CodeBlobClosure* cf) { | 4201 void Threads::oops_do(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf) { |
4202 ALL_JAVA_THREADS(p) { | 4202 ALL_JAVA_THREADS(p) { |
4203 p->oops_do(f, cf); | 4203 p->oops_do(f, cld_f, cf); |
4204 } | 4204 } |
4205 VMThread::vm_thread()->oops_do(f, cf); | 4205 VMThread::vm_thread()->oops_do(f, cld_f, cf); |
4206 } | 4206 } |
4207 | 4207 |
4208 void Threads::possibly_parallel_oops_do(OopClosure* f, CodeBlobClosure* cf) { | 4208 void Threads::possibly_parallel_oops_do(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf) { |
4209 // Introduce a mechanism allowing parallel threads to claim threads as | 4209 // Introduce a mechanism allowing parallel threads to claim threads as |
4210 // root groups. Overhead should be small enough to use all the time, | 4210 // root groups. Overhead should be small enough to use all the time, |
4211 // even in sequential code. | 4211 // even in sequential code. |
4212 SharedHeap* sh = SharedHeap::heap(); | 4212 SharedHeap* sh = SharedHeap::heap(); |
4213 // Cannot yet substitute active_workers for n_par_threads | 4213 // Cannot yet substitute active_workers for n_par_threads |
4220 (SharedHeap::heap()->n_par_threads() == | 4220 (SharedHeap::heap()->n_par_threads() == |
4221 SharedHeap::heap()->workers()->active_workers()), "Mismatch"); | 4221 SharedHeap::heap()->workers()->active_workers()), "Mismatch"); |
4222 int cp = SharedHeap::heap()->strong_roots_parity(); | 4222 int cp = SharedHeap::heap()->strong_roots_parity(); |
4223 ALL_JAVA_THREADS(p) { | 4223 ALL_JAVA_THREADS(p) { |
4224 if (p->claim_oops_do(is_par, cp)) { | 4224 if (p->claim_oops_do(is_par, cp)) { |
4225 p->oops_do(f, cf); | 4225 p->oops_do(f, cld_f, cf); |
4226 } | 4226 } |
4227 } | 4227 } |
4228 VMThread* vmt = VMThread::vm_thread(); | 4228 VMThread* vmt = VMThread::vm_thread(); |
4229 if (vmt->claim_oops_do(is_par, cp)) { | 4229 if (vmt->claim_oops_do(is_par, cp)) { |
4230 vmt->oops_do(f, cf); | 4230 vmt->oops_do(f, cld_f, cf); |
4231 } | 4231 } |
4232 } | 4232 } |
4233 | 4233 |
4234 #ifndef SERIALGC | 4234 #ifndef SERIALGC |
4235 // Used by ParallelScavenge | 4235 // Used by ParallelScavenge |