Path: blob/master/src/hotspot/share/include/jmm.h
40951 views
/*1* Copyright (c) 2003, 2020, 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_2 = 0x20020000, // JDK 1053JMM_VERSION_3 = 0x20030000, // JDK 1454JMM_VERSION = JMM_VERSION_355};5657typedef struct {58unsigned int isLowMemoryDetectionSupported : 1;59unsigned int isCompilationTimeMonitoringSupported : 1;60unsigned int isThreadContentionMonitoringSupported : 1;61unsigned int isCurrentThreadCpuTimeSupported : 1;62unsigned int isOtherThreadCpuTimeSupported : 1;63unsigned int isObjectMonitorUsageSupported : 1;64unsigned int isSynchronizerUsageSupported : 1;65unsigned int isThreadAllocatedMemorySupported : 1;66unsigned int isRemoteDiagnosticCommandsSupported : 1;67unsigned int : 22;68} jmmOptionalSupport;6970typedef enum {71JMM_CLASS_LOADED_COUNT = 1, /* Total number of loaded classes */72JMM_CLASS_UNLOADED_COUNT = 2, /* Total number of unloaded classes */73JMM_THREAD_TOTAL_COUNT = 3, /* Total number of threads that have been started */74JMM_THREAD_LIVE_COUNT = 4, /* Current number of live threads */75JMM_THREAD_PEAK_COUNT = 5, /* Peak number of live threads */76JMM_THREAD_DAEMON_COUNT = 6, /* Current number of daemon threads */77JMM_JVM_INIT_DONE_TIME_MS = 7, /* Time when the JVM finished initialization */78JMM_COMPILE_TOTAL_TIME_MS = 8, /* Total accumulated time spent in compilation */79JMM_GC_TIME_MS = 9, /* Total accumulated time spent in collection */80JMM_GC_COUNT = 10, /* Total number of collections */81JMM_JVM_UPTIME_MS = 11, /* The JVM uptime in milliseconds */8283JMM_INTERNAL_ATTRIBUTE_INDEX = 100,84JMM_CLASS_LOADED_BYTES = 101, /* Number of bytes loaded instance classes */85JMM_CLASS_UNLOADED_BYTES = 102, /* Number of bytes unloaded instance classes */86JMM_TOTAL_CLASSLOAD_TIME_MS = 103, /* Accumulated VM class loader time */87JMM_VM_GLOBAL_COUNT = 104, /* Number of VM internal flags */88JMM_SAFEPOINT_COUNT = 105, /* Total number of safepoints */89JMM_TOTAL_SAFEPOINTSYNC_TIME_MS = 106, /* Accumulated time spent getting to safepoints */90JMM_TOTAL_STOPPED_TIME_MS = 107, /* Accumulated time spent at safepoints */91JMM_TOTAL_APP_TIME_MS = 108, /* Accumulated time spent in Java application */92JMM_VM_THREAD_COUNT = 109, /* Current number of VM internal threads */93JMM_CLASS_INIT_TOTAL_COUNT = 110, /* Number of classes for which initializers were run */94JMM_CLASS_INIT_TOTAL_TIME_MS = 111, /* Accumulated time spent in class initializers */95JMM_METHOD_DATA_SIZE_BYTES = 112, /* Size of method data in memory */96JMM_CLASS_VERIFY_TOTAL_TIME_MS = 113, /* Accumulated time spent in class verifier */97JMM_SHARED_CLASS_LOADED_COUNT = 114, /* Number of shared classes loaded */98JMM_SHARED_CLASS_UNLOADED_COUNT = 115, /* Number of shared classes unloaded */99JMM_SHARED_CLASS_LOADED_BYTES = 116, /* Number of bytes loaded shared classes */100JMM_SHARED_CLASS_UNLOADED_BYTES = 117, /* Number of bytes unloaded shared classes */101102JMM_OS_ATTRIBUTE_INDEX = 200,103JMM_OS_PROCESS_ID = 201, /* Process id of the JVM */104JMM_OS_MEM_TOTAL_PHYSICAL_BYTES = 202, /* Physical memory size */105106JMM_GC_EXT_ATTRIBUTE_INFO_SIZE = 401 /* the size of the GC specific attributes for a given GC memory manager */107} jmmLongAttribute;108109typedef enum {110JMM_VERBOSE_GC = 21,111JMM_VERBOSE_CLASS = 22,112JMM_THREAD_CONTENTION_MONITORING = 23,113JMM_THREAD_CPU_TIME = 24,114JMM_THREAD_ALLOCATED_MEMORY = 25115} jmmBoolAttribute;116117118enum {119JMM_THREAD_STATE_FLAG_SUSPENDED = 0x00100000,120JMM_THREAD_STATE_FLAG_NATIVE = 0x00400000121};122123#define JMM_THREAD_STATE_FLAG_MASK 0xFFF00000124125typedef enum {126JMM_STAT_PEAK_THREAD_COUNT = 801,127JMM_STAT_THREAD_CONTENTION_COUNT = 802,128JMM_STAT_THREAD_CONTENTION_TIME = 803,129JMM_STAT_THREAD_CONTENTION_STAT = 804,130JMM_STAT_PEAK_POOL_USAGE = 805,131JMM_STAT_GC_STAT = 806132} jmmStatisticType;133134typedef enum {135JMM_USAGE_THRESHOLD_HIGH = 901,136JMM_USAGE_THRESHOLD_LOW = 902,137JMM_COLLECTION_USAGE_THRESHOLD_HIGH = 903,138JMM_COLLECTION_USAGE_THRESHOLD_LOW = 904139} jmmThresholdType;140141/* Should match what is allowed in globals.hpp */142typedef enum {143JMM_VMGLOBAL_TYPE_UNKNOWN = 0,144JMM_VMGLOBAL_TYPE_JBOOLEAN = 1,145JMM_VMGLOBAL_TYPE_JSTRING = 2,146JMM_VMGLOBAL_TYPE_JLONG = 3,147JMM_VMGLOBAL_TYPE_JDOUBLE = 4148} jmmVMGlobalType;149150typedef enum {151JMM_VMGLOBAL_ORIGIN_DEFAULT = 1, /* Default value */152JMM_VMGLOBAL_ORIGIN_COMMAND_LINE = 2, /* Set at command line (or JNI invocation) */153JMM_VMGLOBAL_ORIGIN_MANAGEMENT = 3, /* Set via management interface */154JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR = 4, /* Set via environment variables */155JMM_VMGLOBAL_ORIGIN_CONFIG_FILE = 5, /* Set via config file (such as .hotspotrc) */156JMM_VMGLOBAL_ORIGIN_ERGONOMIC = 6, /* Set via ergonomic */157JMM_VMGLOBAL_ORIGIN_ATTACH_ON_DEMAND = 7, /* Set via attach */158JMM_VMGLOBAL_ORIGIN_OTHER = 99 /* Set via some other mechanism */159} jmmVMGlobalOrigin;160161typedef struct {162jstring name;163jvalue value;164jmmVMGlobalType type; /* Data type */165jmmVMGlobalOrigin origin; /* Default or non-default value */166unsigned int writeable : 1; /* dynamically writeable */167unsigned int external : 1; /* external supported interface */168unsigned int reserved : 30;169void *reserved1;170void *reserved2;171} jmmVMGlobal;172173typedef struct {174const char* name;175char type;176const char* description;177} jmmExtAttributeInfo;178179/* Caller has to set the following fields before calling GetLastGCStat180* o usage_before_gc - array of MemoryUsage objects181* o usage_after_gc - array of MemoryUsage objects182* o gc_ext_attribute_values_size - size of gc_ext_atttribute_values array183* o gc_ext_attribtue_values - array of jvalues184*/185typedef struct {186jlong gc_index; /* Index of the collections */187jlong start_time; /* Start time of the GC */188jlong end_time; /* End time of the GC */189jobjectArray usage_before_gc; /* Memory usage array before GC */190jobjectArray usage_after_gc; /* Memory usage array after GC */191jint gc_ext_attribute_values_size; /* set by the caller of GetGCStat */192jvalue* gc_ext_attribute_values; /* Array of jvalue for GC extension attributes */193jint num_gc_ext_attributes; /* number of GC extension attribute values s are filled */194/* -1 indicates gc_ext_attribute_values is not big enough */195} jmmGCStat;196197typedef struct {198const char* name; /* Name of the diagnostic command */199const char* description; /* Short description */200const char* impact; /* Impact on the JVM */201const char* permission_class; /* Class name of the required permission if any */202const char* permission_name; /* Permission name of the required permission if any */203const char* permission_action; /* Action name of the required permission if any*/204int num_arguments; /* Number of supported options or arguments */205jboolean enabled; /* True if the diagnostic command can be invoked, false otherwise*/206} dcmdInfo;207208typedef struct {209const char* name; /* Option/Argument name*/210const char* description; /* Short description */211const char* type; /* Type: STRING, BOOLEAN, etc. */212const char* default_string; /* Default value in a parsable string */213jboolean mandatory; /* True if the option/argument is mandatory */214jboolean option; /* True if it is an option, false if it is an argument */215/* (see diagnosticFramework.hpp for option/argument definitions) */216jboolean multiple; /* True is the option can be specified several time */217int position; /* Expected position for this argument (this field is */218/* meaningless for options) */219} dcmdArgInfo;220221typedef struct jmmInterface_1_ {222void* reserved1;223void* reserved2;224225jint (JNICALL *GetVersion) (JNIEnv *env);226227jint (JNICALL *GetOptionalSupport) (JNIEnv *env,228jmmOptionalSupport* support_ptr);229230jint (JNICALL *GetThreadInfo) (JNIEnv *env,231jlongArray ids,232jint maxDepth,233jobjectArray infoArray);234235jobjectArray (JNICALL *GetMemoryPools) (JNIEnv* env, jobject mgr);236237jobjectArray (JNICALL *GetMemoryManagers) (JNIEnv* env, jobject pool);238239jobject (JNICALL *GetMemoryPoolUsage) (JNIEnv* env, jobject pool);240jobject (JNICALL *GetPeakMemoryPoolUsage) (JNIEnv* env, jobject pool);241242jlong (JNICALL *GetOneThreadAllocatedMemory)243(JNIEnv *env,244jlong thread_id);245void (JNICALL *GetThreadAllocatedMemory)246(JNIEnv *env,247jlongArray ids,248jlongArray sizeArray);249250jobject (JNICALL *GetMemoryUsage) (JNIEnv* env, jboolean heap);251252jlong (JNICALL *GetLongAttribute) (JNIEnv *env, jobject obj, jmmLongAttribute att);253jboolean (JNICALL *GetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att);254jboolean (JNICALL *SetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att, jboolean flag);255256jint (JNICALL *GetLongAttributes) (JNIEnv *env,257jobject obj,258jmmLongAttribute* atts,259jint count,260jlong* result);261262jobjectArray (JNICALL *FindCircularBlockedThreads) (JNIEnv *env);263264// Not used in JDK 6 or JDK 7265jlong (JNICALL *GetThreadCpuTime) (JNIEnv *env, jlong thread_id);266267jobjectArray (JNICALL *GetVMGlobalNames) (JNIEnv *env);268jint (JNICALL *GetVMGlobals) (JNIEnv *env,269jobjectArray names,270jmmVMGlobal *globals,271jint count);272273jint (JNICALL *GetInternalThreadTimes) (JNIEnv *env,274jobjectArray names,275jlongArray times);276277jboolean (JNICALL *ResetStatistic) (JNIEnv *env,278jvalue obj,279jmmStatisticType type);280281void (JNICALL *SetPoolSensor) (JNIEnv *env,282jobject pool,283jmmThresholdType type,284jobject sensor);285286jlong (JNICALL *SetPoolThreshold) (JNIEnv *env,287jobject pool,288jmmThresholdType type,289jlong threshold);290jobject (JNICALL *GetPoolCollectionUsage) (JNIEnv* env, jobject pool);291292jint (JNICALL *GetGCExtAttributeInfo) (JNIEnv *env,293jobject mgr,294jmmExtAttributeInfo *ext_info,295jint count);296void (JNICALL *GetLastGCStat) (JNIEnv *env,297jobject mgr,298jmmGCStat *gc_stat);299300jlong (JNICALL *GetThreadCpuTimeWithKind)301(JNIEnv *env,302jlong thread_id,303jboolean user_sys_cpu_time);304void (JNICALL *GetThreadCpuTimesWithKind)305(JNIEnv *env,306jlongArray ids,307jlongArray timeArray,308jboolean user_sys_cpu_time);309310jint (JNICALL *DumpHeap0) (JNIEnv *env,311jstring outputfile,312jboolean live);313jobjectArray (JNICALL *FindDeadlocks) (JNIEnv *env,314jboolean object_monitors_only);315void (JNICALL *SetVMGlobal) (JNIEnv *env,316jstring flag_name,317jvalue new_value);318void* reserved6;319jobjectArray (JNICALL *DumpThreads) (JNIEnv *env,320jlongArray ids,321jboolean lockedMonitors,322jboolean lockedSynchronizers,323jint maxDepth);324void (JNICALL *SetGCNotificationEnabled) (JNIEnv *env,325jobject mgr,326jboolean enabled);327jobjectArray (JNICALL *GetDiagnosticCommands) (JNIEnv *env);328void (JNICALL *GetDiagnosticCommandInfo)329(JNIEnv *env,330jobjectArray cmds,331dcmdInfo *infoArray);332void (JNICALL *GetDiagnosticCommandArgumentsInfo)333(JNIEnv *env,334jstring commandName,335dcmdArgInfo *infoArray);336jstring (JNICALL *ExecuteDiagnosticCommand)337(JNIEnv *env,338jstring command);339void (JNICALL *SetDiagnosticFrameworkNotificationEnabled)340(JNIEnv *env,341jboolean enabled);342} JmmInterface;343344#ifdef __cplusplus345} /* extern "C" */346#endif /* __cplusplus */347348#endif /* !_JAVA_JMM_H_ */349350351