Skip to content

Commit 6611ab8

Browse files
superajun-wsjluchsh
authored andcommitted
hotspot: support jmm mxbean
1 parent 415e3d5 commit 6611ab8

File tree

3 files changed

+409
-2
lines changed

3 files changed

+409
-2
lines changed

src/hotspot/share/include/jmm.h

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ enum {
5353
JMM_VERSION_2 = 0x20020000, // JDK 10
5454
JMM_VERSION_3 = 0x20030000, // JDK 14
5555
JMM_VERSION_4 = 0x20040000, // JDK 21
56+
#if HOTSPOT_TARGET_CLASSLIB == 8
57+
JMM_VERSION = 0x20010203
58+
#else
5659
JMM_VERSION = JMM_VERSION_4
60+
#endif
5761
};
5862

5963
typedef struct {
@@ -62,6 +66,9 @@ typedef struct {
6266
unsigned int isThreadContentionMonitoringSupported : 1;
6367
unsigned int isCurrentThreadCpuTimeSupported : 1;
6468
unsigned int isOtherThreadCpuTimeSupported : 1;
69+
#if HOTSPOT_TARGET_CLASSLIB == 8
70+
unsigned int isBootClassPathSupported : 1;
71+
#endif
6572
unsigned int isObjectMonitorUsageSupported : 1;
6673
unsigned int isSynchronizerUsageSupported : 1;
6774
unsigned int isThreadAllocatedMemorySupported : 1;
@@ -346,6 +353,140 @@ typedef struct jmmInterface_1_ {
346353
jboolean enabled);
347354
} JmmInterface;
348355

356+
#if HOTSPOT_TARGET_CLASSLIB == 8
357+
typedef struct jmmInterface_1_2_3_ {
358+
jlong (JNICALL *GetTotalThreadAllocatedMemory)
359+
(JNIEnv *env);
360+
jlong (JNICALL *GetOneThreadAllocatedMemory)
361+
(JNIEnv *env,
362+
jlong thread_id);
363+
364+
jint (JNICALL *GetVersion) (JNIEnv *env);
365+
366+
jint (JNICALL *GetOptionalSupport) (JNIEnv *env,
367+
jmmOptionalSupport* support_ptr);
368+
369+
/* This is used by JDK 6 and earlier.
370+
* For JDK 7 and after, use GetInputArgumentArray.
371+
*/
372+
jobject (JNICALL *GetInputArguments) (JNIEnv *env);
373+
374+
jint (JNICALL *GetThreadInfo) (JNIEnv *env,
375+
jlongArray ids,
376+
jint maxDepth,
377+
jobjectArray infoArray);
378+
jobjectArray (JNICALL *GetInputArgumentArray) (JNIEnv *env);
379+
380+
jobjectArray (JNICALL *GetMemoryPools) (JNIEnv* env, jobject mgr);
381+
382+
jobjectArray (JNICALL *GetMemoryManagers) (JNIEnv* env, jobject pool);
383+
384+
jobject (JNICALL *GetMemoryPoolUsage) (JNIEnv* env, jobject pool);
385+
jobject (JNICALL *GetPeakMemoryPoolUsage) (JNIEnv* env, jobject pool);
386+
387+
void (JNICALL *GetThreadAllocatedMemory)
388+
(JNIEnv *env,
389+
jlongArray ids,
390+
jlongArray sizeArray);
391+
392+
jobject (JNICALL *GetMemoryUsage) (JNIEnv* env, jboolean heap);
393+
394+
jlong (JNICALL *GetLongAttribute) (JNIEnv *env, jobject obj, jmmLongAttribute att);
395+
jboolean (JNICALL *GetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att);
396+
jboolean (JNICALL *SetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att, jboolean flag);
397+
398+
jint (JNICALL *GetLongAttributes) (JNIEnv *env,
399+
jobject obj,
400+
jmmLongAttribute* atts,
401+
jint count,
402+
jlong* result);
403+
404+
jobjectArray (JNICALL *FindCircularBlockedThreads) (JNIEnv *env);
405+
406+
// Not used in JDK 6 or JDK 7
407+
jlong (JNICALL *GetThreadCpuTime) (JNIEnv *env, jlong thread_id);
408+
409+
jobjectArray (JNICALL *GetVMGlobalNames) (JNIEnv *env);
410+
jint (JNICALL *GetVMGlobals) (JNIEnv *env,
411+
jobjectArray names,
412+
jmmVMGlobal *globals,
413+
jint count);
414+
415+
jint (JNICALL *GetInternalThreadTimes) (JNIEnv *env,
416+
jobjectArray names,
417+
jlongArray times);
418+
419+
jboolean (JNICALL *ResetStatistic) (JNIEnv *env,
420+
jvalue obj,
421+
jmmStatisticType type);
422+
423+
void (JNICALL *SetPoolSensor) (JNIEnv *env,
424+
jobject pool,
425+
jmmThresholdType type,
426+
jobject sensor);
427+
428+
jlong (JNICALL *SetPoolThreshold) (JNIEnv *env,
429+
jobject pool,
430+
jmmThresholdType type,
431+
jlong threshold);
432+
jobject (JNICALL *GetPoolCollectionUsage) (JNIEnv* env, jobject pool);
433+
434+
jint (JNICALL *GetGCExtAttributeInfo) (JNIEnv *env,
435+
jobject mgr,
436+
jmmExtAttributeInfo *ext_info,
437+
jint count);
438+
void (JNICALL *GetLastGCStat) (JNIEnv *env,
439+
jobject mgr,
440+
jmmGCStat *gc_stat);
441+
442+
jlong (JNICALL *GetThreadCpuTimeWithKind)
443+
(JNIEnv *env,
444+
jlong thread_id,
445+
jboolean user_sys_cpu_time);
446+
void (JNICALL *GetThreadCpuTimesWithKind)
447+
(JNIEnv *env,
448+
jlongArray ids,
449+
jlongArray timeArray,
450+
jboolean user_sys_cpu_time);
451+
452+
jint (JNICALL *DumpHeap0) (JNIEnv *env,
453+
jstring outputfile,
454+
jboolean live);
455+
jobjectArray (JNICALL *FindDeadlocks) (JNIEnv *env,
456+
jboolean object_monitors_only);
457+
void (JNICALL *SetVMGlobal) (JNIEnv *env,
458+
jstring flag_name,
459+
jvalue new_value);
460+
jobjectArray (JNICALL *DumpThreadsMaxDepth) (JNIEnv *env,
461+
jlongArray ids,
462+
jboolean lockedMonitors,
463+
jboolean lockedSynchronizers,
464+
jint maxDepth);
465+
jobjectArray (JNICALL *DumpThreads) (JNIEnv *env,
466+
jlongArray ids,
467+
jboolean lockedMonitors,
468+
jboolean lockedSynchronizers);
469+
void (JNICALL *SetGCNotificationEnabled) (JNIEnv *env,
470+
jobject mgr,
471+
jboolean enabled);
472+
jobjectArray (JNICALL *GetDiagnosticCommands) (JNIEnv *env);
473+
void (JNICALL *GetDiagnosticCommandInfo)
474+
(JNIEnv *env,
475+
jobjectArray cmds,
476+
dcmdInfo *infoArray);
477+
void (JNICALL *GetDiagnosticCommandArgumentsInfo)
478+
(JNIEnv *env,
479+
jstring commandName,
480+
dcmdArgInfo *infoArray);
481+
jstring (JNICALL *ExecuteDiagnosticCommand)
482+
(JNIEnv *env,
483+
jstring command);
484+
void (JNICALL *SetDiagnosticFrameworkNotificationEnabled)
485+
(JNIEnv *env,
486+
jboolean enabled);
487+
} JmmInterface_1_2_3;
488+
#endif
489+
349490
#ifdef __cplusplus
350491
} /* extern "C" */
351492
#endif /* __cplusplus */

