Index: vm/include/open/vm.h =================================================================== --- vm/include/open/vm.h (revision 568974) +++ vm/include/open/vm.h (working copy) @@ -1101,6 +1101,20 @@ // Numbers can include 'm' or 'M' for megabytes, 'k' or 'K' for kilobytes, and 'g' or 'G' for gigabytes (for example, 32k is the same as 32768). VMEXPORT int64 get_numerical_property(const char *property_name, int64 default_value, PropertyTable table_number); +/** + * Returns the address of the global flag that specifies whether + * MethodEntry event is enabled. JIT should call this function in case + * a method is compiled with exe_notify_method_entry flag set. + */ +char *get_method_entry_flag_address(); + +/** + * Returns the address of the global flag that specifies whether + * MethodExit event is enabled. JIT should call this function in case + * a method is compiled with exe_notify_method_entry flag set. + */ +char *get_method_exit_flag_address(); + //// // end miscellaneous functions. //// Index: vm/vmcore/include/jvmti_internal.h =================================================================== --- vm/vmcore/include/jvmti_internal.h (revision 568974) +++ vm/vmcore/include/jvmti_internal.h (working copy) @@ -338,6 +338,36 @@ cml_report_inlined = value; } + char *get_method_entry_flag_address() + { + return &method_entry_enabled_flag; + } + + char *get_method_exit_flag_address() + { + return &method_exit_enabled_flag; + } + + char get_method_entry_flag() + { + return method_entry_enabled_flag; + } + + char get_method_exit_flag() + { + return method_exit_enabled_flag; + } + + void set_method_entry_flag(char value) + { + method_entry_enabled_flag = value; + } + + void get_method_exit_flag(char value) + { + method_exit_enabled_flag = value; + } + private: protected: @@ -357,6 +387,7 @@ unsigned global_capabilities; bool single_step_enabled; bool cml_report_inlined; + char method_entry_enabled_flag, method_exit_enabled_flag; }; /* end of class DebugUtilsTI */ jvmtiError add_event_to_thread(jvmtiEnv *env, jvmtiEvent event_type, jthread event_thread); Index: vm/vmcore/src/jvmti/jvmti.cpp =================================================================== --- vm/vmcore/src/jvmti/jvmti.cpp (revision 568974) +++ vm/vmcore/src/jvmti/jvmti.cpp (working copy) @@ -325,7 +325,9 @@ prepareListNumber(0), global_capabilities(0), single_step_enabled(false), - cml_report_inlined(false) + cml_report_inlined(false), + method_entry_enabled_flag(0), + method_exit_enabled_flag(0) { jvmtiError UNUSED res = _allocate( MAX_NOTIFY_LIST * sizeof(Class**), (unsigned char**)¬ifyLoadList ); Index: vm/vmcore/src/jvmti/jvmti_event.cpp =================================================================== --- vm/vmcore/src/jvmti/jvmti_event.cpp (revision 568974) +++ vm/vmcore/src/jvmti/jvmti_event.cpp (working copy) @@ -383,6 +383,41 @@ } } } + else if(JVMTI_EVENT_METHOD_ENTRY == event_type) + { + if (JVMTI_ENABLE == mode) + { + TRACE2("jvmti.event.method.entry", "ENABLED global method entry flag"); + ti->set_method_entry_flag(1); + } + else if (JVMTI_DISABLE == mode && ti->get_method_entry_flag() != 0) + { + LMAutoUnlock lock(&ti->TIenvs_lock); + bool disable = check_event_is_disable(JVMTI_EVENT_METHOD_ENTRY, ti); + if (disable) { + TRACE2("jvmti.event.method.entry", "DISABLED global method entry flag"); + ti->set_method_entry_flag(0); + } + } + } + else if(JVMTI_EVENT_METHOD_EXIT == event_type || JVMTI_EVENT_FRAME_POP == event_type) + { + if (JVMTI_ENABLE == mode) + { + TRACE2("jvmti.event.method.exit", "ENABLED global method exit flag"); + ti->set_method_entry_flag(1); + } + else if (JVMTI_DISABLE == mode && ti->get_method_entry_flag() != 0) + { + LMAutoUnlock lock(&ti->TIenvs_lock); + bool disable = check_event_is_disable(JVMTI_EVENT_METHOD_EXIT, ti) || + check_event_is_disable(JVMTI_EVENT_FRAME_POP, ti); + if (disable) { + TRACE2("jvmti.event.method.entry", "DISABLED global method entry flag"); + ti->set_method_entry_flag(0); + } + } + } } if( JVMTI_EVENT_DATA_DUMP_REQUEST == event_type ) { if(JVMTI_ENABLE == mode) { Index: vm/vmcore/src/class_support/C_Interface.cpp =================================================================== --- vm/vmcore/src/class_support/C_Interface.cpp (revision 568974) +++ vm/vmcore/src/class_support/C_Interface.cpp (working copy) @@ -2928,3 +2928,13 @@ } return false; } + +char * get_method_entry_flag_address() +{ + return VM_Global_State::loader_env->TI->get_method_entry_flag_address(); +} + +char * get_method_exit_flag_address() +{ + return VM_Global_State::loader_env->TI->get_method_exit_flag_address(); +}