Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/services/management.hpp
32285 views
/*1* Copyright (c) 2003, 2013, 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.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_SERVICES_MANAGEMENT_HPP25#define SHARE_VM_SERVICES_MANAGEMENT_HPP2627#include "memory/allocation.hpp"28#include "runtime/handles.hpp"29#include "runtime/timer.hpp"30#include "services/jmm.h"3132class OopClosure;33class ThreadSnapshot;3435class Management : public AllStatic {36private:37static PerfVariable* _begin_vm_creation_time;38static PerfVariable* _end_vm_creation_time;39static PerfVariable* _vm_init_done_time;40static jmmOptionalSupport _optional_support;41static TimeStamp _stamp; // Timestamp since vm init done time4243// Management klasses44static Klass* _sensor_klass;45static Klass* _threadInfo_klass;46static Klass* _memoryUsage_klass;47static Klass* _memoryPoolMXBean_klass;48static Klass* _memoryManagerMXBean_klass;49static Klass* _garbageCollectorMXBean_klass;50static Klass* _managementFactory_klass;51static Klass* _garbageCollectorImpl_klass;52static Klass* _diagnosticCommandImpl_klass;53static Klass* _managementFactoryHelper_klass;54static Klass* _gcInfo_klass;5556static Klass* load_and_initialize_klass(Symbol* sh, TRAPS);5758public:59static void init();60static void initialize(TRAPS);6162static jlong ticks_to_ms(jlong ticks) NOT_MANAGEMENT_RETURN_(0L);63static jlong timestamp() NOT_MANAGEMENT_RETURN_(0L);6465static void oops_do(OopClosure* f) NOT_MANAGEMENT_RETURN;66static void* get_jmm_interface(int version);67static void get_optional_support(jmmOptionalSupport* support);6869static void get_loaded_classes(JavaThread* cur_thread, GrowableArray<KlassHandle>* klass_handle_array);7071static void record_vm_startup_time(jlong begin, jlong duration)72NOT_MANAGEMENT_RETURN;73static void record_vm_init_completed() {74// Initialize the timestamp to get the current time75_vm_init_done_time->set_value(os::javaTimeMillis());7677// Update the timestamp to the vm init done time78_stamp.update();79}8081static jlong begin_vm_creation_time() {82return _begin_vm_creation_time->get_value();83}84static jlong vm_init_done_time() {85return _vm_init_done_time->get_value();86}8788// methods to return a Klass*.89static Klass* java_lang_management_ThreadInfo_klass(TRAPS);90static Klass* java_lang_management_MemoryUsage_klass(TRAPS)91NOT_MANAGEMENT_RETURN_(NULL);92static Klass* java_lang_management_MemoryPoolMXBean_klass(TRAPS);93static Klass* java_lang_management_MemoryManagerMXBean_klass(TRAPS);94static Klass* java_lang_management_GarbageCollectorMXBean_klass(TRAPS);95static Klass* sun_management_Sensor_klass(TRAPS)96NOT_MANAGEMENT_RETURN_(NULL);97static Klass* sun_management_ManagementFactory_klass(TRAPS)98NOT_MANAGEMENT_RETURN_(NULL);99static Klass* sun_management_GarbageCollectorImpl_klass(TRAPS)100NOT_MANAGEMENT_RETURN_(NULL);101static Klass* com_sun_management_GcInfo_klass(TRAPS)102NOT_MANAGEMENT_RETURN_(NULL);103static Klass* sun_management_DiagnosticCommandImpl_klass(TRAPS)104NOT_MANAGEMENT_RETURN_(NULL);105static Klass* sun_management_ManagementFactoryHelper_klass(TRAPS)106NOT_MANAGEMENT_RETURN_(NULL);107108static instanceOop create_thread_info_instance(ThreadSnapshot* snapshot, TRAPS);109static instanceOop create_thread_info_instance(ThreadSnapshot* snapshot, objArrayHandle monitors_array, typeArrayHandle depths_array, objArrayHandle synchronizers_array, TRAPS);110};111112class TraceVmCreationTime : public StackObj {113private:114TimeStamp _timer;115jlong _begin_time;116117public:118TraceVmCreationTime() {}119~TraceVmCreationTime() {}120121void start()122{ _timer.update_to(0); _begin_time = os::javaTimeMillis(); }123124/**125* Only call this if initialization completes successfully; it will126* crash if PerfMemory_exit() has already been called (usually by127* os::shutdown() when there was an initialization failure).128*/129void end()130{ Management::record_vm_startup_time(_begin_time, _timer.milliseconds()); }131132};133134#endif // SHARE_VM_SERVICES_MANAGEMENT_HPP135136137