diff options
author | Mark Probst <mark.probst@gmail.com> | 2013-01-26 10:51:23 +0400 |
---|---|---|
committer | Mark Probst <mark.probst@gmail.com> | 2013-01-26 15:53:26 +0400 |
commit | 85b33433e4904992decd763cb597813ac642435f (patch) | |
tree | 810c924abb88f605ae5c611a7d87ef0ea8045f96 | |
parent | 10fa0cd33877de58176384cc3431d41af2c9a714 (diff) |
[sgen] DTrace probes for internal allocations.
-rw-r--r-- | data/mono.d | 3 | ||||
-rw-r--r-- | mono/metadata/sgen-internal.c | 34 | ||||
-rw-r--r-- | mono/utils/dtrace.h | 7 |
3 files changed, 32 insertions, 12 deletions
diff --git a/data/mono.d b/data/mono.d index e74ff82054f..0933e3b7645 100644 --- a/data/mono.d +++ b/data/mono.d @@ -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 diff --git a/mono/metadata/sgen-internal.c b/mono/metadata/sgen-internal.c index 2d4c108ea75..ad97e0d0892 100644 --- a/mono/metadata/sgen-internal.c +++ b/mono/metadata/sgen-internal.c @@ -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 diff --git a/mono/utils/dtrace.h b/mono/utils/dtrace.h index feb356f870f..2cee8fa483b 100644 --- a/mono/utils/dtrace.h +++ b/mono/utils/dtrace.h @@ -185,6 +185,13 @@ #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 |