< prev index next >

src/hotspot/share/prims/jvmtiExport.cpp

Print this page

        

*** 1198,1209 **** --- 1198,1212 ---- bool JvmtiExport::_can_post_breakpoint = false; bool JvmtiExport::_can_post_field_access = false; bool JvmtiExport::_can_post_field_modification = false; bool JvmtiExport::_can_post_method_entry = false; bool JvmtiExport::_can_post_method_exit = false; + bool JvmtiExport::_can_post_frame_pop = false; bool JvmtiExport::_can_pop_frame = false; bool JvmtiExport::_can_force_early_return = false; + bool JvmtiExport::_can_support_fibers = false; + bool JvmtiExport::_can_support_continuations = false; bool JvmtiExport::_early_vmstart_recorded = false; bool JvmtiExport::_should_post_single_step = false; bool JvmtiExport::_should_post_field_access = false;
*** 1227,1236 **** --- 1230,1245 ---- bool JvmtiExport::_should_post_object_free = false; bool JvmtiExport::_should_post_resource_exhausted = false; bool JvmtiExport::_should_post_vm_object_alloc = false; bool JvmtiExport::_should_post_sampled_object_alloc = false; bool JvmtiExport::_should_post_on_exceptions = false; + bool JvmtiExport::_should_post_continuation_run = false; + bool JvmtiExport::_should_post_continuation_yield = false; + bool JvmtiExport::_should_post_fiber_scheduled = false; + bool JvmtiExport::_should_post_fiber_terminated = false; + bool JvmtiExport::_should_post_fiber_mount = false; + bool JvmtiExport::_should_post_fiber_unmount = false; //////////////////////////////////////////////////////////////////////////////////////////////// //
*** 1473,1482 **** --- 1482,1718 ---- } } } } + + void JvmtiExport::post_fiber_scheduled(jthread thread, jobject fiber) { + if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) { + return; + } + EVT_TRIG_TRACE(JVMTI_EVENT_FIBER_SCHEDULED, ("[%p] Trg Fiber Scheduled event triggered", fiber)); + + JavaThread *cur_thread = JavaThread::current(); + JvmtiThreadState *state = cur_thread->jvmti_thread_state(); + if (state == NULL) { + return; + } + + if (state->is_enabled(JVMTI_EVENT_FIBER_SCHEDULED)) { + JvmtiEnvThreadStateIterator it(state); + + for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + if (ets->is_enabled(JVMTI_EVENT_FIBER_SCHEDULED)) { + JvmtiEnv *env = ets->get_env(); + if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { + continue; + } + EVT_TRACE(JVMTI_EVENT_FIBER_SCHEDULED, ("[%p] Evt Fiber Scheduled event sent", fiber)); + + JvmtiThreadEventMark jem(cur_thread); + JvmtiJavaThreadEventTransition jet(cur_thread); + jvmtiEventFiberScheduled callback = env->callbacks()->FiberScheduled; + if (callback != NULL) { + (*callback)(env->jvmti_external(), jem.jni_env(), thread, fiber); + } + } + } + } + } + + void JvmtiExport::post_fiber_terminated(jthread thread, jobject fiber) { + if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) { + return; + } + EVT_TRIG_TRACE(JVMTI_EVENT_FIBER_TERMINATED, ("[%p] Trg Fiber Terminated event triggered", fiber)); + + JavaThread *cur_thread = JavaThread::current(); + JvmtiThreadState *state = cur_thread->jvmti_thread_state(); + if (state == NULL) { + return; + } + + if (state->is_enabled(JVMTI_EVENT_FIBER_TERMINATED)) { + JvmtiEnvThreadStateIterator it(state); + + for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + if (ets->is_enabled(JVMTI_EVENT_FIBER_TERMINATED)) { + JvmtiEnv *env = ets->get_env(); + if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { + continue; + } + EVT_TRACE(JVMTI_EVENT_FIBER_TERMINATED, ("[%p] Evt Fiber Terminated event sent", fiber)); + + JvmtiThreadEventMark jem(cur_thread); + JvmtiJavaThreadEventTransition jet(cur_thread); + jvmtiEventFiberTerminated callback = env->callbacks()->FiberTerminated; + if (callback != NULL) { + (*callback)(env->jvmti_external(), jem.jni_env(), thread, fiber); + } + } + } + } + } + + void JvmtiExport::post_fiber_mount(jthread thread, jobject fiber) { + if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) { + return; + } + EVT_TRIG_TRACE(JVMTI_EVENT_FIBER_MOUNT, ("[%p] Trg Fiber Mount event triggered", fiber)); + + JavaThread *cur_thread = JavaThread::current(); + JvmtiThreadState *state = cur_thread->jvmti_thread_state(); + if (state == NULL) { + return; + } + + if (state->is_enabled(JVMTI_EVENT_FIBER_MOUNT)) { + JvmtiEnvThreadStateIterator it(state); + + for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + if (ets->is_enabled(JVMTI_EVENT_FIBER_MOUNT)) { + JvmtiEnv *env = ets->get_env(); + if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { + continue; + } + EVT_TRACE(JVMTI_EVENT_FIBER_MOUNT, ("[%p] Evt Fiber Mount event sent", fiber)); + + JvmtiThreadEventMark jem(cur_thread); + JvmtiJavaThreadEventTransition jet(cur_thread); + jvmtiEventFiberMount callback = env->callbacks()->FiberMount; + if (callback != NULL) { + (*callback)(env->jvmti_external(), jem.jni_env(), thread, fiber); + } + } + } + } + } + + void JvmtiExport::post_fiber_unmount(jthread thread, jobject fiber) { + if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) { + return; + } + EVT_TRIG_TRACE(JVMTI_EVENT_FIBER_UNMOUNT, ("[%p] Trg Fiber Unmount event triggered", fiber)); + + JavaThread *cur_thread = JavaThread::current(); + JvmtiThreadState *state = cur_thread->jvmti_thread_state(); + if (state == NULL) { + return; + } + + if (state->is_enabled(JVMTI_EVENT_FIBER_UNMOUNT)) { + JvmtiEnvThreadStateIterator it(state); + + for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + if (ets->is_enabled(JVMTI_EVENT_FIBER_UNMOUNT)) { + JvmtiEnv *env = ets->get_env(); + if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { + continue; + } + EVT_TRACE(JVMTI_EVENT_FIBER_UNMOUNT, ("[%p] Evt Fiber Unmount event sent", fiber)); + + JvmtiThreadEventMark jem(cur_thread); + JvmtiJavaThreadEventTransition jet(cur_thread); + jvmtiEventFiberUnmount callback = env->callbacks()->FiberUnmount; + if (callback != NULL) { + (*callback)(env->jvmti_external(), jem.jni_env(), thread, fiber); + } + } + } + } + } + + void JvmtiExport::post_continuation_run(JavaThread* thread, jint continuation_frame_count) { + if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) { + return; + } + EVT_TRIG_TRACE(JVMTI_EVENT_CONTINUATION_RUN, ("Trg Continuation Run event triggered")); + + assert (thread == JavaThread::current(), "must be"); + JvmtiThreadState *state = thread->jvmti_thread_state(); + if (state == NULL) { + return; + } + state->invalidate_cur_stack_depth(); + + if (state->is_enabled(JVMTI_EVENT_CONTINUATION_RUN)) { + JvmtiEnvThreadStateIterator it(state); + + for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + if (ets->is_enabled(JVMTI_EVENT_CONTINUATION_RUN)) { + JvmtiEnv *env = ets->get_env(); + if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { + continue; + } + EVT_TRACE(JVMTI_EVENT_CONTINUATION_RUN, ("Evt Continuation Run event sent")); + + JvmtiThreadEventMark jem(thread); + JvmtiJavaThreadEventTransition jet(thread); + jvmtiEventContinuationRun callback = env->callbacks()->ContinuationRun; + if (callback != NULL) { + (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), continuation_frame_count); + } + } + } + } + } + + void JvmtiExport::post_continuation_yield(JavaThread* thread, jint continuation_frame_count) { + if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) { + return; + } + EVT_TRIG_TRACE(JVMTI_EVENT_CONTINUATION_YIELD, ("Trg Continuation Yield event triggered")); + + assert (thread == JavaThread::current(), "must be"); + JvmtiThreadState *state = thread->jvmti_thread_state(); + if (state == NULL) { + return; + } + state->invalidate_cur_stack_depth(); + + if (state->is_enabled(JVMTI_EVENT_CONTINUATION_YIELD)) { + JvmtiEnvThreadStateIterator it(state); + + for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + if (ets->is_enabled(JVMTI_EVENT_CONTINUATION_YIELD)) { + JvmtiEnv *env = ets->get_env(); + if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { + continue; + } + EVT_TRACE(JVMTI_EVENT_CONTINUATION_RUN, ("Evt Continuation Run event sent")); + + JvmtiThreadEventMark jem(thread); + JvmtiJavaThreadEventTransition jet(thread); + jvmtiEventContinuationYield callback = env->callbacks()->ContinuationYield; + if (callback != NULL) { + (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), continuation_frame_count); + } + } + } + } + + // Clear frame_pop requests in frames popped by yield + if (can_post_frame_pop()) { + JvmtiEnvThreadStateIterator it(state); + int top_frame_num = state->cur_stack_depth() + continuation_frame_count; + + for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + if (!ets->has_frame_pops()) { + continue; + } + for (int frame_idx = 0; frame_idx < continuation_frame_count; frame_idx++) { + int frame_num = top_frame_num - frame_idx; + + if (ets->is_frame_pop(frame_num)) { + // remove the frame's entry + ets->clear_frame_pop(frame_num); + } + } + } + } + } + void JvmtiExport::post_object_free(JvmtiEnv* env, jlong tag) { assert(SafepointSynchronize::is_at_safepoint(), "must be executed at safepoint"); assert(env->is_enabled(JVMTI_EVENT_OBJECT_FREE), "checking"); EVT_TRIG_TRACE(JVMTI_EVENT_OBJECT_FREE, ("[?] Trg Object Free triggered" ));
< prev index next >