< prev index next >

src/hotspot/share/jfr/support/jfrThreadLocal.cpp

Print this page
@@ -393,15 +393,18 @@
    assert(t != nullptr, "invariant");
    if (is_impersonating(t)) {
      return t->jfr_thread_local()->_thread_id_alias;
    }
    JfrThreadLocal* const tl = t->jfr_thread_local();
-   if (!t->is_Java_thread() || !Atomic::load_acquire(&tl->_vthread)) {
+   if (!t->is_Java_thread()) {
      return jvm_thread_id(t, tl);
    }
-   // virtual thread
    const JavaThread* jt = JavaThread::cast(t);
+   if (!is_vthread(jt)) {
+     return jvm_thread_id(t, tl);
+   }
+   // virtual thread
    const traceid tid = vthread_id(jt);
    assert(tid != 0, "invariant");
    if (!tl->is_vthread_excluded()) {
      const u2 current_epoch = AccessThreadTraceId::current_epoch();
      if (vthread_epoch(jt) != current_epoch) {

@@ -454,11 +457,11 @@
    return jvm_thread_id(t, t->jfr_thread_local());
  }
  
  bool JfrThreadLocal::is_vthread(const JavaThread* jt) {
    assert(jt != nullptr, "invariant");
-   return Atomic::load_acquire(&jt->jfr_thread_local()->_vthread);
+   return Atomic::load_acquire(&jt->jfr_thread_local()->_vthread) && jt->last_continuation() != nullptr;
  }
  
  inline bool is_virtual(const JavaThread* jt, oop thread) {
    assert(jt != nullptr, "invariant");
    return thread != jt->threadObj();
< prev index next >