989 |
989 |
990 // NamedThread -- non-JavaThread subclasses with multiple |
990 // NamedThread -- non-JavaThread subclasses with multiple |
991 // uniquely named instances should derive from this. |
991 // uniquely named instances should derive from this. |
992 NamedThread::NamedThread() : Thread() { |
992 NamedThread::NamedThread() : Thread() { |
993 _name = NULL; |
993 _name = NULL; |
|
994 _processed_thread = NULL; |
994 } |
995 } |
995 |
996 |
996 NamedThread::~NamedThread() { |
997 NamedThread::~NamedThread() { |
997 if (_name != NULL) { |
998 if (_name != NULL) { |
998 FREE_C_HEAP_ARRAY(char, _name); |
999 FREE_C_HEAP_ARRAY(char, _name); |
2331 |
2332 |
2332 void JavaThread::gc_prologue() { |
2333 void JavaThread::gc_prologue() { |
2333 frames_do(frame_gc_prologue); |
2334 frames_do(frame_gc_prologue); |
2334 } |
2335 } |
2335 |
2336 |
|
2337 // If the caller is a NamedThread, then remember, in the current scope, |
|
2338 // the given JavaThread in its _processed_thread field. |
|
2339 class RememberProcessedThread: public StackObj { |
|
2340 NamedThread* _cur_thr; |
|
2341 public: |
|
2342 RememberProcessedThread(JavaThread* jthr) { |
|
2343 Thread* thread = Thread::current(); |
|
2344 if (thread->is_Named_thread()) { |
|
2345 _cur_thr = (NamedThread *)thread; |
|
2346 _cur_thr->set_processed_thread(jthr); |
|
2347 } else { |
|
2348 _cur_thr = NULL; |
|
2349 } |
|
2350 } |
|
2351 |
|
2352 ~RememberProcessedThread() { |
|
2353 if (_cur_thr) { |
|
2354 _cur_thr->set_processed_thread(NULL); |
|
2355 } |
|
2356 } |
|
2357 }; |
2336 |
2358 |
2337 void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { |
2359 void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { |
2338 // Flush deferred store-barriers, if any, associated with |
2360 // Flush deferred store-barriers, if any, associated with |
2339 // initializing stores done by this JavaThread in the current epoch. |
2361 // initializing stores done by this JavaThread in the current epoch. |
2340 Universe::heap()->flush_deferred_store_barrier(this); |
2362 Universe::heap()->flush_deferred_store_barrier(this); |
2347 |
2369 |
2348 assert( (!has_last_Java_frame() && java_call_counter() == 0) || |
2370 assert( (!has_last_Java_frame() && java_call_counter() == 0) || |
2349 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); |
2371 (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); |
2350 |
2372 |
2351 if (has_last_Java_frame()) { |
2373 if (has_last_Java_frame()) { |
|
2374 // Record JavaThread to GC thread |
|
2375 RememberProcessedThread rpt(this); |
2352 |
2376 |
2353 // Traverse the privileged stack |
2377 // Traverse the privileged stack |
2354 if (_privileged_stack_top != NULL) { |
2378 if (_privileged_stack_top != NULL) { |
2355 _privileged_stack_top->oops_do(f); |
2379 _privileged_stack_top->oops_do(f); |
2356 } |
2380 } |