< prev index next >

src/hotspot/share/services/management.cpp

Print this page
rev 47287 : Port 09.17.Thread_SMR_logging_update from JDK9 to JDK10
rev 47289 : eosterlund, stefank CR - refactor code into threadSMR.cpp and threadSMR.hpp
rev 47292 : stefank, coleenp CR - refactor most JavaThreadIterator usage to use JavaThreadIteratorWithHandle.


1307 //         For PEAK_POOL_USAGE stat, obj is required to be a memory pool object.
1308 //         For THREAD_CONTENTION_COUNT and TIME stat, obj is required to be a thread ID.
1309 //  type - the type of statistic to be reset
1310 //
1311 JVM_ENTRY(jboolean, jmm_ResetStatistic(JNIEnv *env, jvalue obj, jmmStatisticType type))
1312   ResourceMark rm(THREAD);
1313 
1314   switch (type) {
1315     case JMM_STAT_PEAK_THREAD_COUNT:
1316       ThreadService::reset_peak_thread_count();
1317       return true;
1318 
1319     case JMM_STAT_THREAD_CONTENTION_COUNT:
1320     case JMM_STAT_THREAD_CONTENTION_TIME: {
1321       jlong tid = obj.j;
1322       if (tid < 0) {
1323         THROW_(vmSymbols::java_lang_IllegalArgumentException(), JNI_FALSE);
1324       }
1325 
1326       // Look for the JavaThread of this given tid
1327       ThreadsListHandle tlh;
1328       if (tid == 0) {
1329         JavaThreadIterator jti(tlh.list());
1330         // reset contention statistics for all threads if tid == 0
1331         for (JavaThread* java_thread = jti.first(); java_thread != NULL; java_thread = jti.next()) {
1332           if (type == JMM_STAT_THREAD_CONTENTION_COUNT) {
1333             ThreadService::reset_contention_count_stat(java_thread);
1334           } else {
1335             ThreadService::reset_contention_time_stat(java_thread);
1336           }
1337         }
1338       } else {
1339         // reset contention statistics for a given thread
1340         JavaThread* java_thread = tlh.list()->find_JavaThread_from_java_tid(tid);
1341         if (java_thread == NULL) {
1342           return false;
1343         }
1344 
1345         if (type == JMM_STAT_THREAD_CONTENTION_COUNT) {
1346           ThreadService::reset_contention_count_stat(java_thread);
1347         } else {
1348           ThreadService::reset_contention_time_stat(java_thread);
1349         }
1350       }
1351       return true;
1352       break;
1353     }
1354     case JMM_STAT_PEAK_POOL_USAGE: {
1355       jobject o = obj.l;
1356       if (o == NULL) {
1357         THROW_(vmSymbols::java_lang_NullPointerException(), JNI_FALSE);
1358       }
1359 
1360       oop pool_obj = JNIHandles::resolve(o);




1307 //         For PEAK_POOL_USAGE stat, obj is required to be a memory pool object.
1308 //         For THREAD_CONTENTION_COUNT and TIME stat, obj is required to be a thread ID.
1309 //  type - the type of statistic to be reset
1310 //
1311 JVM_ENTRY(jboolean, jmm_ResetStatistic(JNIEnv *env, jvalue obj, jmmStatisticType type))
1312   ResourceMark rm(THREAD);
1313 
1314   switch (type) {
1315     case JMM_STAT_PEAK_THREAD_COUNT:
1316       ThreadService::reset_peak_thread_count();
1317       return true;
1318 
1319     case JMM_STAT_THREAD_CONTENTION_COUNT:
1320     case JMM_STAT_THREAD_CONTENTION_TIME: {
1321       jlong tid = obj.j;
1322       if (tid < 0) {
1323         THROW_(vmSymbols::java_lang_IllegalArgumentException(), JNI_FALSE);
1324       }
1325 
1326       // Look for the JavaThread of this given tid
1327       JavaThreadIteratorWithHandle jtiwh;
1328       if (tid == 0) {

1329         // reset contention statistics for all threads if tid == 0
1330         for (; JavaThread *java_thread = jtiwh.next(); ) {
1331           if (type == JMM_STAT_THREAD_CONTENTION_COUNT) {
1332             ThreadService::reset_contention_count_stat(java_thread);
1333           } else {
1334             ThreadService::reset_contention_time_stat(java_thread);
1335           }
1336         }
1337       } else {
1338         // reset contention statistics for a given thread
1339         JavaThread* java_thread = jtiwh.list()->find_JavaThread_from_java_tid(tid);
1340         if (java_thread == NULL) {
1341           return false;
1342         }
1343 
1344         if (type == JMM_STAT_THREAD_CONTENTION_COUNT) {
1345           ThreadService::reset_contention_count_stat(java_thread);
1346         } else {
1347           ThreadService::reset_contention_time_stat(java_thread);
1348         }
1349       }
1350       return true;
1351       break;
1352     }
1353     case JMM_STAT_PEAK_POOL_USAGE: {
1354       jobject o = obj.l;
1355       if (o == NULL) {
1356         THROW_(vmSymbols::java_lang_NullPointerException(), JNI_FALSE);
1357       }
1358 
1359       oop pool_obj = JNIHandles::resolve(o);


< prev index next >