Fri, 10 Jul 2009 11:10:00 -0700
6857194: Add hotspot perf counters to aid class loading performance measurement
Summary: Add new jvmstat counters to measure detailed class loading time
Reviewed-by: acorn, kamg
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 1999-2007 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 | /////////////////////////////////////////////////////////////// |
duke@435 | 26 | // |
duke@435 | 27 | // class JvmtiTrace |
duke@435 | 28 | // |
duke@435 | 29 | // Support for JVMTI tracing code |
duke@435 | 30 | // |
duke@435 | 31 | |
duke@435 | 32 | // Support tracing except in product build on the client compiler |
duke@435 | 33 | #ifndef PRODUCT |
duke@435 | 34 | #define JVMTI_TRACE 1 |
duke@435 | 35 | #else |
duke@435 | 36 | #ifdef COMPILER2 |
duke@435 | 37 | #define JVMTI_TRACE 1 |
duke@435 | 38 | #endif |
duke@435 | 39 | #endif |
duke@435 | 40 | |
duke@435 | 41 | #ifdef JVMTI_TRACE |
duke@435 | 42 | |
duke@435 | 43 | class JvmtiTrace : AllStatic { |
duke@435 | 44 | |
duke@435 | 45 | static bool _initialized; |
duke@435 | 46 | static bool _on; |
duke@435 | 47 | static bool _trace_event_controller; |
duke@435 | 48 | static jbyte _trace_flags[]; |
duke@435 | 49 | static jbyte _event_trace_flags[]; |
duke@435 | 50 | static const char* _event_names[]; |
duke@435 | 51 | static jint _max_function_index; |
duke@435 | 52 | static jint _max_event_index; |
duke@435 | 53 | static short _exclude_functions[]; |
duke@435 | 54 | static const char* _function_names[]; |
duke@435 | 55 | |
duke@435 | 56 | public: |
duke@435 | 57 | |
duke@435 | 58 | enum { |
duke@435 | 59 | SHOW_IN = 01, |
duke@435 | 60 | SHOW_OUT = 02, |
duke@435 | 61 | SHOW_ERROR = 04, |
duke@435 | 62 | SHOW_IN_DETAIL = 010, |
duke@435 | 63 | SHOW_OUT_DETAIL = 020, |
duke@435 | 64 | SHOW_EVENT_TRIGGER = 040, |
duke@435 | 65 | SHOW_EVENT_SENT = 0100 |
duke@435 | 66 | }; |
duke@435 | 67 | |
duke@435 | 68 | static bool tracing() { return _on; } |
duke@435 | 69 | static bool trace_event_controller() { return _trace_event_controller; } |
duke@435 | 70 | static jbyte trace_flags(int num) { return _trace_flags[num]; } |
duke@435 | 71 | static jbyte event_trace_flags(int num) { return _event_trace_flags[num]; } |
duke@435 | 72 | static const char* function_name(int num) { return _function_names[num]; } // To Do: add range checking |
duke@435 | 73 | |
duke@435 | 74 | static const char* event_name(int num) { |
duke@435 | 75 | static char* ext_event_name = (char*)"(extension event)"; |
duke@435 | 76 | if (num >= JVMTI_MIN_EVENT_TYPE_VAL && num <= JVMTI_MAX_EVENT_TYPE_VAL) { |
duke@435 | 77 | return _event_names[num]; |
duke@435 | 78 | } else { |
duke@435 | 79 | return ext_event_name; |
duke@435 | 80 | } |
duke@435 | 81 | } |
duke@435 | 82 | |
duke@435 | 83 | static const char* enum_name(const char** names, const jint* values, jint value); |
duke@435 | 84 | |
duke@435 | 85 | static void initialize(); |
duke@435 | 86 | static void shutdown(); |
duke@435 | 87 | |
duke@435 | 88 | // return a valid string no matter what state the thread is in |
duke@435 | 89 | static const char *safe_get_thread_name(Thread *thread); |
duke@435 | 90 | |
duke@435 | 91 | // return the name of the current thread |
duke@435 | 92 | static const char *safe_get_current_thread_name(); |
duke@435 | 93 | |
duke@435 | 94 | // return a valid string no matter what the state of k_mirror |
duke@435 | 95 | static const char *get_class_name(oop k_mirror); |
duke@435 | 96 | }; |
duke@435 | 97 | |
duke@435 | 98 | #endif /*JVMTI_TRACE */ |