< prev index next >

src/hotspot/share/prims/jvmtiEnv.cpp

Print this page

1346 jvmtiError
1347 JvmtiEnv::GetOwnedMonitorInfo(jthread thread, jint* owned_monitor_count_ptr, jobject** owned_monitors_ptr) {
1348   JavaThread* calling_thread = JavaThread::current();
1349   HandleMark hm(calling_thread);
1350 
1351   // growable array of jvmti monitors info on the C-heap
1352   GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list =
1353       new (mtServiceability) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, mtServiceability);
1354 
1355   JvmtiVTMSTransitionDisabler disabler(thread);
1356   ThreadsListHandle tlh(calling_thread);
1357 
1358   JavaThread* java_thread = nullptr;
1359   oop thread_oop = nullptr;
1360   jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_oop);
1361   if (err != JVMTI_ERROR_NONE) {
1362     delete owned_monitors_list;
1363     return err;
1364   }
1365 
1366   if (java_thread != nullptr) {
1367     Handle thread_handle(calling_thread, thread_oop);
1368     EscapeBarrier eb(true, calling_thread, java_thread);
1369     if (!eb.deoptimize_objects(MaxJavaStackTraceDepth)) {
1370       delete owned_monitors_list;
1371       return JVMTI_ERROR_OUT_OF_MEMORY;
1372     }
1373     // get owned monitors info with handshake
1374     GetOwnedMonitorInfoClosure op(this, calling_thread, owned_monitors_list);
1375     JvmtiHandshake::execute(&op, &tlh, java_thread, thread_handle);
1376     err = op.result();
1377   }




1378 
1379   jint owned_monitor_count = owned_monitors_list->length();
1380   if (err == JVMTI_ERROR_NONE) {
1381     if ((err = allocate(owned_monitor_count * sizeof(jobject *),
1382                       (unsigned char**)owned_monitors_ptr)) == JVMTI_ERROR_NONE) {
1383       // copy into the returned array
1384       for (int i = 0; i < owned_monitor_count; i++) {
1385         (*owned_monitors_ptr)[i] =
1386           ((jvmtiMonitorStackDepthInfo*)owned_monitors_list->at(i))->monitor;
1387       }
1388       *owned_monitor_count_ptr = owned_monitor_count;
1389     }
1390   }
1391   // clean up.
1392   for (int i = 0; i < owned_monitor_count; i++) {
1393     deallocate((unsigned char*)owned_monitors_list->at(i));
1394   }
1395   delete owned_monitors_list;
1396 
1397   return err;

1404 jvmtiError
1405 JvmtiEnv::GetOwnedMonitorStackDepthInfo(jthread thread, jint* monitor_info_count_ptr, jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
1406   JavaThread* calling_thread = JavaThread::current();
1407   HandleMark hm(calling_thread);
1408 
1409   // growable array of jvmti monitors info on the C-heap
1410   GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list =
1411          new (mtServiceability) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, mtServiceability);
1412 
1413   JvmtiVTMSTransitionDisabler disabler(thread);
1414   ThreadsListHandle tlh(calling_thread);
1415 
1416   JavaThread* java_thread = nullptr;
1417   oop thread_oop = nullptr;
1418   jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_oop);
1419   if (err != JVMTI_ERROR_NONE) {
1420     delete owned_monitors_list;
1421     return err;
1422   }
1423 
1424   if (java_thread != nullptr) {
1425     Handle thread_handle(calling_thread, thread_oop);
1426     EscapeBarrier eb(true, calling_thread, java_thread);
1427     if (!eb.deoptimize_objects(MaxJavaStackTraceDepth)) {
1428       delete owned_monitors_list;
1429       return JVMTI_ERROR_OUT_OF_MEMORY;
1430     }
1431     // get owned monitors info with handshake
1432     GetOwnedMonitorInfoClosure op(this, calling_thread, owned_monitors_list);
1433     JvmtiHandshake::execute(&op, &tlh, java_thread, thread_handle);
1434     err = op.result();
1435   }




1436 
1437   jint owned_monitor_count = owned_monitors_list->length();
1438   if (err == JVMTI_ERROR_NONE) {
1439     if ((err = allocate(owned_monitor_count * sizeof(jvmtiMonitorStackDepthInfo),
1440                         (unsigned char**)monitor_info_ptr)) == JVMTI_ERROR_NONE) {
1441       // copy to output array.
1442       for (int i = 0; i < owned_monitor_count; i++) {
1443         (*monitor_info_ptr)[i].monitor =
1444           ((jvmtiMonitorStackDepthInfo*)owned_monitors_list->at(i))->monitor;
1445         (*monitor_info_ptr)[i].stack_depth =
1446           ((jvmtiMonitorStackDepthInfo*)owned_monitors_list->at(i))->stack_depth;
1447       }
1448     }
1449     *monitor_info_count_ptr = owned_monitor_count;
1450   }
1451 
1452   // clean up.
1453   for (int i = 0; i < owned_monitor_count; i++) {
1454     deallocate((unsigned char*)owned_monitors_list->at(i));
1455   }

