duke@435: /* fparain@5047: * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as trims@1907: * published by the Free Software Foundation. Oracle designates this duke@435: * particular file as subject to the "Classpath" exception as provided trims@1907: * by Oracle in the LICENSE file that accompanied this code. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: */ duke@435: duke@435: #ifndef _JAVA_JMM_H_ duke@435: #define _JAVA_JMM_H_ duke@435: duke@435: /* duke@435: * This is a private interface used by JDK for JVM monitoring duke@435: * and management. duke@435: * duke@435: * Bump the version number when either of the following happens: duke@435: * duke@435: * 1. There is a change in functions in JmmInterface. duke@435: * duke@435: * 2. There is a change in the contract between VM and Java classes. duke@435: */ duke@435: duke@435: #include "jni.h" duke@435: duke@435: #ifdef __cplusplus duke@435: extern "C" { duke@435: #endif duke@435: duke@435: enum { duke@435: JMM_VERSION_1 = 0x20010000, duke@435: JMM_VERSION_1_0 = 0x20010000, duke@435: JMM_VERSION_1_1 = 0x20010100, // JDK 6 duke@435: JMM_VERSION_1_2 = 0x20010200, // JDK 7 fparain@3329: JMM_VERSION_1_2_1 = 0x20010201, // JDK 7 GA fparain@5047: JMM_VERSION_1_2_2 = 0x20010202, fparain@5047: JMM_VERSION = 0x20010203 duke@435: }; duke@435: duke@435: typedef struct { duke@435: unsigned int isLowMemoryDetectionSupported : 1; duke@435: unsigned int isCompilationTimeMonitoringSupported : 1; duke@435: unsigned int isThreadContentionMonitoringSupported : 1; duke@435: unsigned int isCurrentThreadCpuTimeSupported : 1; duke@435: unsigned int isOtherThreadCpuTimeSupported : 1; duke@435: unsigned int isBootClassPathSupported : 1; duke@435: unsigned int isObjectMonitorUsageSupported : 1; duke@435: unsigned int isSynchronizerUsageSupported : 1; phh@2423: unsigned int isThreadAllocatedMemorySupported : 1; fparain@5047: unsigned int isRemoteDiagnosticCommandsSupported : 1; fparain@5047: unsigned int : 22; duke@435: } jmmOptionalSupport; duke@435: duke@435: typedef enum { duke@435: JMM_CLASS_LOADED_COUNT = 1, /* Total number of loaded classes */ duke@435: JMM_CLASS_UNLOADED_COUNT = 2, /* Total number of unloaded classes */ duke@435: JMM_THREAD_TOTAL_COUNT = 3, /* Total number of threads that have been started */ duke@435: JMM_THREAD_LIVE_COUNT = 4, /* Current number of live threads */ duke@435: JMM_THREAD_PEAK_COUNT = 5, /* Peak number of live threads */ duke@435: JMM_THREAD_DAEMON_COUNT = 6, /* Current number of daemon threads */ duke@435: JMM_JVM_INIT_DONE_TIME_MS = 7, /* Time when the JVM finished initialization */ duke@435: JMM_COMPILE_TOTAL_TIME_MS = 8, /* Total accumulated time spent in compilation */ duke@435: JMM_GC_TIME_MS = 9, /* Total accumulated time spent in collection */ duke@435: JMM_GC_COUNT = 10, /* Total number of collections */ duke@435: duke@435: JMM_INTERNAL_ATTRIBUTE_INDEX = 100, duke@435: JMM_CLASS_LOADED_BYTES = 101, /* Number of bytes loaded instance classes */ duke@435: JMM_CLASS_UNLOADED_BYTES = 102, /* Number of bytes unloaded instance classes */ duke@435: JMM_TOTAL_CLASSLOAD_TIME_MS = 103, /* Accumulated VM class loader time (TraceClassLoadingTime) */ duke@435: JMM_VM_GLOBAL_COUNT = 104, /* Number of VM internal flags */ duke@435: JMM_SAFEPOINT_COUNT = 105, /* Total number of safepoints */ duke@435: JMM_TOTAL_SAFEPOINTSYNC_TIME_MS = 106, /* Accumulated time spent getting to safepoints */ duke@435: JMM_TOTAL_STOPPED_TIME_MS = 107, /* Accumulated time spent at safepoints */ duke@435: JMM_TOTAL_APP_TIME_MS = 108, /* Accumulated time spent in Java application */ duke@435: JMM_VM_THREAD_COUNT = 109, /* Current number of VM internal threads */ duke@435: JMM_CLASS_INIT_TOTAL_COUNT = 110, /* Number of classes for which initializers were run */ duke@435: JMM_CLASS_INIT_TOTAL_TIME_MS = 111, /* Accumulated time spent in class initializers */ duke@435: JMM_METHOD_DATA_SIZE_BYTES = 112, /* Size of method data in memory */ duke@435: JMM_CLASS_VERIFY_TOTAL_TIME_MS = 113, /* Accumulated time spent in class verifier */ duke@435: JMM_SHARED_CLASS_LOADED_COUNT = 114, /* Number of shared classes loaded */ duke@435: JMM_SHARED_CLASS_UNLOADED_COUNT = 115, /* Number of shared classes unloaded */ duke@435: JMM_SHARED_CLASS_LOADED_BYTES = 116, /* Number of bytes loaded shared classes */ duke@435: JMM_SHARED_CLASS_UNLOADED_BYTES = 117, /* Number of bytes unloaded shared classes */ duke@435: duke@435: JMM_OS_ATTRIBUTE_INDEX = 200, duke@435: JMM_OS_PROCESS_ID = 201, /* Process id of the JVM */ duke@435: JMM_OS_MEM_TOTAL_PHYSICAL_BYTES = 202, /* Physical memory size */ duke@435: duke@435: JMM_GC_EXT_ATTRIBUTE_INFO_SIZE = 401 /* the size of the GC specific attributes for a given GC memory manager */ duke@435: } jmmLongAttribute; duke@435: duke@435: typedef enum { duke@435: JMM_VERBOSE_GC = 21, duke@435: JMM_VERBOSE_CLASS = 22, duke@435: JMM_THREAD_CONTENTION_MONITORING = 23, phh@2423: JMM_THREAD_CPU_TIME = 24, phh@2423: JMM_THREAD_ALLOCATED_MEMORY = 25 duke@435: } jmmBoolAttribute; duke@435: duke@435: duke@435: enum { duke@435: JMM_THREAD_STATE_FLAG_SUSPENDED = 0x00100000, duke@435: JMM_THREAD_STATE_FLAG_NATIVE = 0x00400000 duke@435: }; duke@435: duke@435: #define JMM_THREAD_STATE_FLAG_MASK 0xFFF00000 duke@435: duke@435: typedef enum { duke@435: JMM_STAT_PEAK_THREAD_COUNT = 801, duke@435: JMM_STAT_THREAD_CONTENTION_COUNT = 802, duke@435: JMM_STAT_THREAD_CONTENTION_TIME = 803, duke@435: JMM_STAT_THREAD_CONTENTION_STAT = 804, duke@435: JMM_STAT_PEAK_POOL_USAGE = 805, duke@435: JMM_STAT_GC_STAT = 806 duke@435: } jmmStatisticType; duke@435: duke@435: typedef enum { duke@435: JMM_USAGE_THRESHOLD_HIGH = 901, duke@435: JMM_USAGE_THRESHOLD_LOW = 902, duke@435: JMM_COLLECTION_USAGE_THRESHOLD_HIGH = 903, duke@435: JMM_COLLECTION_USAGE_THRESHOLD_LOW = 904 duke@435: } jmmThresholdType; duke@435: duke@435: /* Should match what is allowed in globals.hpp */ duke@435: typedef enum { duke@435: JMM_VMGLOBAL_TYPE_UNKNOWN = 0, duke@435: JMM_VMGLOBAL_TYPE_JBOOLEAN = 1, duke@435: JMM_VMGLOBAL_TYPE_JSTRING = 2, duke@435: JMM_VMGLOBAL_TYPE_JLONG = 3 duke@435: } jmmVMGlobalType; duke@435: duke@435: typedef enum { duke@435: JMM_VMGLOBAL_ORIGIN_DEFAULT = 1, /* Default value */ duke@435: JMM_VMGLOBAL_ORIGIN_COMMAND_LINE = 2, /* Set at command line (or JNI invocation) */ duke@435: JMM_VMGLOBAL_ORIGIN_MANAGEMENT = 3, /* Set via management interface */ duke@435: JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR = 4, /* Set via environment variables */ duke@435: JMM_VMGLOBAL_ORIGIN_CONFIG_FILE = 5, /* Set via config file (such as .hotspotrc) */ duke@435: JMM_VMGLOBAL_ORIGIN_ERGONOMIC = 6, /* Set via ergonomic */ duke@435: JMM_VMGLOBAL_ORIGIN_OTHER = 99 /* Set via some other mechanism */ duke@435: } jmmVMGlobalOrigin; duke@435: duke@435: typedef struct { duke@435: jstring name; duke@435: jvalue value; duke@435: jmmVMGlobalType type; /* Data type */ duke@435: jmmVMGlobalOrigin origin; /* Default or non-default value */ duke@435: unsigned int writeable : 1; /* dynamically writeable */ duke@435: unsigned int external : 1; /* external supported interface */ duke@435: unsigned int reserved : 30; duke@435: void *reserved1; duke@435: void *reserved2; duke@435: } jmmVMGlobal; duke@435: duke@435: typedef struct { duke@435: const char* name; duke@435: char type; duke@435: const char* description; duke@435: } jmmExtAttributeInfo; duke@435: duke@435: /* Caller has to set the following fields before calling GetLastGCStat duke@435: * o usage_before_gc - array of MemoryUsage objects duke@435: * o usage_after_gc - array of MemoryUsage objects duke@435: * o gc_ext_attribute_values_size - size of gc_ext_atttribute_values array duke@435: * o gc_ext_attribtue_values - array of jvalues duke@435: */ duke@435: typedef struct { duke@435: jlong gc_index; /* Index of the collections */ duke@435: jlong start_time; /* Start time of the GC */ duke@435: jlong end_time; /* End time of the GC */ duke@435: jobjectArray usage_before_gc; /* Memory usage array before GC */ duke@435: jobjectArray usage_after_gc; /* Memory usage array after GC */ duke@435: jint gc_ext_attribute_values_size; /* set by the caller of GetGCStat */ duke@435: jvalue* gc_ext_attribute_values; /* Array of jvalue for GC extension attributes */ duke@435: jint num_gc_ext_attributes; /* number of GC extension attribute values s are filled */ duke@435: /* -1 indicates gc_ext_attribute_values is not big enough */ duke@435: } jmmGCStat; duke@435: fparain@3329: typedef struct { fparain@5047: const char* name; /* Name of the diagnostic command */ fparain@5047: const char* description; /* Short description */ fparain@5047: const char* impact; /* Impact on the JVM */ fparain@5047: const char* permission_class; /* Class name of the required permission if any */ fparain@5047: const char* permission_name; /* Permission name of the required permission if any */ fparain@5047: const char* permission_action; /* Action name of the required permission if any*/ fparain@5047: int num_arguments; /* Number of supported options or arguments */ fparain@5047: jboolean enabled; /* True if the diagnostic command can be invoked, false otherwise */ fparain@3329: } dcmdInfo; fparain@3329: fparain@3329: typedef struct { fparain@5047: const char* name; /* Option/Argument name*/ fparain@5047: const char* description; /* Short description */ fparain@5047: const char* type; /* Type: STRING, BOOLEAN, etc. */ fparain@5047: const char* default_string; /* Default value in a parsable string */ fparain@5047: jboolean mandatory; /* True if the option/argument is mandatory */ fparain@5047: jboolean option; /* True if it is an option, false if it is an argument */ fparain@5047: /* (see diagnosticFramework.hpp for option/argument definitions) */ fparain@5047: jboolean multiple; /* True if the option can be specified several time */ fparain@5047: int position; /* Expected position for this argument (this field is */ fparain@5047: /* meaningless for options) */ fparain@3329: } dcmdArgInfo; fparain@3329: duke@435: typedef struct jmmInterface_1_ { duke@435: void* reserved1; duke@435: void* reserved2; duke@435: duke@435: jint (JNICALL *GetVersion) (JNIEnv *env); duke@435: duke@435: jint (JNICALL *GetOptionalSupport) (JNIEnv *env, duke@435: jmmOptionalSupport* support_ptr); duke@435: duke@435: /* This is used by JDK 6 and earlier. duke@435: * For JDK 7 and after, use GetInputArgumentArray. duke@435: */ duke@435: jobject (JNICALL *GetInputArguments) (JNIEnv *env); duke@435: duke@435: jint (JNICALL *GetThreadInfo) (JNIEnv *env, duke@435: jlongArray ids, duke@435: jint maxDepth, duke@435: jobjectArray infoArray); duke@435: jobjectArray (JNICALL *GetInputArgumentArray) (JNIEnv *env); duke@435: duke@435: jobjectArray (JNICALL *GetMemoryPools) (JNIEnv* env, jobject mgr); duke@435: duke@435: jobjectArray (JNICALL *GetMemoryManagers) (JNIEnv* env, jobject pool); duke@435: duke@435: jobject (JNICALL *GetMemoryPoolUsage) (JNIEnv* env, jobject pool); duke@435: jobject (JNICALL *GetPeakMemoryPoolUsage) (JNIEnv* env, jobject pool); duke@435: phh@2423: void (JNICALL *GetThreadAllocatedMemory) phh@2423: (JNIEnv *env, phh@2423: jlongArray ids, phh@2423: jlongArray sizeArray); duke@435: duke@435: jobject (JNICALL *GetMemoryUsage) (JNIEnv* env, jboolean heap); duke@435: duke@435: jlong (JNICALL *GetLongAttribute) (JNIEnv *env, jobject obj, jmmLongAttribute att); duke@435: jboolean (JNICALL *GetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att); duke@435: jboolean (JNICALL *SetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att, jboolean flag); duke@435: duke@435: jint (JNICALL *GetLongAttributes) (JNIEnv *env, duke@435: jobject obj, duke@435: jmmLongAttribute* atts, duke@435: jint count, duke@435: jlong* result); duke@435: duke@435: jobjectArray (JNICALL *FindCircularBlockedThreads) (JNIEnv *env); phh@2423: phh@2423: // Not used in JDK 6 or JDK 7 duke@435: jlong (JNICALL *GetThreadCpuTime) (JNIEnv *env, jlong thread_id); duke@435: duke@435: jobjectArray (JNICALL *GetVMGlobalNames) (JNIEnv *env); duke@435: jint (JNICALL *GetVMGlobals) (JNIEnv *env, duke@435: jobjectArray names, duke@435: jmmVMGlobal *globals, duke@435: jint count); duke@435: duke@435: jint (JNICALL *GetInternalThreadTimes) (JNIEnv *env, duke@435: jobjectArray names, duke@435: jlongArray times); duke@435: duke@435: jboolean (JNICALL *ResetStatistic) (JNIEnv *env, duke@435: jvalue obj, duke@435: jmmStatisticType type); duke@435: duke@435: void (JNICALL *SetPoolSensor) (JNIEnv *env, duke@435: jobject pool, duke@435: jmmThresholdType type, duke@435: jobject sensor); duke@435: duke@435: jlong (JNICALL *SetPoolThreshold) (JNIEnv *env, duke@435: jobject pool, duke@435: jmmThresholdType type, duke@435: jlong threshold); duke@435: jobject (JNICALL *GetPoolCollectionUsage) (JNIEnv* env, jobject pool); duke@435: duke@435: jint (JNICALL *GetGCExtAttributeInfo) (JNIEnv *env, duke@435: jobject mgr, duke@435: jmmExtAttributeInfo *ext_info, duke@435: jint count); duke@435: void (JNICALL *GetLastGCStat) (JNIEnv *env, duke@435: jobject mgr, duke@435: jmmGCStat *gc_stat); phh@2423: phh@2423: jlong (JNICALL *GetThreadCpuTimeWithKind) phh@2423: (JNIEnv *env, phh@2423: jlong thread_id, phh@2423: jboolean user_sys_cpu_time); phh@2423: void (JNICALL *GetThreadCpuTimesWithKind) phh@2423: (JNIEnv *env, phh@2423: jlongArray ids, phh@2423: jlongArray timeArray, phh@2423: jboolean user_sys_cpu_time); phh@2423: duke@435: jint (JNICALL *DumpHeap0) (JNIEnv *env, duke@435: jstring outputfile, duke@435: jboolean live); phh@2423: jobjectArray (JNICALL *FindDeadlocks) (JNIEnv *env, phh@2423: jboolean object_monitors_only); duke@435: void (JNICALL *SetVMGlobal) (JNIEnv *env, duke@435: jstring flag_name, duke@435: jvalue new_value); duke@435: void* reserved6; duke@435: jobjectArray (JNICALL *DumpThreads) (JNIEnv *env, duke@435: jlongArray ids, duke@435: jboolean lockedMonitors, duke@435: jboolean lockedSynchronizers); fparain@2888: void (JNICALL *SetGCNotificationEnabled) (JNIEnv *env, fparain@2888: jobject mgr, fparain@2888: jboolean enabled); fparain@3329: jobjectArray (JNICALL *GetDiagnosticCommands) (JNIEnv *env); fparain@3329: void (JNICALL *GetDiagnosticCommandInfo) fparain@3329: (JNIEnv *env, fparain@3329: jobjectArray cmds, fparain@3329: dcmdInfo *infoArray); fparain@3329: void (JNICALL *GetDiagnosticCommandArgumentsInfo) fparain@3329: (JNIEnv *env, fparain@3329: jstring commandName, fparain@3329: dcmdArgInfo *infoArray); fparain@3329: jstring (JNICALL *ExecuteDiagnosticCommand) fparain@3329: (JNIEnv *env, fparain@3329: jstring command); fparain@5047: void (JNICALL *SetDiagnosticFrameworkNotificationEnabled) fparain@5047: (JNIEnv *env, fparain@5047: jboolean enabled); duke@435: } JmmInterface; duke@435: duke@435: #ifdef __cplusplus duke@435: } /* extern "C" */ duke@435: #endif /* __cplusplus */ duke@435: duke@435: #endif /* !_JAVA_JMM_H_ */