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) {
1536 if (jt != NULL && tlh.includes(jt) && !jt->is_exiting() && jt->threadObj() != NULL) {
1537 int frame_number = _state->count_frames() - _depth;
1538 _state->env_thread_state((JvmtiEnvBase*)_env)->set_frame_pop(frame_number);
1539 } else {
1540 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
1541 }
1542 }
1543
1544 void
1545 VM_GetOwnedMonitorInfo::doit() {
1546 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
1547 ThreadsListHandle tlh;
1548 if (_java_thread != NULL && tlh.includes(_java_thread)
1549 && !_java_thread->is_exiting() && _java_thread->threadObj() != NULL) {
1550 _result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, _java_thread,
1551 _owned_monitors_list);
1552 }
1553 }
1554
1555 void
1556 VM_GetCurrentContendedMonitor::doit() {
1557 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
1558 ThreadsListHandle tlh;
1559 if (_java_thread != NULL && tlh.includes(_java_thread)
1560 && !_java_thread->is_exiting() && _java_thread->threadObj() != NULL) {
1561 _result = ((JvmtiEnvBase *)_env)->get_current_contended_monitor(_calling_thread,_java_thread,_owned_monitor_ptr);
1562 }
1563 }
1564
1565 void
1566 VM_GetStackTrace::doit() {
1567 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
1568 ThreadsListHandle tlh;
1569 if (_java_thread != NULL && tlh.includes(_java_thread)
1570 && !_java_thread->is_exiting() && _java_thread->threadObj() != NULL) {
1571 _result = ((JvmtiEnvBase *)_env)->get_stack_trace(_java_thread,
1572 _start_depth, _max_count,
1573 _frame_buffer, _count_ptr);
1574 }
1575 }
1576
1577 void
1578 VM_GetFrameCount::doit() {
1579 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
1580 JavaThread* jt = _state->get_thread();
1581 ThreadsListHandle tlh;
1582 if (jt != NULL && tlh.includes(jt) && !jt->is_exiting() && jt->threadObj() != NULL) {
|
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_vmthread_processing_handshake() ||
656 java_thread->is_thread_fully_suspended(false, &debug_bits)),
657 "at safepoint or target thread is suspended");
658 oop obj = NULL;
659 ObjectMonitor *mon = java_thread->current_waiting_monitor();
660 if (mon == NULL) {
661 // thread is not doing an Object.wait() call
662 mon = java_thread->current_pending_monitor();
663 if (mon != NULL) {
664 // The thread is trying to enter() an ObjectMonitor.
665 obj = (oop)mon->object();
666 assert(obj != NULL, "ObjectMonitor should have a valid object!");
667 }
668 // implied else: no contended ObjectMonitor
669 } else {
670 // thread is doing an Object.wait() call
671 obj = (oop)mon->object();
672 assert(obj != NULL, "Object.wait() should have an object");
673 }
674
675 if (obj == NULL) {
1537 if (jt != NULL && tlh.includes(jt) && !jt->is_exiting() && jt->threadObj() != NULL) {
1538 int frame_number = _state->count_frames() - _depth;
1539 _state->env_thread_state((JvmtiEnvBase*)_env)->set_frame_pop(frame_number);
1540 } else {
1541 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
1542 }
1543 }
1544
1545 void
1546 VM_GetOwnedMonitorInfo::doit() {
1547 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
1548 ThreadsListHandle tlh;
1549 if (_java_thread != NULL && tlh.includes(_java_thread)
1550 && !_java_thread->is_exiting() && _java_thread->threadObj() != NULL) {
1551 _result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, _java_thread,
1552 _owned_monitors_list);
1553 }
1554 }
1555
1556 void
1557 GetOneCurrentContendedMonitor::do_thread(Thread *target) {
1558 _result = ((JvmtiEnvBase *)_env)->get_current_contended_monitor(_calling_thread, (JavaThread *)target, _owned_monitor_ptr);
1559 }
1560
1561 void
1562 VM_GetStackTrace::doit() {
1563 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
1564 ThreadsListHandle tlh;
1565 if (_java_thread != NULL && tlh.includes(_java_thread)
1566 && !_java_thread->is_exiting() && _java_thread->threadObj() != NULL) {
1567 _result = ((JvmtiEnvBase *)_env)->get_stack_trace(_java_thread,
1568 _start_depth, _max_count,
1569 _frame_buffer, _count_ptr);
1570 }
1571 }
1572
1573 void
1574 VM_GetFrameCount::doit() {
1575 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
1576 JavaThread* jt = _state->get_thread();
1577 ThreadsListHandle tlh;
1578 if (jt != NULL && tlh.includes(jt) && !jt->is_exiting() && jt->threadObj() != NULL) {
|