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