< prev index next >

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

Print this page

 71  public:
 72   JfrCheckpointThreadClosure(JfrCheckpointWriter& writer) : _writer(writer),
 73                                                             _ctx(writer.context()),
 74                                                             _count_position(writer.reserve(sizeof(u4))),
 75                                                             _curthread(Thread::current()),
 76                                                             _count(0) {
 77   }
 78 
 79   ~JfrCheckpointThreadClosure() {
 80     if (_count == 0) {
 81       // restore
 82       _writer.set_context(_ctx);
 83       return;
 84     }
 85     _writer.write_count(_count, _count_position);
 86   }
 87 
 88   void do_thread(Thread* t);
 89 };
 90 

 91 void JfrCheckpointThreadClosure::do_thread(Thread* t) {
 92   assert(t != NULL, "invariant");
 93   ++_count;
 94   _writer.write_key(JfrThreadId::jfr_id(t));


 95   const char* const name = JfrThreadName::name(t);
 96   assert(name != NULL, "invariant");
 97   _writer.write(name);
 98   _writer.write<traceid>(JfrThreadId::os_id(t));
 99   if (t->is_Java_thread()) {




100     _writer.write(name);
101     _writer.write(JfrThreadId::id(t));
102     _writer.write(JfrThreadGroup::thread_group_id(JavaThread::cast(t), _curthread));
103     return;
104   }
105   _writer.write((const char*)NULL); // java name
106   _writer.write((traceid)0); // java thread id
107   _writer.write((traceid)0); // java thread group
108 }
109 
110 void JfrThreadConstantSet::serialize(JfrCheckpointWriter& writer) {
111   JfrCheckpointThreadClosure tc(writer);
112   JfrJavaThreadIterator javathreads(false); // include not yet live threads (_thread_new)
113   while (javathreads.has_next()) {
114     tc.do_thread(javathreads.next());
115   }
116   JfrNonJavaThreadIterator nonjavathreads;
117   while (nonjavathreads.has_next()) {
118     tc.do_thread(nonjavathreads.next());
119   }
120 }
121 
122 void JfrThreadGroupConstant::serialize(JfrCheckpointWriter& writer) {
123   JfrThreadGroup::serialize(writer);
124 }
125 
126 static const char* flag_value_origin_to_string(JVMFlagOrigin origin) {
127   switch (origin) {

250     writer.write_key(i);
251     writer.write(CodeCache::get_code_heap_name(i));
252   }
253 };
254 
255 void VMOperationTypeConstant::serialize(JfrCheckpointWriter& writer) {
256   static const u4 nof_entries = VM_Operation::VMOp_Terminating;
257   writer.write_count(nof_entries);
258   for (u4 i = 0; i < nof_entries; ++i) {
259     writer.write_key(i);
260     writer.write(VM_Operation::name(VM_Operation::VMOp_Type(i)));
261   }
262 }
263 
264 void ThreadStateConstant::serialize(JfrCheckpointWriter& writer) {
265   JfrThreadState::serialize(writer);
266 }
267 
268 void JfrThreadConstant::serialize(JfrCheckpointWriter& writer) {
269   assert(_thread != NULL, "invariant");
270   assert(_thread == Thread::current(), "invariant");
271   writer.write_count(1);
272   writer.write_key(JfrThreadId::jfr_id(_thread));
273   const char* const name = JfrThreadName::name(_thread);
274   writer.write(name);
275   writer.write(JfrThreadId::os_id(_thread));
276   if (_thread->is_Java_thread()) {





277     writer.write(name);
278     writer.write(JfrThreadId::id(_thread));
279     JavaThread* const jt = JavaThread::cast(_thread);
280     const traceid thread_group_id = JfrThreadGroup::thread_group_id(jt, jt);


281     writer.write(thread_group_id);
282     JfrThreadGroup::serialize(&writer, thread_group_id);
283     return;



284   }
285   writer.write((const char*)NULL); // java name
286   writer.write((traceid)0); // java thread id
287   writer.write((traceid)0); // java thread group
288 }
289 
290 void BytecodeConstant::serialize(JfrCheckpointWriter& writer) {
291   static const u4 nof_entries = Bytecodes::number_of_codes;
292   writer.write_count(nof_entries);
293   for (u4 i = 0; i < nof_entries; ++i) {
294     writer.write_key(i);
295     writer.write(Bytecodes::name((Bytecodes::Code)i));
296   }
297 }
298 
299 void CompilerTypeConstant::serialize(JfrCheckpointWriter& writer) {
300   static const u4 nof_entries = compiler_number_of_types;
301   writer.write_count(nof_entries);
302   for (u4 i = 0; i < nof_entries; ++i) {
303     writer.write_key(i);
304     writer.write(compilertype2name((CompilerType)i));
305   }
306 }

 71  public:
 72   JfrCheckpointThreadClosure(JfrCheckpointWriter& writer) : _writer(writer),
 73                                                             _ctx(writer.context()),
 74                                                             _count_position(writer.reserve(sizeof(u4))),
 75                                                             _curthread(Thread::current()),
 76                                                             _count(0) {
 77   }
 78 
 79   ~JfrCheckpointThreadClosure() {
 80     if (_count == 0) {
 81       // restore
 82       _writer.set_context(_ctx);
 83       return;
 84     }
 85     _writer.write_count(_count, _count_position);
 86   }
 87 
 88   void do_thread(Thread* t);
 89 };
 90 
 91 // only static thread ids, VirtualThread ids are handled dynamically
 92 void JfrCheckpointThreadClosure::do_thread(Thread* t) {
 93   assert(t != NULL, "invariant");
 94   ++_count;
 95   const traceid tid = JfrThreadId::jfr_id(t);
 96   assert(tid != 0, "invariant");
 97   _writer.write_key(tid);
 98   const char* const name = JfrThreadName::name(t);
 99   assert(name != NULL, "invariant");
100   _writer.write(name);
101   _writer.write<traceid>(JfrThreadId::os_id(t));
102   if (!t->is_Java_thread()) {
103     _writer.write((const char*)NULL); // java name
104     _writer.write((traceid)0); // java thread id
105     _writer.write((traceid)0); // java thread group
106   } else {
107     _writer.write(name);
108     _writer.write(tid);
109     _writer.write(JfrThreadGroup::thread_group_id(JavaThread::cast(t), _curthread));

110   }
111   _writer.write<bool>(false); // isVirtual


112 }
113 
114 void JfrThreadConstantSet::serialize(JfrCheckpointWriter& writer) {
115   JfrCheckpointThreadClosure tc(writer);
116   JfrJavaThreadIterator javathreads(false); // include not yet live threads (_thread_new)
117   while (javathreads.has_next()) {
118     tc.do_thread(javathreads.next());
119   }
120   JfrNonJavaThreadIterator nonjavathreads;
121   while (nonjavathreads.has_next()) {
122     tc.do_thread(nonjavathreads.next());
123   }
124 }
125 
126 void JfrThreadGroupConstant::serialize(JfrCheckpointWriter& writer) {
127   JfrThreadGroup::serialize(writer);
128 }
129 
130 static const char* flag_value_origin_to_string(JVMFlagOrigin origin) {
131   switch (origin) {

254     writer.write_key(i);
255     writer.write(CodeCache::get_code_heap_name(i));
256   }
257 };
258 
259 void VMOperationTypeConstant::serialize(JfrCheckpointWriter& writer) {
260   static const u4 nof_entries = VM_Operation::VMOp_Terminating;
261   writer.write_count(nof_entries);
262   for (u4 i = 0; i < nof_entries; ++i) {
263     writer.write_key(i);
264     writer.write(VM_Operation::name(VM_Operation::VMOp_Type(i)));
265   }
266 }
267 
268 void ThreadStateConstant::serialize(JfrCheckpointWriter& writer) {
269   JfrThreadState::serialize(writer);
270 }
271 
272 void JfrThreadConstant::serialize(JfrCheckpointWriter& writer) {
273   assert(_thread != NULL, "invariant");

274   writer.write_count(1);
275   writer.write_key(JfrThreadId::jfr_id(_thread, _tid));
276   const char* const name = JfrThreadName::name(_thread, _vthread);
277   writer.write(name);
278   writer.write(JfrThreadId::os_id(_thread));
279   if (!_thread->is_Java_thread()) {
280     writer.write((const char*)NULL); // java name
281     writer.write((traceid)0);        // java thread id
282     writer.write((traceid)0);        // java thread group
283     writer.write<bool>(false);       // isVirtual
284   } else {
285     writer.write(name);
286     writer.write(JfrThreadId::id(_thread, _vthread));
287     const bool vthread = _vthread != NULL;
288     // VirtualThread threadgroup reserved id 1
289     const traceid thread_group_id = vthread ? 1 :
290       JfrThreadGroup::thread_group_id(JavaThread::cast(_thread), Thread::current());
291     writer.write(thread_group_id);
292     writer.write<bool>(vthread);    // isVirtual
293     // VirtualThread threadgroup already serialized invariant
294     if (!vthread) {
295       JfrThreadGroup::serialize(&writer, thread_group_id);
296     }
297   }



298 }
299 
300 void BytecodeConstant::serialize(JfrCheckpointWriter& writer) {
301   static const u4 nof_entries = Bytecodes::number_of_codes;
302   writer.write_count(nof_entries);
303   for (u4 i = 0; i < nof_entries; ++i) {
304     writer.write_key(i);
305     writer.write(Bytecodes::name((Bytecodes::Code)i));
306   }
307 }
308 
309 void CompilerTypeConstant::serialize(JfrCheckpointWriter& writer) {
310   static const u4 nof_entries = compiler_number_of_types;
311   writer.write_count(nof_entries);
312   for (u4 i = 0; i < nof_entries; ++i) {
313     writer.write_key(i);
314     writer.write(compilertype2name((CompilerType)i));
315   }
316 }
< prev index next >