2840 if (DebugDeoptimization && deopt) {
2841 tty->print_cr("[AFTER Deoptimization]");
2842 trace_frames();
2843 }
2844 }
2845
2846
2847 // Make zombies
2848 void JavaThread::make_zombies() {
2849 for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
2850 if (fst.current()->can_be_deoptimized()) {
2851 // it is a Java nmethod
2852 nmethod* nm = CodeCache::find_nmethod(fst.current()->pc());
2853 nm->make_not_entrant();
2854 }
2855 }
2856 }
2857 #endif // PRODUCT
2858
2859
2860 void JavaThread::deoptimized_wrt_marked_nmethods() {
2861 if (!has_last_Java_frame()) return;
2862 // BiasedLocking needs an updated RegisterMap for the revoke monitors pass
2863 StackFrameStream fst(this, UseBiasedLocking);
2864 for (; !fst.is_done(); fst.next()) {
2865 if (fst.current()->should_be_deoptimized()) {
2866 Deoptimization::deoptimize(this, *fst.current(), fst.register_map());
2867 }
2868 }
2869 }
2870
2871
2872 // If the caller is a NamedThread, then remember, in the current scope,
2873 // the given JavaThread in its _processed_thread field.
2874 class RememberProcessedThread: public StackObj {
2875 NamedThread* _cur_thr;
2876 public:
2877 RememberProcessedThread(JavaThread* jthr) {
2878 Thread* thread = Thread::current();
2879 if (thread->is_Named_thread()) {
2880 _cur_thr = (NamedThread *)thread;
2881 _cur_thr->set_processed_thread(jthr);
2882 } else {
2883 _cur_thr = NULL;
2884 }
2885 }
2886
2887 ~RememberProcessedThread() {
2888 if (_cur_thr) {
2889 _cur_thr->set_processed_thread(NULL);
2890 }
2891 }
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 void Threads::deoptimized_wrt_marked_nmethods() {
4605 ALL_JAVA_THREADS(p) {
4606 p->deoptimized_wrt_marked_nmethods();
4607 }
4608 }
4609
4610
4611 // Get count Java threads that are waiting to enter the specified monitor.
4612 GrowableArray<JavaThread*>* Threads::get_pending_threads(ThreadsList * t_list,
4613 int count,
4614 address monitor) {
4615 GrowableArray<JavaThread*>* result = new GrowableArray<JavaThread*>(count);
4616
4617 int i = 0;
4618 DO_JAVA_THREADS(t_list, p) {
4619 if (!p->can_call_java()) continue;
4620
4621 address pending = (address)p->current_pending_monitor();
4622 if (pending == monitor) { // found a match
4623 if (i < count) result->append(p); // save the first count matches
4624 i++;
4625 }
4626 }
4627
4628 return result;
4629 }
|
2840 if (DebugDeoptimization && deopt) {
2841 tty->print_cr("[AFTER Deoptimization]");
2842 trace_frames();
2843 }
2844 }
2845
2846
2847 // Make zombies
2848 void JavaThread::make_zombies() {
2849 for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
2850 if (fst.current()->can_be_deoptimized()) {
2851 // it is a Java nmethod
2852 nmethod* nm = CodeCache::find_nmethod(fst.current()->pc());
2853 nm->make_not_entrant();
2854 }
2855 }
2856 }
2857 #endif // PRODUCT
2858
2859
2860 void JavaThread::deoptimize_marked_methods() {
2861 if (!has_last_Java_frame()) return;
2862 // BiasedLocking needs an updated RegisterMap for the revoke monitors pass
2863 StackFrameStream fst(this, UseBiasedLocking);
2864 for (; !fst.is_done(); fst.next()) {
2865 if (fst.current()->should_be_deoptimized()) {
2866 Deoptimization::deoptimize(this, *fst.current(), fst.register_map());
2867 }
2868 }
2869 }
2870
2871 // If the caller is a NamedThread, then remember, in the current scope,
2872 // the given JavaThread in its _processed_thread field.
2873 class RememberProcessedThread: public StackObj {
2874 NamedThread* _cur_thr;
2875 public:
2876 RememberProcessedThread(JavaThread* jthr) {
2877 Thread* thread = Thread::current();
2878 if (thread->is_Named_thread()) {
2879 _cur_thr = (NamedThread *)thread;
2880 _cur_thr->set_processed_thread(jthr);
2881 } else {
2882 _cur_thr = NULL;
2883 }
2884 }
2885
2886 ~RememberProcessedThread() {
2887 if (_cur_thr) {
2888 _cur_thr->set_processed_thread(NULL);
2889 }
2890 }
4582 void Threads::metadata_do(MetadataClosure* f) {
4583 ALL_JAVA_THREADS(p) {
4584 p->metadata_do(f);
4585 }
4586 }
4587
4588 class ThreadHandlesClosure : public ThreadClosure {
4589 void (*_f)(Metadata*);
4590 public:
4591 ThreadHandlesClosure(void f(Metadata*)) : _f(f) {}
4592 virtual void do_thread(Thread* thread) {
4593 thread->metadata_handles_do(_f);
4594 }
4595 };
4596
4597 void Threads::metadata_handles_do(void f(Metadata*)) {
4598 // Only walk the Handles in Thread.
4599 ThreadHandlesClosure handles_closure(f);
4600 threads_do(&handles_closure);
4601 }
4602
4603 // Get count Java threads that are waiting to enter the specified monitor.
4604 GrowableArray<JavaThread*>* Threads::get_pending_threads(ThreadsList * t_list,
4605 int count,
4606 address monitor) {
4607 GrowableArray<JavaThread*>* result = new GrowableArray<JavaThread*>(count);
4608
4609 int i = 0;
4610 DO_JAVA_THREADS(t_list, p) {
4611 if (!p->can_call_java()) continue;
4612
4613 address pending = (address)p->current_pending_monitor();
4614 if (pending == monitor) { // found a match
4615 if (i < count) result->append(p); // save the first count matches
4616 i++;
4617 }
4618 }
4619
4620 return result;
4621 }
|