< prev index next >

src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadState.cpp

Print this page
@@ -82,46 +82,51 @@
      writer.write_key(states[i].id);
      writer.write(states[i].description);
    }
  }
  
- traceid JfrThreadId::id(const Thread* t) {
+ traceid JfrThreadId::id(const Thread* t, oop vthread) {
    assert(t != NULL, "invariant");
    if (!t->is_Java_thread()) {
      return os_id(t);
    }
+   if (vthread != NULL) {
+     return java_lang_Thread::thread_id(vthread);
+   }
    const oop thread_obj = JavaThread::cast(t)->threadObj();
    return thread_obj != NULL ? java_lang_Thread::thread_id(thread_obj) : 0;
  }
  
  traceid JfrThreadId::os_id(const Thread* t) {
    assert(t != NULL, "invariant");
    const OSThread* const os_thread = t->osthread();
    return os_thread != NULL ? os_thread->thread_id() : 0;
  }
  
- traceid JfrThreadId::jfr_id(const Thread* t) {
+ traceid JfrThreadId::jfr_id(const Thread* t, traceid tid) {
    assert(t != NULL, "invariant");
-   return t->jfr_thread_local()->thread_id();
+   return tid != 0 ? tid : JfrThreadLocal::vm_thread_id(t);
  }
  
  // caller needs ResourceMark
- const char* get_java_thread_name(const JavaThread* jt) {
+ const char* get_java_thread_name(const JavaThread* jt, oop vthread) {
    assert(jt != NULL, "invariant");
    const char* name_str = "<no-name - thread name unresolved>";
-   const oop thread_obj = jt->threadObj();
-   if (thread_obj != NULL) {
+   oop thread_obj = vthread != NULL ? vthread : jt->threadObj();
+   if (thread_obj == NULL) {
+     if (jt->is_attaching_via_jni()) {
+       name_str = "<no-name - thread is attaching>";
+     }
+   } else {
      const oop name = java_lang_Thread::name(thread_obj);
      if (name != NULL) {
        name_str = java_lang_String::as_utf8_string(name);
      }
-   } else if (jt->is_attaching_via_jni()) {
-     name_str = "<no-name - thread is attaching>";
    }
    assert(name_str != NULL, "unexpected NULL thread name");
    return name_str;
  }
  
- const char* JfrThreadName::name(const Thread* t) {
+ const char* JfrThreadName::name(const Thread* t, oop vthread) {
    assert(t != NULL, "invariant");
-   return t->is_Java_thread() ? get_java_thread_name(JavaThread::cast(t)) : t->name();
+   return t->is_Java_thread() ? get_java_thread_name(JavaThread::cast(t), vthread) : t->name();
  }
< prev index next >