1487 // Iterate over all the modules loaded to the system. 1488 ClassLoaderDataGraph::modules_do(&do_module); 1489 1490 jint len = _tbl->length(); 1491 guarantee(len > 0, "at least one module must be present"); 1492 1493 jobject* array = (jobject*)env->jvmtiMalloc((jlong)(len * sizeof(jobject))); 1494 if (array == NULL) { 1495 return JVMTI_ERROR_OUT_OF_MEMORY; 1496 } 1497 for (jint idx = 0; idx < len; idx++) { 1498 array[idx] = JNIHandles::make_local(Thread::current(), _tbl->at(idx).resolve()); 1499 } 1500 _tbl = NULL; 1501 *modules_ptr = array; 1502 *module_count_ptr = len; 1503 return JVMTI_ERROR_NONE; 1504 } 1505 1506 void 1507 VM_UpdateForPopTopFrame::doit() { 1508 JavaThread* jt = _state->get_thread(); 1509 ThreadsListHandle tlh; 1510 if (jt != NULL && tlh.includes(jt) && !jt->is_exiting() && jt->threadObj() != NULL) { 1511 _state->update_for_pop_top_frame(); 1512 } else { 1513 _result = JVMTI_ERROR_THREAD_NOT_ALIVE; 1514 } 1515 } 1516 1517 void 1518 VM_SetFramePop::doit() { 1519 JavaThread* jt = _state->get_thread(); 1520 ThreadsListHandle tlh; 1521 if (jt != NULL && tlh.includes(jt) && !jt->is_exiting() && jt->threadObj() != NULL) { 1522 int frame_number = _state->count_frames() - _depth; 1523 _state->env_thread_state((JvmtiEnvBase*)_env)->set_frame_pop(frame_number); 1524 } else { 1525 _result = JVMTI_ERROR_THREAD_NOT_ALIVE; 1526 } 1527 } 1528 1529 void 1530 GetOwnedMonitorInfoClosure::do_thread(Thread *target) { 1531 assert(target->is_Java_thread(), "just checking"); 1532 JavaThread *jt = (JavaThread *)target; 1533 if (!jt->is_exiting() && (jt->threadObj() != NULL)) { 1534 _result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, 1535 jt, 1536 _owned_monitors_list); 1537 } 1538 } 1539 1540 void 1541 GetCurrentContendedMonitorClosure::do_thread(Thread *target) { 1542 assert(target->is_Java_thread(), "just checking"); 1543 JavaThread *jt = (JavaThread *)target; 1544 if (!jt->is_exiting() && (jt->threadObj() != NULL)) { 1545 _result = ((JvmtiEnvBase *)_env)->get_current_contended_monitor(_calling_thread, | 1487 // Iterate over all the modules loaded to the system. 1488 ClassLoaderDataGraph::modules_do(&do_module); 1489 1490 jint len = _tbl->length(); 1491 guarantee(len > 0, "at least one module must be present"); 1492 1493 jobject* array = (jobject*)env->jvmtiMalloc((jlong)(len * sizeof(jobject))); 1494 if (array == NULL) { 1495 return JVMTI_ERROR_OUT_OF_MEMORY; 1496 } 1497 for (jint idx = 0; idx < len; idx++) { 1498 array[idx] = JNIHandles::make_local(Thread::current(), _tbl->at(idx).resolve()); 1499 } 1500 _tbl = NULL; 1501 *modules_ptr = array; 1502 *module_count_ptr = len; 1503 return JVMTI_ERROR_NONE; 1504 } 1505 1506 void 1507 UpdateForPopTopFrameClosure::do_thread(Thread *target) { 1508 JavaThread* jt = _state->get_thread(); 1509 assert(jt == target, "just checking"); 1510 if (!jt->is_exiting() && jt->threadObj() != NULL) { 1511 _state->update_for_pop_top_frame(); 1512 _result = JVMTI_ERROR_NONE; 1513 } 1514 } 1515 1516 void 1517 SetFramePopClosure::do_thread(Thread *target) { 1518 JavaThread* jt = _state->get_thread(); 1519 assert(jt == target, "just checking"); 1520 if (!jt->is_exiting() && jt->threadObj() != NULL) { 1521 int frame_number = _state->count_frames() - _depth; 1522 _state->env_thread_state((JvmtiEnvBase*)_env)->set_frame_pop(frame_number); 1523 _result = JVMTI_ERROR_NONE; 1524 } 1525 } 1526 1527 void 1528 GetOwnedMonitorInfoClosure::do_thread(Thread *target) { 1529 assert(target->is_Java_thread(), "just checking"); 1530 JavaThread *jt = (JavaThread *)target; 1531 if (!jt->is_exiting() && (jt->threadObj() != NULL)) { 1532 _result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, 1533 jt, 1534 _owned_monitors_list); 1535 } 1536 } 1537 1538 void 1539 GetCurrentContendedMonitorClosure::do_thread(Thread *target) { 1540 assert(target->is_Java_thread(), "just checking"); 1541 JavaThread *jt = (JavaThread *)target; 1542 if (!jt->is_exiting() && (jt->threadObj() != NULL)) { 1543 _result = ((JvmtiEnvBase *)_env)->get_current_contended_monitor(_calling_thread, |