< prev index next >

src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp

Print this page

 67 
 68 Semaphore ThreadIdExclusiveAccess::_mutex_semaphore(1);
 69 
 70 static bool has_thread_exited(traceid tid) {
 71   assert(tid != 0, "invariant");
 72   if (unloaded_thread_id_set == NULL) {
 73     return false;
 74   }
 75   ThreadIdExclusiveAccess lock;
 76   return JfrPredicate<traceid, compare_traceid>::test(unloaded_thread_id_set, tid);
 77 }
 78 
 79 static void add_to_unloaded_thread_set(traceid tid) {
 80   ThreadIdExclusiveAccess lock;
 81   if (unloaded_thread_id_set == NULL) {
 82     unloaded_thread_id_set = c_heap_allocate_array<traceid>();
 83   }
 84   JfrMutablePredicate<traceid, compare_traceid>::test(unloaded_thread_id_set, tid);
 85 }
 86 
 87 void ObjectSampleCheckpoint::on_thread_exit(JavaThread* jt) {
 88   assert(jt != NULL, "invariant");
 89   if (LeakProfiler::is_running()) {
 90     add_to_unloaded_thread_set(jt->jfr_thread_local()->thread_id());
 91   }
 92 }
 93 
 94 void ObjectSampleCheckpoint::clear() {
 95   assert(SafepointSynchronize::is_at_safepoint(), "invariant");
 96   if (unloaded_thread_id_set != NULL) {
 97     delete unloaded_thread_id_set;
 98     unloaded_thread_id_set = NULL;
 99   }
100   assert(unloaded_thread_id_set == NULL, "invariant");
101 }
102 
103 template <typename Processor>
104 static void do_samples(ObjectSample* sample, const ObjectSample* end, Processor& processor) {
105   assert(sample != NULL, "invariant");
106   while (sample != end) {
107     processor.sample_do(sample);
108     sample = sample->next();
109   }
110 }

312     add_to_leakp_set(frame._klass, frame._methodid);
313   }
314 }
315 
316 static void write_blob(const JfrBlobHandle& blob, JfrCheckpointWriter& writer, bool reset) {
317   if (reset) {
318     blob->reset_write_state();
319     return;
320   }
321   blob->exclusive_write(writer);
322 }
323 
324 static void write_type_set_blob(const ObjectSample* sample, JfrCheckpointWriter& writer, bool reset) {
325   if (sample->has_type_set()) {
326     write_blob(sample->type_set(), writer, reset);
327   }
328 }
329 
330 static void write_thread_blob(const ObjectSample* sample, JfrCheckpointWriter& writer, bool reset) {
331   assert(sample->has_thread(), "invariant");
332   if (has_thread_exited(sample->thread_id())) {
333     write_blob(sample->thread(), writer, reset);
334   }
335 }
336 
337 static void write_stacktrace_blob(const ObjectSample* sample, JfrCheckpointWriter& writer, bool reset) {
338   if (sample->has_stacktrace()) {
339     write_blob(sample->stacktrace(), writer, reset);
340   }
341 }
342 
343 static void write_blobs(const ObjectSample* sample, JfrCheckpointWriter& writer, bool reset) {
344   assert(sample != NULL, "invariant");
345   write_stacktrace_blob(sample, writer, reset);
346   write_thread_blob(sample, writer, reset);
347   write_type_set_blob(sample, writer, reset);
348 }
349 
350 class BlobWriter {
351  private:
352   const ObjectSampler* _sampler;

 67 
 68 Semaphore ThreadIdExclusiveAccess::_mutex_semaphore(1);
 69 
 70 static bool has_thread_exited(traceid tid) {
 71   assert(tid != 0, "invariant");
 72   if (unloaded_thread_id_set == NULL) {
 73     return false;
 74   }
 75   ThreadIdExclusiveAccess lock;
 76   return JfrPredicate<traceid, compare_traceid>::test(unloaded_thread_id_set, tid);
 77 }
 78 
 79 static void add_to_unloaded_thread_set(traceid tid) {
 80   ThreadIdExclusiveAccess lock;
 81   if (unloaded_thread_id_set == NULL) {
 82     unloaded_thread_id_set = c_heap_allocate_array<traceid>();
 83   }
 84   JfrMutablePredicate<traceid, compare_traceid>::test(unloaded_thread_id_set, tid);
 85 }
 86 
 87 void ObjectSampleCheckpoint::on_thread_exit(traceid tid) {
 88   assert(tid != 0, "invariant");
 89   if (LeakProfiler::is_running()) {
 90     add_to_unloaded_thread_set(tid);
 91   }
 92 }
 93 
 94 void ObjectSampleCheckpoint::clear() {
 95   assert(SafepointSynchronize::is_at_safepoint(), "invariant");
 96   if (unloaded_thread_id_set != NULL) {
 97     delete unloaded_thread_id_set;
 98     unloaded_thread_id_set = NULL;
 99   }
100   assert(unloaded_thread_id_set == NULL, "invariant");
101 }
102 
103 template <typename Processor>
104 static void do_samples(ObjectSample* sample, const ObjectSample* end, Processor& processor) {
105   assert(sample != NULL, "invariant");
106   while (sample != end) {
107     processor.sample_do(sample);
108     sample = sample->next();
109   }
110 }

312     add_to_leakp_set(frame._klass, frame._methodid);
313   }
314 }
315 
316 static void write_blob(const JfrBlobHandle& blob, JfrCheckpointWriter& writer, bool reset) {
317   if (reset) {
318     blob->reset_write_state();
319     return;
320   }
321   blob->exclusive_write(writer);
322 }
323 
324 static void write_type_set_blob(const ObjectSample* sample, JfrCheckpointWriter& writer, bool reset) {
325   if (sample->has_type_set()) {
326     write_blob(sample->type_set(), writer, reset);
327   }
328 }
329 
330 static void write_thread_blob(const ObjectSample* sample, JfrCheckpointWriter& writer, bool reset) {
331   assert(sample->has_thread(), "invariant");
332   if (sample->is_virtual_thread() || has_thread_exited(sample->thread_id())) {
333     write_blob(sample->thread(), writer, reset);
334   }
335 }
336 
337 static void write_stacktrace_blob(const ObjectSample* sample, JfrCheckpointWriter& writer, bool reset) {
338   if (sample->has_stacktrace()) {
339     write_blob(sample->stacktrace(), writer, reset);
340   }
341 }
342 
343 static void write_blobs(const ObjectSample* sample, JfrCheckpointWriter& writer, bool reset) {
344   assert(sample != NULL, "invariant");
345   write_stacktrace_blob(sample, writer, reset);
346   write_thread_blob(sample, writer, reset);
347   write_type_set_blob(sample, writer, reset);
348 }
349 
350 class BlobWriter {
351  private:
352   const ObjectSampler* _sampler;
< prev index next >