src/share/vm/services/jmm.h

Thu, 05 Jun 2008 15:57:56 -0700

author
ysr
date
Thu, 05 Jun 2008 15:57:56 -0700
changeset 777
37f87013dfd8
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6711316: Open source the Garbage-First garbage collector
Summary: First mercurial integration of the code for the Garbage-First garbage collector.
Reviewed-by: apetrusenko, iveresov, jmasa, sgoldman, tonyp, ysr

duke@435 1 /*
duke@435 2 * Copyright 2003-2006 Sun Microsystems, Inc. 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
duke@435 7 * published by the Free Software Foundation. Sun designates this
duke@435 8 * particular file as subject to the "Classpath" exception as provided
duke@435 9 * by Sun 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 *
duke@435 21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 22 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 23 * have any 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
duke@435 51 JMM_VERSION = 0x20010200
duke@435 52 };
duke@435 53
duke@435 54 typedef struct {
duke@435 55 unsigned int isLowMemoryDetectionSupported : 1;
duke@435 56 unsigned int isCompilationTimeMonitoringSupported : 1;
duke@435 57 unsigned int isThreadContentionMonitoringSupported : 1;
duke@435 58 unsigned int isCurrentThreadCpuTimeSupported : 1;
duke@435 59 unsigned int isOtherThreadCpuTimeSupported : 1;
duke@435 60 unsigned int isBootClassPathSupported : 1;
duke@435 61 unsigned int isObjectMonitorUsageSupported : 1;
duke@435 62 unsigned int isSynchronizerUsageSupported : 1;
duke@435 63 unsigned int : 24;
duke@435 64 } jmmOptionalSupport;
duke@435 65
duke@435 66 typedef enum {
duke@435 67 JMM_CLASS_LOADED_COUNT = 1, /* Total number of loaded classes */
duke@435 68 JMM_CLASS_UNLOADED_COUNT = 2, /* Total number of unloaded classes */
duke@435 69 JMM_THREAD_TOTAL_COUNT = 3, /* Total number of threads that have been started */
duke@435 70 JMM_THREAD_LIVE_COUNT = 4, /* Current number of live threads */
duke@435 71 JMM_THREAD_PEAK_COUNT = 5, /* Peak number of live threads */
duke@435 72 JMM_THREAD_DAEMON_COUNT = 6, /* Current number of daemon threads */
duke@435 73 JMM_JVM_INIT_DONE_TIME_MS = 7, /* Time when the JVM finished initialization */
duke@435 74 JMM_COMPILE_TOTAL_TIME_MS = 8, /* Total accumulated time spent in compilation */
duke@435 75 JMM_GC_TIME_MS = 9, /* Total accumulated time spent in collection */
duke@435 76 JMM_GC_COUNT = 10, /* Total number of collections */
duke@435 77
duke@435 78 JMM_INTERNAL_ATTRIBUTE_INDEX = 100,
duke@435 79 JMM_CLASS_LOADED_BYTES = 101, /* Number of bytes loaded instance classes */
duke@435 80 JMM_CLASS_UNLOADED_BYTES = 102, /* Number of bytes unloaded instance classes */
duke@435 81 JMM_TOTAL_CLASSLOAD_TIME_MS = 103, /* Accumulated VM class loader time (TraceClassLoadingTime) */
duke@435 82 JMM_VM_GLOBAL_COUNT = 104, /* Number of VM internal flags */
duke@435 83 JMM_SAFEPOINT_COUNT = 105, /* Total number of safepoints */
duke@435 84 JMM_TOTAL_SAFEPOINTSYNC_TIME_MS = 106, /* Accumulated time spent getting to safepoints */
duke@435 85 JMM_TOTAL_STOPPED_TIME_MS = 107, /* Accumulated time spent at safepoints */
duke@435 86 JMM_TOTAL_APP_TIME_MS = 108, /* Accumulated time spent in Java application */
duke@435 87 JMM_VM_THREAD_COUNT = 109, /* Current number of VM internal threads */
duke@435 88 JMM_CLASS_INIT_TOTAL_COUNT = 110, /* Number of classes for which initializers were run */
duke@435 89 JMM_CLASS_INIT_TOTAL_TIME_MS = 111, /* Accumulated time spent in class initializers */
duke@435 90 JMM_METHOD_DATA_SIZE_BYTES = 112, /* Size of method data in memory */
duke@435 91 JMM_CLASS_VERIFY_TOTAL_TIME_MS = 113, /* Accumulated time spent in class verifier */
duke@435 92 JMM_SHARED_CLASS_LOADED_COUNT = 114, /* Number of shared classes loaded */
duke@435 93 JMM_SHARED_CLASS_UNLOADED_COUNT = 115, /* Number of shared classes unloaded */
duke@435 94 JMM_SHARED_CLASS_LOADED_BYTES = 116, /* Number of bytes loaded shared classes */
duke@435 95 JMM_SHARED_CLASS_UNLOADED_BYTES = 117, /* Number of bytes unloaded shared classes */
duke@435 96
duke@435 97 JMM_OS_ATTRIBUTE_INDEX = 200,
duke@435 98 JMM_OS_PROCESS_ID = 201, /* Process id of the JVM */
duke@435 99 JMM_OS_MEM_TOTAL_PHYSICAL_BYTES = 202, /* Physical memory size */
duke@435 100
duke@435 101 JMM_GC_EXT_ATTRIBUTE_INFO_SIZE = 401 /* the size of the GC specific attributes for a given GC memory manager */
duke@435 102 } jmmLongAttribute;
duke@435 103
duke@435 104 typedef enum {
duke@435 105 JMM_VERBOSE_GC = 21,
duke@435 106 JMM_VERBOSE_CLASS = 22,
duke@435 107 JMM_THREAD_CONTENTION_MONITORING = 23,
duke@435 108 JMM_THREAD_CPU_TIME = 24
duke@435 109 } jmmBoolAttribute;
duke@435 110
duke@435 111
duke@435 112 enum {
duke@435 113 JMM_THREAD_STATE_FLAG_SUSPENDED = 0x00100000,
duke@435 114 JMM_THREAD_STATE_FLAG_NATIVE = 0x00400000
duke@435 115 };
duke@435 116
duke@435 117 #define JMM_THREAD_STATE_FLAG_MASK 0xFFF00000
duke@435 118
duke@435 119 typedef enum {
duke@435 120 JMM_STAT_PEAK_THREAD_COUNT = 801,
duke@435 121 JMM_STAT_THREAD_CONTENTION_COUNT = 802,
duke@435 122 JMM_STAT_THREAD_CONTENTION_TIME = 803,
duke@435 123 JMM_STAT_THREAD_CONTENTION_STAT = 804,
duke@435 124 JMM_STAT_PEAK_POOL_USAGE = 805,
duke@435 125 JMM_STAT_GC_STAT = 806
duke@435 126 } jmmStatisticType;
duke@435 127
duke@435 128 typedef enum {
duke@435 129 JMM_USAGE_THRESHOLD_HIGH = 901,
duke@435 130 JMM_USAGE_THRESHOLD_LOW = 902,
duke@435 131 JMM_COLLECTION_USAGE_THRESHOLD_HIGH = 903,
duke@435 132 JMM_COLLECTION_USAGE_THRESHOLD_LOW = 904
duke@435 133 } jmmThresholdType;
duke@435 134
duke@435 135 /* Should match what is allowed in globals.hpp */
duke@435 136 typedef enum {
duke@435 137 JMM_VMGLOBAL_TYPE_UNKNOWN = 0,
duke@435 138 JMM_VMGLOBAL_TYPE_JBOOLEAN = 1,
duke@435 139 JMM_VMGLOBAL_TYPE_JSTRING = 2,
duke@435 140 JMM_VMGLOBAL_TYPE_JLONG = 3
duke@435 141 } jmmVMGlobalType;
duke@435 142
duke@435 143 typedef enum {
duke@435 144 JMM_VMGLOBAL_ORIGIN_DEFAULT = 1, /* Default value */
duke@435 145 JMM_VMGLOBAL_ORIGIN_COMMAND_LINE = 2, /* Set at command line (or JNI invocation) */
duke@435 146 JMM_VMGLOBAL_ORIGIN_MANAGEMENT = 3, /* Set via management interface */
duke@435 147 JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR = 4, /* Set via environment variables */
duke@435 148 JMM_VMGLOBAL_ORIGIN_CONFIG_FILE = 5, /* Set via config file (such as .hotspotrc) */
duke@435 149 JMM_VMGLOBAL_ORIGIN_ERGONOMIC = 6, /* Set via ergonomic */
duke@435 150 JMM_VMGLOBAL_ORIGIN_OTHER = 99 /* Set via some other mechanism */
duke@435 151 } jmmVMGlobalOrigin;
duke@435 152
duke@435 153 typedef struct {
duke@435 154 jstring name;
duke@435 155 jvalue value;
duke@435 156 jmmVMGlobalType type; /* Data type */
duke@435 157 jmmVMGlobalOrigin origin; /* Default or non-default value */
duke@435 158 unsigned int writeable : 1; /* dynamically writeable */
duke@435 159 unsigned int external : 1; /* external supported interface */
duke@435 160 unsigned int reserved : 30;
duke@435 161 void *reserved1;
duke@435 162 void *reserved2;
duke@435 163 } jmmVMGlobal;
duke@435 164
duke@435 165 typedef struct {
duke@435 166 const char* name;
duke@435 167 char type;
duke@435 168 const char* description;
duke@435 169 } jmmExtAttributeInfo;
duke@435 170
duke@435 171 /* Caller has to set the following fields before calling GetLastGCStat
duke@435 172 * o usage_before_gc - array of MemoryUsage objects
duke@435 173 * o usage_after_gc - array of MemoryUsage objects
duke@435 174 * o gc_ext_attribute_values_size - size of gc_ext_atttribute_values array
duke@435 175 * o gc_ext_attribtue_values - array of jvalues
duke@435 176 */
duke@435 177 typedef struct {
duke@435 178 jlong gc_index; /* Index of the collections */
duke@435 179 jlong start_time; /* Start time of the GC */
duke@435 180 jlong end_time; /* End time of the GC */
duke@435 181 jobjectArray usage_before_gc; /* Memory usage array before GC */
duke@435 182 jobjectArray usage_after_gc; /* Memory usage array after GC */
duke@435 183 jint gc_ext_attribute_values_size; /* set by the caller of GetGCStat */
duke@435 184 jvalue* gc_ext_attribute_values; /* Array of jvalue for GC extension attributes */
duke@435 185 jint num_gc_ext_attributes; /* number of GC extension attribute values s are filled */
duke@435 186 /* -1 indicates gc_ext_attribute_values is not big enough */
duke@435 187 } jmmGCStat;
duke@435 188
duke@435 189 typedef struct jmmInterface_1_ {
duke@435 190 void* reserved1;
duke@435 191 void* reserved2;
duke@435 192
duke@435 193 jint (JNICALL *GetVersion) (JNIEnv *env);
duke@435 194
duke@435 195 jint (JNICALL *GetOptionalSupport) (JNIEnv *env,
duke@435 196 jmmOptionalSupport* support_ptr);
duke@435 197
duke@435 198 /* This is used by JDK 6 and earlier.
duke@435 199 * For JDK 7 and after, use GetInputArgumentArray.
duke@435 200 */
duke@435 201 jobject (JNICALL *GetInputArguments) (JNIEnv *env);
duke@435 202
duke@435 203 jint (JNICALL *GetThreadInfo) (JNIEnv *env,
duke@435 204 jlongArray ids,
duke@435 205 jint maxDepth,
duke@435 206 jobjectArray infoArray);
duke@435 207 jobjectArray (JNICALL *GetInputArgumentArray) (JNIEnv *env);
duke@435 208
duke@435 209 jobjectArray (JNICALL *GetMemoryPools) (JNIEnv* env, jobject mgr);
duke@435 210
duke@435 211 jobjectArray (JNICALL *GetMemoryManagers) (JNIEnv* env, jobject pool);
duke@435 212
duke@435 213 jobject (JNICALL *GetMemoryPoolUsage) (JNIEnv* env, jobject pool);
duke@435 214 jobject (JNICALL *GetPeakMemoryPoolUsage) (JNIEnv* env, jobject pool);
duke@435 215
duke@435 216 void* reserved4;
duke@435 217
duke@435 218 jobject (JNICALL *GetMemoryUsage) (JNIEnv* env, jboolean heap);
duke@435 219
duke@435 220 jlong (JNICALL *GetLongAttribute) (JNIEnv *env, jobject obj, jmmLongAttribute att);
duke@435 221 jboolean (JNICALL *GetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att);
duke@435 222 jboolean (JNICALL *SetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att, jboolean flag);
duke@435 223
duke@435 224 jint (JNICALL *GetLongAttributes) (JNIEnv *env,
duke@435 225 jobject obj,
duke@435 226 jmmLongAttribute* atts,
duke@435 227 jint count,
duke@435 228 jlong* result);
duke@435 229
duke@435 230 jobjectArray (JNICALL *FindCircularBlockedThreads) (JNIEnv *env);
duke@435 231 jlong (JNICALL *GetThreadCpuTime) (JNIEnv *env, jlong thread_id);
duke@435 232
duke@435 233 jobjectArray (JNICALL *GetVMGlobalNames) (JNIEnv *env);
duke@435 234 jint (JNICALL *GetVMGlobals) (JNIEnv *env,
duke@435 235 jobjectArray names,
duke@435 236 jmmVMGlobal *globals,
duke@435 237 jint count);
duke@435 238
duke@435 239 jint (JNICALL *GetInternalThreadTimes) (JNIEnv *env,
duke@435 240 jobjectArray names,
duke@435 241 jlongArray times);
duke@435 242
duke@435 243 jboolean (JNICALL *ResetStatistic) (JNIEnv *env,
duke@435 244 jvalue obj,
duke@435 245 jmmStatisticType type);
duke@435 246
duke@435 247 void (JNICALL *SetPoolSensor) (JNIEnv *env,
duke@435 248 jobject pool,
duke@435 249 jmmThresholdType type,
duke@435 250 jobject sensor);
duke@435 251
duke@435 252 jlong (JNICALL *SetPoolThreshold) (JNIEnv *env,
duke@435 253 jobject pool,
duke@435 254 jmmThresholdType type,
duke@435 255 jlong threshold);
duke@435 256 jobject (JNICALL *GetPoolCollectionUsage) (JNIEnv* env, jobject pool);
duke@435 257
duke@435 258 jint (JNICALL *GetGCExtAttributeInfo) (JNIEnv *env,
duke@435 259 jobject mgr,
duke@435 260 jmmExtAttributeInfo *ext_info,
duke@435 261 jint count);
duke@435 262 void (JNICALL *GetLastGCStat) (JNIEnv *env,
duke@435 263 jobject mgr,
duke@435 264 jmmGCStat *gc_stat);
duke@435 265 jlong (JNICALL *GetThreadCpuTimeWithKind) (JNIEnv *env,
duke@435 266 jlong thread_id,
duke@435 267 jboolean user_sys_cpu_time);
duke@435 268 void* reserved5;
duke@435 269 jint (JNICALL *DumpHeap0) (JNIEnv *env,
duke@435 270 jstring outputfile,
duke@435 271 jboolean live);
duke@435 272 jobjectArray (JNICALL *FindDeadlocks) (JNIEnv *env, jboolean object_monitors_only);
duke@435 273 void (JNICALL *SetVMGlobal) (JNIEnv *env,
duke@435 274 jstring flag_name,
duke@435 275 jvalue new_value);
duke@435 276 void* reserved6;
duke@435 277 jobjectArray (JNICALL *DumpThreads) (JNIEnv *env,
duke@435 278 jlongArray ids,
duke@435 279 jboolean lockedMonitors,
duke@435 280 jboolean lockedSynchronizers);
duke@435 281 } JmmInterface;
duke@435 282
duke@435 283 #ifdef __cplusplus
duke@435 284 } /* extern "C" */
duke@435 285 #endif /* __cplusplus */
duke@435 286
duke@435 287 #endif /* !_JAVA_JMM_H_ */

mercurial