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