src/share/vm/services/management.hpp

changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/services/management.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,106 @@
     1.4 +/*
     1.5 + * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +class OopClosure;
    1.29 +class ThreadSnapshot;
    1.30 +
    1.31 +class Management : public AllStatic {
    1.32 +private:
    1.33 +  static PerfVariable*      _begin_vm_creation_time;
    1.34 +  static PerfVariable*      _end_vm_creation_time;
    1.35 +  static PerfVariable*      _vm_init_done_time;
    1.36 +  static jmmOptionalSupport _optional_support;
    1.37 +  static TimeStamp          _stamp; // Timestamp since vm init done time
    1.38 +
    1.39 +  // Management klasses
    1.40 +  static klassOop           _sensor_klass;
    1.41 +  static klassOop           _threadInfo_klass;
    1.42 +  static klassOop           _memoryUsage_klass;
    1.43 +  static klassOop           _memoryPoolMXBean_klass;
    1.44 +  static klassOop           _memoryManagerMXBean_klass;
    1.45 +  static klassOop           _garbageCollectorMXBean_klass;
    1.46 +  static klassOop           _managementFactory_klass;
    1.47 +
    1.48 +  static klassOop load_and_initialize_klass(symbolHandle sh, TRAPS);
    1.49 +
    1.50 +public:
    1.51 +  static void init();
    1.52 +  static void initialize(TRAPS);
    1.53 +
    1.54 +  static jlong ticks_to_ms(jlong ticks);
    1.55 +  static jlong timestamp();
    1.56 +
    1.57 +  static void  oops_do(OopClosure* f);
    1.58 +  static void* get_jmm_interface(int version);
    1.59 +  static void  get_optional_support(jmmOptionalSupport* support);
    1.60 +
    1.61 +  static void get_loaded_classes(JavaThread* cur_thread, GrowableArray<KlassHandle>* klass_handle_array);
    1.62 +
    1.63 +  static void  record_vm_startup_time(jlong begin, jlong duration);
    1.64 +  static void  record_vm_init_completed() {
    1.65 +    // Initialize the timestamp to get the current time
    1.66 +    _vm_init_done_time->set_value(os::javaTimeMillis());
    1.67 +
    1.68 +    // Update the timestamp to the vm init done time
    1.69 +    _stamp.update();
    1.70 +  }
    1.71 +
    1.72 +  static jlong vm_init_done_time() {
    1.73 +    return _vm_init_done_time->get_value();
    1.74 +  }
    1.75 +
    1.76 +  // methods to return a klassOop.
    1.77 +  static klassOop java_lang_management_ThreadInfo_klass(TRAPS);
    1.78 +  static klassOop java_lang_management_MemoryUsage_klass(TRAPS);
    1.79 +  static klassOop java_lang_management_MemoryPoolMXBean_klass(TRAPS);
    1.80 +  static klassOop java_lang_management_MemoryManagerMXBean_klass(TRAPS);
    1.81 +  static klassOop java_lang_management_GarbageCollectorMXBean_klass(TRAPS);
    1.82 +  static klassOop sun_management_Sensor_klass(TRAPS);
    1.83 +  static klassOop sun_management_ManagementFactory_klass(TRAPS);
    1.84 +
    1.85 +  static instanceOop create_thread_info_instance(ThreadSnapshot* snapshot, TRAPS);
    1.86 +  static instanceOop create_thread_info_instance(ThreadSnapshot* snapshot, objArrayHandle monitors_array, typeArrayHandle depths_array, objArrayHandle synchronizers_array, TRAPS);
    1.87 +};
    1.88 +
    1.89 +class TraceVmCreationTime : public StackObj {
    1.90 +private:
    1.91 +  TimeStamp _timer;
    1.92 +  jlong     _begin_time;
    1.93 +
    1.94 +public:
    1.95 +  TraceVmCreationTime() {}
    1.96 +  ~TraceVmCreationTime() {}
    1.97 +
    1.98 +  void start()
    1.99 +  { _timer.update_to(0); _begin_time = os::javaTimeMillis(); }
   1.100 +
   1.101 +  /**
   1.102 +   * Only call this if initialization completes successfully; it will
   1.103 +   * crash if PerfMemory_exit() has already been called (usually by
   1.104 +   * os::shutdown() when there was an initialization failure).
   1.105 +   */
   1.106 +  void end()
   1.107 +  { Management::record_vm_startup_time(_begin_time, _timer.milliseconds()); }
   1.108 +
   1.109 +};

mercurial