2816 if (DebugDeoptimization && deopt) {
2817 tty->print_cr("[AFTER Deoptimization]");
2818 trace_frames();
2819 }
2820 }
2821
2822
2823 // Make zombies
2824 void JavaThread::make_zombies() {
2825 for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
2826 if (fst.current()->can_be_deoptimized()) {
2827 // it is a Java nmethod
2828 nmethod* nm = CodeCache::find_nmethod(fst.current()->pc());
2829 nm->make_not_entrant();
2830 }
2831 }
2832 }
2833 #endif // PRODUCT
2834
2835
2836 void JavaThread::deoptimized_wrt_marked_nmethods() {
2837 if (!has_last_Java_frame()) return;
2838 // BiasedLocking needs an updated RegisterMap for the revoke monitors pass
2839 StackFrameStream fst(this, UseBiasedLocking);
2840 for (; !fst.is_done(); fst.next()) {
2841 if (fst.current()->should_be_deoptimized()) {
2842 Deoptimization::deoptimize(this, *fst.current(), fst.register_map());
2843 }
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 }
4580 void Threads::metadata_do(MetadataClosure* f) {
4581 ALL_JAVA_THREADS(p) {
4582 p->metadata_do(f);
4583 }
4584 }
4585
4586 class ThreadHandlesClosure : public ThreadClosure {
4587 void (*_f)(Metadata*);
4588 public:
4589 ThreadHandlesClosure(void f(Metadata*)) : _f(f) {}
4590 virtual void do_thread(Thread* thread) {
4591 thread->metadata_handles_do(_f);
4592 }
4593 };
4594
4595 void Threads::metadata_handles_do(void f(Metadata*)) {
4596 // Only walk the Handles in Thread.
4597 ThreadHandlesClosure handles_closure(f);
4598 threads_do(&handles_closure);
4599 }
4600
4601 void Threads::deoptimized_wrt_marked_nmethods() {
4602 ALL_JAVA_THREADS(p) {
4603 p->deoptimized_wrt_marked_nmethods();
4604 }
4605 }
4606
4607
4608 // Get count Java threads that are waiting to enter the specified monitor.
4609 GrowableArray<JavaThread*>* Threads::get_pending_threads(ThreadsList * t_list,
4610 int count,
4611 address monitor) {
4612 GrowableArray<JavaThread*>* result = new GrowableArray<JavaThread*>(count);
4613
4614 int i = 0;
4615 DO_JAVA_THREADS(t_list, p) {
4616 if (!p->can_call_java()) continue;
4617
4618 address pending = (address)p->current_pending_monitor();
4619 if (pending == monitor) { // found a match
4620 if (i < count) result->append(p); // save the first count matches
4621 i++;
4622 }
4623 }
4624
4625 return result;
4626 }
|
2816 if (DebugDeoptimization && deopt) {
2817 tty->print_cr("[AFTER Deoptimization]");
2818 trace_frames();
2819 }
2820 }
2821
2822
2823 // Make zombies
2824 void JavaThread::make_zombies() {
2825 for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
2826 if (fst.current()->can_be_deoptimized()) {
2827 // it is a Java nmethod
2828 nmethod* nm = CodeCache::find_nmethod(fst.current()->pc());
2829 nm->make_not_entrant();
2830 }
2831 }
2832 }
2833 #endif // PRODUCT
2834
2835
2836 void JavaThread::deoptimize_marked_methods(bool in_handshake) {
2837 if (!has_last_Java_frame()) return;
2838 // BiasedLocking needs an updated RegisterMap for the revoke monitors pass
2839 StackFrameStream fst(this, UseBiasedLocking);
2840 for (; !fst.is_done(); fst.next()) {
2841 if (fst.current()->should_be_deoptimized()) {
2842 Deoptimization::deoptimize(this, *fst.current(), fst.register_map(), in_handshake);
2843 }
2844 }
2845 }
2846
2847 // If the caller is a NamedThread, then remember, in the current scope,
2848 // the given JavaThread in its _processed_thread field.
2849 class RememberProcessedThread: public StackObj {
2850 NamedThread* _cur_thr;
2851 public:
2852 RememberProcessedThread(JavaThread* jthr) {
2853 Thread* thread = Thread::current();
2854 if (thread->is_Named_thread()) {
2855 _cur_thr = (NamedThread *)thread;
2856 _cur_thr->set_processed_thread(jthr);
2857 } else {
2858 _cur_thr = NULL;
2859 }
2860 }
2861
2862 ~RememberProcessedThread() {
2863 if (_cur_thr) {
2864 _cur_thr->set_processed_thread(NULL);
2865 }
2866 }
4579 void Threads::metadata_do(MetadataClosure* f) {
4580 ALL_JAVA_THREADS(p) {
4581 p->metadata_do(f);
4582 }
4583 }
4584
4585 class ThreadHandlesClosure : public ThreadClosure {
4586 void (*_f)(Metadata*);
4587 public:
4588 ThreadHandlesClosure(void f(Metadata*)) : _f(f) {}
4589 virtual void do_thread(Thread* thread) {
4590 thread->metadata_handles_do(_f);
4591 }
4592 };
4593
4594 void Threads::metadata_handles_do(void f(Metadata*)) {
4595 // Only walk the Handles in Thread.
4596 ThreadHandlesClosure handles_closure(f);
4597 threads_do(&handles_closure);
4598 }
4599
4600 // Get count Java threads that are waiting to enter the specified monitor.
4601 GrowableArray<JavaThread*>* Threads::get_pending_threads(ThreadsList * t_list,
4602 int count,
4603 address monitor) {
4604 GrowableArray<JavaThread*>* result = new GrowableArray<JavaThread*>(count);
4605
4606 int i = 0;
4607 DO_JAVA_THREADS(t_list, p) {
4608 if (!p->can_call_java()) continue;
4609
4610 address pending = (address)p->current_pending_monitor();
4611 if (pending == monitor) { // found a match
4612 if (i < count) result->append(p); // save the first count matches
4613 i++;
4614 }
4615 }
4616
4617 return result;
4618 }
|