src/share/vm/prims/jvmtiEventController.hpp

Wed, 08 Oct 2008 08:10:51 -0700

author
ksrini
date
Wed, 08 Oct 2008 08:10:51 -0700
changeset 823
f008d3631bd1
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6755845: JVM_FindClassFromBoot triggers assertions
Summary: Fixes assertions caused by one jvm_entry calling another, solved by refactoring code and modified gamma test.
Reviewed-by: dholmes, xlu

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

mercurial