[profiler] Only forward declare structs that need it.
[mono.git] / mono / profiler / proflog.c
index 3f215535b80f6df7689e96ef2405f75b3eb2eb2d..e53cef3034e6963aa0c562cead8e95a60cb916ee 100644 (file)
 #include <mono/utils/mono-mmap.h>
 #include <mono/utils/mono-counters.h>
 #include <mono/utils/mono-os-mutex.h>
+#include <mono/utils/mono-os-semaphore.h>
 #include <mono/utils/mono-conc-hashtable.h>
 #include <mono/utils/lock-free-alloc.h>
 #include <mono/utils/lock-free-queue.h>
+#include <mono/utils/hazard-pointer.h>
+#include <mono/utils/mono-threads.h>
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
@@ -143,8 +146,6 @@ static gint32 image_unloads;
 static gint32 class_loads;
 static gint32 class_unloads;
 
-typedef struct _LogBuffer LogBuffer;
-
 /*
  * file format:
  * [header] [buffer]*
@@ -439,6 +440,7 @@ typedef struct _LogBuffer LogBuffer;
 
 // Pending data to be written to the log, for a single thread.
 // Threads periodically flush their own LogBuffers by calling safe_send
+typedef struct _LogBuffer LogBuffer;
 struct _LogBuffer {
        // Next (older) LogBuffer in processing queue
        LogBuffer *next;
@@ -475,7 +477,6 @@ ign_res (int G_GNUC_UNUSED unused, ...)
 #define EXIT_LOG(lb) (lb)->locked--;
 
 typedef struct _BinaryObject BinaryObject;
-
 struct _BinaryObject {
        BinaryObject *next;
        void *addr;
@@ -513,19 +514,17 @@ struct _MonoProfiler {
        GPtrArray *coverage_filters;
 };
 
-typedef struct _WriterQueueEntry WriterQueueEntry;
-struct _WriterQueueEntry {
+typedef struct {
        MonoLockFreeQueueNode node;
        GPtrArray *methods;
        LogBuffer *buffer;
-};
+} WriterQueueEntry;
 
-typedef struct _MethodInfo MethodInfo;
-struct _MethodInfo {
+typedef struct {
        MonoMethod *method;
        MonoJitInfo *ji;
        uint64_t time;
-};
+} MethodInfo;
 
 #ifdef TLS_INIT
 #undef TLS_INIT
@@ -2090,12 +2089,11 @@ mono_sample_hit (MonoProfiler *profiler, unsigned char *ip, void *context)
 
                sample = mono_lock_free_alloc (&profiler->sample_allocator);
                sample->prof = profiler;
+               mono_lock_free_queue_node_init (&sample->node, TRUE);
 
                InterlockedIncrement (&sample_allocations);
        }
 
-       mono_lock_free_queue_node_init (&sample->node, TRUE);
-
        sample->count = 0;
        mono_stack_walk_async_safe (&async_walk_stack, context, sample);
 
@@ -3233,20 +3231,18 @@ static gboolean coverage_initialized = FALSE;
 static GPtrArray *coverage_data = NULL;
 static int previous_offset = 0;
 
-typedef struct _MethodNode MethodNode;
-struct _MethodNode {
+typedef struct {
        MonoLockFreeQueueNode node;
        MonoMethod *method;
-};
+} MethodNode;
 
-typedef struct _CoverageEntry CoverageEntry;
-struct _CoverageEntry {
+typedef struct {
        int offset;
        int counter;
        char *filename;
        int line;
        int column;
-};
+} CoverageEntry;
 
 static void
 free_coverage_entry (gpointer data, gpointer userdata)
@@ -4021,7 +4017,7 @@ helper_thread (void* arg)
        MonoThread *thread = NULL;
 
        mono_threads_attach_tools_thread ();
-       mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler helper");
+       mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler helper");
 
        //fprintf (stderr, "Server listening\n");
        command_socket = -1;
@@ -4276,7 +4272,7 @@ writer_thread (void *arg)
        MonoProfiler *prof = (MonoProfiler *)arg;
 
        mono_threads_attach_tools_thread ();
-       mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler writer");
+       mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler writer");
 
        dump_header (prof);
 
@@ -4316,8 +4312,6 @@ handle_dumper_queue_entry (MonoProfiler *prof)
        SampleHit *sample;
 
        if ((sample = (SampleHit *) mono_lock_free_queue_dequeue (&prof->dumper_queue))) {
-               mono_lock_free_queue_node_init (&sample->node, TRUE);
-
                for (int i = 0; i < sample->count; ++i) {
                        MonoMethod *method = sample->frames [i].method;
                        MonoDomain *domain = sample->frames [i].domain;
@@ -4389,7 +4383,7 @@ dumper_thread (void *arg)
        MonoProfiler *prof = (MonoProfiler *)arg;
 
        mono_threads_attach_tools_thread ();
-       mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler dumper");
+       mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler dumper");
 
        while (InterlockedRead (&prof->run_dumper_thread)) {
                mono_os_sem_wait (&prof->dumper_queue_sem, MONO_SEM_FLAGS_NONE);