src/hotspot/share/services/management.cpp

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ void Management::init() {
135135
_optional_support.isOtherThreadCpuTimeSupported = 0;
136136
}
137137

138+
#if HOTSPOT_TARGET_CLASSLIB == 8
139+
_optional_support.isBootClassPathSupported = 1;
140+
#endif
138141
_optional_support.isObjectMonitorUsageSupported = 1;
139142
#if INCLUDE_SERVICES
140143
// This depends on the heap inspector
@@ -1173,8 +1176,8 @@ JVM_END
11731176
// locked_monitors - if true, dump locked object monitors
11741177
// locked_synchronizers - if true, dump locked JSR-166 synchronizers
11751178
//
1176-
JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboolean locked_monitors,
1177-
jboolean locked_synchronizers, jint maxDepth))
1179+
jobjectArray dump_threads_common(JNIEnv *env, jlongArray thread_ids, jboolean locked_monitors,
1180+
jboolean locked_synchronizers, jint maxDepth, TRAPS) {
11781181
ResourceMark rm(THREAD);
11791182

11801183
typeArrayOop ta = typeArrayOop(JNIHandles::resolve(thread_ids));
@@ -1303,6 +1306,11 @@ JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboo
13031306
}
13041307

13051308
return (jobjectArray) JNIHandles::make_local(THREAD, result_h());
1309+
}
1310+
1311+
JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboolean locked_monitors,
1312+
jboolean locked_synchronizers, jint maxDepth))
1313+
return dump_threads_common(env, thread_ids, locked_monitors, locked_synchronizers, maxDepth, THREAD);
13061314
JVM_END
13071315

