314 // back to the regular interpreter dispatch table. 315 // Note: We call Interpreter::notice_safepoints() and ignore_safepoints() 316 // in a VM_Operation to safely make the dispatch table switch. We 317 // no longer rely on the safepoint mechanism to do any of this work 318 // for us. 319 void VM_ChangeSingleStep::doit() { 320 log_debug(interpreter, safepoint)("changing single step to '%s'", _on ? "on" : "off"); 321 JvmtiEventControllerPrivate::set_should_post_single_step(_on); 322 if (_on) { 323 Interpreter::notice_safepoints(); 324 } else { 325 Interpreter::ignore_safepoints(); 326 } 327 } 328 329 330 void JvmtiEventControllerPrivate::enter_interp_only_mode(JvmtiThreadState *state) { 331 EC_TRACE(("[%s] # Entering interpreter only mode", 332 JvmtiTrace::safe_get_thread_name(state->get_thread()))); 333 EnterInterpOnlyModeClosure hs; 334 if (SafepointSynchronize::is_at_safepoint()) { 335 hs.do_thread(state->get_thread()); 336 } else { 337 Handshake::execute_direct(&hs, state->get_thread()); 338 } 339 } 340 341 342 void 343 JvmtiEventControllerPrivate::leave_interp_only_mode(JvmtiThreadState *state) { 344 EC_TRACE(("[%s] # Leaving interpreter only mode", 345 JvmtiTrace::safe_get_thread_name(state->get_thread()))); 346 state->leave_interp_only_mode(); 347 } 348 349 350 void 351 JvmtiEventControllerPrivate::trace_changed(JvmtiThreadState *state, jlong now_enabled, jlong changed) { 352 #ifdef JVMTI_TRACE 353 if (JvmtiTrace::trace_event_controller()) { 354 SafeResourceMark rm; 355 // traces standard events only 356 for (int ei = JVMTI_MIN_EVENT_TYPE_VAL; ei <= JVMTI_MAX_EVENT_TYPE_VAL; ++ei) { 357 jlong bit = JvmtiEventEnabled::bit_for((jvmtiEvent)ei); 963 } 964 } 965 966 void 967 JvmtiEventController::set_extension_event_callback(JvmtiEnvBase *env, 968 jint extension_event_index, 969 jvmtiExtensionEvent callback) { 970 if (Threads::number_of_threads() == 0) { 971 JvmtiEventControllerPrivate::set_extension_event_callback(env, extension_event_index, callback); 972 } else { 973 MutexLocker mu(JvmtiThreadState_lock); 974 JvmtiEventControllerPrivate::set_extension_event_callback(env, extension_event_index, callback); 975 } 976 } 977 978 979 980 981 void 982 JvmtiEventController::set_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { 983 MutexLocker mu(SafepointSynchronize::is_at_safepoint() ? NULL : JvmtiThreadState_lock); 984 JvmtiEventControllerPrivate::set_frame_pop(ets, fpop); 985 } 986 987 988 void 989 JvmtiEventController::clear_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { 990 MutexLocker mu(SafepointSynchronize::is_at_safepoint() ? NULL : JvmtiThreadState_lock); 991 JvmtiEventControllerPrivate::clear_frame_pop(ets, fpop); 992 } 993 994 995 void 996 JvmtiEventController::clear_to_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { 997 MutexLocker mu(SafepointSynchronize::is_at_safepoint() ? NULL : JvmtiThreadState_lock); 998 JvmtiEventControllerPrivate::clear_to_frame_pop(ets, fpop); 999 } 1000 1001 void 1002 JvmtiEventController::change_field_watch(jvmtiEvent event_type, bool added) { 1003 MutexLocker mu(JvmtiThreadState_lock); 1004 JvmtiEventControllerPrivate::change_field_watch(event_type, added); 1005 } 1006 1007 void 1008 JvmtiEventController::thread_started(JavaThread *thread) { 1009 // operates only on the current thread 1010 // JvmtiThreadState_lock grabbed only if needed. 1011 JvmtiEventControllerPrivate::thread_started(thread); 1012 } 1013 1014 void 1015 JvmtiEventController::thread_ended(JavaThread *thread) { 1016 // operates only on the current thread 1017 // JvmtiThreadState_lock grabbed only if needed. | 314 // back to the regular interpreter dispatch table. 315 // Note: We call Interpreter::notice_safepoints() and ignore_safepoints() 316 // in a VM_Operation to safely make the dispatch table switch. We 317 // no longer rely on the safepoint mechanism to do any of this work 318 // for us. 319 void VM_ChangeSingleStep::doit() { 320 log_debug(interpreter, safepoint)("changing single step to '%s'", _on ? "on" : "off"); 321 JvmtiEventControllerPrivate::set_should_post_single_step(_on); 322 if (_on) { 323 Interpreter::notice_safepoints(); 324 } else { 325 Interpreter::ignore_safepoints(); 326 } 327 } 328 329 330 void JvmtiEventControllerPrivate::enter_interp_only_mode(JvmtiThreadState *state) { 331 EC_TRACE(("[%s] # Entering interpreter only mode", 332 JvmtiTrace::safe_get_thread_name(state->get_thread()))); 333 EnterInterpOnlyModeClosure hs; 334 assert(state->get_thread()->is_Java_thread(), "just checking"); 335 JavaThread *target = (JavaThread *)state->get_thread(); 336 if (target->active_handshaker() != NULL) { 337 hs.do_thread(target); 338 } else { 339 Handshake::execute_direct(&hs, target); 340 } 341 } 342 343 344 void 345 JvmtiEventControllerPrivate::leave_interp_only_mode(JvmtiThreadState *state) { 346 EC_TRACE(("[%s] # Leaving interpreter only mode", 347 JvmtiTrace::safe_get_thread_name(state->get_thread()))); 348 state->leave_interp_only_mode(); 349 } 350 351 352 void 353 JvmtiEventControllerPrivate::trace_changed(JvmtiThreadState *state, jlong now_enabled, jlong changed) { 354 #ifdef JVMTI_TRACE 355 if (JvmtiTrace::trace_event_controller()) { 356 SafeResourceMark rm; 357 // traces standard events only 358 for (int ei = JVMTI_MIN_EVENT_TYPE_VAL; ei <= JVMTI_MAX_EVENT_TYPE_VAL; ++ei) { 359 jlong bit = JvmtiEventEnabled::bit_for((jvmtiEvent)ei); 965 } 966 } 967 968 void 969 JvmtiEventController::set_extension_event_callback(JvmtiEnvBase *env, 970 jint extension_event_index, 971 jvmtiExtensionEvent callback) { 972 if (Threads::number_of_threads() == 0) { 973 JvmtiEventControllerPrivate::set_extension_event_callback(env, extension_event_index, callback); 974 } else { 975 MutexLocker mu(JvmtiThreadState_lock); 976 JvmtiEventControllerPrivate::set_extension_event_callback(env, extension_event_index, callback); 977 } 978 } 979 980 981 982 983 void 984 JvmtiEventController::set_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { 985 MutexLocker mu(JvmtiThreadState_lock); 986 JvmtiEventControllerPrivate::set_frame_pop(ets, fpop); 987 } 988 989 990 void 991 JvmtiEventController::clear_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { 992 MutexLocker mu(JvmtiThreadState_lock); 993 JvmtiEventControllerPrivate::clear_frame_pop(ets, fpop); 994 } 995 996 997 void 998 JvmtiEventController::clear_to_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { 999 MutexLocker mu(JvmtiThreadState_lock); 1000 JvmtiEventControllerPrivate::clear_to_frame_pop(ets, fpop); 1001 } 1002 1003 void 1004 JvmtiEventController::change_field_watch(jvmtiEvent event_type, bool added) { 1005 MutexLocker mu(JvmtiThreadState_lock); 1006 JvmtiEventControllerPrivate::change_field_watch(event_type, added); 1007 } 1008 1009 void 1010 JvmtiEventController::thread_started(JavaThread *thread) { 1011 // operates only on the current thread 1012 // JvmtiThreadState_lock grabbed only if needed. 1013 JvmtiEventControllerPrivate::thread_started(thread); 1014 } 1015 1016 void 1017 JvmtiEventController::thread_ended(JavaThread *thread) { 1018 // operates only on the current thread 1019 // JvmtiThreadState_lock grabbed only if needed. |