src/share/vm/prims/jvmtiEventController.hpp

Sun, 15 Sep 2013 15:28:58 +0200

author
goetz
date
Sun, 15 Sep 2013 15:28:58 +0200
changeset 6470
abe03600372a
parent 2314
f95d63e2154a
child 6876
710a3c8b516e
permissions
-rw-r--r--

8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
Summary: Implement profiling for c2 jit compilation. Also enable new cppInterpreter features.
Reviewed-by: kvn

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_PRIMS_JVMTIEVENTCONTROLLER_HPP
stefank@2314 26 #define SHARE_VM_PRIMS_JVMTIEVENTCONTROLLER_HPP
stefank@2314 27
stefank@2314 28 #include "jvmtifiles/jvmti.h"
stefank@2314 29 #include "memory/allocation.hpp"
stefank@2314 30 #include "memory/allocation.inline.hpp"
stefank@2314 31 #include "utilities/globalDefinitions.hpp"
duke@435 32
duke@435 33 // forward declaration
duke@435 34 class JvmtiEventControllerPrivate;
duke@435 35 class JvmtiEventController;
duke@435 36 class JvmtiEnvThreadState;
duke@435 37 class JvmtiFramePop;
duke@435 38 class JvmtiEnvBase;
duke@435 39
duke@435 40
duke@435 41 // Extension event support
duke@435 42 //
duke@435 43 // jvmtiExtEvent is the extensions equivalent of jvmtiEvent
duke@435 44 // jvmtiExtCallbacks is the extensions equivalent of jvmtiEventCallbacks
duke@435 45
duke@435 46 // Extension events start JVMTI_MIN_EVENT_TYPE_VAL-1 and work towards 0.
duke@435 47 typedef enum {
duke@435 48 EXT_EVENT_CLASS_UNLOAD = JVMTI_MIN_EVENT_TYPE_VAL-1,
duke@435 49 EXT_MIN_EVENT_TYPE_VAL = EXT_EVENT_CLASS_UNLOAD,
duke@435 50 EXT_MAX_EVENT_TYPE_VAL = EXT_EVENT_CLASS_UNLOAD
duke@435 51 } jvmtiExtEvent;
duke@435 52
duke@435 53 typedef struct {
duke@435 54 jvmtiExtensionEvent ClassUnload;
duke@435 55 } jvmtiExtEventCallbacks;
duke@435 56
duke@435 57
duke@435 58 // The complete range of events is EXT_MIN_EVENT_TYPE_VAL to
duke@435 59 // JVMTI_MAX_EVENT_TYPE_VAL (inclusive and contiguous).
duke@435 60 const int TOTAL_MIN_EVENT_TYPE_VAL = EXT_MIN_EVENT_TYPE_VAL;
duke@435 61 const int TOTAL_MAX_EVENT_TYPE_VAL = JVMTI_MAX_EVENT_TYPE_VAL;
duke@435 62
duke@435 63
duke@435 64 ///////////////////////////////////////////////////////////////
duke@435 65 //
duke@435 66 // JvmtiEventEnabled
duke@435 67 //
duke@435 68 // Utility class
duke@435 69 //
duke@435 70 // A boolean array indexed by event_type, used as an internal
duke@435 71 // data structure to track what JVMTI event types are enabled.
duke@435 72 // Used for user set enabling and disabling (globally and on a
duke@435 73 // per thread basis), and for computed merges across environments,
duke@435 74 // threads and the VM as a whole.
duke@435 75 //
duke@435 76 // for inlines see jvmtiEventController_inline.hpp
duke@435 77 //
duke@435 78
duke@435 79 class JvmtiEventEnabled VALUE_OBJ_CLASS_SPEC {
duke@435 80 private:
duke@435 81 friend class JvmtiEventControllerPrivate;
duke@435 82 jlong _enabled_bits;
duke@435 83 #ifndef PRODUCT
duke@435 84 enum {
duke@435 85 JEE_INIT_GUARD = 0xEAD0
duke@435 86 } _init_guard;
duke@435 87 #endif
duke@435 88 static jlong bit_for(jvmtiEvent event_type);
duke@435 89 jlong get_bits();
duke@435 90 void set_bits(jlong bits);
duke@435 91 public:
duke@435 92 JvmtiEventEnabled();
duke@435 93 void clear();
duke@435 94 bool is_enabled(jvmtiEvent event_type);
duke@435 95 void set_enabled(jvmtiEvent event_type, bool enabled);
duke@435 96 };
duke@435 97
duke@435 98
duke@435 99 ///////////////////////////////////////////////////////////////
duke@435 100 //
duke@435 101 // JvmtiEnvThreadEventEnable
duke@435 102 //
duke@435 103 // JvmtiEventController data specific to a particular environment and thread.
duke@435 104 //
duke@435 105 // for inlines see jvmtiEventController_inline.hpp
duke@435 106 //
duke@435 107
duke@435 108 class JvmtiEnvThreadEventEnable VALUE_OBJ_CLASS_SPEC {
duke@435 109 private:
duke@435 110 friend class JvmtiEventControllerPrivate;
duke@435 111 JvmtiEventEnabled _event_user_enabled;
duke@435 112 JvmtiEventEnabled _event_enabled;
duke@435 113
duke@435 114 public:
duke@435 115 JvmtiEnvThreadEventEnable();
duke@435 116 ~JvmtiEnvThreadEventEnable();
duke@435 117 bool is_enabled(jvmtiEvent event_type);
duke@435 118 void set_user_enabled(jvmtiEvent event_type, bool enabled);
duke@435 119 };
duke@435 120
duke@435 121
duke@435 122 ///////////////////////////////////////////////////////////////
duke@435 123 //
duke@435 124 // JvmtiThreadEventEnable
duke@435 125 //
duke@435 126 // JvmtiEventController data specific to a particular thread.
duke@435 127 //
duke@435 128 // for inlines see jvmtiEventController_inline.hpp
duke@435 129 //
duke@435 130
duke@435 131 class JvmtiThreadEventEnable VALUE_OBJ_CLASS_SPEC {
duke@435 132 private:
duke@435 133 friend class JvmtiEventControllerPrivate;
duke@435 134 JvmtiEventEnabled _event_enabled;
duke@435 135
duke@435 136 public:
duke@435 137 JvmtiThreadEventEnable();
duke@435 138 ~JvmtiThreadEventEnable();
duke@435 139 bool is_enabled(jvmtiEvent event_type);
duke@435 140 };
duke@435 141
duke@435 142
duke@435 143 ///////////////////////////////////////////////////////////////
duke@435 144 //
duke@435 145 // JvmtiEnvEventEnable
duke@435 146 //
duke@435 147 // JvmtiEventController data specific to a particular environment.
duke@435 148 //
duke@435 149 // for inlines see jvmtiEventController_inline.hpp
duke@435 150 //
duke@435 151
duke@435 152 class JvmtiEnvEventEnable VALUE_OBJ_CLASS_SPEC {
duke@435 153 private:
duke@435 154 friend class JvmtiEventControllerPrivate;
duke@435 155
duke@435 156 // user set global event enablement indexed by jvmtiEvent
duke@435 157 JvmtiEventEnabled _event_user_enabled;
duke@435 158
duke@435 159 // this flag indicates the presence (true) or absence (false) of event callbacks
duke@435 160 // it is indexed by jvmtiEvent
duke@435 161 JvmtiEventEnabled _event_callback_enabled;
duke@435 162
duke@435 163 // indexed by jvmtiEvent true if enabled globally or on any thread.
duke@435 164 // True only if there is a callback for it.
duke@435 165 JvmtiEventEnabled _event_enabled;
duke@435 166
duke@435 167 public:
duke@435 168 JvmtiEnvEventEnable();
duke@435 169 ~JvmtiEnvEventEnable();
duke@435 170 bool is_enabled(jvmtiEvent event_type);
duke@435 171 void set_user_enabled(jvmtiEvent event_type, bool enabled);
duke@435 172 };
duke@435 173
duke@435 174
duke@435 175 ///////////////////////////////////////////////////////////////
duke@435 176 //
duke@435 177 // JvmtiEventController
duke@435 178 //
duke@435 179 // The class is the access point for all actions that change
duke@435 180 // which events are active, this include:
duke@435 181 // enabling and disabling events
duke@435 182 // changing the callbacks/eventhook (they may be null)
duke@435 183 // setting and clearing field watchpoints
duke@435 184 // setting frame pops
duke@435 185 // encountering frame pops
duke@435 186 //
duke@435 187 // for inlines see jvmtiEventController_inline.hpp
duke@435 188 //
duke@435 189
duke@435 190 class JvmtiEventController : AllStatic {
duke@435 191 private:
duke@435 192 friend class JvmtiEventControllerPrivate;
duke@435 193
duke@435 194 // for all environments, global array indexed by jvmtiEvent
duke@435 195 static JvmtiEventEnabled _universal_global_event_enabled;
duke@435 196
duke@435 197 public:
duke@435 198 static bool is_enabled(jvmtiEvent event_type);
duke@435 199
duke@435 200 // events that can ONLY be enabled/disabled globally (can't toggle on individual threads).
duke@435 201 static bool is_global_event(jvmtiEvent event_type);
duke@435 202
duke@435 203 // is the event_type valid?
duke@435 204 // to do: check against valid event array
duke@435 205 static bool is_valid_event_type(jvmtiEvent event_type) {
duke@435 206 return ((int)event_type >= TOTAL_MIN_EVENT_TYPE_VAL)
duke@435 207 && ((int)event_type <= TOTAL_MAX_EVENT_TYPE_VAL);
duke@435 208 }
duke@435 209
duke@435 210 // Use (thread == NULL) to enable/disable an event globally.
duke@435 211 // Use (thread != NULL) to enable/disable an event for a particular thread.
duke@435 212 // thread is ignored for events that can only be specified globally
duke@435 213 static void set_user_enabled(JvmtiEnvBase *env, JavaThread *thread,
duke@435 214 jvmtiEvent event_type, bool enabled);
duke@435 215
duke@435 216 // Setting callbacks changes computed enablement and must be done
duke@435 217 // at a safepoint otherwise a NULL callback could be attempted
duke@435 218 static void set_event_callbacks(JvmtiEnvBase *env,
duke@435 219 const jvmtiEventCallbacks* callbacks,
duke@435 220 jint size_of_callbacks);
duke@435 221
duke@435 222 // Sets the callback function for a single extension event and enables
duke@435 223 // (or disables it).
duke@435 224 static void set_extension_event_callback(JvmtiEnvBase* env,
duke@435 225 jint extension_event_index,
duke@435 226 jvmtiExtensionEvent callback);
duke@435 227
duke@435 228 static void set_frame_pop(JvmtiEnvThreadState *env_thread, JvmtiFramePop fpop);
duke@435 229 static void clear_frame_pop(JvmtiEnvThreadState *env_thread, JvmtiFramePop fpop);
duke@435 230 static void clear_to_frame_pop(JvmtiEnvThreadState *env_thread, JvmtiFramePop fpop);
duke@435 231
duke@435 232 static void change_field_watch(jvmtiEvent event_type, bool added);
duke@435 233
duke@435 234 static void thread_started(JavaThread *thread);
duke@435 235 static void thread_ended(JavaThread *thread);
duke@435 236
duke@435 237 static void env_initialize(JvmtiEnvBase *env);
duke@435 238 static void env_dispose(JvmtiEnvBase *env);
duke@435 239
duke@435 240 static void vm_start();
duke@435 241 static void vm_init();
duke@435 242 static void vm_death();
duke@435 243 };
duke@435 244
stefank@2314 245 #endif // SHARE_VM_PRIMS_JVMTIEVENTCONTROLLER_HPP

mercurial