< prev index next >

src/share/vm/runtime/thread.cpp

Print this page




3284   _task  = NULL;
3285   _queue = queue;
3286   _counters = counters;
3287   _buffer_blob = NULL;
3288   _compiler = NULL;
3289 
3290 #ifndef PRODUCT
3291   _ideal_graph_printer = NULL;
3292 #endif
3293 }
3294 
3295 bool CompilerThread::can_call_java() const {
3296   return _compiler != NULL && _compiler->is_jvmci();
3297 }
3298 
3299 // Create sweeper thread
3300 CodeCacheSweeperThread::CodeCacheSweeperThread()
3301 : JavaThread(&sweeper_thread_entry) {
3302   _scanned_nmethod = NULL;
3303 }

3304 void CodeCacheSweeperThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
3305   JavaThread::oops_do(f, cld_f, cf);
3306   if (_scanned_nmethod != NULL && cf != NULL) {
3307     // Safepoints can occur when the sweeper is scanning an nmethod so
3308     // process it here to make sure it isn't unloaded in the middle of
3309     // a scan.
3310     cf->do_code_blob(_scanned_nmethod);
3311   }
3312 }
3313 










3314 
3315 // ======= Threads ========
3316 
3317 // The Threads class links together all active threads, and provides
3318 // operations over all threads.  It is protected by its own Mutex
3319 // lock, which is also used in other contexts to protect thread
3320 // operations from having the thread being operated on from exiting
3321 // and going away unexpectedly (e.g., safepoint synchronization)
3322 
3323 JavaThread* Threads::_thread_list = NULL;
3324 int         Threads::_number_of_threads = 0;
3325 int         Threads::_number_of_non_daemon_threads = 0;
3326 int         Threads::_return_code = 0;
3327 int         Threads::_thread_claim_parity = 0;
3328 size_t      JavaThread::_stack_size_at_create = 0;
3329 #ifdef ASSERT
3330 bool        Threads::_vm_complete = false;
3331 #endif
3332 
3333 // All JavaThreads


4331 #if INCLUDE_ALL_GCS
4332 // Used by ParallelScavenge
4333 void Threads::create_thread_roots_tasks(GCTaskQueue* q) {
4334   ALL_JAVA_THREADS(p) {
4335     q->enqueue(new ThreadRootsTask(p));
4336   }
4337   q->enqueue(new ThreadRootsTask(VMThread::vm_thread()));
4338 }
4339 
4340 // Used by Parallel Old
4341 void Threads::create_thread_roots_marking_tasks(GCTaskQueue* q) {
4342   ALL_JAVA_THREADS(p) {
4343     q->enqueue(new ThreadRootsMarkingTask(p));
4344   }
4345   q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread()));
4346 }
4347 #endif // INCLUDE_ALL_GCS
4348 
4349 void Threads::nmethods_do(CodeBlobClosure* cf) {
4350   ALL_JAVA_THREADS(p) {




4351     p->nmethods_do(cf);

4352   }
4353   VMThread::vm_thread()->nmethods_do(cf);
4354 }
4355 
4356 void Threads::metadata_do(void f(Metadata*)) {
4357   ALL_JAVA_THREADS(p) {
4358     p->metadata_do(f);
4359   }
4360 }
4361 
4362 class ThreadHandlesClosure : public ThreadClosure {
4363   void (*_f)(Metadata*);
4364  public:
4365   ThreadHandlesClosure(void f(Metadata*)) : _f(f) {}
4366   virtual void do_thread(Thread* thread) {
4367     thread->metadata_handles_do(_f);
4368   }
4369 };
4370 
4371 void Threads::metadata_handles_do(void f(Metadata*)) {




3284   _task  = NULL;
3285   _queue = queue;
3286   _counters = counters;
3287   _buffer_blob = NULL;
3288   _compiler = NULL;
3289 
3290 #ifndef PRODUCT
3291   _ideal_graph_printer = NULL;
3292 #endif
3293 }
3294 
3295 bool CompilerThread::can_call_java() const {
3296   return _compiler != NULL && _compiler->is_jvmci();
3297 }
3298 
3299 // Create sweeper thread
3300 CodeCacheSweeperThread::CodeCacheSweeperThread()
3301 : JavaThread(&sweeper_thread_entry) {
3302   _scanned_nmethod = NULL;
3303 }
3304 
3305 void CodeCacheSweeperThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
3306   JavaThread::oops_do(f, cld_f, cf);
3307   if (_scanned_nmethod != NULL && cf != NULL) {
3308     // Safepoints can occur when the sweeper is scanning an nmethod so
3309     // process it here to make sure it isn't unloaded in the middle of
3310     // a scan.
3311     cf->do_code_blob(_scanned_nmethod);
3312   }
3313 }
3314 
3315 void CodeCacheSweeperThread::nmethods_do(CodeBlobClosure* cf) {
3316   Thread::nmethods_do(cf);
3317   if (_scanned_nmethod != NULL && cf != NULL) {
3318     // Safepoints can occur when the sweeper is scanning an nmethod so
3319     // process it here to make sure it isn't unloaded in the middle of
3320     // a scan.
3321     cf->do_code_blob(_scanned_nmethod);
3322   }
3323 }
3324 
3325 
3326 // ======= Threads ========
3327 
3328 // The Threads class links together all active threads, and provides
3329 // operations over all threads.  It is protected by its own Mutex
3330 // lock, which is also used in other contexts to protect thread
3331 // operations from having the thread being operated on from exiting
3332 // and going away unexpectedly (e.g., safepoint synchronization)
3333 
3334 JavaThread* Threads::_thread_list = NULL;
3335 int         Threads::_number_of_threads = 0;
3336 int         Threads::_number_of_non_daemon_threads = 0;
3337 int         Threads::_return_code = 0;
3338 int         Threads::_thread_claim_parity = 0;
3339 size_t      JavaThread::_stack_size_at_create = 0;
3340 #ifdef ASSERT
3341 bool        Threads::_vm_complete = false;
3342 #endif
3343 
3344 // All JavaThreads


