annotate src/share/vm/services/jmm.h @ 10487:c558850fac57

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