src/share/vm/services/jmm.h

Wed, 03 Jul 2019 20:42:37 +0800

author
aoqi
date
Wed, 03 Jul 2019 20:42:37 +0800
changeset 9637
eef07cd490d4
parent 6876
710a3c8b516e
child 10015
eb7ce841ccec
permissions
-rw-r--r--

Merge

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

mercurial