comparison src/share/vm/services/management.hpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children c18cbe5936b8
comparison
equal deleted inserted replaced
-1:000000000000 0:a61af66fc99e
1 /*
2 * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 class OopClosure;
26 class ThreadSnapshot;
27
28 class Management : public AllStatic {
29 private:
30 static PerfVariable* _begin_vm_creation_time;
31 static PerfVariable* _end_vm_creation_time;
32 static PerfVariable* _vm_init_done_time;
33 static jmmOptionalSupport _optional_support;
34 static TimeStamp _stamp; // Timestamp since vm init done time
35
36 // Management klasses
37 static klassOop _sensor_klass;
38 static klassOop _threadInfo_klass;
39 static klassOop _memoryUsage_klass;
40 static klassOop _memoryPoolMXBean_klass;
41 static klassOop _memoryManagerMXBean_klass;
42 static klassOop _garbageCollectorMXBean_klass;
43 static klassOop _managementFactory_klass;
44
45 static klassOop load_and_initialize_klass(symbolHandle sh, TRAPS);
46
47 public:
48 static void init();
49 static void initialize(TRAPS);
50
51 static jlong ticks_to_ms(jlong ticks);
52 static jlong timestamp();
53
54 static void oops_do(OopClosure* f);
55 static void* get_jmm_interface(int version);
56 static void get_optional_support(jmmOptionalSupport* support);
57
58 static void get_loaded_classes(JavaThread* cur_thread, GrowableArray<KlassHandle>* klass_handle_array);
59
60 static void record_vm_startup_time(jlong begin, jlong duration);
61 static void record_vm_init_completed() {
62 // Initialize the timestamp to get the current time
63 _vm_init_done_time->set_value(os::javaTimeMillis());
64
65 // Update the timestamp to the vm init done time
66 _stamp.update();
67 }
68
69 static jlong vm_init_done_time() {
70 return _vm_init_done_time->get_value();
71 }
72
73 // methods to return a klassOop.
74 static klassOop java_lang_management_ThreadInfo_klass(TRAPS);
75 static klassOop java_lang_management_MemoryUsage_klass(TRAPS);
76 static klassOop java_lang_management_MemoryPoolMXBean_klass(TRAPS);
77 static klassOop java_lang_management_MemoryManagerMXBean_klass(TRAPS);
78 static klassOop java_lang_management_GarbageCollectorMXBean_klass(TRAPS);
79 static klassOop sun_management_Sensor_klass(TRAPS);
80 static klassOop sun_management_ManagementFactory_klass(TRAPS);
81
82 static instanceOop create_thread_info_instance(ThreadSnapshot* snapshot, TRAPS);
83 static instanceOop create_thread_info_instance(ThreadSnapshot* snapshot, objArrayHandle monitors_array, typeArrayHandle depths_array, objArrayHandle synchronizers_array, TRAPS);
84 };
85
86 class TraceVmCreationTime : public StackObj {
87 private:
88 TimeStamp _timer;
89 jlong _begin_time;
90
91 public:
92 TraceVmCreationTime() {}
93 ~TraceVmCreationTime() {}
94
95 void start()
96 { _timer.update_to(0); _begin_time = os::javaTimeMillis(); }
97
98 /**
99 * Only call this if initialization completes successfully; it will
100 * crash if PerfMemory_exit() has already been called (usually by
101 * os::shutdown() when there was an initialization failure).
102 */
103 void end()
104 { Management::record_vm_startup_time(_begin_time, _timer.milliseconds()); }
105
106 };