1346 jvmtiError
1347 JvmtiEnv::GetOwnedMonitorInfo(jthread thread, jint* owned_monitor_count_ptr, jobject** owned_monitors_ptr) {
1348   JavaThread* calling_thread = JavaThread::current();
1349   HandleMark hm(calling_thread);
1350 
1351   // growable array of jvmti monitors info on the C-heap
1352   GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list =
1353       new (mtServiceability) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, mtServiceability);
1354 
1355   JvmtiVTMSTransitionDisabler disabler(thread);
1356   ThreadsListHandle tlh(calling_thread);
1357 
1358   JavaThread* java_thread = nullptr;
1359   oop thread_oop = nullptr;
1360   jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_oop);
1361   if (err != JVMTI_ERROR_NONE) {
1362     delete owned_monitors_list;
1363     return err;
1364   }
1365 
1366   Handle thread_handle(calling_thread, thread_oop);
1367   EscapeBarrier eb(java_thread != nullptr, calling_thread, java_thread);
1368   if (!eb.deoptimize_objects(MaxJavaStackTraceDepth)) {
1369     delete owned_monitors_list;
1370     return JVMTI_ERROR_OUT_OF_MEMORY;






1371   }
1372   // get owned monitors info with handshake
1373   GetOwnedMonitorInfoClosure op(this, calling_thread, owned_monitors_list);
1374   JvmtiHandshake::execute(&op, &tlh, java_thread, thread_handle);
1375   err = op.result();
1376 
1377   jint owned_monitor_count = owned_monitors_list->length();
1378   if (err == JVMTI_ERROR_NONE) {
1379     if ((err = allocate(owned_monitor_count * sizeof(jobject *),
1380                       (unsigned char**)owned_monitors_ptr)) == JVMTI_ERROR_NONE) {
1381       // copy into the returned array
1382       for (int i = 0; i < owned_monitor_count; i++) {
1383         (*owned_monitors_ptr)[i] =
1384           ((jvmtiMonitorStackDepthInfo*)owned_monitors_list->at(i))->monitor;
1385       }
1386       *owned_monitor_count_ptr = owned_monitor_count;
1387     }
1388   }
1389   // clean up.
1390   for (int i = 0; i < owned_monitor_count; i++) {
1391     deallocate((unsigned char*)owned_monitors_list->at(i));
1392   }
1393   delete owned_monitors_list;
1394 
1395   return err;

1402 jvmtiError
1403 JvmtiEnv::GetOwnedMonitorStackDepthInfo(jthread thread, jint* monitor_info_count_ptr, jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
1404   JavaThread* calling_thread = JavaThread::current();
1405   HandleMark hm(calling_thread);
1406 
1407   // growable array of jvmti monitors info on the C-heap
1408   GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list =
1409          new (mtServiceability) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, mtServiceability);
1410 
1411   JvmtiVTMSTransitionDisabler disabler(thread);
1412   ThreadsListHandle tlh(calling_thread);
1413 
1414   JavaThread* java_thread = nullptr;
1415   oop thread_oop = nullptr;
1416   jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_oop);
1417   if (err != JVMTI_ERROR_NONE) {
1418     delete owned_monitors_list;
1419     return err;
1420   }
1421 
1422   Handle thread_handle(calling_thread, thread_oop);
1423   EscapeBarrier eb(java_thread != nullptr, calling_thread, java_thread);
1424   if (!eb.deoptimize_objects(MaxJavaStackTraceDepth)) {
1425     delete owned_monitors_list;
1426     return JVMTI_ERROR_OUT_OF_MEMORY;






1427   }
1428   // get owned monitors info with handshake
1429   GetOwnedMonitorInfoClosure op(this, calling_thread, owned_monitors_list);
1430   JvmtiHandshake::execute(&op, &tlh, java_thread, thread_handle);
1431   err = op.result();
1432 
1433   jint owned_monitor_count = owned_monitors_list->length();
1434   if (err == JVMTI_ERROR_NONE) {
1435     if ((err = allocate(owned_monitor_count * sizeof(jvmtiMonitorStackDepthInfo),
1436                         (unsigned char**)monitor_info_ptr)) == JVMTI_ERROR_NONE) {
1437       // copy to output array.
1438       for (int i = 0; i < owned_monitor_count; i++) {
1439         (*monitor_info_ptr)[i].monitor =
1440           ((jvmtiMonitorStackDepthInfo*)owned_monitors_list->at(i))->monitor;
1441         (*monitor_info_ptr)[i].stack_depth =
1442           ((jvmtiMonitorStackDepthInfo*)owned_monitors_list->at(i))->stack_depth;
1443       }
1444     }
1445     *monitor_info_count_ptr = owned_monitor_count;
1446   }
1447 
1448   // clean up.
1449   for (int i = 0; i < owned_monitor_count; i++) {
1450     deallocate((unsigned char*)owned_monitors_list->at(i));
1451   }
< prev index next >