< prev index next >

src/hotspot/share/prims/jvmtiEnvBase.cpp

Print this page
rev 56777 : See CR7-to-CR8-changes.


 637         if (mi->owner() != NULL && mi->owner() == hobj()) {
 638           ret++;
 639         }
 640       }
 641     }
 642   }
 643   return ret;
 644 }
 645 
 646 
 647 
 648 jvmtiError
 649 JvmtiEnvBase::get_current_contended_monitor(JavaThread *calling_thread, JavaThread *java_thread, jobject *monitor_ptr) {
 650 #ifdef ASSERT
 651   uint32_t debug_bits = 0;
 652 #endif
 653   assert((SafepointSynchronize::is_at_safepoint() ||
 654           java_thread->is_thread_fully_suspended(false, &debug_bits)),
 655          "at safepoint or target thread is suspended");
 656   oop obj = NULL;
 657   ObjectMonitor *mon = java_thread->current_waiting_monitor();

 658   if (mon == NULL) {
 659     // thread is not doing an Object.wait() call
 660     mon = java_thread->current_pending_monitor();
 661     if (mon != NULL) {
 662       // The thread is trying to enter() an ObjectMonitor.
 663       obj = (oop)mon->object();
 664       assert(obj != NULL, "ObjectMonitor should have a valid object!");
 665     }
 666     // implied else: no contended ObjectMonitor
 667   } else {
 668     // thread is doing an Object.wait() call
 669     obj = (oop)mon->object();
 670     assert(obj != NULL, "Object.wait() should have an object");
 671   }
 672 
 673   if (obj == NULL) {
 674     *monitor_ptr = NULL;
 675   } else {
 676     HandleMark hm;
 677     Handle     hobj(Thread::current(), obj);
 678     *monitor_ptr = jni_reference(calling_thread, hobj);
 679   }
 680   return JVMTI_ERROR_NONE;


 716   err = jmc.error();
 717 
 718   return err;
 719 }
 720 
 721 // Save JNI local handles for any objects that this frame owns.
 722 jvmtiError
 723 JvmtiEnvBase::get_locked_objects_in_frame(JavaThread* calling_thread, JavaThread* java_thread,
 724                                  javaVFrame *jvf, GrowableArray<jvmtiMonitorStackDepthInfo*>* owned_monitors_list, jint stack_depth) {
 725   jvmtiError err = JVMTI_ERROR_NONE;
 726   ResourceMark rm;
 727 
 728   GrowableArray<MonitorInfo*>* mons = jvf->monitors();
 729   if (mons->is_empty()) {
 730     return err;  // this javaVFrame holds no monitors
 731   }
 732 
 733   HandleMark hm;
 734   oop wait_obj = NULL;
 735   {

 736     // save object of current wait() call (if any) for later comparison
 737     ObjectMonitor *mon = java_thread->current_waiting_monitor();
 738     if (mon != NULL) {
 739       wait_obj = (oop)mon->object();
 740     }
 741   }
 742   oop pending_obj = NULL;
 743   {

 744     // save object of current enter() call (if any) for later comparison
 745     ObjectMonitor *mon = java_thread->current_pending_monitor();
 746     if (mon != NULL) {
 747       pending_obj = (oop)mon->object();
 748     }
 749   }
 750 
 751   for (int i = 0; i < mons->length(); i++) {
 752     MonitorInfo *mi = mons->at(i);
 753 
 754     if (mi->owner_is_scalar_replaced()) continue;
 755 
 756     oop obj = mi->owner();
 757     if (obj == NULL) {
 758       // this monitor doesn't have an owning object so skip it
 759       continue;
 760     }
 761 
 762     if (wait_obj == obj) {
 763       // the thread is waiting on this monitor so it isn't really owned
 764       continue;
 765     }




 637         if (mi->owner() != NULL && mi->owner() == hobj()) {
 638           ret++;
 639         }
 640       }
 641     }
 642   }
 643   return ret;
 644 }
 645 
 646 
 647 
 648 jvmtiError
 649 JvmtiEnvBase::get_current_contended_monitor(JavaThread *calling_thread, JavaThread *java_thread, jobject *monitor_ptr) {
 650 #ifdef ASSERT
 651   uint32_t debug_bits = 0;
 652 #endif
 653   assert((SafepointSynchronize::is_at_safepoint() ||
 654           java_thread->is_thread_fully_suspended(false, &debug_bits)),
 655          "at safepoint or target thread is suspended");
 656   oop obj = NULL;
 657   ObjectMonitorHandle omh;
 658   ObjectMonitor *mon = java_thread->current_waiting_monitor(&omh);
 659   if (mon == NULL) {
 660     // thread is not doing an Object.wait() call
 661     mon = java_thread->current_pending_monitor(&omh);
 662     if (mon != NULL) {
 663       // The thread is trying to enter() an ObjectMonitor.
 664       obj = (oop)mon->object();
 665       assert(obj != NULL, "ObjectMonitor should have a valid object!");
 666     }
 667     // implied else: no contended ObjectMonitor
 668   } else {
 669     // thread is doing an Object.wait() call
 670     obj = (oop)mon->object();
 671     assert(obj != NULL, "Object.wait() should have an object");
 672   }
 673 
 674   if (obj == NULL) {
 675     *monitor_ptr = NULL;
 676   } else {
 677     HandleMark hm;
 678     Handle     hobj(Thread::current(), obj);
 679     *monitor_ptr = jni_reference(calling_thread, hobj);
 680   }
 681   return JVMTI_ERROR_NONE;


 717   err = jmc.error();
 718 
 719   return err;
 720 }
 721 
 722 // Save JNI local handles for any objects that this frame owns.
 723 jvmtiError
 724 JvmtiEnvBase::get_locked_objects_in_frame(JavaThread* calling_thread, JavaThread* java_thread,
 725                                  javaVFrame *jvf, GrowableArray<jvmtiMonitorStackDepthInfo*>* owned_monitors_list, jint stack_depth) {
 726   jvmtiError err = JVMTI_ERROR_NONE;
 727   ResourceMark rm;
 728 
 729   GrowableArray<MonitorInfo*>* mons = jvf->monitors();
 730   if (mons->is_empty()) {
 731     return err;  // this javaVFrame holds no monitors
 732   }
 733 
 734   HandleMark hm;
 735   oop wait_obj = NULL;
 736   {
 737     ObjectMonitorHandle omh;
 738     // save object of current wait() call (if any) for later comparison
 739     ObjectMonitor *mon = java_thread->current_waiting_monitor(&omh);
 740     if (mon != NULL) {
 741       wait_obj = (oop)mon->object();
 742     }
 743   }
 744   oop pending_obj = NULL;
 745   {
 746     ObjectMonitorHandle omh;
 747     // save object of current enter() call (if any) for later comparison
 748     ObjectMonitor *mon = java_thread->current_pending_monitor(&omh);
 749     if (mon != NULL) {
 750       pending_obj = (oop)mon->object();
 751     }
 752   }
 753 
 754   for (int i = 0; i < mons->length(); i++) {
 755     MonitorInfo *mi = mons->at(i);
 756 
 757     if (mi->owner_is_scalar_replaced()) continue;
 758 
 759     oop obj = mi->owner();
 760     if (obj == NULL) {
 761       // this monitor doesn't have an owning object so skip it
 762       continue;
 763     }
 764 
 765     if (wait_obj == obj) {
 766       // the thread is waiting on this monitor so it isn't really owned
 767       continue;
 768     }


< prev index next >