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 Thread *current = Thread::current(); 337 if ((target == current) || (target->active_handshaker() == current)) { 338 hs.do_thread(target); 339 } else { 340 Handshake::execute_direct(&hs, target); 341 } 342 } 343 344 345 void 346 JvmtiEventControllerPrivate::leave_interp_only_mode(JvmtiThreadState *state) { 347 EC_TRACE(("[%s] # Leaving interpreter only mode", 348 JvmtiTrace::safe_get_thread_name(state->get_thread()))); 349 state->leave_interp_only_mode(); 350 } 351 352 353 void 354 JvmtiEventControllerPrivate::trace_changed(JvmtiThreadState *state, jlong now_enabled, jlong changed) { 355 #ifdef JVMTI_TRACE 356 if (JvmtiTrace::trace_event_controller()) { 357 SafeResourceMark rm; 358 // traces standard events only 359 for (int ei = JVMTI_MIN_EVENT_TYPE_VAL; ei <= JVMTI_MAX_EVENT_TYPE_VAL; ++ei) { 360 jlong bit = JvmtiEventEnabled::bit_for((jvmtiEvent)ei); 966 } 967 } 968 969 void 970 JvmtiEventController::set_extension_event_callback(JvmtiEnvBase *env, 971 jint extension_event_index, 972 jvmtiExtensionEvent callback) { 973 if (Threads::number_of_threads() == 0) { 974 JvmtiEventControllerPrivate::set_extension_event_callback(env, extension_event_index, callback); 975 } else { 976 MutexLocker mu(JvmtiThreadState_lock); 977 JvmtiEventControllerPrivate::set_extension_event_callback(env, extension_event_index, callback); 978 } 979 } 980 981 982 983 984 void 985 JvmtiEventController::set_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { 986 assert(SafepointSynchronize::is_at_safepoint() || JvmtiThreadState_lock->is_locked(), "Safepoint or must be locked"); 987 JvmtiEventControllerPrivate::set_frame_pop(ets, fpop); 988 } 989 990 991 void 992 JvmtiEventController::clear_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { 993 assert(SafepointSynchronize::is_at_safepoint() || JvmtiThreadState_lock->is_locked(), "Safepoint or must be locked"); 994 JvmtiEventControllerPrivate::clear_frame_pop(ets, fpop); 995 } 996 997 998 void 999 JvmtiEventController::clear_to_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { 1000 assert(SafepointSynchronize::is_at_safepoint() || JvmtiThreadState_lock->is_locked(), "Safepoint or must be locked"); 1001 JvmtiEventControllerPrivate::clear_to_frame_pop(ets, fpop); 1002 } 1003 1004 void 1005 JvmtiEventController::change_field_watch(jvmtiEvent event_type, bool added) { 1006 MutexLocker mu(JvmtiThreadState_lock); 1007 JvmtiEventControllerPrivate::change_field_watch(event_type, added); 1008 } 1009 1010 void 1011 JvmtiEventController::thread_started(JavaThread *thread) { 1012 // operates only on the current thread 1013 // JvmtiThreadState_lock grabbed only if needed. 1014 JvmtiEventControllerPrivate::thread_started(thread); 1015 } 1016 1017 void 1018 JvmtiEventController::thread_ended(JavaThread *thread) { 1019 // operates only on the current thread 1020 // JvmtiThreadState_lock grabbed only if needed. |