< prev index next >

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

Print this page
@@ -30,15 +30,13 @@
  #include "jfr/recorder/jfrRecorder.hpp"
  #include "jfr/support/jfrThreadLocal.hpp"
  #include "jfr/utilities/jfrIterator.hpp"
  #include "jfr/utilities/jfrLinkedList.inline.hpp"
  #include "memory/resourceArea.hpp"
- #include "runtime/handles.inline.hpp"
- #include "runtime/safepoint.hpp"
  #include "runtime/semaphore.hpp"
  #include "runtime/thread.inline.hpp"
- #include "utilities/exceptions.hpp"
+ #include "utilities/macros.hpp"
  
  class JfrSerializerRegistration : public JfrCHeapObj {
   public:
    JfrSerializerRegistration* _next; // list support
   private:

@@ -99,30 +97,29 @@
  void JfrTypeManager::write_threads(JfrCheckpointWriter& writer) {
    serialize_threads(writer);
    serialize_thread_groups(writer);
  }
  
- void JfrTypeManager::create_thread_blob(Thread* t) {
-   assert(t != NULL, "invariant");
-   ResourceMark rm(t);
-   HandleMark hm(t);
-   JfrThreadConstant type_thread(t);
-   JfrCheckpointWriter writer(t, true, THREADS, false);
+ JfrBlobHandle JfrTypeManager::create_thread_blob(JavaThread* jt, traceid tid, oop vthread) {
+   assert(jt != NULL, "invariant");
+   ResourceMark rm(jt);
+   JfrCheckpointWriter writer(jt, true, THREADS, false); // thread local lease
    writer.write_type(TYPE_THREAD);
+   JfrThreadConstant type_thread(jt, tid, vthread);
    type_thread.serialize(writer);
-   // create and install a checkpoint blob
-   t->jfr_thread_local()->set_thread_blob(writer.move());
-   assert(t->jfr_thread_local()->has_thread_blob(), "invariant");
+   return writer.move();
  }
  
- void JfrTypeManager::write_thread_checkpoint(Thread* t) {
+ void JfrTypeManager::write_checkpoint(Thread* t, traceid tid, oop vthread) {
    assert(t != NULL, "invariant");
-   if (!t->jfr_thread_local()->has_thread_blob()) {
-     create_thread_blob(t);
-   }
-   JfrCheckpointWriter writer(t, false, THREADS, false);
-   t->jfr_thread_local()->thread_blob()->write(writer);
+   Thread* const current = Thread::current(); // not necessarily the same as t
+   assert(current != NULL, "invariant");
+   ResourceMark rm(current);
+   JfrCheckpointWriter writer(current, true, THREADS, !current->is_Java_thread());
+   writer.write_type(TYPE_THREAD);
+   JfrThreadConstant type_thread(t, tid, vthread);
+   type_thread.serialize(writer);
  }
  
  class SerializerRegistrationGuard : public StackObj {
   private:
    static Semaphore _mutex_semaphore;
< prev index next >