13081316
// Reset statistic. Return true if the requested statistic is reset.
@@ -2298,13 +2306,72 @@ const struct jmmInterface_1_ jmm_interface = {
22982306
jmm_ExecuteDiagnosticCommand,
22992307
jmm_SetDiagnosticFrameworkNotificationEnabled
23002308
};
2309+
2310+
#if HOTSPOT_TARGET_CLASSLIB == 8
2311+
2312+
extern "C" jobjectArray jmm_DumpThreads_JDK8(JNIEnv *env, jlongArray thread_ids, jboolean locked_monitors,
2313+
jboolean locked_synchronizers);
2314+
extern "C" jobjectArray jmm_GetInputArgumentArray(JNIEnv *env);
2315+
extern "C" jobject jmm_GetInputArguments(JNIEnv *env);
2316+
extern "C" void jmm_GetDiagnosticCommandArgumentsInfo_JDK8(JNIEnv *env, jstring command, dcmdArgInfo* infoArray);
2317+
2318+
const struct jmmInterface_1_2_3_ jmm_interface_1_2_3 = {
2319+
jmm_GetTotalThreadAllocatedMemory,
2320+
jmm_GetOneThreadAllocatedMemory,
2321+
jmm_GetVersion,
2322+
jmm_GetOptionalSupport,
2323+
jmm_GetInputArguments,
2324+
jmm_GetThreadInfo,
2325+
jmm_GetInputArgumentArray,
2326+
jmm_GetMemoryPools,
2327+
jmm_GetMemoryManagers,
2328+
jmm_GetMemoryPoolUsage,
2329+
jmm_GetPeakMemoryPoolUsage,
2330+
jmm_GetThreadAllocatedMemory,
2331+
jmm_GetMemoryUsage,
2332+
jmm_GetLongAttribute,
2333+
jmm_GetBoolAttribute,
2334+
jmm_SetBoolAttribute,
2335+
jmm_GetLongAttributes,
2336+
jmm_FindMonitorDeadlockedThreads,
2337+
jmm_GetThreadCpuTime,
2338+
jmm_GetVMGlobalNames,
2339+
jmm_GetVMGlobals,
2340+
jmm_GetInternalThreadTimes,
2341+
jmm_ResetStatistic,
2342+
jmm_SetPoolSensor,
2343+
jmm_SetPoolThreshold,
2344+
jmm_GetPoolCollectionUsage,
2345+
jmm_GetGCExtAttributeInfo,
2346+
jmm_GetLastGCStat,
2347+
jmm_GetThreadCpuTimeWithKind,
2348+
jmm_GetThreadCpuTimesWithKind,
2349+
jmm_DumpHeap0,
2350+
jmm_FindDeadlockedThreads,
2351+
jmm_SetVMGlobal,
2352+
jmm_DumpThreads,
2353+
jmm_DumpThreads_JDK8,
2354+
jmm_SetGCNotificationEnabled,
2355+
jmm_GetDiagnosticCommands,
2356+
jmm_GetDiagnosticCommandInfo,
2357+
jmm_GetDiagnosticCommandArgumentsInfo_JDK8,
2358+
jmm_ExecuteDiagnosticCommand,
2359+
jmm_SetDiagnosticFrameworkNotificationEnabled
2360+
};
2361+
#endif
23012362
#endif // INCLUDE_MANAGEMENT
23022363

23032364
void* Management::get_jmm_interface(int version) {
23042365
#if INCLUDE_MANAGEMENT
2366+
#if HOTSPOT_TARGET_CLASSLIB == 8
2367+
if (version == JMM_VERSION_1_0) {
2368+
return (void*) &jmm_interface_1_2_3;
2369+
}
2370+
#else
23052371
if (version == JMM_VERSION) {
23062372
return (void*) &jmm_interface;
23072373
}
2374+
#endif
23082375
#endif // INCLUDE_MANAGEMENT
23092376
return nullptr;
23102377
}

0 commit comments

Comments
 (0)