[sgen] DTrace probes for internal allocations.
authorMark Probst <mark.probst@gmail.com>
Sat, 26 Jan 2013 06:51:23 +0000 (07:51 +0100)
committerMark Probst <mark.probst@gmail.com>
Sat, 26 Jan 2013 11:53:26 +0000 (12:53 +0100)
data/mono.d
mono/metadata/sgen-internal.c
mono/utils/dtrace.h

index e74ff82054f1786676ee49863347175130f5d383..0933e3b76453208ed910b5a04bdf7722e22a3086 100644 (file)
@@ -74,6 +74,9 @@ provider mono {
 
        probe gc__global__remset__add (uintptr_t ref_addr, uintptr_t obj_addr, uintptr_t size, char *ns_name, char *class_name);
        probe gc__obj__cemented (uintptr_t addr, uintptr_t size, char *ns_name, char *class_name);
+
+       probe gc__internal__alloc (uintptr_t addr, int type, uintptr_t size);
+       probe gc__internal__dealloc (uintptr_t add, uintptr_t size, int type);
 };
 
 #pragma D attributes Evolving/Evolving/Common provider mono provider
index 2d4c108ea75feaeb5db563494207ef2fd7377da1..ad97e0d08920c82019fed08504ccd359e1c1f2bf 100644 (file)
@@ -126,15 +126,16 @@ sgen_alloc_internal_dynamic (size_t size, int type, gboolean assert_on_failure)
                p = sgen_alloc_os_memory (size, SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE, NULL);
                if (!p)
                        sgen_assert_memory_alloc (NULL, size, description_for_type (type));
-               return p;
-       }
+       } else {
+               index = index_for_size (size);
 
-       index = index_for_size (size);
+               p = mono_lock_free_alloc (&allocators [index]);
+               if (!p)
+                       sgen_assert_memory_alloc (NULL, size, description_for_type (type));
+               memset (p, 0, size);
+       }
 
-       p = mono_lock_free_alloc (&allocators [index]);
-       if (!p)
-               sgen_assert_memory_alloc (NULL, size, description_for_type (type));
-       memset (p, 0, size);
+       MONO_GC_INTERNAL_ALLOC (p, size, type);
        return p;
 }
 
@@ -144,22 +145,26 @@ sgen_free_internal_dynamic (void *addr, size_t size, int type)
        if (!addr)
                return;
 
-       if (size > allocator_sizes [NUM_ALLOCATORS - 1]) {
+       if (size > allocator_sizes [NUM_ALLOCATORS - 1])
                sgen_free_os_memory (addr, size, SGEN_ALLOC_INTERNAL);
-               return;
-       }
+       else
+               mono_lock_free_free (addr);
 
-       mono_lock_free_free (addr);
+       MONO_GC_INTERNAL_DEALLOC (addr, size, type);
 }
 
 void*
 sgen_alloc_internal (int type)
 {
        int index = fixed_type_allocator_indexes [type];
+       int size = allocator_sizes [index];
        void *p;
        g_assert (index >= 0 && index < NUM_ALLOCATORS);
        p = mono_lock_free_alloc (&allocators [index]);
-       memset (p, 0, allocator_sizes [index]);
+       memset (p, 0, size);
+
+       MONO_GC_INTERNAL_ALLOC (p, size, type);
+
        return p;
 }
 
@@ -175,6 +180,11 @@ sgen_free_internal (void *addr, int type)
        g_assert (index >= 0 && index < NUM_ALLOCATORS);
 
        mono_lock_free_free (addr);
+
+       if (MONO_GC_INTERNAL_DEALLOC_ENABLED ()) {
+               int size = allocator_sizes [index];
+               MONO_GC_INTERNAL_DEALLOC (addr, size, type);
+       }
 }
 
 void
index feb356f870f04ef981688d562d25c9f72e14ae9d..2cee8fa483b71dbdf96ff91598eea4c47d7bb5ba 100644 (file)
 #define MONO_GC_OBJ_CEMENTED(addr,size,ns_name,class_name)
 #define MONO_GC_OBJ_CEMENTED_ENABLED() (0)
 
+
+#define MONO_GC_INTERNAL_ALLOC(addr,size)
+#define MONO_GC_INTERNAL_ALLOC_ENABLED()       (0)
+
+#define MONO_GC_INTERNAL_DEALLOC(addr,size)
+#define MONO_GC_INTERNAL_DEALLOC_ENABLED()     (0)
+
 #endif
 
 #endif