src/share/vm/services/jmm.h

Mon, 19 Aug 2013 18:17:58 +0200

author
ehelin
date
Mon, 19 Aug 2013 18:17:58 +0200
changeset 5552
422920730903
parent 5047
31a4e55f8c9d
child 6026
e4f478e7781b
permissions
-rw-r--r--

8023219: NPG: MetaspaceMemoryPool should report statistics for all of metaspace
Reviewed-by: stefank, sjohanss

duke@435 1 /*
fparain@5047 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
trims@1907 7 * published by the Free Software Foundation. Oracle designates this
duke@435 8 * particular file as subject to the "Classpath" exception as provided
trims@1907 9 * by Oracle in the LICENSE file that accompanied this code.
duke@435 10 *
duke@435 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 15 * accompanied this code).
duke@435 16 *
duke@435 17 * You should have received a copy of the GNU General Public License version
duke@435 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 20 *
trims@1907 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 22 * or visit www.oracle.com if you need additional information or have any
trims@1907 23 * questions.
duke@435 24 */
duke@435 25
duke@435 26 #ifndef _JAVA_JMM_H_
duke@435 27 #define _JAVA_JMM_H_
duke@435 28
duke@435 29 /*
duke@435 30 * This is a private interface used by JDK for JVM monitoring
duke@435 31 * and management.
duke@435 32 *
duke@435 33 * Bump the version number when either of the following happens:
duke@435 34 *
duke@435 35 * 1. There is a change in functions in JmmInterface.
duke@435 36 *
duke@435 37 * 2. There is a change in the contract between VM and Java classes.
duke@435 38 */
duke@435 39
duke@435 40 #include "jni.h"
duke@435 41
duke@435 42 #ifdef __cplusplus
duke@435 43 extern "C" {
duke@435 44 #endif
duke@435 45
duke@435 46 enum {
duke@435 47 JMM_VERSION_1 = 0x20010000,
duke@435 48 JMM_VERSION_1_0 = 0x20010000,
duke@435 49 JMM_VERSION_1_1 = 0x20010100, // JDK 6
duke@435 50 JMM_VERSION_1_2 = 0x20010200, // JDK 7
fparain@3329 51 JMM_VERSION_1_2_1 = 0x20010201, // JDK 7 GA
fparain@5047 52 JMM_VERSION_1_2_2 = 0x20010202,
fparain@5047 53 JMM_VERSION = 0x20010203
duke@435 54 };
duke@435 55
duke@435 56 typedef struct {
duke@435 57 unsigned int isLowMemoryDetectionSupported : 1;
duke@435 58 unsigned int isCompilationTimeMonitoringSupported : 1;
duke@435 59 unsigned int isThreadContentionMonitoringSupported : 1;
duke@435 60 unsigned int isCurrentThreadCpuTimeSupported : 1;
duke@435 61 unsigned int isOtherThreadCpuTimeSupported : 1;
duke@435 62 unsigned int isBootClassPathSupported : 1;
duke@435 63 unsigned int isObjectMonitorUsageSupported : 1;
duke@435 64 unsigned int isSynchronizerUsageSupported : 1;
phh@2423 65 unsigned int isThreadAllocatedMemorySupported : 1;
fparain@5047 66 unsigned int isRemoteDiagnosticCommandsSupported : 1;
fparain@5047 67 unsigned int : 22;
duke@435 68 } jmmOptionalSupport;
duke@435 69
duke@435 70 typedef enum {
duke@435 71 JMM_CLASS_LOADED_COUNT = 1, /* Total number of loaded classes */
duke@435 72 JMM_CLASS_UNLOADED_COUNT = 2, /* Total number of unloaded classes */
duke@435 73 JMM_THREAD_TOTAL_COUNT = 3, /* Total number of threads that have been started */
duke@435 74 JMM_THREAD_LIVE_COUNT = 4, /* Current number of live threads */
duke@435 75 JMM_THREAD_PEAK_COUNT = 5, /* Peak number of live threads */
duke@435 76 JMM_THREAD_DAEMON_COUNT = 6, /* Current number of daemon threads */
duke@435 77 JMM_JVM_INIT_DONE_TIME_MS = 7, /* Time when the JVM finished initialization */
duke@435 78 JMM_COMPILE_TOTAL_TIME_MS = 8, /* Total accumulated time spent in compilation */
duke@435 79 JMM_GC_TIME_MS = 9, /* Total accumulated time spent in collection */
duke@435 80 JMM_GC_COUNT = 10, /* Total number of collections */
duke@435 81
duke@435 82 JMM_INTERNAL_ATTRIBUTE_INDEX = 100,
duke@435 83 JMM_CLASS_LOADED_BYTES = 101, /* Number of bytes loaded instance classes */
duke@435 84 JMM_CLASS_UNLOADED_BYTES = 102, /* Number of bytes unloaded instance classes */
duke@435 85 JMM_TOTAL_CLASSLOAD_TIME_MS = 103, /* Accumulated VM class loader time (TraceClassLoadingTime) */
duke@435 86 JMM_VM_GLOBAL_COUNT = 104, /* Number of VM internal flags */
duke@435 87 JMM_SAFEPOINT_COUNT = 105, /* Total number of safepoints */
duke@435 88 JMM_TOTAL_SAFEPOINTSYNC_TIME_MS = 106, /* Accumulated time spent getting to safepoints */
duke@435 89 JMM_TOTAL_STOPPED_TIME_MS = 107, /* Accumulated time spent at safepoints */
duke@435 90 JMM_TOTAL_APP_TIME_MS = 108, /* Accumulated time spent in Java application */
duke@435 91 JMM_VM_THREAD_COUNT = 109, /* Current number of VM internal threads */
duke@435 92 JMM_CLASS_INIT_TOTAL_COUNT = 110, /* Number of classes for which initializers were run */
duke@435 93 JMM_CLASS_INIT_TOTAL_TIME_MS = 111, /* Accumulated time spent in class initializers */
duke@435 94 JMM_METHOD_DATA_SIZE_BYTES = 112, /* Size of method data in memory */
duke@435 95 JMM_CLASS_VERIFY_TOTAL_TIME_MS = 113, /* Accumulated time spent in class verifier */
duke@435 96 JMM_SHARED_CLASS_LOADED_COUNT = 114, /* Number of shared classes loaded */
duke@435 97 JMM_SHARED_CLASS_UNLOADED_COUNT = 115, /* Number of shared classes unloaded */
duke@435 98 JMM_SHARED_CLASS_LOADED_BYTES = 116, /* Number of bytes loaded shared classes */
duke@435 99 JMM_SHARED_CLASS_UNLOADED_BYTES = 117, /* Number of bytes unloaded shared classes */
duke@435 100
duke@435 101 JMM_OS_ATTRIBUTE_INDEX = 200,
duke@435 102 JMM_OS_PROCESS_ID = 201, /* Process id of the JVM */
duke@435 103 JMM_OS_MEM_TOTAL_PHYSICAL_BYTES = 202, /* Physical memory size */
duke@435 104
duke@435 105 JMM_GC_EXT_ATTRIBUTE_INFO_SIZE = 401 /* the size of the GC specific attributes for a given GC memory manager */
duke@435 106 } jmmLongAttribute;
duke@435 107
duke@435 108 typedef enum {
duke@435 109 JMM_VERBOSE_GC = 21,
duke@435 110 JMM_VERBOSE_CLASS = 22,
duke@435 111 JMM_THREAD_CONTENTION_MONITORING = 23,
phh@2423 112 JMM_THREAD_CPU_TIME = 24,
phh@2423 113 JMM_THREAD_ALLOCATED_MEMORY = 25
duke@435 114 } jmmBoolAttribute;
duke@435 115
duke@435 116
duke@435 117 enum {
duke@435 118 JMM_THREAD_STATE_FLAG_SUSPENDED = 0x00100000,
duke@435 119 JMM_THREAD_STATE_FLAG_NATIVE = 0x00400000
duke@435 120 };
duke@435 121
duke@435 122 #define JMM_THREAD_STATE_FLAG_MASK 0xFFF00000
duke@435 123
duke@435 124 typedef enum {
duke@435 125 JMM_STAT_PEAK_THREAD_COUNT = 801,
duke@435 126 JMM_STAT_THREAD_CONTENTION_COUNT = 802,
duke@435 127 JMM_STAT_THREAD_CONTENTION_TIME = 803,
duke@435 128 JMM_STAT_THREAD_CONTENTION_STAT = 804,
duke@435 129 JMM_STAT_PEAK_POOL_USAGE = 805,
duke@435 130 JMM_STAT_GC_STAT = 806
duke@435 131 } jmmStatisticType;
duke@435 132
duke@435 133 typedef enum {
duke@435 134 JMM_USAGE_THRESHOLD_HIGH = 901,
duke@435 135 JMM_USAGE_THRESHOLD_LOW = 902,
duke@435 136 JMM_COLLECTION_USAGE_THRESHOLD_HIGH = 903,
duke@435 137 JMM_COLLECTION_USAGE_THRESHOLD_LOW = 904
duke@435 138 } jmmThresholdType;
duke@435 139
duke@435 140 /* Should match what is allowed in globals.hpp */
duke@435 141 typedef enum {
duke@435 142 JMM_VMGLOBAL_TYPE_UNKNOWN = 0,
duke@435 143 JMM_VMGLOBAL_TYPE_JBOOLEAN = 1,
duke@435 144 JMM_VMGLOBAL_TYPE_JSTRING = 2,
duke@435 145 JMM_VMGLOBAL_TYPE_JLONG = 3
duke@435 146 } jmmVMGlobalType;
duke@435 147
duke@435 148 typedef enum {
duke@435 149 JMM_VMGLOBAL_ORIGIN_DEFAULT = 1, /* Default value */
duke@435 150 JMM_VMGLOBAL_ORIGIN_COMMAND_LINE = 2, /* Set at command line (or JNI invocation) */
duke@435 151 JMM_VMGLOBAL_ORIGIN_MANAGEMENT = 3, /* Set via management interface */
duke@435 152 JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR = 4, /* Set via environment variables */
duke@435 153 JMM_VMGLOBAL_ORIGIN_CONFIG_FILE = 5, /* Set via config file (such as .hotspotrc) */
duke@435 154 JMM_VMGLOBAL_ORIGIN_ERGONOMIC = 6, /* Set via ergonomic */
duke@435 155 JMM_VMGLOBAL_ORIGIN_OTHER = 99 /* Set via some other mechanism */
duke@435 156 } jmmVMGlobalOrigin;
duke@435 157
duke@435 158 typedef struct {
duke@435 159 jstring name;
duke@435 160 jvalue value;
duke@435 161 jmmVMGlobalType type; /* Data type */
duke@435 162 jmmVMGlobalOrigin origin; /* Default or non-default value */
duke@435 163 unsigned int writeable : 1; /* dynamically writeable */
duke@435 164 unsigned int external : 1; /* external supported interface */
duke@435 165 unsigned int reserved : 30;
duke@435 166 void *reserved1;
duke@435 167 void *reserved2;
duke@435 168 } jmmVMGlobal;
duke@435 169
duke@435 170 typedef struct {
duke@435 171 const char* name;
duke@435 172 char type;
duke@435 173 const char* description;
duke@435 174 } jmmExtAttributeInfo;
duke@435 175
duke@435 176 /* Caller has to set the following fields before calling GetLastGCStat
duke@435 177 * o usage_before_gc - array of MemoryUsage objects
duke@435 178 * o usage_after_gc - array of MemoryUsage objects
duke@435 179 * o gc_ext_attribute_values_size - size of gc_ext_atttribute_values array
duke@435 180 * o gc_ext_attribtue_values - array of jvalues
duke@435 181 */
duke@435 182 typedef struct {
duke@435 183 jlong gc_index; /* Index of the collections */
duke@435 184 jlong start_time; /* Start time of the GC */
duke@435 185 jlong end_time; /* End time of the GC */
duke@435 186 jobjectArray usage_before_gc; /* Memory usage array before GC */
duke@435 187 jobjectArray usage_after_gc; /* Memory usage array after GC */
duke@435 188 jint gc_ext_attribute_values_size; /* set by the caller of GetGCStat */
duke@435 189 jvalue* gc_ext_attribute_values; /* Array of jvalue for GC extension attributes */
duke@435 190 jint num_gc_ext_attributes; /* number of GC extension attribute values s are filled */
duke@435 191 /* -1 indicates gc_ext_attribute_values is not big enough */
duke@435 192 } jmmGCStat;
duke@435 193
fparain@3329 194 typedef struct {
fparain@5047 195 const char* name; /* Name of the diagnostic command */
fparain@5047 196 const char* description; /* Short description */
fparain@5047 197 const char* impact; /* Impact on the JVM */
fparain@5047 198 const char* permission_class; /* Class name of the required permission if any */
fparain@5047 199 const char* permission_name; /* Permission name of the required permission if any */
fparain@5047 200 const char* permission_action; /* Action name of the required permission if any*/
fparain@5047 201 int num_arguments; /* Number of supported options or arguments */
fparain@5047 202 jboolean enabled; /* True if the diagnostic command can be invoked, false otherwise */
fparain@3329 203 } dcmdInfo;
fparain@3329 204
fparain@3329 205 typedef struct {
fparain@5047 206 const char* name; /* Option/Argument name*/
fparain@5047 207 const char* description; /* Short description */
fparain@5047 208 const char* type; /* Type: STRING, BOOLEAN, etc. */
fparain@5047 209 const char* default_string; /* Default value in a parsable string */
fparain@5047 210 jboolean mandatory; /* True if the option/argument is mandatory */
fparain@5047 211 jboolean option; /* True if it is an option, false if it is an argument */
fparain@5047 212 /* (see diagnosticFramework.hpp for option/argument definitions) */
fparain@5047 213 jboolean multiple; /* True if the option can be specified several time */
fparain@5047 214 int position; /* Expected position for this argument (this field is */
fparain@5047 215 /* meaningless for options) */
fparain@3329 216 } dcmdArgInfo;
fparain@3329 217
duke@435 218 typedef struct jmmInterface_1_ {
duke@435 219 void* reserved1;
duke@435 220 void* reserved2;
duke@435 221
duke@435 222 jint (JNICALL *GetVersion) (JNIEnv *env);
duke@435 223
duke@435 224 jint (JNICALL *GetOptionalSupport) (JNIEnv *env,
duke@435 225 jmmOptionalSupport* support_ptr);
duke@435 226
duke@435 227 /* This is used by JDK 6 and earlier.
duke@435 228 * For JDK 7 and after, use GetInputArgumentArray.
duke@435 229 */
duke@435 230 jobject (JNICALL *GetInputArguments) (JNIEnv *env);
duke@435 231
duke@435 232 jint (JNICALL *GetThreadInfo) (JNIEnv *env,
duke@435 233 jlongArray ids,
duke@435 234 jint maxDepth,
duke@435 235 jobjectArray infoArray);
duke@435 236 jobjectArray (JNICALL *GetInputArgumentArray) (JNIEnv *env);
duke@435 237
duke@435 238 jobjectArray (JNICALL *GetMemoryPools) (JNIEnv* env, jobject mgr);
duke@435 239
duke@435 240 jobjectArray (JNICALL *GetMemoryManagers) (JNIEnv* env, jobject pool);
duke@435 241
duke@435 242 jobject (JNICALL *GetMemoryPoolUsage) (JNIEnv* env, jobject pool);
duke@435 243 jobject (JNICALL *GetPeakMemoryPoolUsage) (JNIEnv* env, jobject pool);
duke@435 244
phh@2423 245 void (JNICALL *GetThreadAllocatedMemory)
phh@2423 246 (JNIEnv *env,
phh@2423 247 jlongArray ids,
phh@2423 248 jlongArray sizeArray);
duke@435 249
duke@435 250 jobject (JNICALL *GetMemoryUsage) (JNIEnv* env, jboolean heap);
duke@435 251
duke@435 252 jlong (JNICALL *GetLongAttribute) (JNIEnv *env, jobject obj, jmmLongAttribute att);
duke@435 253 jboolean (JNICALL *GetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att);
duke@435 254 jboolean (JNICALL *SetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att, jboolean flag);
duke@435 255
duke@435 256 jint (JNICALL *GetLongAttributes) (JNIEnv *env,
duke@435 257 jobject obj,
duke@435 258 jmmLongAttribute* atts,
duke@435 259 jint count,
duke@435 260 jlong* result);
duke@435 261
duke@435 262 jobjectArray (JNICALL *FindCircularBlockedThreads) (JNIEnv *env);
phh@2423 263
phh@2423 264 // Not used in JDK 6 or JDK 7
duke@435 265 jlong (JNICALL *GetThreadCpuTime) (JNIEnv *env, jlong thread_id);
duke@435 266
duke@435 267 jobjectArray (JNICALL *GetVMGlobalNames) (JNIEnv *env);
duke@435 268 jint (JNICALL *GetVMGlobals) (JNIEnv *env,
duke@435 269 jobjectArray names,
duke@435 270 jmmVMGlobal *globals,
duke@435 271 jint count);
duke@435 272
duke@435 273 jint (JNICALL *GetInternalThreadTimes) (JNIEnv *env,
duke@435 274 jobjectArray names,
duke@435 275 jlongArray times);
duke@435 276
duke@435 277 jboolean (JNICALL *ResetStatistic) (JNIEnv *env,
duke@435 278 jvalue obj,
duke@435 279 jmmStatisticType type);
duke@435 280
duke@435 281 void (JNICALL *SetPoolSensor) (JNIEnv *env,
duke@435 282 jobject pool,
duke@435 283 jmmThresholdType type,
duke@435 284 jobject sensor);
duke@435 285
duke@435 286 jlong (JNICALL *SetPoolThreshold) (JNIEnv *env,
duke@435 287 jobject pool,
duke@435 288 jmmThresholdType type,
duke@435 289 jlong threshold);
duke@435 290 jobject (JNICALL *GetPoolCollectionUsage) (JNIEnv* env, jobject pool);
duke@435 291
duke@435 292 jint (JNICALL *GetGCExtAttributeInfo) (JNIEnv *env,
duke@435 293 jobject mgr,
duke@435 294 jmmExtAttributeInfo *ext_info,
duke@435 295 jint count);
duke@435 296 void (JNICALL *GetLastGCStat) (JNIEnv *env,
duke@435 297 jobject mgr,
duke@435 298 jmmGCStat *gc_stat);
phh@2423 299
phh@2423 300 jlong (JNICALL *GetThreadCpuTimeWithKind)
phh@2423 301 (JNIEnv *env,
phh@2423 302 jlong thread_id,
phh@2423 303 jboolean user_sys_cpu_time);
phh@2423 304 void (JNICALL *GetThreadCpuTimesWithKind)
phh@2423 305 (JNIEnv *env,
phh@2423 306 jlongArray ids,
phh@2423 307 jlongArray timeArray,
phh@2423 308 jboolean user_sys_cpu_time);
phh@2423 309
duke@435 310 jint (JNICALL *DumpHeap0) (JNIEnv *env,
duke@435 311 jstring outputfile,
duke@435 312 jboolean live);
phh@2423 313 jobjectArray (JNICALL *FindDeadlocks) (JNIEnv *env,
phh@2423 314 jboolean object_monitors_only);
duke@435 315 void (JNICALL *SetVMGlobal) (JNIEnv *env,
duke@435 316 jstring flag_name,
duke@435 317 jvalue new_value);
duke@435 318 void* reserved6;
duke@435 319 jobjectArray (JNICALL *DumpThreads) (JNIEnv *env,
duke@435 320 jlongArray ids,
duke@435 321 jboolean lockedMonitors,
duke@435 322 jboolean lockedSynchronizers);
fparain@2888 323 void (JNICALL *SetGCNotificationEnabled) (JNIEnv *env,
fparain@2888 324 jobject mgr,
fparain@2888 325 jboolean enabled);
fparain@3329 326 jobjectArray (JNICALL *GetDiagnosticCommands) (JNIEnv *env);
fparain@3329 327 void (JNICALL *GetDiagnosticCommandInfo)
fparain@3329 328 (JNIEnv *env,
fparain@3329 329 jobjectArray cmds,
fparain@3329 330 dcmdInfo *infoArray);
fparain@3329 331 void (JNICALL *GetDiagnosticCommandArgumentsInfo)
fparain@3329 332 (JNIEnv *env,
fparain@3329 333 jstring commandName,
fparain@3329 334 dcmdArgInfo *infoArray);
fparain@3329 335 jstring (JNICALL *ExecuteDiagnosticCommand)
fparain@3329 336 (JNIEnv *env,
fparain@3329 337 jstring command);
fparain@5047 338 void (JNICALL *SetDiagnosticFrameworkNotificationEnabled)
fparain@5047 339 (JNIEnv *env,
fparain@5047 340 jboolean enabled);
duke@435 341 } JmmInterface;
duke@435 342
duke@435 343 #ifdef __cplusplus
duke@435 344 } /* extern "C" */
duke@435 345 #endif /* __cplusplus */
duke@435 346
duke@435 347 #endif /* !_JAVA_JMM_H_ */

mercurial