Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/prims/jvmtiEventController.hpp
32285 views
/*1* Copyright (c) 2003, 2010, 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_PRIMS_JVMTIEVENTCONTROLLER_HPP25#define SHARE_VM_PRIMS_JVMTIEVENTCONTROLLER_HPP2627#include "jvmtifiles/jvmti.h"28#include "memory/allocation.hpp"29#include "memory/allocation.inline.hpp"30#include "utilities/globalDefinitions.hpp"3132// forward declaration33class JvmtiEventControllerPrivate;34class JvmtiEventController;35class JvmtiEnvThreadState;36class JvmtiFramePop;37class JvmtiEnvBase;383940// Extension event support41//42// jvmtiExtEvent is the extensions equivalent of jvmtiEvent43// jvmtiExtCallbacks is the extensions equivalent of jvmtiEventCallbacks4445// Extension events start JVMTI_MIN_EVENT_TYPE_VAL-1 and work towards 0.46typedef enum {47EXT_EVENT_CLASS_UNLOAD = JVMTI_MIN_EVENT_TYPE_VAL-1,48EXT_MIN_EVENT_TYPE_VAL = EXT_EVENT_CLASS_UNLOAD,49EXT_MAX_EVENT_TYPE_VAL = EXT_EVENT_CLASS_UNLOAD50} jvmtiExtEvent;5152typedef struct {53jvmtiExtensionEvent ClassUnload;54} jvmtiExtEventCallbacks;555657// The complete range of events is EXT_MIN_EVENT_TYPE_VAL to58// JVMTI_MAX_EVENT_TYPE_VAL (inclusive and contiguous).59const int TOTAL_MIN_EVENT_TYPE_VAL = EXT_MIN_EVENT_TYPE_VAL;60const int TOTAL_MAX_EVENT_TYPE_VAL = JVMTI_MAX_EVENT_TYPE_VAL;616263///////////////////////////////////////////////////////////////64//65// JvmtiEventEnabled66//67// Utility class68//69// A boolean array indexed by event_type, used as an internal70// data structure to track what JVMTI event types are enabled.71// Used for user set enabling and disabling (globally and on a72// per thread basis), and for computed merges across environments,73// threads and the VM as a whole.74//75// for inlines see jvmtiEventController_inline.hpp76//7778class JvmtiEventEnabled VALUE_OBJ_CLASS_SPEC {79private:80friend class JvmtiEventControllerPrivate;81jlong _enabled_bits;82#ifndef PRODUCT83enum {84JEE_INIT_GUARD = 0xEAD085} _init_guard;86#endif87static jlong bit_for(jvmtiEvent event_type);88jlong get_bits();89void set_bits(jlong bits);90public:91JvmtiEventEnabled();92void clear();93bool is_enabled(jvmtiEvent event_type);94void set_enabled(jvmtiEvent event_type, bool enabled);95};969798///////////////////////////////////////////////////////////////99//100// JvmtiEnvThreadEventEnable101//102// JvmtiEventController data specific to a particular environment and thread.103//104// for inlines see jvmtiEventController_inline.hpp105//106107class JvmtiEnvThreadEventEnable VALUE_OBJ_CLASS_SPEC {108private:109friend class JvmtiEventControllerPrivate;110JvmtiEventEnabled _event_user_enabled;111JvmtiEventEnabled _event_enabled;112113public:114JvmtiEnvThreadEventEnable();115~JvmtiEnvThreadEventEnable();116bool is_enabled(jvmtiEvent event_type);117void set_user_enabled(jvmtiEvent event_type, bool enabled);118};119120121///////////////////////////////////////////////////////////////122//123// JvmtiThreadEventEnable124//125// JvmtiEventController data specific to a particular thread.126//127// for inlines see jvmtiEventController_inline.hpp128//129130class JvmtiThreadEventEnable VALUE_OBJ_CLASS_SPEC {131private:132friend class JvmtiEventControllerPrivate;133JvmtiEventEnabled _event_enabled;134135public:136JvmtiThreadEventEnable();137~JvmtiThreadEventEnable();138bool is_enabled(jvmtiEvent event_type);139};140141142///////////////////////////////////////////////////////////////143//144// JvmtiEnvEventEnable145//146// JvmtiEventController data specific to a particular environment.147//148// for inlines see jvmtiEventController_inline.hpp149//150151class JvmtiEnvEventEnable VALUE_OBJ_CLASS_SPEC {152private:153friend class JvmtiEventControllerPrivate;154155// user set global event enablement indexed by jvmtiEvent156JvmtiEventEnabled _event_user_enabled;157158// this flag indicates the presence (true) or absence (false) of event callbacks159// it is indexed by jvmtiEvent160JvmtiEventEnabled _event_callback_enabled;161162// indexed by jvmtiEvent true if enabled globally or on any thread.163// True only if there is a callback for it.164JvmtiEventEnabled _event_enabled;165166public:167JvmtiEnvEventEnable();168~JvmtiEnvEventEnable();169bool is_enabled(jvmtiEvent event_type);170void set_user_enabled(jvmtiEvent event_type, bool enabled);171};172173174///////////////////////////////////////////////////////////////175//176// JvmtiEventController177//178// The class is the access point for all actions that change179// which events are active, this include:180// enabling and disabling events181// changing the callbacks/eventhook (they may be null)182// setting and clearing field watchpoints183// setting frame pops184// encountering frame pops185//186// for inlines see jvmtiEventController_inline.hpp187//188189class JvmtiEventController : AllStatic {190private:191friend class JvmtiEventControllerPrivate;192193// for all environments, global array indexed by jvmtiEvent194static JvmtiEventEnabled _universal_global_event_enabled;195196public:197static bool is_enabled(jvmtiEvent event_type);198199// events that can ONLY be enabled/disabled globally (can't toggle on individual threads).200static bool is_global_event(jvmtiEvent event_type);201202// is the event_type valid?203// to do: check against valid event array204static bool is_valid_event_type(jvmtiEvent event_type) {205return ((int)event_type >= TOTAL_MIN_EVENT_TYPE_VAL)206&& ((int)event_type <= TOTAL_MAX_EVENT_TYPE_VAL);207}208209// Use (thread == NULL) to enable/disable an event globally.210// Use (thread != NULL) to enable/disable an event for a particular thread.211// thread is ignored for events that can only be specified globally212static void set_user_enabled(JvmtiEnvBase *env, JavaThread *thread,213jvmtiEvent event_type, bool enabled);214215// Setting callbacks changes computed enablement and must be done216// at a safepoint otherwise a NULL callback could be attempted217static void set_event_callbacks(JvmtiEnvBase *env,218const jvmtiEventCallbacks* callbacks,219jint size_of_callbacks);220221// Sets the callback function for a single extension event and enables222// (or disables it).223static void set_extension_event_callback(JvmtiEnvBase* env,224jint extension_event_index,225jvmtiExtensionEvent callback);226227static void set_frame_pop(JvmtiEnvThreadState *env_thread, JvmtiFramePop fpop);228static void clear_frame_pop(JvmtiEnvThreadState *env_thread, JvmtiFramePop fpop);229static void clear_to_frame_pop(JvmtiEnvThreadState *env_thread, JvmtiFramePop fpop);230231static void change_field_watch(jvmtiEvent event_type, bool added);232233static void thread_started(JavaThread *thread);234static void thread_ended(JavaThread *thread);235236static void env_initialize(JvmtiEnvBase *env);237static void env_dispose(JvmtiEnvBase *env);238239static void vm_start();240static void vm_init();241static void vm_death();242};243244#endif // SHARE_VM_PRIMS_JVMTIEVENTCONTROLLER_HPP245246247