< prev index next >

src/hotspot/share/prims/jvmtiEnvBase.cpp

Print this page
rev 57595 : v2.09a with 8235795, 8235931 and 8236035 extracted; rebased to jdk-14+28; merge with 8236035.patch.cr1; merge with 8235795.patch.cr1; merge with 8236035.patch.cr2; merge with 8235795.patch.cr2; merge with 8235795.patch.cr3.


 634         MonitorInfo *mi = mons->at(i);
 635         if (mi->owner_is_scalar_replaced()) continue;
 636 
 637         // see if owner of the monitor is our object
 638         if (mi->owner() != NULL && mi->owner() == hobj()) {
 639           ret++;
 640         }
 641       }
 642     }
 643   }
 644   return ret;
 645 }
 646 
 647 
 648 
 649 jvmtiError
 650 JvmtiEnvBase::get_current_contended_monitor(JavaThread *calling_thread, JavaThread *java_thread, jobject *monitor_ptr) {
 651 #ifdef ASSERT
 652   uint32_t debug_bits = 0;
 653 #endif




 654   assert((SafepointSynchronize::is_at_safepoint() ||
 655           java_thread->is_thread_fully_suspended(false, &debug_bits)),
 656          "at safepoint or target thread is suspended");
 657   oop obj = NULL;
 658   ObjectMonitor *mon = java_thread->current_waiting_monitor();




 659   if (mon == NULL) {
 660     // thread is not doing an Object.wait() call
 661     mon = java_thread->current_pending_monitor();
 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     // save object of current wait() call (if any) for later comparison
 738     ObjectMonitor *mon = java_thread->current_waiting_monitor();
 739     if (mon != NULL) {
 740       wait_obj = (oop)mon->object();
 741     }
 742   }
 743   oop pending_obj = NULL;
 744   {




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




 634         MonitorInfo *mi = mons->at(i);
 635         if (mi->owner_is_scalar_replaced()) continue;
 636 
 637         // see if owner of the monitor is our object
 638         if (mi->owner() != NULL && mi->owner() == hobj()) {
 639           ret++;
 640         }
 641       }
 642     }
 643   }
 644   return ret;
 645 }
 646 
 647 
 648 
 649 jvmtiError
 650 JvmtiEnvBase::get_current_contended_monitor(JavaThread *calling_thread, JavaThread *java_thread, jobject *monitor_ptr) {
 651 #ifdef ASSERT
 652   uint32_t debug_bits = 0;
 653 #endif
 654   // Note: The is_thread_fully_suspended() part of the assert() is
 655   // from an older implementation that recognized suspension as
 656   // being safe. However, that was racy in the face of rogue resumes.
 657   // Should be replaced with "calling_thread == java_thread".
 658   assert((SafepointSynchronize::is_at_safepoint() ||
 659           java_thread->is_thread_fully_suspended(false, &debug_bits)),
 660          "at safepoint or target thread is suspended");
 661   oop obj = NULL;
 662   // For all of the get_current_contended_monitor() call sites, we
 663   // are either at a safepoint or the calling thread is operating
 664   // on itself so this ObjectMonitorHandle is not strictly necessary.
 665   ObjectMonitorHandle omh;
 666   ObjectMonitor *mon = java_thread->current_waiting_monitor(&omh);
 667   if (mon == NULL) {
 668     // thread is not doing an Object.wait() call
 669     mon = java_thread->current_pending_monitor(&omh);
 670     if (mon != NULL) {
 671       // The thread is trying to enter() an ObjectMonitor.
 672       obj = (oop)mon->object();
 673       assert(obj != NULL, "ObjectMonitor should have a valid object!");
 674     }
 675     // implied else: no contended ObjectMonitor
 676   } else {
 677     // thread is doing an Object.wait() call
 678     obj = (oop)mon->object();
 679     assert(obj != NULL, "Object.wait() should have an object");
 680   }
 681 
 682   if (obj == NULL) {
 683     *monitor_ptr = NULL;
 684   } else {
 685     HandleMark hm;
 686     Handle     hobj(Thread::current(), obj);
 687     *monitor_ptr = jni_reference(calling_thread, hobj);
 688   }
 689   return JVMTI_ERROR_NONE;


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


< prev index next >