src/share/vm/services/jmm.h

changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/services/jmm.h	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,287 @@
     1.4 +/*
     1.5 + * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Sun designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Sun in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.26 + * have any questions.
    1.27 + */
    1.28 +
    1.29 +#ifndef _JAVA_JMM_H_
    1.30 +#define _JAVA_JMM_H_
    1.31 +
    1.32 +/*
    1.33 + * This is a private interface used by JDK for JVM monitoring
    1.34 + * and management.
    1.35 + *
    1.36 + * Bump the version number when either of the following happens:
    1.37 + *
    1.38 + * 1. There is a change in functions in JmmInterface.
    1.39 + *
    1.40 + * 2. There is a change in the contract between VM and Java classes.
    1.41 + */
    1.42 +
    1.43 +#include "jni.h"
    1.44 +
    1.45 +#ifdef __cplusplus
    1.46 +extern "C" {
    1.47 +#endif
    1.48 +
    1.49 +enum {
    1.50 +  JMM_VERSION_1   = 0x20010000,
    1.51 +  JMM_VERSION_1_0 = 0x20010000,
    1.52 +  JMM_VERSION_1_1 = 0x20010100, // JDK 6
    1.53 +  JMM_VERSION_1_2 = 0x20010200, // JDK 7
    1.54 +  JMM_VERSION     = 0x20010200
    1.55 +};
    1.56 +
    1.57 +typedef struct {
    1.58 +  unsigned int isLowMemoryDetectionSupported : 1;
    1.59 +  unsigned int isCompilationTimeMonitoringSupported : 1;
    1.60 +  unsigned int isThreadContentionMonitoringSupported : 1;
    1.61 +  unsigned int isCurrentThreadCpuTimeSupported : 1;
    1.62 +  unsigned int isOtherThreadCpuTimeSupported : 1;
    1.63 +  unsigned int isBootClassPathSupported : 1;
    1.64 +  unsigned int isObjectMonitorUsageSupported : 1;
    1.65 +  unsigned int isSynchronizerUsageSupported : 1;
    1.66 +  unsigned int : 24;
    1.67 +} jmmOptionalSupport;
    1.68 +
    1.69 +typedef enum {
    1.70 +  JMM_CLASS_LOADED_COUNT             = 1,    /* Total number of loaded classes */
    1.71 +  JMM_CLASS_UNLOADED_COUNT           = 2,    /* Total number of unloaded classes */
    1.72 +  JMM_THREAD_TOTAL_COUNT             = 3,    /* Total number of threads that have been started */
    1.73 +  JMM_THREAD_LIVE_COUNT              = 4,    /* Current number of live threads */
    1.74 +  JMM_THREAD_PEAK_COUNT              = 5,    /* Peak number of live threads */
    1.75 +  JMM_THREAD_DAEMON_COUNT            = 6,    /* Current number of daemon threads */
    1.76 +  JMM_JVM_INIT_DONE_TIME_MS          = 7,    /* Time when the JVM finished initialization */
    1.77 +  JMM_COMPILE_TOTAL_TIME_MS          = 8,    /* Total accumulated time spent in compilation */
    1.78 +  JMM_GC_TIME_MS                     = 9,    /* Total accumulated time spent in collection */
    1.79 +  JMM_GC_COUNT                       = 10,   /* Total number of collections */
    1.80 +
    1.81 +  JMM_INTERNAL_ATTRIBUTE_INDEX       = 100,
    1.82 +  JMM_CLASS_LOADED_BYTES             = 101,  /* Number of bytes loaded instance classes */
    1.83 +  JMM_CLASS_UNLOADED_BYTES           = 102,  /* Number of bytes unloaded instance classes */
    1.84 +  JMM_TOTAL_CLASSLOAD_TIME_MS        = 103,  /* Accumulated VM class loader time (TraceClassLoadingTime) */
    1.85 +  JMM_VM_GLOBAL_COUNT                = 104,  /* Number of VM internal flags */
    1.86 +  JMM_SAFEPOINT_COUNT                = 105,  /* Total number of safepoints */
    1.87 +  JMM_TOTAL_SAFEPOINTSYNC_TIME_MS    = 106,  /* Accumulated time spent getting to safepoints */
    1.88 +  JMM_TOTAL_STOPPED_TIME_MS          = 107,  /* Accumulated time spent at safepoints */
    1.89 +  JMM_TOTAL_APP_TIME_MS              = 108,  /* Accumulated time spent in Java application */
    1.90 +  JMM_VM_THREAD_COUNT                = 109,  /* Current number of VM internal threads */
    1.91 +  JMM_CLASS_INIT_TOTAL_COUNT         = 110,  /* Number of classes for which initializers were run */
    1.92 +  JMM_CLASS_INIT_TOTAL_TIME_MS       = 111,  /* Accumulated time spent in class initializers */
    1.93 +  JMM_METHOD_DATA_SIZE_BYTES         = 112,  /* Size of method data in memory */
    1.94 +  JMM_CLASS_VERIFY_TOTAL_TIME_MS     = 113,  /* Accumulated time spent in class verifier */
    1.95 +  JMM_SHARED_CLASS_LOADED_COUNT      = 114,  /* Number of shared classes loaded */
    1.96 +  JMM_SHARED_CLASS_UNLOADED_COUNT    = 115,  /* Number of shared classes unloaded */
    1.97 +  JMM_SHARED_CLASS_LOADED_BYTES      = 116,  /* Number of bytes loaded shared classes */
    1.98 +  JMM_SHARED_CLASS_UNLOADED_BYTES    = 117,  /* Number of bytes unloaded shared classes */
    1.99 +
   1.100 +  JMM_OS_ATTRIBUTE_INDEX             = 200,
   1.101 +  JMM_OS_PROCESS_ID                  = 201,  /* Process id of the JVM */
   1.102 +  JMM_OS_MEM_TOTAL_PHYSICAL_BYTES    = 202,  /* Physical memory size */
   1.103 +
   1.104 +  JMM_GC_EXT_ATTRIBUTE_INFO_SIZE     = 401   /* the size of the GC specific attributes for a given GC memory manager */
   1.105 +} jmmLongAttribute;
   1.106 +
   1.107 +typedef enum {
   1.108 +  JMM_VERBOSE_GC                     = 21,
   1.109 +  JMM_VERBOSE_CLASS                  = 22,
   1.110 +  JMM_THREAD_CONTENTION_MONITORING   = 23,
   1.111 +  JMM_THREAD_CPU_TIME                = 24
   1.112 +} jmmBoolAttribute;
   1.113 +
   1.114 +
   1.115 +enum {
   1.116 +  JMM_THREAD_STATE_FLAG_SUSPENDED = 0x00100000,
   1.117 +  JMM_THREAD_STATE_FLAG_NATIVE    = 0x00400000
   1.118 +};
   1.119 +
   1.120 +#define JMM_THREAD_STATE_FLAG_MASK  0xFFF00000
   1.121 +
   1.122 +typedef enum {
   1.123 +  JMM_STAT_PEAK_THREAD_COUNT         = 801,
   1.124 +  JMM_STAT_THREAD_CONTENTION_COUNT   = 802,
   1.125 +  JMM_STAT_THREAD_CONTENTION_TIME    = 803,
   1.126 +  JMM_STAT_THREAD_CONTENTION_STAT    = 804,
   1.127 +  JMM_STAT_PEAK_POOL_USAGE           = 805,
   1.128 +  JMM_STAT_GC_STAT                   = 806
   1.129 +} jmmStatisticType;
   1.130 +
   1.131 +typedef enum {
   1.132 +  JMM_USAGE_THRESHOLD_HIGH            = 901,
   1.133 +  JMM_USAGE_THRESHOLD_LOW             = 902,
   1.134 +  JMM_COLLECTION_USAGE_THRESHOLD_HIGH = 903,
   1.135 +  JMM_COLLECTION_USAGE_THRESHOLD_LOW  = 904
   1.136 +} jmmThresholdType;
   1.137 +
   1.138 +/* Should match what is allowed in globals.hpp */
   1.139 +typedef enum {
   1.140 +  JMM_VMGLOBAL_TYPE_UNKNOWN  = 0,
   1.141 +  JMM_VMGLOBAL_TYPE_JBOOLEAN = 1,
   1.142 +  JMM_VMGLOBAL_TYPE_JSTRING  = 2,
   1.143 +  JMM_VMGLOBAL_TYPE_JLONG    = 3
   1.144 +} jmmVMGlobalType;
   1.145 +
   1.146 +typedef enum {
   1.147 +  JMM_VMGLOBAL_ORIGIN_DEFAULT      = 1,   /* Default value */
   1.148 +  JMM_VMGLOBAL_ORIGIN_COMMAND_LINE = 2,   /* Set at command line (or JNI invocation) */
   1.149 +  JMM_VMGLOBAL_ORIGIN_MANAGEMENT   = 3,   /* Set via management interface */
   1.150 +  JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR  = 4,   /* Set via environment variables */
   1.151 +  JMM_VMGLOBAL_ORIGIN_CONFIG_FILE  = 5,   /* Set via config file (such as .hotspotrc) */
   1.152 +  JMM_VMGLOBAL_ORIGIN_ERGONOMIC    = 6,   /* Set via ergonomic */
   1.153 +  JMM_VMGLOBAL_ORIGIN_OTHER        = 99   /* Set via some other mechanism */
   1.154 +} jmmVMGlobalOrigin;
   1.155 +
   1.156 +typedef struct {
   1.157 +  jstring           name;
   1.158 +  jvalue            value;
   1.159 +  jmmVMGlobalType   type;           /* Data type */
   1.160 +  jmmVMGlobalOrigin origin;         /* Default or non-default value */
   1.161 +  unsigned int      writeable : 1;  /* dynamically writeable */
   1.162 +  unsigned int      external  : 1;  /* external supported interface */
   1.163 +  unsigned int      reserved  : 30;
   1.164 +  void *reserved1;
   1.165 +  void *reserved2;
   1.166 +} jmmVMGlobal;
   1.167 +
   1.168 +typedef struct {
   1.169 +  const char*  name;
   1.170 +  char         type;
   1.171 +  const char*  description;
   1.172 +} jmmExtAttributeInfo;
   1.173 +
   1.174 +/* Caller has to set the following fields before calling GetLastGCStat
   1.175 + *   o usage_before_gc               - array of MemoryUsage objects
   1.176 + *   o usage_after_gc                - array of MemoryUsage objects
   1.177 + *   o gc_ext_attribute_values_size - size of gc_ext_atttribute_values array
   1.178 + *   o gc_ext_attribtue_values      - array of jvalues
   1.179 + */
   1.180 +typedef struct {
   1.181 +  jlong        gc_index;                       /* Index of the collections */
   1.182 +  jlong        start_time;                     /* Start time of the GC */
   1.183 +  jlong        end_time;                       /* End time of the GC */
   1.184 +  jobjectArray usage_before_gc;                /* Memory usage array before GC */
   1.185 +  jobjectArray usage_after_gc;                 /* Memory usage array after GC */
   1.186 +  jint         gc_ext_attribute_values_size;   /* set by the caller of GetGCStat */
   1.187 +  jvalue*      gc_ext_attribute_values;        /* Array of jvalue for GC extension attributes */
   1.188 +  jint         num_gc_ext_attributes;          /* number of GC extension attribute values s are filled */
   1.189 +                                               /* -1 indicates gc_ext_attribute_values is not big enough */
   1.190 +} jmmGCStat;
   1.191 +
   1.192 +typedef struct jmmInterface_1_ {
   1.193 +  void*        reserved1;
   1.194 +  void*        reserved2;
   1.195 +
   1.196 +  jint         (JNICALL *GetVersion)             (JNIEnv *env);
   1.197 +
   1.198 +  jint         (JNICALL *GetOptionalSupport)     (JNIEnv *env,
   1.199 +                                                  jmmOptionalSupport* support_ptr);
   1.200 +
   1.201 +  /* This is used by JDK 6 and earlier.
   1.202 +   * For JDK 7 and after, use GetInputArgumentArray.
   1.203 +   */
   1.204 +  jobject      (JNICALL *GetInputArguments)      (JNIEnv *env);
   1.205 +
   1.206 +  jint         (JNICALL *GetThreadInfo)          (JNIEnv *env,
   1.207 +                                                  jlongArray ids,
   1.208 +                                                  jint maxDepth,
   1.209 +                                                  jobjectArray infoArray);
   1.210 +  jobjectArray (JNICALL *GetInputArgumentArray)  (JNIEnv *env);
   1.211 +
   1.212 +  jobjectArray (JNICALL *GetMemoryPools)         (JNIEnv* env, jobject mgr);
   1.213 +
   1.214 +  jobjectArray (JNICALL *GetMemoryManagers)      (JNIEnv* env, jobject pool);
   1.215 +
   1.216 +  jobject      (JNICALL *GetMemoryPoolUsage)     (JNIEnv* env, jobject pool);
   1.217 +  jobject      (JNICALL *GetPeakMemoryPoolUsage) (JNIEnv* env, jobject pool);
   1.218 +
   1.219 +  void*        reserved4;
   1.220 +
   1.221 +  jobject      (JNICALL *GetMemoryUsage)         (JNIEnv* env, jboolean heap);
   1.222 +
   1.223 +  jlong        (JNICALL *GetLongAttribute)       (JNIEnv *env, jobject obj, jmmLongAttribute att);
   1.224 +  jboolean     (JNICALL *GetBoolAttribute)       (JNIEnv *env, jmmBoolAttribute att);
   1.225 +  jboolean     (JNICALL *SetBoolAttribute)       (JNIEnv *env, jmmBoolAttribute att, jboolean flag);
   1.226 +
   1.227 +  jint         (JNICALL *GetLongAttributes)      (JNIEnv *env,
   1.228 +                                                  jobject obj,
   1.229 +                                                  jmmLongAttribute* atts,
   1.230 +                                                  jint count,
   1.231 +                                                  jlong* result);
   1.232 +
   1.233 +  jobjectArray (JNICALL *FindCircularBlockedThreads) (JNIEnv *env);
   1.234 +  jlong        (JNICALL *GetThreadCpuTime)       (JNIEnv *env, jlong thread_id);
   1.235 +
   1.236 +  jobjectArray (JNICALL *GetVMGlobalNames)       (JNIEnv *env);
   1.237 +  jint         (JNICALL *GetVMGlobals)           (JNIEnv *env,
   1.238 +                                                  jobjectArray names,
   1.239 +                                                  jmmVMGlobal *globals,
   1.240 +                                                  jint count);
   1.241 +
   1.242 +  jint         (JNICALL *GetInternalThreadTimes) (JNIEnv *env,
   1.243 +                                                  jobjectArray names,
   1.244 +                                                  jlongArray times);
   1.245 +
   1.246 +  jboolean     (JNICALL *ResetStatistic)         (JNIEnv *env,
   1.247 +                                                  jvalue obj,
   1.248 +                                                  jmmStatisticType type);
   1.249 +
   1.250 +  void         (JNICALL *SetPoolSensor)          (JNIEnv *env,
   1.251 +                                                  jobject pool,
   1.252 +                                                  jmmThresholdType type,
   1.253 +                                                  jobject sensor);
   1.254 +
   1.255 +  jlong        (JNICALL *SetPoolThreshold)       (JNIEnv *env,
   1.256 +                                                  jobject pool,
   1.257 +                                                  jmmThresholdType type,
   1.258 +                                                  jlong threshold);
   1.259 +  jobject      (JNICALL *GetPoolCollectionUsage) (JNIEnv* env, jobject pool);
   1.260 +
   1.261 +  jint         (JNICALL *GetGCExtAttributeInfo)  (JNIEnv *env,
   1.262 +                                                  jobject mgr,
   1.263 +                                                  jmmExtAttributeInfo *ext_info,
   1.264 +                                                  jint count);
   1.265 +  void         (JNICALL *GetLastGCStat)          (JNIEnv *env,
   1.266 +                                                  jobject mgr,
   1.267 +                                                  jmmGCStat *gc_stat);
   1.268 +  jlong        (JNICALL *GetThreadCpuTimeWithKind) (JNIEnv *env,
   1.269 +                                                    jlong thread_id,
   1.270 +                                                    jboolean user_sys_cpu_time);
   1.271 +  void*        reserved5;
   1.272 +  jint         (JNICALL *DumpHeap0)              (JNIEnv *env,
   1.273 +                                                  jstring outputfile,
   1.274 +                                                  jboolean live);
   1.275 +  jobjectArray (JNICALL *FindDeadlocks)             (JNIEnv *env, jboolean object_monitors_only);
   1.276 +  void         (JNICALL *SetVMGlobal)            (JNIEnv *env,
   1.277 +                                                  jstring flag_name,
   1.278 +                                                  jvalue  new_value);
   1.279 +  void*        reserved6;
   1.280 +  jobjectArray (JNICALL *DumpThreads)            (JNIEnv *env,
   1.281 +                                                  jlongArray ids,
   1.282 +                                                  jboolean lockedMonitors,
   1.283 +                                                  jboolean lockedSynchronizers);
   1.284 +} JmmInterface;
   1.285 +
   1.286 +#ifdef __cplusplus
   1.287 +} /* extern "C" */
   1.288 +#endif /* __cplusplus */
   1.289 +
   1.290 +#endif /* !_JAVA_JMM_H_ */

mercurial