< prev index next >

src/share/vm/prims/jvmtiEnvBase.cpp

Print this page




1473       }
1474     }
1475     if (found == false) {
1476       // This is off stack monitor (e.g. acquired via jni MonitorEnter).
1477       jvmtiError err;
1478       jvmtiMonitorStackDepthInfo *jmsdi;
1479       err = _env->allocate(sizeof(jvmtiMonitorStackDepthInfo), (unsigned char **)&jmsdi);
1480       if (err != JVMTI_ERROR_NONE) {
1481         _error = err;
1482         return;
1483       }
1484       Handle hobj(Thread::current(), obj);
1485       jmsdi->monitor = _env->jni_reference(_calling_thread, hobj);
1486       // stack depth is unknown for this monitor.
1487       jmsdi->stack_depth = -1;
1488       _owned_monitors_list->append(jmsdi);
1489     }
1490   }
1491 }
1492 
1493 GrowableArray<jobject>* JvmtiModuleClosure::_tbl = NULL;
1494 
1495 jvmtiError
1496 JvmtiModuleClosure::get_all_modules(JvmtiEnv* env, jint* module_count_ptr, jobject** modules_ptr) {
1497   ResourceMark rm;
1498   MutexLocker ml(Module_lock);
1499 
1500   _tbl = new GrowableArray<jobject>(77);
1501   if (_tbl == NULL) {
1502     return JVMTI_ERROR_OUT_OF_MEMORY;
1503   }
1504 
1505   // Iterate over all the modules loaded to the system.
1506   ClassLoaderDataGraph::modules_do(&do_module);
1507 
1508   jint len = _tbl->length();
1509   guarantee(len > 0, "at least one module must be present");
1510 
1511   jobject* array = (jobject*)env->jvmtiMalloc((jlong)(len * sizeof(jobject)));
1512   if (array == NULL) {
1513     return JVMTI_ERROR_OUT_OF_MEMORY;
1514   }
1515   for (jint idx = 0; idx < len; idx++) {
1516     array[idx] = _tbl->at(idx);
1517   }
1518   _tbl = NULL;
1519   *modules_ptr = array;
1520   *module_count_ptr = len;
1521   return JVMTI_ERROR_NONE;
1522 }
1523 


1473       }
1474     }
1475     if (found == false) {
1476       // This is off stack monitor (e.g. acquired via jni MonitorEnter).
1477       jvmtiError err;
1478       jvmtiMonitorStackDepthInfo *jmsdi;
1479       err = _env->allocate(sizeof(jvmtiMonitorStackDepthInfo), (unsigned char **)&jmsdi);
1480       if (err != JVMTI_ERROR_NONE) {
1481         _error = err;
1482         return;
1483       }
1484       Handle hobj(Thread::current(), obj);
1485       jmsdi->monitor = _env->jni_reference(_calling_thread, hobj);
1486       // stack depth is unknown for this monitor.
1487       jmsdi->stack_depth = -1;
1488       _owned_monitors_list->append(jmsdi);
1489     }
1490   }
1491 }
1492 
1493 GrowableArray<OopHandle>* JvmtiModuleClosure::_tbl = NULL;
1494 
1495 jvmtiError
1496 JvmtiModuleClosure::get_all_modules(JvmtiEnv* env, jint* module_count_ptr, jobject** modules_ptr) {
1497   ResourceMark rm;
1498   MutexLocker ml(Module_lock);
1499 
1500   _tbl = new GrowableArray<OopHandle>(77);
1501   if (_tbl == NULL) {
1502     return JVMTI_ERROR_OUT_OF_MEMORY;
1503   }
1504 
1505   // Iterate over all the modules loaded to the system.
1506   ClassLoaderDataGraph::modules_do(&do_module);
1507 
1508   jint len = _tbl->length();
1509   guarantee(len > 0, "at least one module must be present");
1510 
1511   jobject* array = (jobject*)env->jvmtiMalloc((jlong)(len * sizeof(jobject)));
1512   if (array == NULL) {
1513     return JVMTI_ERROR_OUT_OF_MEMORY;
1514   }
1515   for (jint idx = 0; idx < len; idx++) {
1516     array[idx] = JNIHandles::make_local(Thread::current(), _tbl->at(idx).resolve());
1517   }
1518   _tbl = NULL;
1519   *modules_ptr = array;
1520   *module_count_ptr = len;
1521   return JVMTI_ERROR_NONE;
1522 }
1523 
< prev index next >