< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page
rev 54697 : imported patch 8221734-v2-merge


2817   if (DebugDeoptimization && deopt) {
2818     tty->print_cr("[AFTER Deoptimization]");
2819     trace_frames();
2820   }
2821 }
2822 
2823 
2824 // Make zombies
2825 void JavaThread::make_zombies() {
2826   for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
2827     if (fst.current()->can_be_deoptimized()) {
2828       // it is a Java nmethod
2829       nmethod* nm = CodeCache::find_nmethod(fst.current()->pc());
2830       nm->make_not_entrant();
2831     }
2832   }
2833 }
2834 #endif // PRODUCT
2835 
2836 
2837 void JavaThread::deoptimized_wrt_marked_nmethods() {
2838   if (!has_last_Java_frame()) return;
2839   // BiasedLocking needs an updated RegisterMap for the revoke monitors pass
2840   StackFrameStream fst(this, UseBiasedLocking);
2841   for (; !fst.is_done(); fst.next()) {
2842     if (fst.current()->should_be_deoptimized()) {
2843       Deoptimization::deoptimize(this, *fst.current(), fst.register_map());
2844     }
2845   }
2846 }
2847 
2848 
2849 // If the caller is a NamedThread, then remember, in the current scope,
2850 // the given JavaThread in its _processed_thread field.
2851 class RememberProcessedThread: public StackObj {
2852   NamedThread* _cur_thr;
2853  public:
2854   RememberProcessedThread(JavaThread* jthr) {
2855     Thread* thread = Thread::current();
2856     if (thread->is_Named_thread()) {
2857       _cur_thr = (NamedThread *)thread;
2858       _cur_thr->set_processed_thread(jthr);
2859     } else {
2860       _cur_thr = NULL;
2861     }
2862   }
2863 
2864   ~RememberProcessedThread() {
2865     if (_cur_thr) {
2866       _cur_thr->set_processed_thread(NULL);
2867     }
2868   }


4584 void Threads::metadata_do(MetadataClosure* f) {
4585   ALL_JAVA_THREADS(p) {
4586     p->metadata_do(f);
4587   }
4588 }
4589 
4590 class ThreadHandlesClosure : public ThreadClosure {
4591   void (*_f)(Metadata*);
4592  public:
4593   ThreadHandlesClosure(void f(Metadata*)) : _f(f) {}
4594   virtual void do_thread(Thread* thread) {
4595     thread->metadata_handles_do(_f);
4596   }
4597 };
4598 
4599 void Threads::metadata_handles_do(void f(Metadata*)) {
4600   // Only walk the Handles in Thread.
4601   ThreadHandlesClosure handles_closure(f);
4602   threads_do(&handles_closure);
4603 }
4604 
4605 void Threads::deoptimized_wrt_marked_nmethods() {
4606   ALL_JAVA_THREADS(p) {
4607     p->deoptimized_wrt_marked_nmethods();
4608   }
4609 }
4610 
4611 
4612 // Get count Java threads that are waiting to enter the specified monitor.
4613 GrowableArray<JavaThread*>* Threads::get_pending_threads(ThreadsList * t_list,
4614                                                          int count,
4615                                                          address monitor) {
4616   GrowableArray<JavaThread*>* result = new GrowableArray<JavaThread*>(count);
4617 
4618   int i = 0;
4619   DO_JAVA_THREADS(t_list, p) {
4620     if (!p->can_call_java()) continue;
4621 
4622     address pending = (address)p->current_pending_monitor();
4623     if (pending == monitor) {             // found a match
4624       if (i < count) result->append(p);   // save the first count matches
4625       i++;
4626     }
4627   }
4628 
4629   return result;
4630 }




2817   if (DebugDeoptimization && deopt) {
2818     tty->print_cr("[AFTER Deoptimization]");
2819     trace_frames();
2820   }
2821 }
2822 
2823 
2824 // Make zombies
2825 void JavaThread::make_zombies() {
2826   for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
2827     if (fst.current()->can_be_deoptimized()) {
2828       // it is a Java nmethod
2829       nmethod* nm = CodeCache::find_nmethod(fst.current()->pc());
2830       nm->make_not_entrant();
2831     }
2832   }
2833 }
2834 #endif // PRODUCT
2835 
2836 
2837 void JavaThread::deoptimize_marked_methods(bool in_handshake) {
2838   if (!has_last_Java_frame()) return;
2839   // BiasedLocking needs an updated RegisterMap for the revoke monitors pass
2840   StackFrameStream fst(this, UseBiasedLocking);
2841   for (; !fst.is_done(); fst.next()) {
2842     if (fst.current()->should_be_deoptimized()) {
2843       Deoptimization::deoptimize(this, *fst.current(), fst.register_map(), in_handshake);
2844     }
2845   }
2846 }
2847 

2848 // If the caller is a NamedThread, then remember, in the current scope,
2849 // the given JavaThread in its _processed_thread field.
2850 class RememberProcessedThread: public StackObj {
2851   NamedThread* _cur_thr;
2852  public:
2853   RememberProcessedThread(JavaThread* jthr) {
2854     Thread* thread = Thread::current();
2855     if (thread->is_Named_thread()) {
2856       _cur_thr = (NamedThread *)thread;
2857       _cur_thr->set_processed_thread(jthr);
2858     } else {
2859       _cur_thr = NULL;
2860     }
2861   }
2862 
2863   ~RememberProcessedThread() {
2864     if (_cur_thr) {
2865       _cur_thr->set_processed_thread(NULL);
2866     }
2867   }


4583 void Threads::metadata_do(MetadataClosure* f) {
4584   ALL_JAVA_THREADS(p) {
4585     p->metadata_do(f);
4586   }
4587 }
4588 
4589 class ThreadHandlesClosure : public ThreadClosure {
4590   void (*_f)(Metadata*);
4591  public:
4592   ThreadHandlesClosure(void f(Metadata*)) : _f(f) {}
4593   virtual void do_thread(Thread* thread) {
4594     thread->metadata_handles_do(_f);
4595   }
4596 };
4597 
4598 void Threads::metadata_handles_do(void f(Metadata*)) {
4599   // Only walk the Handles in Thread.
4600   ThreadHandlesClosure handles_closure(f);
4601   threads_do(&handles_closure);
4602 }







4603 
4604 // Get count Java threads that are waiting to enter the specified monitor.
4605 GrowableArray<JavaThread*>* Threads::get_pending_threads(ThreadsList * t_list,
4606                                                          int count,
4607                                                          address monitor) {
4608   GrowableArray<JavaThread*>* result = new GrowableArray<JavaThread*>(count);
4609 
4610   int i = 0;
4611   DO_JAVA_THREADS(t_list, p) {
4612     if (!p->can_call_java()) continue;
4613 
4614     address pending = (address)p->current_pending_monitor();
4615     if (pending == monitor) {             // found a match
4616       if (i < count) result->append(p);   // save the first count matches
4617       i++;
4618     }
4619   }
4620 
4621   return result;
4622 }


< prev index next >