Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/services/jmm.h
32285 views
/*1* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef _JAVA_JMM_H_26#define _JAVA_JMM_H_2728/*29* This is a private interface used by JDK for JVM monitoring30* and management.31*32* Bump the version number when either of the following happens:33*34* 1. There is a change in functions in JmmInterface.35*36* 2. There is a change in the contract between VM and Java classes.37*/3839#include "jni.h"4041#ifdef __cplusplus42extern "C" {43#endif4445enum {46JMM_VERSION_1 = 0x20010000,47JMM_VERSION_1_0 = 0x20010000,48JMM_VERSION_1_1 = 0x20010100, // JDK 649JMM_VERSION_1_2 = 0x20010200, // JDK 750JMM_VERSION_1_2_1 = 0x20010201, // JDK 7 GA51JMM_VERSION_1_2_2 = 0x20010202,52JMM_VERSION = 0x2001020353};5455typedef struct {56unsigned int isLowMemoryDetectionSupported : 1;57unsigned int isCompilationTimeMonitoringSupported : 1;58unsigned int isThreadContentionMonitoringSupported : 1;59unsigned int isCurrentThreadCpuTimeSupported : 1;60unsigned int isOtherThreadCpuTimeSupported : 1;61unsigned int isBootClassPathSupported : 1;62unsigned int isObjectMonitorUsageSupported : 1;63unsigned int isSynchronizerUsageSupported : 1;64unsigned int isThreadAllocatedMemorySupported : 1;65unsigned int isRemoteDiagnosticCommandsSupported : 1;66unsigned int : 22;67} jmmOptionalSupport;6869typedef enum {70JMM_CLASS_LOADED_COUNT = 1, /* Total number of loaded classes */71JMM_CLASS_UNLOADED_COUNT = 2, /* Total number of unloaded classes */72JMM_THREAD_TOTAL_COUNT = 3, /* Total number of threads that have been started */73JMM_THREAD_LIVE_COUNT = 4, /* Current number of live threads */74JMM_THREAD_PEAK_COUNT = 5, /* Peak number of live threads */75JMM_THREAD_DAEMON_COUNT = 6, /* Current number of daemon threads */76JMM_JVM_INIT_DONE_TIME_MS = 7, /* Time when the JVM finished initialization */77JMM_COMPILE_TOTAL_TIME_MS = 8, /* Total accumulated time spent in compilation */78JMM_GC_TIME_MS = 9, /* Total accumulated time spent in collection */79JMM_GC_COUNT = 10, /* Total number of collections */80JMM_JVM_UPTIME_MS = 11, /* The JVM uptime in milliseconds */8182JMM_INTERNAL_ATTRIBUTE_INDEX = 100,83JMM_CLASS_LOADED_BYTES = 101, /* Number of bytes loaded instance classes */84JMM_CLASS_UNLOADED_BYTES = 102, /* Number of bytes unloaded instance classes */85JMM_TOTAL_CLASSLOAD_TIME_MS = 103, /* Accumulated VM class loader time (TraceClassLoadingTime) */86JMM_VM_GLOBAL_COUNT = 104, /* Number of VM internal flags */87JMM_SAFEPOINT_COUNT = 105, /* Total number of safepoints */88JMM_TOTAL_SAFEPOINTSYNC_TIME_MS = 106, /* Accumulated time spent getting to safepoints */89JMM_TOTAL_STOPPED_TIME_MS = 107, /* Accumulated time spent at safepoints */90JMM_TOTAL_APP_TIME_MS = 108, /* Accumulated time spent in Java application */91JMM_VM_THREAD_COUNT = 109, /* Current number of VM internal threads */92JMM_CLASS_INIT_TOTAL_COUNT = 110, /* Number of classes for which initializers were run */93JMM_CLASS_INIT_TOTAL_TIME_MS = 111, /* Accumulated time spent in class initializers */94JMM_METHOD_DATA_SIZE_BYTES = 112, /* Size of method data in memory */95JMM_CLASS_VERIFY_TOTAL_TIME_MS = 113, /* Accumulated time spent in class verifier */96JMM_SHARED_CLASS_LOADED_COUNT = 114, /* Number of shared classes loaded */97JMM_SHARED_CLASS_UNLOADED_COUNT = 115, /* Number of shared classes unloaded */98JMM_SHARED_CLASS_LOADED_BYTES = 116, /* Number of bytes loaded shared classes */99JMM_SHARED_CLASS_UNLOADED_BYTES = 117, /* Number of bytes unloaded shared classes */100101JMM_OS_ATTRIBUTE_INDEX = 200,102JMM_OS_PROCESS_ID = 201, /* Process id of the JVM */103JMM_OS_MEM_TOTAL_PHYSICAL_BYTES = 202, /* Physical memory size */104105JMM_GC_EXT_ATTRIBUTE_INFO_SIZE = 401 /* the size of the GC specific attributes for a given GC memory manager */106} jmmLongAttribute;107108typedef enum {109JMM_VERBOSE_GC = 21,110JMM_VERBOSE_CLASS = 22,111JMM_THREAD_CONTENTION_MONITORING = 23,112JMM_THREAD_CPU_TIME = 24,113JMM_THREAD_ALLOCATED_MEMORY = 25114} jmmBoolAttribute;115116117enum {118JMM_THREAD_STATE_FLAG_SUSPENDED = 0x00100000,119JMM_THREAD_STATE_FLAG_NATIVE = 0x00400000120};121122#define JMM_THREAD_STATE_FLAG_MASK 0xFFF00000123124typedef enum {125JMM_STAT_PEAK_THREAD_COUNT = 801,126JMM_STAT_THREAD_CONTENTION_COUNT = 802,127JMM_STAT_THREAD_CONTENTION_TIME = 803,128JMM_STAT_THREAD_CONTENTION_STAT = 804,129JMM_STAT_PEAK_POOL_USAGE = 805,130JMM_STAT_GC_STAT = 806131} jmmStatisticType;132133typedef enum {134JMM_USAGE_THRESHOLD_HIGH = 901,135JMM_USAGE_THRESHOLD_LOW = 902,136JMM_COLLECTION_USAGE_THRESHOLD_HIGH = 903,137JMM_COLLECTION_USAGE_THRESHOLD_LOW = 904138} jmmThresholdType;139140/* Should match what is allowed in globals.hpp */141typedef enum {142JMM_VMGLOBAL_TYPE_UNKNOWN = 0,143JMM_VMGLOBAL_TYPE_JBOOLEAN = 1,144JMM_VMGLOBAL_TYPE_JSTRING = 2,145JMM_VMGLOBAL_TYPE_JLONG = 3,146JMM_VMGLOBAL_TYPE_JDOUBLE = 4147} jmmVMGlobalType;148149typedef enum {150JMM_VMGLOBAL_ORIGIN_DEFAULT = 1, /* Default value */151JMM_VMGLOBAL_ORIGIN_COMMAND_LINE = 2, /* Set at command line (or JNI invocation) */152JMM_VMGLOBAL_ORIGIN_MANAGEMENT = 3, /* Set via management interface */153JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR = 4, /* Set via environment variables */154JMM_VMGLOBAL_ORIGIN_CONFIG_FILE = 5, /* Set via config file (such as .hotspotrc) */155JMM_VMGLOBAL_ORIGIN_ERGONOMIC = 6, /* Set via ergonomic */156JMM_VMGLOBAL_ORIGIN_OTHER = 99 /* Set via some other mechanism */157} jmmVMGlobalOrigin;158159typedef struct {160jstring name;161jvalue value;162jmmVMGlobalType type; /* Data type */163jmmVMGlobalOrigin origin; /* Default or non-default value */164unsigned int writeable : 1; /* dynamically writeable */165unsigned int external : 1; /* external supported interface */166unsigned int reserved : 30;167void *reserved1;168void *reserved2;169} jmmVMGlobal;170171typedef struct {172const char* name;173char type;174const char* description;175} jmmExtAttributeInfo;176177/* Caller has to set the following fields before calling GetLastGCStat178* o usage_before_gc - array of MemoryUsage objects179* o usage_after_gc - array of MemoryUsage objects180* o gc_ext_attribute_values_size - size of gc_ext_atttribute_values array181* o gc_ext_attribtue_values - array of jvalues182*/183typedef struct {184jlong gc_index; /* Index of the collections */185jlong start_time; /* Start time of the GC */186jlong end_time; /* End time of the GC */187jobjectArray usage_before_gc; /* Memory usage array before GC */188jobjectArray usage_after_gc; /* Memory usage array after GC */189jint gc_ext_attribute_values_size; /* set by the caller of GetGCStat */190jvalue* gc_ext_attribute_values; /* Array of jvalue for GC extension attributes */191jint num_gc_ext_attributes; /* number of GC extension attribute values s are filled */192/* -1 indicates gc_ext_attribute_values is not big enough */193} jmmGCStat;194195typedef struct {196const char* name; /* Name of the diagnostic command */197const char* description; /* Short description */198const char* impact; /* Impact on the JVM */199const char* permission_class; /* Class name of the required permission if any */200const char* permission_name; /* Permission name of the required permission if any */201const char* permission_action; /* Action name of the required permission if any*/202int num_arguments; /* Number of supported options or arguments */203jboolean enabled; /* True if the diagnostic command can be invoked, false otherwise */204} dcmdInfo;205206typedef struct {207const char* name; /* Option/Argument name*/208const char* description; /* Short description */209const char* type; /* Type: STRING, BOOLEAN, etc. */210const char* default_string; /* Default value in a parsable string */211jboolean mandatory; /* True if the option/argument is mandatory */212jboolean option; /* True if it is an option, false if it is an argument */213/* (see diagnosticFramework.hpp for option/argument definitions) */214jboolean multiple; /* True if the option can be specified several time */215int position; /* Expected position for this argument (this field is */216/* meaningless for options) */217} dcmdArgInfo;218219typedef struct jmmInterface_1_ {220void* reserved1;221jlong (JNICALL *GetOneThreadAllocatedMemory)222(JNIEnv *env,223jlong thread_id);224225jint (JNICALL *GetVersion) (JNIEnv *env);226227jint (JNICALL *GetOptionalSupport) (JNIEnv *env,228jmmOptionalSupport* support_ptr);229230/* This is used by JDK 6 and earlier.231* For JDK 7 and after, use GetInputArgumentArray.232*/233jobject (JNICALL *GetInputArguments) (JNIEnv *env);234235jint (JNICALL *GetThreadInfo) (JNIEnv *env,236jlongArray ids,237jint maxDepth,238jobjectArray infoArray);239jobjectArray (JNICALL *GetInputArgumentArray) (JNIEnv *env);240241jobjectArray (JNICALL *GetMemoryPools) (JNIEnv* env, jobject mgr);242243jobjectArray (JNICALL *GetMemoryManagers) (JNIEnv* env, jobject pool);244245jobject (JNICALL *GetMemoryPoolUsage) (JNIEnv* env, jobject pool);246jobject (JNICALL *GetPeakMemoryPoolUsage) (JNIEnv* env, jobject pool);247248void (JNICALL *GetThreadAllocatedMemory)249(JNIEnv *env,250jlongArray ids,251jlongArray sizeArray);252253jobject (JNICALL *GetMemoryUsage) (JNIEnv* env, jboolean heap);254255jlong (JNICALL *GetLongAttribute) (JNIEnv *env, jobject obj, jmmLongAttribute att);256jboolean (JNICALL *GetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att);257jboolean (JNICALL *SetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att, jboolean flag);258259jint (JNICALL *GetLongAttributes) (JNIEnv *env,260jobject obj,261jmmLongAttribute* atts,262jint count,263jlong* result);264265jobjectArray (JNICALL *FindCircularBlockedThreads) (JNIEnv *env);266267// Not used in JDK 6 or JDK 7268jlong (JNICALL *GetThreadCpuTime) (JNIEnv *env, jlong thread_id);269270jobjectArray (JNICALL *GetVMGlobalNames) (JNIEnv *env);271jint (JNICALL *GetVMGlobals) (JNIEnv *env,272jobjectArray names,273jmmVMGlobal *globals,274jint count);275276jint (JNICALL *GetInternalThreadTimes) (JNIEnv *env,277jobjectArray names,278jlongArray times);279280jboolean (JNICALL *ResetStatistic) (JNIEnv *env,281jvalue obj,282jmmStatisticType type);283284void (JNICALL *SetPoolSensor) (JNIEnv *env,285jobject pool,286jmmThresholdType type,287jobject sensor);288289jlong (JNICALL *SetPoolThreshold) (JNIEnv *env,290jobject pool,291jmmThresholdType type,292jlong threshold);293jobject (JNICALL *GetPoolCollectionUsage) (JNIEnv* env, jobject pool);294295jint (JNICALL *GetGCExtAttributeInfo) (JNIEnv *env,296jobject mgr,297jmmExtAttributeInfo *ext_info,298jint count);299void (JNICALL *GetLastGCStat) (JNIEnv *env,300jobject mgr,301jmmGCStat *gc_stat);302303jlong (JNICALL *GetThreadCpuTimeWithKind)304(JNIEnv *env,305jlong thread_id,306jboolean user_sys_cpu_time);307void (JNICALL *GetThreadCpuTimesWithKind)308(JNIEnv *env,309jlongArray ids,310jlongArray timeArray,311jboolean user_sys_cpu_time);312313jint (JNICALL *DumpHeap0) (JNIEnv *env,314jstring outputfile,315jboolean live);316jobjectArray (JNICALL *FindDeadlocks) (JNIEnv *env,317jboolean object_monitors_only);318void (JNICALL *SetVMGlobal) (JNIEnv *env,319jstring flag_name,320jvalue new_value);321jobjectArray (JNICALL *DumpThreadsMaxDepth) (JNIEnv *env,322jlongArray ids,323jboolean lockedMonitors,324jboolean lockedSynchronizers,325jint maxDepth);326jobjectArray (JNICALL *DumpThreads) (JNIEnv *env,327jlongArray ids,328jboolean lockedMonitors,329jboolean lockedSynchronizers);330void (JNICALL *SetGCNotificationEnabled) (JNIEnv *env,331jobject mgr,332jboolean enabled);333jobjectArray (JNICALL *GetDiagnosticCommands) (JNIEnv *env);334void (JNICALL *GetDiagnosticCommandInfo)335(JNIEnv *env,336jobjectArray cmds,337dcmdInfo *infoArray);338void (JNICALL *GetDiagnosticCommandArgumentsInfo)339(JNIEnv *env,340jstring commandName,341dcmdArgInfo *infoArray);342jstring (JNICALL *ExecuteDiagnosticCommand)343(JNIEnv *env,344jstring command);345void (JNICALL *SetDiagnosticFrameworkNotificationEnabled)346(JNIEnv *env,347jboolean enabled);348} JmmInterface;349350#ifdef __cplusplus351} /* extern "C" */352#endif /* __cplusplus */353354#endif /* !_JAVA_JMM_H_ */355356357