src/share/vm/services/management.hpp

Thu, 05 Jun 2008 15:57:56 -0700

author
ysr
date
Thu, 05 Jun 2008 15:57:56 -0700
changeset 777
37f87013dfd8
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6711316: Open source the Garbage-First garbage collector
Summary: First mercurial integration of the code for the Garbage-First garbage collector.
Reviewed-by: apetrusenko, iveresov, jmasa, sgoldman, tonyp, ysr

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

mercurial