comparison src/share/vm/services/management.cpp @ 2453:78542e2b5e35

7036199: Adding a notification to the implementation of GarbageCollectorMXBeans Summary: Add a notification to the GarbageCollectorMXBeans Reviewed-by: acorn, mchung
author fparain
date Thu, 12 May 2011 10:30:11 -0700
parents 02f78cfa4656
children
comparison
equal deleted inserted replaced
17:8b0415062273 18:2e466268e4c4
40 #include "runtime/os.hpp" 40 #include "runtime/os.hpp"
41 #include "runtime/serviceThread.hpp" 41 #include "runtime/serviceThread.hpp"
42 #include "services/classLoadingService.hpp" 42 #include "services/classLoadingService.hpp"
43 #include "services/heapDumper.hpp" 43 #include "services/heapDumper.hpp"
44 #include "services/lowMemoryDetector.hpp" 44 #include "services/lowMemoryDetector.hpp"
45 #include "services/gcNotifier.hpp"
45 #include "services/management.hpp" 46 #include "services/management.hpp"
46 #include "services/memoryManager.hpp" 47 #include "services/memoryManager.hpp"
47 #include "services/memoryPool.hpp" 48 #include "services/memoryPool.hpp"
48 #include "services/memoryService.hpp" 49 #include "services/memoryService.hpp"
49 #include "services/runtimeService.hpp" 50 #include "services/runtimeService.hpp"
58 klassOop Management::_memoryUsage_klass = NULL; 59 klassOop Management::_memoryUsage_klass = NULL;
59 klassOop Management::_memoryPoolMXBean_klass = NULL; 60 klassOop Management::_memoryPoolMXBean_klass = NULL;
60 klassOop Management::_memoryManagerMXBean_klass = NULL; 61 klassOop Management::_memoryManagerMXBean_klass = NULL;
61 klassOop Management::_garbageCollectorMXBean_klass = NULL; 62 klassOop Management::_garbageCollectorMXBean_klass = NULL;
62 klassOop Management::_managementFactory_klass = NULL; 63 klassOop Management::_managementFactory_klass = NULL;
64 klassOop Management::_garbageCollectorImpl_klass = NULL;
65 klassOop Management::_gcInfo_klass = NULL;
63 66
64 jmmOptionalSupport Management::_optional_support = {0}; 67 jmmOptionalSupport Management::_optional_support = {0};
65 TimeStamp Management::_stamp; 68 TimeStamp Management::_stamp;
66 69
67 void management_init() { 70 void management_init() {
177 f->do_oop((oop*) &_memoryUsage_klass); 180 f->do_oop((oop*) &_memoryUsage_klass);
178 f->do_oop((oop*) &_memoryPoolMXBean_klass); 181 f->do_oop((oop*) &_memoryPoolMXBean_klass);
179 f->do_oop((oop*) &_memoryManagerMXBean_klass); 182 f->do_oop((oop*) &_memoryManagerMXBean_klass);
180 f->do_oop((oop*) &_garbageCollectorMXBean_klass); 183 f->do_oop((oop*) &_garbageCollectorMXBean_klass);
181 f->do_oop((oop*) &_managementFactory_klass); 184 f->do_oop((oop*) &_managementFactory_klass);
185 f->do_oop((oop*) &_garbageCollectorImpl_klass);
186 f->do_oop((oop*) &_gcInfo_klass);
182 } 187 }
183 188
184 klassOop Management::java_lang_management_ThreadInfo_klass(TRAPS) { 189 klassOop Management::java_lang_management_ThreadInfo_klass(TRAPS) {
185 if (_threadInfo_klass == NULL) { 190 if (_threadInfo_klass == NULL) {
186 _threadInfo_klass = load_and_initialize_klass(vmSymbols::java_lang_management_ThreadInfo(), CHECK_NULL); 191 _threadInfo_klass = load_and_initialize_klass(vmSymbols::java_lang_management_ThreadInfo(), CHECK_NULL);
226 klassOop Management::sun_management_ManagementFactory_klass(TRAPS) { 231 klassOop Management::sun_management_ManagementFactory_klass(TRAPS) {
227 if (_managementFactory_klass == NULL) { 232 if (_managementFactory_klass == NULL) {
228 _managementFactory_klass = load_and_initialize_klass(vmSymbols::sun_management_ManagementFactory(), CHECK_NULL); 233 _managementFactory_klass = load_and_initialize_klass(vmSymbols::sun_management_ManagementFactory(), CHECK_NULL);
229 } 234 }
230 return _managementFactory_klass; 235 return _managementFactory_klass;
236 }
237
238 klassOop Management::sun_management_GarbageCollectorImpl_klass(TRAPS) {
239 if (_garbageCollectorImpl_klass == NULL) {
240 _garbageCollectorImpl_klass = load_and_initialize_klass(vmSymbols::sun_management_GarbageCollectorImpl(), CHECK_NULL);
241 }
242 return _garbageCollectorImpl_klass;
243 }
244
245 klassOop Management::com_sun_management_GcInfo_klass(TRAPS) {
246 if (_gcInfo_klass == NULL) {
247 _gcInfo_klass = load_and_initialize_klass(vmSymbols::com_sun_management_GcInfo(), CHECK_NULL);
248 }
249 return _gcInfo_klass;
231 } 250 }
232 251
233 static void initialize_ThreadInfo_constructor_arguments(JavaCallArguments* args, ThreadSnapshot* snapshot, TRAPS) { 252 static void initialize_ThreadInfo_constructor_arguments(JavaCallArguments* args, ThreadSnapshot* snapshot, TRAPS) {
234 Handle snapshot_thread(THREAD, snapshot->threadObj()); 253 Handle snapshot_thread(THREAD, snapshot->threadObj());
235 254
2052 if (gc_stat->gc_ext_attribute_values_size > 0) { 2071 if (gc_stat->gc_ext_attribute_values_size > 0) {
2053 // Current implementation only has 1 attribute (number of GC threads) 2072 // Current implementation only has 1 attribute (number of GC threads)
2054 // The type is 'I' 2073 // The type is 'I'
2055 gc_stat->gc_ext_attribute_values[0].i = mgr->num_gc_threads(); 2074 gc_stat->gc_ext_attribute_values[0].i = mgr->num_gc_threads();
2056 } 2075 }
2076 JVM_END
2077
2078 JVM_ENTRY(void, jmm_SetGCNotificationEnabled(JNIEnv *env, jobject obj, jboolean enabled))
2079 ResourceMark rm(THREAD);
2080 // Get the GCMemoryManager
2081 GCMemoryManager* mgr = get_gc_memory_manager_from_jobject(obj, CHECK);
2082 mgr->set_notification_enabled(enabled?true:false);
2057 JVM_END 2083 JVM_END
2058 2084
2059 // Dump heap - Returns 0 if succeeds. 2085 // Dump heap - Returns 0 if succeeds.
2060 JVM_ENTRY(jint, jmm_DumpHeap0(JNIEnv *env, jstring outputfile, jboolean live)) 2086 JVM_ENTRY(jint, jmm_DumpHeap0(JNIEnv *env, jstring outputfile, jboolean live))
2061 #ifndef SERVICES_KERNEL 2087 #ifndef SERVICES_KERNEL
2120 jmm_GetThreadCpuTimesWithKind, 2146 jmm_GetThreadCpuTimesWithKind,
2121 jmm_DumpHeap0, 2147 jmm_DumpHeap0,
2122 jmm_FindDeadlockedThreads, 2148 jmm_FindDeadlockedThreads,
2123 jmm_SetVMGlobal, 2149 jmm_SetVMGlobal,
2124 NULL, 2150 NULL,
2125 jmm_DumpThreads 2151 jmm_DumpThreads,
2152 jmm_SetGCNotificationEnabled
2126 }; 2153 };
2127 2154
2128 void* Management::get_jmm_interface(int version) { 2155 void* Management::get_jmm_interface(int version) {
2129 if (version == JMM_VERSION_1_0) { 2156 if (version == JMM_VERSION_1_0) {
2130 return (void*) &jmm_interface; 2157 return (void*) &jmm_interface;