8316233: VirtualThreadStart events should not be thread-filtered
Reviewed-by: lmesnik, amenkov, cjplummer
This commit is contained in:
parent
053f45695f
commit
d313915974
@ -13041,7 +13041,7 @@ myInit() {
|
||||
</event>
|
||||
|
||||
<event label="Virtual Thread Start"
|
||||
id="VirtualThreadStart" const="JVMTI_EVENT_VIRTUAL_THREAD_START" filtered="thread" num="87" phase="start" since="21">
|
||||
id="VirtualThreadStart" const="JVMTI_EVENT_VIRTUAL_THREAD_START" num="87" phase="start" since="21">
|
||||
<description>
|
||||
A virtual thread start event is generated before its initial method executes.
|
||||
<p/>
|
||||
|
@ -99,16 +99,16 @@ static const jlong VTHREAD_MOUNT_BIT = (((jlong)1) << (EXT_EVENT_VIRTUAL_THREAD
|
||||
static const jlong VTHREAD_UNMOUNT_BIT = (((jlong)1) << (EXT_EVENT_VIRTUAL_THREAD_UNMOUNT - TOTAL_MIN_EVENT_TYPE_VAL));
|
||||
|
||||
|
||||
static const jlong VTHREAD_BITS = VTHREAD_START_BIT | VTHREAD_END_BIT | VTHREAD_MOUNT_BIT | VTHREAD_UNMOUNT_BIT;
|
||||
static const jlong VTHREAD_FILTERED_EVENT_BITS = VTHREAD_END_BIT | VTHREAD_MOUNT_BIT | VTHREAD_UNMOUNT_BIT;
|
||||
static const jlong MONITOR_BITS = MONITOR_CONTENDED_ENTER_BIT | MONITOR_CONTENDED_ENTERED_BIT |
|
||||
MONITOR_WAIT_BIT | MONITOR_WAITED_BIT;
|
||||
static const jlong EXCEPTION_BITS = EXCEPTION_THROW_BIT | EXCEPTION_CATCH_BIT;
|
||||
static const jlong INTERP_EVENT_BITS = SINGLE_STEP_BIT | METHOD_ENTRY_BIT | METHOD_EXIT_BIT |
|
||||
FRAME_POP_BIT | FIELD_ACCESS_BIT | FIELD_MODIFICATION_BIT;
|
||||
static const jlong THREAD_FILTERED_EVENT_BITS = INTERP_EVENT_BITS | EXCEPTION_BITS | MONITOR_BITS | VTHREAD_BITS |
|
||||
static const jlong THREAD_FILTERED_EVENT_BITS = INTERP_EVENT_BITS | EXCEPTION_BITS | MONITOR_BITS | VTHREAD_FILTERED_EVENT_BITS |
|
||||
BREAKPOINT_BIT | CLASS_LOAD_BIT | CLASS_PREPARE_BIT | THREAD_END_BIT |
|
||||
SAMPLED_OBJECT_ALLOC_BIT;
|
||||
static const jlong NEED_THREAD_LIFE_EVENTS = THREAD_FILTERED_EVENT_BITS | THREAD_START_BIT;
|
||||
static const jlong NEED_THREAD_LIFE_EVENTS = THREAD_FILTERED_EVENT_BITS | THREAD_START_BIT | VTHREAD_START_BIT;
|
||||
static const jlong EARLY_EVENT_BITS = CLASS_FILE_LOAD_HOOK_BIT | CLASS_LOAD_BIT | CLASS_PREPARE_BIT |
|
||||
VM_START_BIT | VM_INIT_BIT | VM_DEATH_BIT | NATIVE_METHOD_BIND_BIT |
|
||||
THREAD_START_BIT | THREAD_END_BIT |
|
||||
|
@ -1549,11 +1549,11 @@ void JvmtiExport::post_thread_end(JavaThread *thread) {
|
||||
|
||||
JvmtiEnvThreadStateIterator it(state);
|
||||
for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
|
||||
JvmtiEnv *env = ets->get_env();
|
||||
if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
|
||||
continue;
|
||||
}
|
||||
if (ets->is_enabled(JVMTI_EVENT_THREAD_END)) {
|
||||
JvmtiEnv *env = ets->get_env();
|
||||
if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
|
||||
continue;
|
||||
}
|
||||
EVT_TRACE(JVMTI_EVENT_THREAD_END, ("[%s] Evt Thread End event sent",
|
||||
JvmtiTrace::safe_get_thread_name(thread) ));
|
||||
|
||||
@ -1575,25 +1575,20 @@ void JvmtiExport::post_vthread_start(jobject vthread) {
|
||||
}
|
||||
EVT_TRIG_TRACE(JVMTI_EVENT_VIRTUAL_THREAD_START, ("[%p] Trg Virtual Thread Start event triggered", vthread));
|
||||
|
||||
JavaThread *cur_thread = JavaThread::current();
|
||||
JvmtiThreadState *state = get_jvmti_thread_state(cur_thread);
|
||||
if (state == nullptr) {
|
||||
return;
|
||||
}
|
||||
JavaThread *thread = JavaThread::current();
|
||||
assert(!thread->is_hidden_from_external_view(), "carrier threads can't be hidden");
|
||||
|
||||
if (state->is_enabled(JVMTI_EVENT_VIRTUAL_THREAD_START)) {
|
||||
JvmtiEnvThreadStateIterator it(state);
|
||||
|
||||
for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
|
||||
JvmtiEnv *env = ets->get_env();
|
||||
if (JvmtiEventController::is_enabled(JVMTI_EVENT_VIRTUAL_THREAD_START)) {
|
||||
JvmtiEnvIterator it;
|
||||
for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) {
|
||||
if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
|
||||
continue;
|
||||
}
|
||||
if (ets->is_enabled(JVMTI_EVENT_VIRTUAL_THREAD_START)) {
|
||||
if (env->is_enabled(JVMTI_EVENT_VIRTUAL_THREAD_START)) {
|
||||
EVT_TRACE(JVMTI_EVENT_VIRTUAL_THREAD_START, ("[%p] Evt Virtual Thread Start event sent", vthread));
|
||||
|
||||
JvmtiVirtualThreadEventMark jem(cur_thread);
|
||||
JvmtiJavaThreadEventTransition jet(cur_thread);
|
||||
JvmtiVirtualThreadEventMark jem(thread);
|
||||
JvmtiJavaThreadEventTransition jet(thread);
|
||||
jvmtiEventVirtualThreadStart callback = env->callbacks()->VirtualThreadStart;
|
||||
if (callback != nullptr) {
|
||||
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread());
|
||||
@ -1609,8 +1604,10 @@ void JvmtiExport::post_vthread_end(jobject vthread) {
|
||||
}
|
||||
EVT_TRIG_TRACE(JVMTI_EVENT_VIRTUAL_THREAD_END, ("[%p] Trg Virtual Thread End event triggered", vthread));
|
||||
|
||||
JavaThread *cur_thread = JavaThread::current();
|
||||
JvmtiThreadState *state = get_jvmti_thread_state(cur_thread);
|
||||
JavaThread *thread = JavaThread::current();
|
||||
assert(!thread->is_hidden_from_external_view(), "carrier threads can't be hidden");
|
||||
|
||||
JvmtiThreadState *state = get_jvmti_thread_state(thread);
|
||||
if (state == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -1626,8 +1623,8 @@ void JvmtiExport::post_vthread_end(jobject vthread) {
|
||||
if (ets->is_enabled(JVMTI_EVENT_VIRTUAL_THREAD_END)) {
|
||||
EVT_TRACE(JVMTI_EVENT_VIRTUAL_THREAD_END, ("[%p] Evt Virtual Thread End event sent", vthread));
|
||||
|
||||
JvmtiVirtualThreadEventMark jem(cur_thread);
|
||||
JvmtiJavaThreadEventTransition jet(cur_thread);
|
||||
JvmtiVirtualThreadEventMark jem(thread);
|
||||
JvmtiJavaThreadEventTransition jet(thread);
|
||||
jvmtiEventVirtualThreadEnd callback = env->callbacks()->VirtualThreadEnd;
|
||||
if (callback != nullptr) {
|
||||
(*callback)(env->jvmti_external(), jem.jni_env(), vthread);
|
||||
|
Loading…
Reference in New Issue
Block a user