4342 #if INCLUDE_ALL_GCS
4343 // Used by ParallelScavenge
4344 void Threads::create_thread_roots_tasks(GCTaskQueue* q) {
4345   ALL_JAVA_THREADS(p) {
4346     q->enqueue(new ThreadRootsTask(p));
4347   }
4348   q->enqueue(new ThreadRootsTask(VMThread::vm_thread()));
4349 }
4350 
4351 // Used by Parallel Old
4352 void Threads::create_thread_roots_marking_tasks(GCTaskQueue* q) {
4353   ALL_JAVA_THREADS(p) {
4354     q->enqueue(new ThreadRootsMarkingTask(p));
4355   }
4356   q->enqueue(new ThreadRootsMarkingTask(VMThread::vm_thread()));
4357 }
4358 #endif // INCLUDE_ALL_GCS
4359 
4360 void Threads::nmethods_do(CodeBlobClosure* cf) {
4361   ALL_JAVA_THREADS(p) {
4362     // This is used by the code cache sweeper to mark nmethods that are active
4363     // on the stack of a Java thread. Ignore the sweeper thread itself to avoid
4364     // marking CodeCacheSweeperThread::_scanned_nmethod as active.
4365     if(!p->is_Code_cache_sweeper_thread()) {
4366       p->nmethods_do(cf);
4367     }
4368   }
4369   VMThread::vm_thread()->nmethods_do(cf);
4370 }
4371 
4372 void Threads::metadata_do(void f(Metadata*)) {
4373   ALL_JAVA_THREADS(p) {
4374     p->metadata_do(f);
4375   }
4376 }
4377 
4378 class ThreadHandlesClosure : public ThreadClosure {
4379   void (*_f)(Metadata*);
4380  public:
4381   ThreadHandlesClosure(void f(Metadata*)) : _f(f) {}
4382   virtual void do_thread(Thread* thread) {
4383     thread->metadata_handles_do(_f);
4384   }
4385 };
4386 
4387 void Threads::metadata_handles_do(void f(Metadata*)) {


< prev index next >