Compare commits

...
Author SHA1 Message Date
Rodrigo Kumpera bcc380d6ba [runtime] Instrument mono_domain_alloc 2014-09-16 18:16:47 -04:00
Rodrigo Kumpera 8516f578ee [runtime] Instrument image and image set mempool allocation. 2014-09-16 16:58:17 -04:00
Rodrigo Kumpera feaa6e19fb [runtime] Implement runtime valloc reporting. 2014-09-08 19:24:31 -04:00
Rodrigo Kumpera e8953e705c Properly name all sgen_alloc_os_memory. 2014-09-08 17:12:58 -04:00
Rodrigo Kumpera 130f08e943 Add reporting to jitinfo. 2014-09-08 17:11:11 -04:00
Rodrigo Kumpera 89558be055 [runtime] Finish metadata reporting. 2014-09-08 16:55:45 -04:00
Rodrigo Kumpera f2c8417122 [runtime] Proposed implementation of the memory profiler.
To get a small taste of it in action run the following program with it:

sing System;
using System.Net;
using System.Runtime.InteropServices;
using System.Linq;

public class Test
{
	[DllImport ("__Internal")]
	public static extern void mono_memprof_dump ();

	static int MethodThatDoesLinq () {
		int[] x = new[] { 1,2,3,4};
		var k = x.Where (_ => _ <= 100).Select (_ => _ + 1);
		int r = 0;
		foreach (var v in k)
			r += v;
		return r;
	}
	public static void Main ()
	{
		mono_memprof_dump ();
		MethodThatDoesLinq ();
		Console.WriteLine ("----------------------");
		mono_memprof_dump ();
	}
}
2014-09-08 02:27:09 -04:00
53 changed files with 1013 additions and 326 deletions

No files matched your search

+8
View File
@@ -57,6 +57,14 @@ typedef struct {
Slot *slot;
} Iter;
size_t
mono_eg_hashtable_get_memory_size (GHashTable *hashtable)
{
return sizeof (GHashTable) +
hashtable->in_use * sizeof (Slot) +
hashtable->table_size * sizeof (Slot*);
}
static const guint prime_tbl[] = {
11, 19, 37, 73, 109, 163, 251, 367, 557, 823, 1237,
1861, 2777, 4177, 6247, 9371, 14057, 21089, 31627,
+2
View File
@@ -467,6 +467,8 @@ guint g_spaced_primes_closest (guint x);
#define g_hash_table_insert(h,k,v) g_hash_table_insert_replace ((h),(k),(v),FALSE)
#define g_hash_table_replace(h,k,v) g_hash_table_insert_replace ((h),(k),(v),TRUE)
size_t mono_eg_hashtable_get_memory_size (GHashTable *hashtable);
gboolean g_direct_equal (gconstpointer v1, gconstpointer v2);
guint g_direct_hash (gconstpointer v1);
gboolean g_int_equal (gconstpointer v1, gconstpointer v2);
+2
View File
@@ -171,6 +171,8 @@ common_sources = \
process.h \
profiler.c \
profiler-private.h \
memory-profiler.h \
memory-profiler.c \
rand.h \
rand.c \
runtime.c \
+1 -1
View File
@@ -925,7 +925,7 @@ create_allocator (int atype, int tls_key)
mono_mb_free (mb);
mono_method_get_header (res)->init_locals = FALSE;
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (AllocatorWrapperInfo));
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (AllocatorWrapperInfo), "wrapper-info");
info->gc_name = "boehm";
info->alloc_type = atype;
mono_marshal_set_wrapper_info (res, info);
+49 -49
View File
@@ -283,9 +283,9 @@ mono_class_from_typeref (MonoImage *image, guint32 type_token)
static void *
mono_image_memdup (MonoImage *image, void *data, guint size)
mono_image_memdup (MonoImage *image, void *data, guint size, const char *what)
{
void *res = mono_image_alloc (image, size);
void *res = mono_image_alloc (image, size, what);
memcpy (res, data, size);
return res;
}
@@ -295,11 +295,11 @@ MonoArrayType *
mono_dup_array_type (MonoImage *image, MonoArrayType *a)
{
if (image) {
a = mono_image_memdup (image, a, sizeof (MonoArrayType));
a = mono_image_memdup (image, a, sizeof (MonoArrayType), "dump-array-type");
if (a->sizes)
a->sizes = mono_image_memdup (image, a->sizes, a->numsizes * sizeof (int));
a->sizes = mono_image_memdup (image, a->sizes, a->numsizes * sizeof (int), "dump-array-sizes");
if (a->lobounds)
a->lobounds = mono_image_memdup (image, a->lobounds, a->numlobounds * sizeof (int));
a->lobounds = mono_image_memdup (image, a->lobounds, a->numlobounds * sizeof (int), "dup-array-lobounds");
} else {
a = g_memdup (a, sizeof (MonoArrayType));
if (a->sizes)
@@ -1341,26 +1341,26 @@ mono_type_has_exceptions (MonoType *type)
* or from the heap.
*/
static gpointer
mono_class_alloc (MonoClass *class, int size)
mono_class_alloc (MonoClass *class, int size, const char *what)
{
if (class->generic_class)
return mono_image_set_alloc (class->generic_class->owner, size);
return mono_image_set_alloc (class->generic_class->owner, size, what);
else
return mono_image_alloc (class->image, size);
return mono_image_alloc (class->image, size, what);
}
static gpointer
mono_class_alloc0 (MonoClass *class, int size)
mono_class_alloc0 (MonoClass *class, int size, const char *what)
{
gpointer res;
res = mono_class_alloc (class, size);
res = mono_class_alloc (class, size, what);
memset (res, 0, size);
return res;
}
#define mono_class_new0(class,struct_type, n_structs) \
((struct_type *) mono_class_alloc0 ((class), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
#define mono_class_new0(class,struct_type, n_structs,what) \
((struct_type *) mono_class_alloc0 ((class), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs)),what))
/**
* mono_class_setup_basic_field_info:
@@ -1402,7 +1402,7 @@ mono_class_setup_basic_field_info (MonoClass *class)
class->field.count = gtd->field.count;
}
class->fields = mono_class_alloc0 (class, sizeof (MonoClassField) * top);
class->fields = mono_class_alloc0 (class, sizeof (MonoClassField) * top, "class-fields");
/*
* Fetch all the field information.
@@ -2025,7 +2025,7 @@ create_array_method (MonoClass *class, const char *name, MonoMethodSignature *si
{
MonoMethod *method;
method = (MonoMethod *) mono_image_alloc0 (class->image, sizeof (MonoMethodPInvoke));
method = (MonoMethod *) mono_image_alloc0 (class->image, sizeof (MonoMethodPInvoke), "method-pinvoke");
method->klass = class;
method->flags = METHOD_ATTRIBUTE_PUBLIC;
method->iflags = METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL;
@@ -2077,7 +2077,7 @@ mono_class_setup_methods (MonoClass *class)
/* The + 1 makes this always non-NULL to pass the check in mono_class_setup_methods () */
count = gklass->method.count;
methods = mono_class_alloc0 (class, sizeof (MonoMethod*) * (count + 1));
methods = mono_class_alloc0 (class, sizeof (MonoMethod*) * (count + 1), "gclass-method-list");
for (i = 0; i < count; i++) {
methods [i] = mono_class_inflate_generic_method_full_checked (
@@ -2109,7 +2109,7 @@ mono_class_setup_methods (MonoClass *class)
count += class->interface_count * count_generic;
}
methods = mono_class_alloc0 (class, sizeof (MonoMethod*) * count);
methods = mono_class_alloc0 (class, sizeof (MonoMethod*) * count, "aclass-method-list");
sig = mono_metadata_signature_alloc (class->image, class->rank);
sig->ret = &mono_defaults.void_class->byval_arg;
@@ -2164,7 +2164,7 @@ mono_class_setup_methods (MonoClass *class)
setup_generic_array_ifaces (class, class->interfaces [i], methods, first_generic + i * count_generic);
} else {
count = class->method.count;
methods = mono_class_alloc (class, sizeof (MonoMethod*) * count);
methods = mono_class_alloc (class, sizeof (MonoMethod*) * count, "class-method-list");
for (i = 0; i < count; ++i) {
int idx = mono_metadata_translate_token_index (class->image, MONO_TABLE_METHOD, class->method.first + i + 1);
methods [i] = mono_get_method (class->image, MONO_TOKEN_METHOD_DEF | idx, class);
@@ -2339,7 +2339,7 @@ mono_class_setup_properties (MonoClass *class)
return;
}
properties = mono_class_new0 (class, MonoProperty, gklass->ext->property.count + 1);
properties = mono_class_new0 (class, MonoProperty, gklass->ext->property.count + 1, "gclass-property-list");
for (i = 0; i < gklass->ext->property.count; i++) {
MonoProperty *prop = &properties [i];
@@ -2368,7 +2368,7 @@ mono_class_setup_properties (MonoClass *class)
return;
}
properties = mono_class_alloc0 (class, sizeof (MonoProperty) * count);
properties = mono_class_alloc0 (class, sizeof (MonoProperty) * count, "class-property-list");
for (i = first; i < last; ++i) {
mono_metadata_decode_table_row (class->image, MONO_TABLE_PROPERTY, i, cols, MONO_PROPERTY_SIZE);
properties [i - first].parent = class;
@@ -2467,7 +2467,7 @@ mono_class_setup_events (MonoClass *class)
first = gklass->ext->event.first;
count = gklass->ext->event.count;
events = mono_class_new0 (class, MonoEvent, count);
events = mono_class_new0 (class, MonoEvent, count, "gclass-event-list");
if (count)
context = mono_class_get_context (class);
@@ -2498,7 +2498,7 @@ mono_class_setup_events (MonoClass *class)
}
}
events = mono_class_alloc0 (class, sizeof (MonoEvent) * count);
events = mono_class_alloc0 (class, sizeof (MonoEvent) * count, "class-event-list");
for (i = first; i < last; ++i) {
MonoEvent *event = &events [i - first];
@@ -3502,13 +3502,13 @@ setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
uint8_t *bitmap;
int bsize;
class->interface_offsets_count = interface_offsets_count;
class->interfaces_packed = mono_class_alloc (class, sizeof (MonoClass*) * interface_offsets_count);
class->interface_offsets_packed = mono_class_alloc (class, sizeof (guint16) * interface_offsets_count);
class->interfaces_packed = mono_class_alloc (class, sizeof (MonoClass*) * interface_offsets_count, "class-interfaces-packed");
class->interface_offsets_packed = mono_class_alloc (class, sizeof (guint16) * interface_offsets_count, "class-interface-offsets-packed");
bsize = (sizeof (guint8) * ((max_iid + 1) >> 3)) + (((max_iid + 1) & 7)? 1 :0);
#ifdef COMPRESSED_INTERFACE_BITMAP
bitmap = g_malloc0 (bsize);
#else
bitmap = mono_class_alloc0 (class, bsize);
bitmap = mono_class_alloc0 (class, bsize, "class-interface-bitmap");
#endif
for (i = 0; i < interface_offsets_count; i++) {
int id = interfaces_full [i]->interface_id;
@@ -3520,7 +3520,7 @@ setup_interface_offsets (MonoClass *class, int cur_slot, gboolean overwrite)
}
#ifdef COMPRESSED_INTERFACE_BITMAP
i = mono_compress_bitmap (NULL, bitmap, bsize);
class->interface_bitmap = mono_class_alloc0 (class, i);
class->interface_bitmap = mono_class_alloc0 (class, i, "class-interface-bitmap");
mono_compress_bitmap (class->interface_bitmap, bitmap, bsize);
g_free (bitmap);
#else
@@ -4227,7 +4227,7 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
return;
}
tmp = mono_class_alloc0 (class, sizeof (gpointer) * gklass->vtable_size);
tmp = mono_class_alloc0 (class, sizeof (gpointer) * gklass->vtable_size, "gclass-vtable");
class->vtable_size = gklass->vtable_size;
for (i = 0; i < gklass->vtable_size; ++i)
if (gklass->vtable [i]) {
@@ -4621,7 +4621,7 @@ mono_class_setup_vtable_general (MonoClass *class, MonoMethod **overrides, int o
mono_memory_barrier ();
class->vtable = class->parent->vtable;
} else {
MonoMethod **tmp = mono_class_alloc0 (class, sizeof (gpointer) * class->vtable_size);
MonoMethod **tmp = mono_class_alloc0 (class, sizeof (gpointer) * class->vtable_size, "class-vtable");
memcpy (tmp, vtable, sizeof (gpointer) * class->vtable_size);
mono_memory_barrier ();
class->vtable = tmp;
@@ -4801,7 +4801,7 @@ generic_array_methods (MonoClass *class)
}
}
list = g_list_reverse (list);
generic_array_method_info = mono_image_alloc (mono_defaults.corlib, sizeof (GenericArrayMethodInfo) * count_generic);
generic_array_method_info = mono_image_alloc (mono_defaults.corlib, sizeof (GenericArrayMethodInfo) * count_generic, "generic-array-method-info");
i = 0;
for (tmp = list; tmp; tmp = tmp->next) {
const char *mname, *iname;
@@ -4830,7 +4830,7 @@ generic_array_methods (MonoClass *class)
g_assert_not_reached ();
}
name = mono_image_alloc (mono_defaults.corlib, strlen (iname) + strlen (mname) + 1);
name = mono_image_alloc (mono_defaults.corlib, strlen (iname) + strlen (mname) + 1, "generic-array-method-info-name");
strcpy (name, iname);
strcpy (name + strlen (iname), mname);
generic_array_method_info [i].name = name;
@@ -4867,7 +4867,7 @@ concat_two_strings_with_zero (MonoImage *image, const char *s1, const char *s2)
{
int null_length = strlen ("(null)");
int len = (s1 ? strlen (s1) : null_length) + (s2 ? strlen (s2) : null_length) + 2;
char *s = mono_image_alloc (image, len);
char *s = mono_image_alloc (image, len, "exception-message");
int result;
result = g_snprintf (s, len, "%s%c%s", s1 ? s1 : "(null)", '\0', s2 ? s2 : "(null)");
@@ -5544,7 +5544,7 @@ mono_class_setup_supertypes (MonoClass *class)
class->idepth = 1;
ms = MAX (MONO_DEFAULT_SUPERTABLE_SIZE, class->idepth);
supertypes = mono_class_alloc0 (class, sizeof (MonoClass *) * ms);
supertypes = mono_class_alloc0 (class, sizeof (MonoClass *) * ms, "class-supertypes");
if (class->parent) {
supertypes [class->idepth - 1] = class;
@@ -5641,7 +5641,7 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError
name = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAME]);
nspace = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAMESPACE]);
class = mono_image_alloc0 (image, sizeof (MonoClass));
class = mono_image_alloc0 (image, sizeof (MonoClass), "class-typedef");
class->name = name;
class->name_space = nspace;
@@ -5889,7 +5889,7 @@ mono_generic_class_get_class (MonoGenericClass *gclass)
return gclass->cached_class;
}
klass = mono_image_set_alloc0 (gclass->owner, sizeof (MonoClass));
klass = mono_image_set_alloc0 (gclass->owner, sizeof (MonoClass), "class-ginst");
gklass = gclass->container_class;
@@ -5974,14 +5974,14 @@ make_generic_param_class (MonoGenericParam *param, MonoImage *image, gboolean is
/* FIXME: */
image = mono_defaults.corlib;
klass = mono_image_alloc0 (image, sizeof (MonoClass));
klass = mono_image_alloc0 (image, sizeof (MonoClass), "class-generic-param");
classes_size += sizeof (MonoClass);
if (pinfo) {
klass->name = pinfo->name;
} else {
int n = mono_generic_param_num (param);
klass->name = mono_image_alloc0 (image, 16);
klass->name = mono_image_alloc0 (image, 16, "generic-param-name");
sprintf ((char*)klass->name, "%d", n);
}
@@ -6016,7 +6016,7 @@ make_generic_param_class (MonoGenericParam *param, MonoImage *image, gboolean is
if (count - pos > 0) {
klass->interface_count = count - pos;
klass->interfaces = mono_image_alloc0 (image, sizeof (MonoClass *) * (count - pos));
klass->interfaces = mono_image_alloc0 (image, sizeof (MonoClass *) * (count - pos), "gparam-interface-list");
klass->interfaces_inited = TRUE;
for (i = pos; i < count; i++)
klass->interfaces [i - pos] = pinfo->constraints [i];
@@ -6092,11 +6092,11 @@ set_anon_gparam_class (MonoGenericParam *param, gboolean is_mvar, MonoClass *kla
if (is_mvar) {
/* No locking needed */
if (!image->mvar_cache_fast)
image->mvar_cache_fast = mono_image_alloc0 (image, sizeof (MonoClass*) * FAST_CACHE_SIZE);
image->mvar_cache_fast = mono_image_alloc0 (image, sizeof (MonoClass*) * FAST_CACHE_SIZE, "mvar-cache");
image->mvar_cache_fast [n] = klass;
} else {
if (!image->var_cache_fast)
image->var_cache_fast = mono_image_alloc0 (image, sizeof (MonoClass*) * FAST_CACHE_SIZE);
image->var_cache_fast = mono_image_alloc0 (image, sizeof (MonoClass*) * FAST_CACHE_SIZE, "var-cache");
image->var_cache_fast [n] = klass;
}
return;
@@ -6197,14 +6197,14 @@ mono_ptr_class_get (MonoType *type)
mono_loader_unlock ();
return result;
}
result = mono_image_alloc0 (image, sizeof (MonoClass));
result = mono_image_alloc0 (image, sizeof (MonoClass), "class-ptr");
classes_size += sizeof (MonoClass);
result->parent = NULL; /* no parent for PTR types */
result->name_space = el_class->name_space;
name = g_strdup_printf ("%s*", el_class->name);
result->name = mono_image_strdup (image, name);
result->name = mono_image_strdup (image, name, "pclass-name");
g_free (name);
mono_profiler_class_event (result, MONO_PROFILE_START_LOAD);
@@ -6471,7 +6471,7 @@ mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
mono_class_init (parent);
}
class = mono_image_alloc0 (image, sizeof (MonoClass));
class = mono_image_alloc0 (image, sizeof (MonoClass), "class-array");
class->image = image;
class->name_space = eclass->name_space;
@@ -6485,7 +6485,7 @@ mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
name [nsize + rank] = '*';
name [nsize + rank + bounded] = ']';
name [nsize + rank + bounded + 1] = 0;
class->name = mono_image_strdup (image, name);
class->name = mono_image_strdup (image, name, "aclass-name");
g_free (name);
mono_profiler_class_event (class, MONO_PROFILE_START_LOAD);
@@ -6555,7 +6555,7 @@ mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
class->element_class = eclass;
if ((rank > 1) || bounded) {
MonoArrayType *at = mono_image_alloc0 (image, sizeof (MonoArrayType));
MonoArrayType *at = mono_image_alloc0 (image, sizeof (MonoArrayType), "class-array-array-type");
class->byval_arg.type = MONO_TYPE_ARRAY;
class->byval_arg.data.array = at;
at->eklass = eclass;
@@ -6869,7 +6869,7 @@ mono_class_get_field_default_value (MonoClassField *field, MonoTypeEnum *def_typ
mono_class_alloc_ext (klass);
def_values = mono_class_alloc0 (klass, sizeof (MonoFieldDefaultValue) * klass->field.count);
def_values = mono_class_alloc0 (klass, sizeof (MonoFieldDefaultValue) * klass->field.count, "class-field-def-values");
mono_image_lock (klass->image);
mono_memory_barrier ();
@@ -8949,7 +8949,7 @@ setup_nested_types (MonoClass *klass)
nested_classes = NULL;
for (l = classes; l; l = l->next)
nested_classes = g_list_prepend_image (klass->image, nested_classes, l->data);
nested_classes = g_list_prepend_image (klass->image, nested_classes, l->data, "class-nested-classes");
g_list_free (classes);
mono_image_lock (klass->image);
@@ -9133,7 +9133,7 @@ mono_field_get_rva (MonoClassField *field)
if (!klass->ext || !klass->ext->field_def_values) {
mono_class_alloc_ext (klass);
field_def_values = mono_class_alloc0 (klass, sizeof (MonoFieldDefaultValue) * klass->field.count);
field_def_values = mono_class_alloc0 (klass, sizeof (MonoFieldDefaultValue) * klass->field.count, "class-field-def-values");
mono_image_lock (klass->image);
if (!klass->ext->field_def_values)
@@ -10098,7 +10098,7 @@ mono_class_alloc_ext (MonoClass *klass)
if (klass->ext)
return;
ext = mono_class_alloc0 (klass, sizeof (MonoClassExt));
ext = mono_class_alloc0 (klass, sizeof (MonoClassExt), "class-ext");
mono_image_lock (klass->image);
mono_memory_barrier ();
if (!klass->ext)
@@ -10130,7 +10130,7 @@ mono_class_setup_interfaces (MonoClass *klass, MonoError *error)
/* generic IList, ICollection, IEnumerable */
interface_count = mono_defaults.generic_ireadonlylist_class ? 2 : 1;
interfaces = mono_image_alloc0 (klass->image, sizeof (MonoClass*) * interface_count);
interfaces = mono_image_alloc0 (klass->image, sizeof (MonoClass*) * interface_count, "interface-list");
args [0] = &klass->element_class->byval_arg;
interfaces [0] = mono_class_bind_generic_parameters (
@@ -10148,7 +10148,7 @@ mono_class_setup_interfaces (MonoClass *klass, MonoError *error)
}
interface_count = gklass->interface_count;
interfaces = mono_class_new0 (klass, MonoClass *, interface_count);
interfaces = mono_class_new0 (klass, MonoClass *, interface_count, "gclass-interface-list");
for (i = 0; i < interface_count; i++) {
interfaces [i] = mono_class_inflate_generic_class_checked (gklass->interfaces [i], mono_generic_class_get_context (klass->generic_class), error);
if (!mono_error_ok (error)) {
+1 -1
View File
@@ -1918,7 +1918,7 @@ cominterop_get_ccw (MonoObject* object, MonoClass* itf)
if (!ccw_entry) {
int vtable_index = method_count-1+start_slot;
vtable = mono_image_alloc0 (klass->image, sizeof (gpointer)*(method_count+start_slot));
vtable = mono_image_alloc0 (klass->image, sizeof (gpointer)*(method_count+start_slot), "ccw-vtable");
memcpy (vtable, iunknown, sizeof (iunknown));
if (start_slot == 7)
memcpy (vtable+3, idispatch, sizeof (idispatch));
+4 -2
View File
@@ -481,10 +481,10 @@ gboolean
mono_is_shadow_copy_enabled (MonoDomain *domain, const gchar *dir_name) MONO_INTERNAL;
gpointer
mono_domain_alloc (MonoDomain *domain, guint size) MONO_INTERNAL;
mono_domain_alloc (MonoDomain *domain, guint size, const char *what) MONO_INTERNAL;
gpointer
mono_domain_alloc0 (MonoDomain *domain, guint size) MONO_INTERNAL;
mono_domain_alloc0 (MonoDomain *domain, guint size, const char *what) MONO_INTERNAL;
gpointer
mono_domain_alloc0_lock_free (MonoDomain *domain, guint size) MONO_INTERNAL;
@@ -661,4 +661,6 @@ MonoJitInfo* mono_jit_info_table_find_internal (MonoDomain *domain, char *addr,
void mono_enable_debug_domain_unload (gboolean enable);
size_t mono_hashtable_get_memory_size (MonoGHashTable *hashtable);
#endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */
+39 -11
View File
@@ -16,6 +16,7 @@
#include <sys/stat.h>
#include <mono/metadata/gc-internal.h>
#include <mono/metadata/memory-profiler.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-compiler.h>
@@ -42,6 +43,7 @@
#include <metadata/threads.h>
#include <metadata/profiler-private.h>
#include <mono/metadata/coree.h>
#include <mono/metadata/memory-profiler.h>
//#define DEBUG_DOMAIN_UNLOAD 1
@@ -203,6 +205,7 @@ static MonoJitInfoTableChunk*
jit_info_table_new_chunk (void)
{
MonoJitInfoTableChunk *chunk = g_new0 (MonoJitInfoTableChunk, 1);
mono_profiler_add_allocation ("jittable:table-chunk", sizeof (MonoJitInfoTableChunk));
chunk->refcount = 1;
return chunk;
@@ -211,7 +214,9 @@ jit_info_table_new_chunk (void)
static MonoJitInfoTable *
jit_info_table_new (MonoDomain *domain)
{
MonoJitInfoTable *table = g_malloc0 (MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*));
size_t size = MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*);
MonoJitInfoTable *table = g_malloc0 (size);
mono_profiler_add_allocation ("jittable:table", size);
table->domain = domain;
table->num_chunks = 1;
@@ -233,8 +238,10 @@ jit_info_table_free (MonoJitInfoTable *table)
if (table->domain->num_jit_info_tables <= 1) {
GSList *list;
for (list = table->domain->jit_info_free_queue; list; list = list->next)
for (list = table->domain->jit_info_free_queue; list; list = list->next) {
mono_profiler_remove_allocation ("jittable:info", sizeof (MonoJitInfo));
g_free (list->data);
}
g_slist_free (table->domain->jit_info_free_queue);
table->domain->jit_info_free_queue = NULL;
@@ -256,15 +263,19 @@ jit_info_table_free (MonoJitInfoTable *table)
for (j = 0; j < num_elements; ++j) {
MonoJitInfo *ji = chunk->data [j];
if (IS_JIT_INFO_TOMBSTONE (ji))
if (IS_JIT_INFO_TOMBSTONE (ji)) {
mono_profiler_remove_allocation ("jittable:tombstone", sizeof (MonoJitInfo));
g_free (ji);
}
}
mono_profiler_remove_allocation ("jittable:table-chunk", sizeof (MonoJitInfoTableChunk));
g_free (chunk);
}
mono_domain_unlock (domain);
mono_profiler_remove_allocation ("jittable:table", MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*) * table->num_chunks);
g_free (table);
}
@@ -480,6 +491,7 @@ jit_info_table_check (MonoJitInfoTable *table)
static MonoJitInfoTable*
jit_info_table_realloc (MonoJitInfoTable *old)
{
size_t table_size;
int i;
int num_elements = jit_info_table_num_elements (old);
int required_size;
@@ -496,9 +508,11 @@ jit_info_table_realloc (MonoJitInfoTable *old)
}
g_assert (num_chunks > 0);
new = g_malloc (MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*) * num_chunks);
table_size = MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*) * num_chunks;
new = g_malloc (table_size);
new->domain = old->domain;
new->num_chunks = num_chunks;
mono_profiler_add_allocation ("jittable:table", table_size);
for (i = 0; i < num_chunks; ++i)
new->chunks [i] = jit_info_table_new_chunk ();
@@ -565,9 +579,10 @@ jit_info_table_split_chunk (MonoJitInfoTableChunk *chunk, MonoJitInfoTableChunk
static MonoJitInfoTable*
jit_info_table_copy_and_split_chunk (MonoJitInfoTable *table, MonoJitInfoTableChunk *chunk)
{
MonoJitInfoTable *new_table = g_malloc (MONO_SIZEOF_JIT_INFO_TABLE
+ sizeof (MonoJitInfoTableChunk*) * (table->num_chunks + 1));
size_t size = MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*) * (table->num_chunks + 1);
MonoJitInfoTable *new_table = g_malloc (size);
int i, j;
mono_profiler_add_allocation ("jittable:table", size);
new_table->domain = table->domain;
new_table->num_chunks = table->num_chunks + 1;
@@ -613,9 +628,10 @@ jit_info_table_purify_chunk (MonoJitInfoTableChunk *old)
static MonoJitInfoTable*
jit_info_table_copy_and_purify_chunk (MonoJitInfoTable *table, MonoJitInfoTableChunk *chunk)
{
MonoJitInfoTable *new_table = g_malloc (MONO_SIZEOF_JIT_INFO_TABLE
+ sizeof (MonoJitInfoTableChunk*) * table->num_chunks);
size_t size = MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*) * table->num_chunks;
MonoJitInfoTable *new_table = g_malloc (size);
int i, j;
mono_profiler_add_allocation ("jittable:table", size);
new_table->domain = table->domain;
new_table->num_chunks = table->num_chunks;
@@ -775,6 +791,7 @@ static MonoJitInfo*
mono_jit_info_make_tombstone (MonoJitInfo *ji)
{
MonoJitInfo *tombstone = g_new0 (MonoJitInfo, 1);
mono_profiler_add_allocation ("jittable:tombstone", sizeof (MonoJitInfo));
tombstone->code_start = ji->code_start;
tombstone->code_size = ji->code_size;
@@ -792,6 +809,7 @@ mono_jit_info_free_or_queue (MonoDomain *domain, MonoJitInfo *ji)
if (domain->num_jit_info_tables <= 1) {
/* Can it actually happen that we only have one table
but ji is still hazardous? */
mono_profiler_remove_allocation ("jittable:info", sizeof (MonoJitInfo));
mono_thread_hazardous_free_or_queue (ji, g_free, TRUE, FALSE);
} else {
domain->jit_info_free_queue = g_slist_prepend (domain->jit_info_free_queue, ji);
@@ -876,6 +894,7 @@ mono_jit_info_add_aot_module (MonoImage *image, gpointer start, gpointer end)
ji->code_start = start;
ji->code_size = (guint8*)end - (guint8*)start;
jit_info_table_add (mono_root_domain, &mono_root_domain->aot_modules, ji);
mono_profiler_add_allocation ("jittable:aot-info", sizeof (MonoJitInfo));
mono_domain_unlock (mono_root_domain);
}
@@ -1065,7 +1084,7 @@ lock_free_mempool_chunk_new (LockFreeMempool *mp, int len)
size = mono_pagesize ();
while (size - sizeof (LockFreeMempoolChunk) < len)
size += mono_pagesize ();
chunk = mono_valloc (0, size, MONO_MMAP_READ|MONO_MMAP_WRITE);
chunk = mono_valloc (0, size, MONO_MMAP_READ|MONO_MMAP_WRITE, "lock-free-mempool");
g_assert (chunk);
chunk->mem = ALIGN_PTR_TO ((char*)chunk + sizeof (LockFreeMempoolChunk), 16);
chunk->size = ((char*)chunk + size) - (char*)chunk->mem;
@@ -1281,6 +1300,8 @@ mono_domain_create (void)
domain = mono_gc_alloc_fixed (sizeof (MonoDomain), domain_gc_desc);
mono_gc_register_root ((char*)&(domain->MONO_DOMAIN_FIRST_GC_TRACKED), G_STRUCT_OFFSET (MonoDomain, MONO_DOMAIN_LAST_GC_TRACKED) - G_STRUCT_OFFSET (MonoDomain, MONO_DOMAIN_FIRST_GC_TRACKED), NULL);
#endif
mono_profiler_register_memory_domain (domain, MEMDOM_APPDOMAIN);
domain->shadow_serial = shadow_serial;
domain->domain = NULL;
domain->setup = NULL;
@@ -1367,6 +1388,9 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
#endif
/* init before wapi so we can record large mallocs */
mono_memory_profiler_init ();
#ifndef HOST_WIN32
wapi_init ();
#endif
@@ -1952,6 +1976,8 @@ mono_domain_free (MonoDomain *domain, gboolean force)
GSList *tmp;
gpointer *p;
mono_profiler_free_memory_domain (domain);
if ((domain == mono_root_domain) && !force) {
g_warning ("cant unload root domain");
return;
@@ -2193,7 +2219,7 @@ mono_domain_get_id (MonoDomain *domain)
* LOCKING: Acquires the domain lock.
*/
gpointer
mono_domain_alloc (MonoDomain *domain, guint size)
mono_domain_alloc (MonoDomain *domain, guint size, const char *what)
{
gpointer res;
@@ -2201,6 +2227,7 @@ mono_domain_alloc (MonoDomain *domain, guint size)
#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters->loader_bytes += size;
#endif
mono_profiler_add_mempool_alloc (domain, size, what);
res = mono_mempool_alloc (domain->mp, size);
mono_domain_unlock (domain);
@@ -2213,7 +2240,7 @@ mono_domain_alloc (MonoDomain *domain, guint size)
* LOCKING: Acquires the domain lock.
*/
gpointer
mono_domain_alloc0 (MonoDomain *domain, guint size)
mono_domain_alloc0 (MonoDomain *domain, guint size, const char *what)
{
gpointer res;
@@ -2221,6 +2248,7 @@ mono_domain_alloc0 (MonoDomain *domain, guint size)
#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters->loader_bytes += size;
#endif
mono_profiler_add_mempool_alloc (domain, size, what);
res = mono_mempool_alloc0 (domain->mp, size);
mono_domain_unlock (domain);
+13 -7
View File
@@ -34,6 +34,7 @@
#include <mono/utils/atomic.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/memory-profiler.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/security-core-clr.h>
#include <mono/metadata/verify-internals.h>
@@ -946,6 +947,7 @@ do_mono_image_load (MonoImage *image, MonoImageOpenStatus *status,
GSList *errors = NULL;
mono_profiler_module_event (image, MONO_PROFILE_START_LOAD);
mono_profiler_register_memory_domain (image, MEMDOM_IMAGE);
mono_image_init (image);
@@ -1528,6 +1530,7 @@ mono_image_close_except_pools (MonoImage *image)
#endif
mono_profiler_module_event (image, MONO_PROFILE_START_UNLOAD);
mono_profiler_free_memory_domain (image);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Unloading image %s [%p].", image->name, image);
@@ -2227,7 +2230,7 @@ mono_image_has_authenticode_entry (MonoImage *image)
}
gpointer
mono_image_alloc (MonoImage *image, guint size)
mono_image_alloc (MonoImage *image, guint size, const char *what)
{
gpointer res;
@@ -2235,6 +2238,7 @@ mono_image_alloc (MonoImage *image, guint size)
mono_perfcounters->loader_bytes += size;
#endif
mono_image_lock (image);
mono_profiler_add_mempool_alloc (image, size, what);
res = mono_mempool_alloc (image->mempool, size);
mono_image_unlock (image);
@@ -2242,7 +2246,7 @@ mono_image_alloc (MonoImage *image, guint size)
}
gpointer
mono_image_alloc0 (MonoImage *image, guint size)
mono_image_alloc0 (MonoImage *image, guint size, const char *what)
{
gpointer res;
@@ -2250,6 +2254,7 @@ mono_image_alloc0 (MonoImage *image, guint size)
mono_perfcounters->loader_bytes += size;
#endif
mono_image_lock (image);
mono_profiler_add_mempool_alloc (image, size, what);
res = mono_mempool_alloc0 (image->mempool, size);
mono_image_unlock (image);
@@ -2257,7 +2262,7 @@ mono_image_alloc0 (MonoImage *image, guint size)
}
char*
mono_image_strdup (MonoImage *image, const char *s)
mono_image_strdup (MonoImage *image, const char *s, const char *what)
{
char *res;
@@ -2265,6 +2270,7 @@ mono_image_strdup (MonoImage *image, const char *s)
mono_perfcounters->loader_bytes += strlen (s);
#endif
mono_image_lock (image);
mono_profiler_add_mempool_alloc (image, strlen (s) + 1, what);
res = mono_mempool_strdup (image->mempool, s);
mono_image_unlock (image);
@@ -2272,11 +2278,11 @@ mono_image_strdup (MonoImage *image, const char *s)
}
GList*
g_list_prepend_image (MonoImage *image, GList *list, gpointer data)
g_list_prepend_image (MonoImage *image, GList *list, gpointer data, const char *what)
{
GList *new_list;
new_list = mono_image_alloc (image, sizeof (GList));
new_list = mono_image_alloc (image, sizeof (GList), what);
new_list->data = data;
new_list->prev = list ? list->prev : NULL;
new_list->next = list;
@@ -2290,11 +2296,11 @@ g_list_prepend_image (MonoImage *image, GList *list, gpointer data)
}
GSList*
g_slist_append_image (MonoImage *image, GSList *list, gpointer data)
g_slist_append_image (MonoImage *image, GSList *list, gpointer data, const char *what)
{
GSList *new_list;
new_list = mono_image_alloc (image, sizeof (GSList));
new_list = mono_image_alloc (image, sizeof (GSList), what);
new_list->data = data;
new_list->next = NULL;
+7 -7
View File
@@ -1241,11 +1241,11 @@ mono_dllmap_insert (MonoImage *assembly, const char *dll, const char *func, cons
global_dll_map = entry;
mono_loader_unlock ();
} else {
entry = mono_image_alloc0 (assembly, sizeof (MonoDllMap));
entry->dll = dll? mono_image_strdup (assembly, dll): NULL;
entry->target = tdll? mono_image_strdup (assembly, tdll): NULL;
entry->func = func? mono_image_strdup (assembly, func): NULL;
entry->target_func = tfunc? mono_image_strdup (assembly, tfunc): NULL;
entry = mono_image_alloc0 (assembly, sizeof (MonoDllMap), "dll-map");
entry->dll = dll? mono_image_strdup (assembly, dll, "dll-name"): NULL;
entry->target = tdll? mono_image_strdup (assembly, tdll, "dll-target"): NULL;
entry->func = func? mono_image_strdup (assembly, func, "dll-func"): NULL;
entry->target_func = tfunc? mono_image_strdup (assembly, tfunc, "dll-target_func"): NULL;
mono_image_lock (assembly);
entry->next = assembly->dll_map;
@@ -1722,9 +1722,9 @@ mono_get_method_from_token (MonoImage *image, guint32 token, MonoClass *klass,
if ((cols [2] & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(cols [1] & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)) {
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethodPInvoke));
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethodPInvoke), "method-pinvoke");
} else {
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethod));
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethod), "method");
methods_size += sizeof (MonoMethod);
}
+8 -8
View File
@@ -1145,7 +1145,7 @@ mono_mb_emit_exception_marshal_directive (MonoMethodBuilder *mb, char *msg)
char *s;
if (!mb->dynamic) {
s = mono_image_strdup (mb->method->klass->image, msg);
s = mono_image_strdup (mb->method->klass->image, msg, "mb-exception-message");
g_free (msg);
} else {
s = g_strdup (msg);
@@ -2726,7 +2726,7 @@ mono_wrapper_info_create (MonoMethodBuilder *mb, WrapperSubtype subtype)
{
WrapperInfo *info;
info = mono_image_alloc0 (mb->method->klass->image, sizeof (WrapperInfo));
info = mono_image_alloc0 (mb->method->klass->image, sizeof (WrapperInfo), "wrapper-info");
info->subtype = subtype;
return info;
}
@@ -3583,7 +3583,7 @@ mono_marshal_get_xappdomain_dispatch (MonoMethod *method, int *marshal_types, in
/* try */
main_clause = mono_image_alloc0 (method->klass->image, sizeof (MonoExceptionClause));
main_clause = mono_image_alloc0 (method->klass->image, sizeof (MonoExceptionClause), "mb-exception-clause");
main_clause->try_offset = mono_mb_get_label (mb);
/* Clean the call context */
@@ -4942,7 +4942,7 @@ emit_runtime_invoke_body (MonoMethodBuilder *mb, MonoClass *target_klass, MonoMe
labels [2] = mono_mb_emit_branch (mb, CEE_LEAVE);
/* Add a try clause around the call */
clause = mono_image_alloc0 (target_klass->image, sizeof (MonoExceptionClause));
clause = mono_image_alloc0 (target_klass->image, sizeof (MonoExceptionClause), "mb-exception-clause");
clause->flags = MONO_EXCEPTION_CLAUSE_NONE;
clause->data.catch_class = mono_defaults.exception_class;
clause->try_offset = labels [1];
@@ -5234,7 +5234,7 @@ mono_marshal_get_runtime_invoke_dynamic (void)
pos = mono_mb_emit_branch (mb, CEE_LEAVE);
clause = mono_image_alloc0 (mono_defaults.corlib, sizeof (MonoExceptionClause));
clause = mono_image_alloc0 (mono_defaults.corlib, sizeof (MonoExceptionClause), "mb-exception-clause");
clause->flags = MONO_EXCEPTION_CLAUSE_FILTER;
clause->try_len = mono_mb_get_label (mb);
@@ -10534,7 +10534,7 @@ mono_marshal_get_synchronized_wrapper (MonoMethod *method)
/* this */
this_local = mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
clause = mono_image_alloc0 (method->klass->image, sizeof (MonoExceptionClause));
clause = mono_image_alloc0 (method->klass->image, sizeof (MonoExceptionClause), "mb-exception-clause");
clause->flags = MONO_EXCEPTION_CLAUSE_FINALLY;
#endif
@@ -12300,7 +12300,7 @@ mono_marshal_load_type_info (MonoClass* klass)
layout = klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK;
/* The mempool is protected by the loader lock */
info = mono_image_alloc0 (klass->image, MONO_SIZEOF_MARSHAL_TYPE + sizeof (MonoMarshalField) * count);
info = mono_image_alloc0 (klass->image, MONO_SIZEOF_MARSHAL_TYPE + sizeof (MonoMarshalField) * count, "marshal-type-info");
info->num_fields = count;
/* Try to find a size for this type in metadata */
@@ -12904,7 +12904,7 @@ mono_marshal_get_thunk_invoke_wrapper (MonoMethod *method)
mono_mb_emit_byte (mb, CEE_STIND_REF);
/* try */
clause = mono_image_alloc0 (image, sizeof (MonoExceptionClause));
clause = mono_image_alloc0 (image, sizeof (MonoExceptionClause), "mb-exception-clause");
clause->try_offset = mono_mb_get_label (mb);
/* push method's args */
+80
View File
@@ -0,0 +1,80 @@
MEMDOM_TYPE_START(MonoImage)
MEMDOM_FIELD(MonoImage, mempool, MEMPOOL)
MEMDOM_FIELD(MonoImage, method_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, class_cache, INTERNAL_HASHTABLE)
MEMDOM_FIELD(MonoImage, methodref_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, field_cache, CONC_HASHTABLE)
MEMDOM_FIELD(MonoImage, typespec_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, memberref_signatures, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, helper_signatures, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, method_signatures, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, name_cache, NESTED_G_HASHTABLE)
MEMDOM_FIELD(MonoImage, array_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, ptr_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, szarray_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_begin_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_end_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, runtime_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, runtime_invoke_vtype_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_abstract_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_bound_static_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, runtime_invoke_direct_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, runtime_invoke_vcall_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, managed_wrapper_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, native_wrapper_aot_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, native_func_wrapper_aot_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, remoting_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, synchronized_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, unbox_wrapper_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, cominterop_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, cominterop_wrapper_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, thunk_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, wrapper_param_names, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, synchronized_generic_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, array_accessor_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, ldfld_wrapper_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, ldflda_wrapper_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, stfld_wrapper_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, isinst_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, castclass_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, proxy_isinst_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, rgctx_template_hash, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_invoke_generic_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_begin_invoke_generic_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_end_invoke_generic_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, property_hash, PROPERTY_HASHTABLE)
MEMDOM_FIELD(MonoImage, var_cache_slow, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, mvar_cache_slow, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, pinvoke_scopes, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, pinvoke_scope_filenames, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, gsharedvt_types, G_HASHTABLE)
MEMDOM_TYPE_END()
MEMDOM_TYPE_START(MonoDomain)
MEMDOM_FIELD(MonoDomain, mp, MEMPOOL)
MEMDOM_FIELD(MonoDomain, env, MONO_HASHTABLE)
MEMDOM_FIELD(MonoDomain, ldstr_table, MONO_HASHTABLE)
MEMDOM_FIELD(MonoDomain, type_hash, MONO_HASHTABLE)
MEMDOM_FIELD(MonoDomain, refobject_hash, MONO_HASHTABLE)
MEMDOM_FIELD(MonoDomain, type_init_exception_hash, MONO_HASHTABLE)
MEMDOM_FIELD(MonoDomain, delegate_hash_table, MONO_HASHTABLE)
MEMDOM_FIELD(MonoDomain, proxy_vtable_hash, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, jit_code_hash, INTERNAL_HASHTABLE)
// MEMDOM_FIELD(MonoDomain, jit_info_table, JIT_INFO_TABLE)
// MEMDOM_FIELD(MonoDomain, aot_modules, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, special_static_fields, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, finalizable_objects_hash, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, method_rgctx_hash, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, generic_virtual_cases, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, generic_virtual_thunks, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, ftnptrs_hash, G_HASHTABLE)
MEMDOM_TYPE_END()
MEMDOM_TYPE_START(MonoImageSet)
MEMDOM_FIELD(MonoImageSet, gclass_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImageSet, ginst_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImageSet, gmethod_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImageSet, gsignature_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImageSet, mempool, MEMPOOL)
MEMDOM_TYPE_END()
+458
View File
@@ -0,0 +1,458 @@
#include <mono/metadata/memory-profiler.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/image.h>
#include <mono/utils/mono-mutex.h>
#include <mono/utils/mono-internal-hash.h>
#include <mono/utils/mono-conc-hashtable.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/atomic.h>
typedef enum
{
MEMPOOL,
G_HASHTABLE,
NESTED_G_HASHTABLE,
MONO_HASHTABLE,
INTERNAL_HASHTABLE,
CONC_HASHTABLE,
PROPERTY_HASHTABLE,
ITEM_KIND_MAX,
} MemDomItemKind;
typedef struct {
MemDomItemKind type;
int offset;
const char *name;
} ItemDesc;
#define MEMDOM_TYPE_START(TYPE) static ItemDesc descriptor_ ## TYPE [] = {
#define MEMDOM_FIELD(TYPE,FIELD,KIND) { KIND, G_STRUCT_OFFSET (TYPE, FIELD), #FIELD },
#define MEMDOM_TYPE_END() { ITEM_KIND_MAX } };
#include "memory-domain-def.h"
static mono_mutex_t memprof_mutex;
static GHashTable *mem_domains, *global_allocs;
typedef struct {
gpointer address;
MemoryDomainKind kind;
size_t extra_alloc;
GHashTable *mempool_allocs;
} MemDomain;
typedef struct {
const char *tag;
size_t alloc_bytes;
size_t alloc_count;
} AllocInfo;
static inline void
memprof_lock (void)
{
mono_mutex_lock (&memprof_mutex);
}
static inline void
memprof_unlock (void)
{
mono_mutex_unlock (&memprof_mutex);
}
static void
free_memdom (gpointer arg)
{
MemDomain *dom = arg;
g_hash_table_destroy (dom->mempool_allocs);
g_free (dom);
}
void
mono_memory_profiler_init (void)
{
mono_mutex_init (&memprof_mutex);
mem_domains = g_hash_table_new_full (mono_aligned_addr_hash, NULL, NULL, free_memdom);
global_allocs = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
}
void
mono_profiler_register_memory_domain (gpointer domain, MemoryDomainKind kind)
{
MemDomain *dom = g_new0 (MemDomain, 1);
dom->address = domain;
dom->kind = kind;
dom->mempool_allocs = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
memprof_lock ();
g_hash_table_insert (mem_domains, domain, dom);
memprof_unlock ();
}
void
mono_profiler_free_memory_domain (gpointer domain)
{
memprof_lock ();
g_hash_table_remove (mem_domains, domain);
memprof_unlock ();
}
static void
add_alloc_to_hashtable (GHashTable *hash, const char *tag, gsize size)
{
AllocInfo *info = g_hash_table_lookup (hash, tag);
if (!info) {
info = g_new0 (AllocInfo, 1);
info->tag = tag;
g_hash_table_insert (hash, (char*)tag, info);
}
info->alloc_bytes += size;
info->alloc_count++;
}
void
mono_profiler_add_mempool_alloc (gpointer domain, gsize size, const char *tag)
{
MemDomain *dom;
memprof_lock ();
dom = g_hash_table_lookup (mem_domains, domain);
if (!dom)
g_print ("WARNING could not find memdom %p\n", domain);
else
add_alloc_to_hashtable (dom->mempool_allocs, tag, size);
memprof_unlock ();
}
void
mono_profiler_add_allocation (const char *tag, gsize size)
{
memprof_lock ();
add_alloc_to_hashtable (global_allocs, tag, size);
memprof_unlock ();
}
void
mono_profiler_remove_allocation (const char *tag, gsize size)
{
AllocInfo *info;
memprof_lock ();
info = g_hash_table_lookup (global_allocs, tag);
if (info)
info->alloc_bytes -= size;
memprof_unlock ();
}
typedef struct {
const char *tag;
gpointer address;
size_t size;
} VAllocRecord;
#define VALLOC_ENTRIES (4096 / sizeof (VAllocRecord) - 1)
typedef struct _VAllocRecordBucket VAllocRecordBucket;
struct _VAllocRecordBucket{
int index;
VAllocRecordBucket *next_bucket;
VAllocRecord entries [VALLOC_ENTRIES];
};
static VAllocRecordBucket *current_bucket;
static VAllocRecordBucket*
alloc_bucket (void)
{
VAllocRecordBucket *old, *bucket;
old = current_bucket;
if (old && old->index < VALLOC_ENTRIES)
return old;
bucket = mono_valloc (NULL, sizeof (VAllocRecordBucket), MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON, NULL);
bucket->index = 0;
do {
old = current_bucket;
bucket->next_bucket = old;
} while (InterlockedCompareExchangePointer ((gpointer)&current_bucket, bucket, old) != old);
return bucket;
}
static VAllocRecord*
get_next_record (void)
{
VAllocRecordBucket *bucket;
int index;
retry:
bucket = current_bucket;
if (!current_bucket)
bucket = alloc_bucket ();
while (bucket->index >= VALLOC_ENTRIES)
bucket = alloc_bucket ();
index = InterlockedIncrement (&bucket->index) - 1;
if (index >= VALLOC_ENTRIES)
goto retry;
return &bucket->entries [index];
}
#define ALIGN_TO(val,align) ((((guint64)val) + ((align) - 1)) & ~((align) - 1))
void
mono_profiler_valloc (gpointer address, size_t size, const char *tag)
{
VAllocRecord *record;
if (!tag)
return;
record = get_next_record ();
record->tag = tag;
record->address = address;
record->size = ALIGN_TO (size, 4096);
}
void
mono_profiler_vfree (gpointer address, size_t size)
{
VAllocRecord *record;
record = get_next_record ();
record->tag = NULL;
record->address = address;
record->size = ALIGN_TO (size, 4096);
}
#if (SIZEOF_VOID_P == 4)
#define UINT_TO_POINTER(u) ((void*)(guint32)(u))
#define POINTER_TO_UINT(p) ((guint32)(void*)(p))
#elif (SIZEOF_VOID_P == 8)
#define UINT_TO_POINTER(u) ((void*)(guint64)(u))
#define POINTER_TO_UINT(p) ((guint64)(void*)(p))
#else
#error Bad size of void pointer
#endif
static void
cat_add_val (GHashTable *hash, const char *tag, size_t new_val)
{
size_t cur_val = POINTER_TO_UINT (g_hash_table_lookup (hash, tag));
g_hash_table_replace (hash, (char*)tag, UINT_TO_POINTER (cur_val + new_val));
}
//This sucks, but tracking partial vfree makes it really complicated
static const char *
find_cat (gpointer address, gpointer limit)
{
int i;
const char *cat = NULL;
VAllocRecordBucket *bucket = current_bucket;
for (bucket = current_bucket; bucket; bucket = bucket->next_bucket) {
for (i = 0; i < MIN (bucket->index, VALLOC_ENTRIES); ++i) {
VAllocRecord *r = &bucket->entries [i];
if (r == limit)
return cat;
if (!r->tag)
continue;
if (r->address <= address && ((char*)r->address + r->size) > (char*)address)
cat = r->tag;
}
}
g_error ("should not happen");
}
static void
cat_del_val (GHashTable *hash, gpointer address, size_t size, gpointer record)
{
size_t cur_val;
const char *cat = find_cat (address, record);
if (!cat) {
printf ("bad vfree %p\n", address);
return;
}
cur_val = POINTER_TO_UINT (g_hash_table_lookup (hash, cat));
g_hash_table_replace (hash, (char*)cat, UINT_TO_POINTER (cur_val - size));
}
static void
dump_cat_alloc (gpointer key, gpointer val, gpointer user_data)
{
printf ("\t%s %zd\n", key, POINTER_TO_UINT (val));
}
//TODO sumarize alloc records
static size_t
dump_valloc (void)
{
int i, entries = 0;
size_t total_alloc = 0, total_free = 0;
VAllocRecordBucket *bucket = current_bucket;
GHashTable *per_cat_alloc = g_hash_table_new (g_str_hash, g_str_equal);
for (bucket = current_bucket; bucket; bucket = bucket->next_bucket) {
for (i = 0; i < MIN (bucket->index, VALLOC_ENTRIES); ++i) {
VAllocRecord *r = &bucket->entries [i];
++entries;
if (r->tag) {
total_alloc += r->size;
cat_add_val (per_cat_alloc, r->tag, r->size);
} else {
total_free += r->size;
cat_del_val (per_cat_alloc, r->address, r->size, r);
}
}
}
g_hash_table_foreach (per_cat_alloc, dump_cat_alloc, NULL);
printf ("VALLOC summary %zd allocated %zd freed - %zd active %d entries\n", total_alloc, total_free, total_alloc - total_free, entries);
g_hash_table_destroy (per_cat_alloc);
return total_alloc;
}
static void
add_nested_hashes (gpointer key, gpointer value, gpointer user_data)
{
GHashTable *prop_hash = (GHashTable*)value;
size_t *size = user_data;
*size += mono_eg_hashtable_get_memory_size (prop_hash);
}
//TODO account for the key/value sizes unique to the cached entry
static size_t
dump_desc (ItemDesc *desc, gpointer *domain)
{
gpointer *slot = (gpointer*)((char*)domain + desc->offset);
size_t size;
const char *kind;
switch (desc->type) {
case MEMPOOL:
if (!*slot)
return 0;
size = mono_mempool_get_allocated (*slot);
kind = "mempool";
break;
case G_HASHTABLE:
if (!*slot)
return 0;
size = mono_eg_hashtable_get_memory_size (*slot);
kind = "g_hashtable";
break;
case NESTED_G_HASHTABLE:
if (!*slot)
return 0;
size = mono_eg_hashtable_get_memory_size (*slot);
g_hash_table_foreach (*slot, add_nested_hashes, &size);
kind = "nested_g_hashtable";
break;
case MONO_HASHTABLE:
if (!*slot)
return 0;
size = mono_hashtable_get_memory_size (*slot);
kind = "mono_hashtable";
break;
case INTERNAL_HASHTABLE:
size = mono_internal_hashtable_get_memory_size ((MonoInternalHashTable*)slot);
kind = "internal_hashtable";
break;
case CONC_HASHTABLE:
if (!*slot)
return 0;
size = mono_conc_hashtable_get_memory_size (*slot);
kind = "conc_hashtable";
break;
case PROPERTY_HASHTABLE:
if (!*slot)
return 0;
size = mono_property_hash_get_memory_size (*slot);
kind = "property_hashtable";
break;
default:
g_assert (0);
}
printf ("\t%s:%s size %zd\n", kind, desc->name, size);
return size;
}
static void
dump_allocs (gpointer key, gpointer val, gpointer user_data)
{
size_t *md_total = user_data;
AllocInfo *info = val;
printf ("\t%s: %zd (%zd allocs)\n", info->tag, info->alloc_bytes, info->alloc_count);
*md_total += info->alloc_bytes;
}
static size_t
dump_memdom (MemDomain *dom, int domsize, ItemDesc *descriptor, char *name)
{
size_t tracked_count = 0;
int i;
size_t total = domsize + dom->extra_alloc;
printf ("%s: size %d extra malloc %zd\n", name, domsize, dom->extra_alloc);
for (i = 0; descriptor [i].type != ITEM_KIND_MAX; ++i)
total += dump_desc (&descriptor [i], dom->address);
printf ("mempool:\n");
g_hash_table_foreach (dom->mempool_allocs, dump_allocs, &tracked_count);
printf ("--total: %zd (mempool tracked %zd)\n\n", total, tracked_count);
g_free (name);
return total;
}
static void
dump_domain (gpointer key, gpointer val, gpointer user_data)
{
size_t *md_total = user_data;
MemDomain *dom = val;
switch (dom->kind) {
case MEMDOM_APPDOMAIN: {
MonoDomain *domain = dom->address;
*md_total += dump_memdom (dom, sizeof (MonoDomain), descriptor_MonoDomain, g_strdup_printf ("domain_%d", domain->domain_id));
break;
}
case MEMDOM_IMAGE: {
MonoImage *image = dom->address;
*md_total += dump_memdom (dom, sizeof (MonoImage), descriptor_MonoImage, g_strdup_printf ("image_%s", image->module_name));
break;
}
case MEMDOM_IMAGE_SET: {
MonoImageSet *set = dom->address;
int i;
GString* name = g_string_new (0);
g_string_append_printf (name, "imageset");
for (i = 0; i < set->nimages; ++i)
g_string_append_printf(name, "_%s", set->images [i]->module_name);
*md_total += dump_memdom (dom, sizeof (MonoImageSet), descriptor_MonoImageSet, g_string_free (name, FALSE));
break;
}
default:
g_assert (0);
}
}
void
mono_memprof_dump (void)
{
size_t grand_total = 0;
memprof_lock ();
printf ("---Alloc Domains---\n");
g_hash_table_foreach (mem_domains, dump_domain, &grand_total);
printf ("---Allocations---\n");
g_hash_table_foreach (global_allocs, dump_allocs, &grand_total);
printf ("---VALLOC---\n");
grand_total += dump_valloc ();
printf ("---------- grand total: %zd\n", grand_total);
memprof_unlock ();
}
+31
View File
@@ -0,0 +1,31 @@
#ifndef __MONO_METADATA_MEMPROF_H__
#define __MONO_METADATA_MEMPROF_H__
#include <glib.h>
#include <mono/utils/mono-compiler.h>
typedef enum {
MEMDOM_APPDOMAIN,
MEMDOM_IMAGE,
MEMDOM_IMAGE_SET,
MEMDOM_MAX,
} MemoryDomainKind;
void mono_profiler_register_memory_domain (gpointer domain, MemoryDomainKind kind) MONO_INTERNAL;
void mono_profiler_free_memory_domain (gpointer domain) MONO_INTERNAL;
void mono_profiler_add_mempool_alloc (gpointer domain, gsize size, const char *tag) MONO_INTERNAL;
/*use this for large allocations that are not automtically tracked */
void mono_profiler_add_allocation (const char *tag, gsize size) MONO_INTERNAL;
void mono_profiler_remove_allocation (const char *tag, gsize size) MONO_INTERNAL;
void mono_profiler_valloc (gpointer address, size_t size, const char *tag) MONO_INTERNAL;
void mono_profiler_vfree (gpointer address, size_t size) MONO_INTERNAL;
void mono_memory_profiler_init (void) MONO_INTERNAL;
void mono_memprof_dump (void);
#endif
+10 -10
View File
@@ -566,21 +566,21 @@ void
mono_image_check_for_module_cctor (MonoImage *image) MONO_INTERNAL;
gpointer
mono_image_alloc (MonoImage *image, guint size) MONO_INTERNAL;
mono_image_alloc (MonoImage *image, guint size, const char *what) MONO_INTERNAL;
gpointer
mono_image_alloc0 (MonoImage *image, guint size) MONO_INTERNAL;
mono_image_alloc0 (MonoImage *image, guint size, const char *what) MONO_INTERNAL;
#define mono_image_new0(image,type,size) ((type *) mono_image_alloc0 (image, sizeof (type)* (size)))
#define mono_image_new0(image,type,size,what) ((type *) mono_image_alloc0 (image, sizeof (type)* (size), what))
char*
mono_image_strdup (MonoImage *image, const char *s) MONO_INTERNAL;
mono_image_strdup (MonoImage *image, const char *s, const char *what) MONO_INTERNAL;
GList*
g_list_prepend_image (MonoImage *image, GList *list, gpointer data) MONO_INTERNAL;
g_list_prepend_image (MonoImage *image, GList *list, gpointer data, const char *what) MONO_INTERNAL;
GSList*
g_slist_append_image (MonoImage *image, GSList *list, gpointer data) MONO_INTERNAL;
g_slist_append_image (MonoImage *image, GSList *list, gpointer data, const char *what) MONO_INTERNAL;
void
mono_image_lock (MonoImage *image) MONO_INTERNAL;
@@ -615,15 +615,15 @@ void
mono_image_append_class_to_reflection_info_set (MonoClass *klass) MONO_INTERNAL;
gpointer
mono_image_set_alloc (MonoImageSet *set, guint size) MONO_INTERNAL;
mono_image_set_alloc (MonoImageSet *set, guint size, const char *what) MONO_INTERNAL;
gpointer
mono_image_set_alloc0 (MonoImageSet *set, guint size) MONO_INTERNAL;
mono_image_set_alloc0 (MonoImageSet *set, guint size, const char *what) MONO_INTERNAL;
char*
mono_image_set_strdup (MonoImageSet *set, const char *s) MONO_INTERNAL;
mono_image_set_strdup (MonoImageSet *set, const char *s, const char *what) MONO_INTERNAL;
#define mono_image_set_new0(image,type,size) ((type *) mono_image_set_alloc0 (image, sizeof (type)* (size)))
#define mono_image_set_new0(image,type,size,what) ((type *) mono_image_set_alloc0 (image, sizeof (type)* (size), what))
MonoType*
mono_metadata_get_shared_type (MonoType *type) MONO_INTERNAL;
+31 -24
View File
@@ -26,6 +26,7 @@
#include "marshal.h"
#include "debug-helpers.h"
#include "abi-details.h"
#include "memory-profiler.h"
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/bsearch.h>
@@ -1268,7 +1269,7 @@ mono_metadata_parse_array_internal (MonoImage *m, MonoGenericContainer *containe
MonoArrayType *array;
MonoType *etype;
array = transient ? g_malloc0 (sizeof (MonoArrayType)) : mono_image_alloc0 (m, sizeof (MonoArrayType));
array = transient ? g_malloc0 (sizeof (MonoArrayType)) : mono_image_alloc0 (m, sizeof (MonoArrayType), "array-type");
etype = mono_metadata_parse_type_full (m, container, MONO_PARSE_TYPE, 0, ptr, &ptr);
if (!etype)
return NULL;
@@ -1277,13 +1278,13 @@ mono_metadata_parse_array_internal (MonoImage *m, MonoGenericContainer *containe
array->numsizes = mono_metadata_decode_value (ptr, &ptr);
if (array->numsizes)
array->sizes = transient ? g_malloc0 (sizeof (int) * array->numsizes) : mono_image_alloc0 (m, sizeof (int) * array->numsizes);
array->sizes = transient ? g_malloc0 (sizeof (int) * array->numsizes) : mono_image_alloc0 (m, sizeof (int) * array->numsizes, "array-sizes");
for (i = 0; i < array->numsizes; ++i)
array->sizes [i] = mono_metadata_decode_value (ptr, &ptr);
array->numlobounds = mono_metadata_decode_value (ptr, &ptr);
if (array->numlobounds)
array->lobounds = transient ? g_malloc0 (sizeof (int) * array->numlobounds) : mono_image_alloc0 (m, sizeof (int) * array->numlobounds);
array->lobounds = transient ? g_malloc0 (sizeof (int) * array->numlobounds) : mono_image_alloc0 (m, sizeof (int) * array->numlobounds, "array-lobounds");
for (i = 0; i < array->numlobounds; ++i)
array->lobounds [i] = mono_metadata_decode_signed_value (ptr, &ptr);
@@ -1581,7 +1582,7 @@ mono_metadata_parse_type_internal (MonoImage *m, MonoGenericContainer *container
int size;
size = MONO_SIZEOF_TYPE + ((gint32)count) * sizeof (MonoCustomMod);
type = transient ? g_malloc0 (size) : mono_image_alloc0 (m, size);
type = transient ? g_malloc0 (size) : mono_image_alloc0 (m, size, "type-with-mods");
type->num_mods = count;
if (count > 64)
g_warning ("got more than 64 modifiers in type");
@@ -1660,7 +1661,7 @@ mono_metadata_parse_type_internal (MonoImage *m, MonoGenericContainer *container
/* printf ("%x %x %c %s\n", type->attrs, type->num_mods, type->pinned ? 'p' : ' ', mono_type_full_name (type)); */
if (type == &stype) {
type = transient ? g_malloc (MONO_SIZEOF_TYPE) : mono_image_alloc (m, MONO_SIZEOF_TYPE);
type = transient ? g_malloc (MONO_SIZEOF_TYPE) : mono_image_alloc (m, MONO_SIZEOF_TYPE, "type");
memcpy (type, &stype, MONO_SIZEOF_TYPE);
}
return type;
@@ -1812,7 +1813,7 @@ mono_metadata_signature_alloc (MonoImage *m, guint32 nparams)
{
MonoMethodSignature *sig;
sig = mono_image_alloc0 (m, MONO_SIZEOF_METHOD_SIGNATURE + ((gint32)nparams) * sizeof (MonoType*));
sig = mono_image_alloc0 (m, MONO_SIZEOF_METHOD_SIGNATURE + ((gint32)nparams) * sizeof (MonoType*), "signature");
sig->param_count = nparams;
sig->sentinelpos = -1;
@@ -1827,7 +1828,7 @@ mono_metadata_signature_dup_internal (MonoImage *image, MonoMemPool *mp, MonoMet
sigsize = MONO_SIZEOF_METHOD_SIGNATURE + sig->param_count * sizeof (MonoType *);
if (image) {
ret = mono_image_alloc (image, sigsize);
ret = mono_image_alloc (image, sigsize, "signature-dup");
} else if (mp) {
ret = mono_mempool_alloc (mp, sigsize);
} else {
@@ -2256,6 +2257,8 @@ get_image_set (MonoImage **images, int nimages)
set->nimages = nimages;
set->images = g_new0 (MonoImage*, nimages);
mono_mutex_init_recursive (&set->lock);
mono_profiler_register_memory_domain (set, MEMDOM_IMAGE_SET);
for (i = 0; i < nimages; ++i)
set->images [i] = images [i];
set->gclass_cache = g_hash_table_new_full (mono_generic_class_hash, mono_generic_class_equal, NULL, (GDestroyNotify)free_generic_class);
@@ -2283,6 +2286,7 @@ static void
delete_image_set (MonoImageSet *set)
{
int i;
mono_profiler_free_memory_domain (set);
g_hash_table_destroy (set->gclass_cache);
g_hash_table_destroy (set->ginst_cache);
@@ -2318,13 +2322,14 @@ mono_image_set_unlock (MonoImageSet *set)
}
gpointer
mono_image_set_alloc (MonoImageSet *set, guint size)
mono_image_set_alloc (MonoImageSet *set, guint size, const char *what)
{
gpointer res;
mono_image_set_lock (set);
if (!set->mempool)
set->mempool = mono_mempool_new_size (1024);
mono_profiler_add_mempool_alloc (set, size, what);
res = mono_mempool_alloc (set->mempool, size);
mono_image_set_unlock (set);
@@ -2332,13 +2337,14 @@ mono_image_set_alloc (MonoImageSet *set, guint size)
}
gpointer
mono_image_set_alloc0 (MonoImageSet *set, guint size)
mono_image_set_alloc0 (MonoImageSet *set, guint size, const char *what)
{
gpointer res;
mono_image_set_lock (set);
if (!set->mempool)
set->mempool = mono_mempool_new_size (1024);
mono_profiler_add_mempool_alloc (set, size, what);
res = mono_mempool_alloc0 (set->mempool, size);
mono_image_set_unlock (set);
@@ -2346,13 +2352,14 @@ mono_image_set_alloc0 (MonoImageSet *set, guint size)
}
char*
mono_image_set_strdup (MonoImageSet *set, const char *s)
mono_image_set_strdup (MonoImageSet *set, const char *s, const char *what)
{
char *res;
mono_image_set_lock (set);
if (!set->mempool)
set->mempool = mono_mempool_new_size (1024);
mono_profiler_add_mempool_alloc (set, strlen (s) + 1, what);
res = mono_mempool_strdup (set->mempool, s);
mono_image_set_unlock (set);
@@ -2851,7 +2858,7 @@ mono_metadata_get_generic_inst (int type_argc, MonoType **type_argv)
ginst = g_hash_table_lookup (set->ginst_cache, ginst);
if (!ginst) {
ginst = mono_image_set_alloc0 (set, size);
ginst = mono_image_set_alloc0 (set, size, "generic-inst");
#ifndef MONO_SMALL_CONFIG
ginst->id = ++next_generic_inst_id;
#endif
@@ -2921,11 +2928,11 @@ mono_metadata_lookup_generic_class (MonoClass *container_class, MonoGenericInst
}
if (is_dynamic) {
MonoDynamicGenericClass *dgclass = mono_image_set_new0 (set, MonoDynamicGenericClass, 1);
MonoDynamicGenericClass *dgclass = mono_image_set_new0 (set, MonoDynamicGenericClass, 1, "sre-dynamic-generic-class");
gclass = &dgclass->generic_class;
gclass->is_dynamic = 1;
} else {
gclass = mono_image_set_new0 (set, MonoGenericClass, 1);
gclass = mono_image_set_new0 (set, MonoGenericClass, 1, "generic-class");
}
gclass->is_tb_open = is_tb_open;
@@ -3086,7 +3093,7 @@ mono_metadata_parse_generic_param (MonoImage *m, MonoGenericContainer *generic_c
/* Create dummy MonoGenericParam */
MonoGenericParam *param;
param = mono_image_alloc0 (m, sizeof (MonoGenericParam));
param = mono_image_alloc0 (m, sizeof (MonoGenericParam), "generic-param");
param->num = index;
param->image = m;
@@ -4038,7 +4045,7 @@ mono_metadata_interfaces_from_typedef_full (MonoImage *meta, guint32 index, Mono
if (heap_alloc_result)
result = g_new0 (MonoClass*, pos - start);
else
result = mono_image_alloc0 (meta, sizeof (MonoClass*) * (pos - start));
result = mono_image_alloc0 (meta, sizeof (MonoClass*) * (pos - start), "class-typedef-interface-list");
pos = start;
while (pos < tdef->rows) {
@@ -4889,7 +4896,7 @@ mono_metadata_type_dup (MonoImage *image, const MonoType *o)
if (o->num_mods)
sizeof_o += o->num_mods * sizeof (MonoCustomMod);
r = image ? mono_image_alloc0 (image, sizeof_o) : g_malloc (sizeof_o);
r = image ? mono_image_alloc0 (image, sizeof_o, "type-dup") : g_malloc (sizeof_o);
memcpy (r, o, sizeof_o);
@@ -5330,12 +5337,12 @@ mono_type_create_from_typespec (MonoImage *image, guint32 type_spec)
static char*
mono_image_strndup (MonoImage *image, const char *data, guint len)
mono_image_strndup (MonoImage *image, const char *data, guint len, const char *what)
{
char *res;
if (!image)
return g_strndup (data, len);
res = mono_image_alloc (image, len + 1);
res = mono_image_alloc (image, len + 1, what);
memcpy (res, data, len);
res [len] = 0;
return res;
@@ -5361,7 +5368,7 @@ mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image
/* fixme: this is incomplete, but I cant find more infos in the specs */
if (image)
res = mono_image_alloc0 (image, sizeof (MonoMarshalSpec));
res = mono_image_alloc0 (image, sizeof (MonoMarshalSpec), "marshal-spec");
else
res = g_new0 (MonoMarshalSpec, 1);
@@ -5412,11 +5419,11 @@ mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image
ptr += len;
/* read custom marshaler type name */
len = mono_metadata_decode_value (ptr, &ptr);
res->data.custom_data.custom_name = mono_image_strndup (image, ptr, len);
res->data.custom_data.custom_name = mono_image_strndup (image, ptr, len, "marshal-spec-custom-name");
ptr += len;
/* read cookie string */
len = mono_metadata_decode_value (ptr, &ptr);
res->data.custom_data.cookie = mono_image_strndup (image, ptr, len);
res->data.custom_data.cookie = mono_image_strndup (image, ptr, len, "marshal-spec-cookie");
res->data.custom_data.image = parent_image;
}
@@ -5802,7 +5809,7 @@ get_constraints (MonoImage *image, int owner, MonoClass ***constraints, MonoGene
}
if (!found)
return TRUE;
res = mono_image_alloc0 (image, sizeof (MonoClass*) * (found + 1));
res = mono_image_alloc0 (image, sizeof (MonoClass*) * (found + 1), "generic-constraints");
for (i = 0, tmp = cons; i < found; ++i, tmp = tmp->next) {
res [i] = tmp->data;
}
@@ -5932,7 +5939,7 @@ mono_metadata_load_generic_params (MonoImage *image, guint32 token, MonoGenericC
mono_metadata_decode_row (tdef, i - 1, cols, MONO_GENERICPARAM_SIZE);
params = NULL;
n = 0;
container = mono_image_alloc0 (image, sizeof (MonoGenericContainer));
container = mono_image_alloc0 (image, sizeof (MonoGenericContainer), "generic-container");
container->image = image;
do {
n++;
@@ -5951,7 +5958,7 @@ mono_metadata_load_generic_params (MonoImage *image, guint32 token, MonoGenericC
} while (cols [MONO_GENERICPARAM_OWNER] == owner);
container->type_argc = n;
container->type_params = mono_image_alloc0 (image, sizeof (MonoGenericParamFull) * n);
container->type_params = mono_image_alloc0 (image, sizeof (MonoGenericParamFull) * n, "generic-container-params");
memcpy (container->type_params, params, sizeof (MonoGenericParamFull) * n);
g_free (params);
container->parent = parent_container;
+7 -7
View File
@@ -155,20 +155,20 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
{
/* Realloc the method info into a mempool */
method = mono_image_alloc0 (image, sizeof (MonoMethodWrapper));
method = mono_image_alloc0 (image, sizeof (MonoMethodWrapper), "mb-method-wrapper");
memcpy (method, mb->method, sizeof (MonoMethodWrapper));
mw = (MonoMethodWrapper*) method;
if (mb->no_dup_name)
method->name = mb->name;
else
method->name = mono_image_strdup (image, mb->name);
method->name = mono_image_strdup (image, mb->name, "mb-method-name");
#ifndef DISABLE_JIT
mw->header = header = (MonoMethodHeader *)
mono_image_alloc0 (image, MONO_SIZEOF_METHOD_HEADER + mb->locals * sizeof (MonoType *));
mono_image_alloc0 (image, MONO_SIZEOF_METHOD_HEADER + mb->locals * sizeof (MonoType *), "mb-method-header");
header->code = mono_image_alloc (image, mb->pos);
header->code = mono_image_alloc (image, mb->pos, "mb-method-code");
memcpy ((char*)header->code, mb->code, mb->pos);
for (i = 0, l = mb->locals_list; l; l = l->next, i++) {
@@ -205,7 +205,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
if (method_is_dynamic (method))
data = g_malloc (sizeof (gpointer) * (i + 1));
else
data = mono_image_alloc (image, sizeof (gpointer) * (i + 1));
data = mono_image_alloc (image, sizeof (gpointer) * (i + 1), "mb-method-data");
/* store the size in the first element */
data [0] = GUINT_TO_POINTER (i);
i = 1;
@@ -232,9 +232,9 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
#endif
if (mb->param_names) {
char **param_names = mono_image_alloc0 (image, signature->param_count * sizeof (gpointer));
char **param_names = mono_image_alloc0 (image, signature->param_count * sizeof (gpointer), "mb-param-name-list");
for (i = 0; i < signature->param_count; ++i)
param_names [i] = mono_image_strdup (image, mb->param_names [i]);
param_names [i] = mono_image_strdup (image, mb->param_names [i], "mb-param-name");
mono_image_lock (image);
if (!image->wrapper_param_names)
+2 -2
View File
@@ -1034,7 +1034,7 @@ mono_monitor_get_fast_enter_method (MonoMethod *monitor_enter_method)
res = register_fastpath (mono_mb_create_method (mb, mono_signature_no_pinvoke (monitor_enter_method), 5), fast_path_idx);
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (WrapperInfo));
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (WrapperInfo), "monitor-wrapper-info");
info->subtype = is_v4 ? WRAPPER_SUBTYPE_FAST_MONITOR_ENTER_V4 : WRAPPER_SUBTYPE_FAST_MONITOR_ENTER;
mono_marshal_set_wrapper_info (res, info);
@@ -1195,7 +1195,7 @@ mono_monitor_get_fast_exit_method (MonoMethod *monitor_exit_method)
res = register_fastpath (mono_mb_create_method (mb, mono_signature_no_pinvoke (monitor_exit_method), 5), FASTPATH_EXIT);
mono_mb_free (mb);
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (WrapperInfo));
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (WrapperInfo), "monitor-wrapper-info");
info->subtype = WRAPPER_SUBTYPE_FAST_MONITOR_EXIT;
mono_marshal_set_wrapper_info (res, info);
+8
View File
@@ -477,6 +477,14 @@ mono_g_hash_table_print_stats (MonoGHashTable *table)
printf ("Size: %d Table Size: %d Max Chain Length: %d\n", table->in_use, table->table_size, max_chain_size);
}
size_t
mono_hashtable_get_memory_size (MonoGHashTable *hashtable)
{
return sizeof (MonoGHashTable) +
hashtable->in_use * sizeof (Slot) +
hashtable->table_size * sizeof (Slot*);
}
#ifdef HAVE_SGEN_GC
/* GC marker function */
+1 -1
View File
@@ -1614,7 +1614,7 @@ char *
mono_string_to_utf8_ignore (MonoString *s) MONO_INTERNAL;
char *
mono_string_to_utf8_image_ignore (MonoImage *image, MonoString *s) MONO_INTERNAL;
mono_string_to_utf8_image_ignore (MonoImage *image, MonoString *s, const char *what) MONO_INTERNAL;
char *
mono_string_to_utf8_mp_ignore (MonoMemPool *mp, MonoString *s) MONO_INTERNAL;
+21 -21
View File
@@ -85,7 +85,7 @@ static void
free_main_args (void);
static char *
mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s, gboolean ignore_error, MonoError *error);
mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s, gboolean ignore_error, const char *what, MonoError *error);
#define ldstr_lock() mono_mutex_lock (&ldstr_section)
@@ -1492,7 +1492,7 @@ init_thunk_free_lists (MonoDomain *domain)
{
if (domain->thunk_free_lists)
return;
domain->thunk_free_lists = mono_domain_alloc0 (domain, sizeof (gpointer) * NUM_FREE_LISTS);
domain->thunk_free_lists = mono_domain_alloc0 (domain, sizeof (gpointer) * NUM_FREE_LISTS, "thunk-free-lists");
}
static int
@@ -1714,7 +1714,7 @@ mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtab
/* If not found, make a new one */
if (!gvc) {
gvc = mono_domain_alloc (domain, sizeof (GenericVirtualCase));
gvc = mono_domain_alloc (domain, sizeof (GenericVirtualCase), "generic-virtual-case");
gvc->method = method;
gvc->code = code;
gvc->count = 0;
@@ -1937,7 +1937,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean
mono_stats.used_class_count++;
mono_stats.class_vtable_size += vtable_size;
interface_offsets = mono_domain_alloc0 (domain, vtable_size);
interface_offsets = mono_domain_alloc0 (domain, vtable_size, "runtime-vtable");
if (ARCH_USE_IMT)
vt = (MonoVTable*) ((char*)interface_offsets + imt_table_bytes);
@@ -1988,7 +1988,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean
if (bitmap != default_bitmap)
g_free (bitmap);
} else {
vt->vtable [class->vtable_size] = mono_domain_alloc0 (domain, class_size);
vt->vtable [class->vtable_size] = mono_domain_alloc0 (domain, class_size, "static-data");
}
vt->has_static_fields = TRUE;
mono_stats.class_static_data_size += class_size;
@@ -2149,7 +2149,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean
/* this is a bounded memory retention issue: may want to
* handle it differently when we'll have a rcu-like system.
*/
runtime_info = mono_image_alloc0 (class->image, MONO_SIZEOF_CLASS_RUNTIME_INFO + new_size * sizeof (gpointer));
runtime_info = mono_image_alloc0 (class->image, MONO_SIZEOF_CLASS_RUNTIME_INFO + new_size * sizeof (gpointer), "runtime-info");
runtime_info->max_domain = new_size - 1;
/* copy the stuff from the older info */
if (old_info) {
@@ -2266,7 +2266,7 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
mono_stats.class_vtable_size += vtsize + extra_interface_vtsize;
interface_offsets = mono_domain_alloc0 (domain, vtsize + extra_interface_vtsize);
interface_offsets = mono_domain_alloc0 (domain, vtsize + extra_interface_vtsize, "runtime-vtable-proxy");
if (ARCH_USE_IMT)
pvt = (MonoVTable*) (interface_offsets + MONO_IMT_SIZE);
else
@@ -2304,7 +2304,7 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
#ifdef COMPRESSED_INTERFACE_BITMAP
bitmap = g_malloc0 (bsize);
#else
bitmap = mono_domain_alloc0 (domain, bsize);
bitmap = mono_domain_alloc0 (domain, bsize, "interface bitmap");
#endif
if (! ARCH_USE_IMT) {
@@ -2358,7 +2358,7 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
#ifdef COMPRESSED_INTERFACE_BITMAP
bcsize = mono_compress_bitmap (NULL, bitmap, bsize);
pvt->interface_bitmap = mono_domain_alloc0 (domain, bcsize);
pvt->interface_bitmap = mono_domain_alloc0 (domain, bcsize, "interface bitmap");
mono_compress_bitmap (pvt->interface_bitmap, bitmap, bsize);
g_free (bitmap);
#else
@@ -2489,7 +2489,7 @@ static gpointer*
copy_remote_class_key (MonoDomain *domain, gpointer *key)
{
int key_size = (GPOINTER_TO_UINT (key [0]) + 1) * sizeof (gpointer);
gpointer *mp_key = mono_domain_alloc (domain, key_size);
gpointer *mp_key = mono_domain_alloc (domain, key_size, "remote-class-key");
memcpy (mp_key, key, key_size);
@@ -2536,12 +2536,12 @@ mono_remote_class (MonoDomain *domain, MonoString *class_name, MonoClass *proxy_
key = mp_key;
if (proxy_class->flags & TYPE_ATTRIBUTE_INTERFACE) {
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*));
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*), "remote-class");
rc->interface_count = 1;
rc->interfaces [0] = proxy_class;
rc->proxy_class = mono_defaults.marshalbyrefobject_class;
} else {
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS);
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS, "remote-class");
rc->interface_count = 0;
rc->proxy_class = proxy_class;
}
@@ -2582,7 +2582,7 @@ clone_remote_class (MonoDomain *domain, MonoRemoteClass* remote_class, MonoClass
if (extra_class->flags & TYPE_ATTRIBUTE_INTERFACE) {
int i,j;
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*) * (remote_class->interface_count + 1));
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*) * (remote_class->interface_count + 1), "remote-class");
rc->proxy_class = remote_class->proxy_class;
rc->interface_count = remote_class->interface_count + 1;
@@ -2597,7 +2597,7 @@ clone_remote_class (MonoDomain *domain, MonoRemoteClass* remote_class, MonoClass
rc->interfaces [j] = extra_class;
} else {
// Replace the old class. The interface array is the same
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*) * remote_class->interface_count);
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*) * remote_class->interface_count, "remote-class");
rc->proxy_class = extra_class;
rc->interface_count = remote_class->interface_count;
if (rc->interface_count > 0)
@@ -5674,9 +5674,9 @@ mono_string_to_utf8_ignore (MonoString *s)
* Same as mono_string_to_utf8_ignore, but allocate the string from the image mempool.
*/
char *
mono_string_to_utf8_image_ignore (MonoImage *image, MonoString *s)
mono_string_to_utf8_image_ignore (MonoImage *image, MonoString *s, const char *what)
{
return mono_string_to_utf8_internal (NULL, image, s, TRUE, NULL);
return mono_string_to_utf8_internal (NULL, image, s, TRUE, what, NULL);
}
/**
@@ -5688,7 +5688,7 @@ mono_string_to_utf8_image_ignore (MonoImage *image, MonoString *s)
char *
mono_string_to_utf8_mp_ignore (MonoMemPool *mp, MonoString *s)
{
return mono_string_to_utf8_internal (mp, NULL, s, TRUE, NULL);
return mono_string_to_utf8_internal (mp, NULL, s, TRUE, NULL, NULL);
}
@@ -5801,7 +5801,7 @@ mono_string_from_utf32 (mono_unichar4 *data)
}
static char *
mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s, gboolean ignore_error, MonoError *error)
mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s, gboolean ignore_error, const char *what, MonoError *error)
{
char *r;
char *mp_s;
@@ -5822,7 +5822,7 @@ mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s,
if (mp)
mp_s = mono_mempool_alloc (mp, len);
else
mp_s = mono_image_alloc (image, len);
mp_s = mono_image_alloc (image, len, what);
memcpy (mp_s, r, len);
@@ -5840,7 +5840,7 @@ mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s,
char *
mono_string_to_utf8_image (MonoImage *image, MonoString *s, MonoError *error)
{
return mono_string_to_utf8_internal (NULL, image, s, FALSE, error);
return mono_string_to_utf8_internal (NULL, image, s, FALSE, NULL, error);
}
/**
@@ -5852,7 +5852,7 @@ mono_string_to_utf8_image (MonoImage *image, MonoString *s, MonoError *error)
char *
mono_string_to_utf8_mp (MonoMemPool *mp, MonoString *s, MonoError *error)
{
return mono_string_to_utf8_internal (mp, NULL, s, FALSE, error);
return mono_string_to_utf8_internal (mp, NULL, s, FALSE, NULL, error);
}
+60 -60
View File
@@ -278,10 +278,10 @@ sigbuffer_free (SigBuffer *buf)
* from the C heap.
*/
static gpointer
image_g_malloc (MonoImage *image, guint size)
image_g_malloc (MonoImage *image, guint size, const char *what)
{
if (image)
return mono_image_alloc (image, size);
return mono_image_alloc (image, size, what);
else
return g_malloc (size);
}
@@ -294,30 +294,30 @@ image_g_malloc (MonoImage *image, guint size)
* from the C heap.
*/
static gpointer
image_g_malloc0 (MonoImage *image, guint size)
image_g_malloc0 (MonoImage *image, guint size, const char *what)
{
if (image)
return mono_image_alloc0 (image, size);
return mono_image_alloc0 (image, size, what);
else
return g_malloc0 (size);
}
#ifndef DISABLE_REFLECTION_EMIT
static char*
image_strdup (MonoImage *image, const char *s)
image_strdup (MonoImage *image, const char *s, const char *what)
{
if (image)
return mono_image_strdup (image, s);
return mono_image_strdup (image, s, what);
else
return g_strdup (s);
}
#endif
#define image_g_new(image,struct_type, n_structs) \
((struct_type *) image_g_malloc (image, ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
#define image_g_new(image,struct_type, n_structs,what) \
((struct_type *) image_g_malloc (image, ((gsize) sizeof (struct_type)) * ((gsize) (n_structs)), what))
#define image_g_new0(image,struct_type, n_structs) \
((struct_type *) image_g_malloc0 (image, ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
#define image_g_new0(image,struct_type, n_structs,what) \
((struct_type *) image_g_malloc0 (image, ((gsize) sizeof (struct_type)) * ((gsize) (n_structs)), what))
static void
@@ -949,7 +949,7 @@ method_encode_clauses (MonoImage *image, MonoDynamicImage *assembly, MonoReflect
guint32 finally_start;
int i, j, clause_index;;
clauses = image_g_new0 (image, MonoExceptionClause, num_clauses);
clauses = image_g_new0 (image, MonoExceptionClause, num_clauses, "sre-exception-clauses");
clause_index = 0;
for (i = mono_array_length (ilgen->ex_handlers) - 1; i >= 0; --i) {
@@ -1218,7 +1218,7 @@ mono_custom_attrs_from_builders (MonoImage *alloc_img, MonoImage *image, MonoArr
}
count -= not_visible;
ainfo = image_g_malloc0 (alloc_img, MONO_SIZEOF_CUSTOM_ATTR_INFO + sizeof (MonoCustomAttrEntry) * count);
ainfo = image_g_malloc0 (alloc_img, MONO_SIZEOF_CUSTOM_ATTR_INFO + sizeof (MonoCustomAttrEntry) * count, "sre-custom-attribure-info");
ainfo->image = image;
ainfo->num_attrs = count;
@@ -1227,7 +1227,7 @@ mono_custom_attrs_from_builders (MonoImage *alloc_img, MonoImage *image, MonoArr
for (i = 0; i < count; ++i) {
cattr = (MonoReflectionCustomAttr*)mono_array_get (cattrs, gpointer, i);
if (custom_attr_visible (image, cattr)) {
unsigned char *saved = mono_image_alloc (image, mono_array_length (cattr->data));
unsigned char *saved = mono_image_alloc (image, mono_array_length (cattr->data), "sre-custom-attr");
memcpy (saved, mono_array_addr (cattr->data, char, 0), mono_array_length (cattr->data));
ainfo->attrs [index].ctor = cattr->ctor->method;
ainfo->attrs [index].data = saved;
@@ -9357,7 +9357,7 @@ parameters_to_signature (MonoImage *image, MonoArray *parameters) {
count = parameters? mono_array_length (parameters): 0;
sig = image_g_malloc0 (image, MONO_SIZEOF_METHOD_SIGNATURE + sizeof (MonoType*) * count);
sig = image_g_malloc0 (image, MONO_SIZEOF_METHOD_SIGNATURE + sizeof (MonoType*) * count, "sre-signature");
sig->param_count = count;
sig->sentinelpos = -1; /* FIXME */
for (i = 0; i < count; ++i)
@@ -9948,7 +9948,7 @@ mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb)
return;
}
klass = mono_image_alloc0 (&tb->module->dynamic_image->image, sizeof (MonoClass));
klass = mono_image_alloc0 (&tb->module->dynamic_image->image, sizeof (MonoClass), "sre-class");
klass->image = &tb->module->dynamic_image->image;
@@ -10068,11 +10068,11 @@ mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb)
g_assert (tb->generic_container && (tb->generic_container->owner.klass == klass));
klass->generic_container = mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer));
klass->generic_container = mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer), "sre-generic-container");
klass->generic_container->owner.klass = klass;
klass->generic_container->type_argc = count;
klass->generic_container->type_params = mono_image_alloc0 (klass->image, sizeof (MonoGenericParamFull) * count);
klass->generic_container->type_params = mono_image_alloc0 (klass->image, sizeof (MonoGenericParamFull) * count, "sre-generic-container-params");
klass->is_generic = 1;
@@ -10149,7 +10149,7 @@ mono_marshal_spec_from_builder (MonoImage *image, MonoAssembly *assembly,
{
MonoMarshalSpec *res;
res = image_g_new0 (image, MonoMarshalSpec, 1);
res = image_g_new0 (image, MonoMarshalSpec, 1, "sre-marshal-spec");
res->native = minfo->type;
switch (minfo->type) {
@@ -10268,9 +10268,9 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
if ((rmb->attrs & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(rmb->iattrs & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
m = (MonoMethod *)image_g_new0 (image, MonoMethodPInvoke, 1);
m = (MonoMethod *)image_g_new0 (image, MonoMethodPInvoke, 1, "sre-method-pinvoke");
else
m = (MonoMethod *)image_g_new0 (image, MonoMethodWrapper, 1);
m = (MonoMethod *)image_g_new0 (image, MonoMethodWrapper, 1, "sre-method-wrapper");
wrapperm = (MonoMethodWrapper*)m;
@@ -10278,7 +10278,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
m->slot = -1;
m->flags = rmb->attrs;
m->iflags = rmb->iattrs;
m->name = mono_string_to_utf8_image_ignore (image, rmb->name);
m->name = mono_string_to_utf8_image_ignore (image, rmb->name, "sre-method-name");
m->klass = klass;
m->signature = sig;
m->sre_method = TRUE;
@@ -10294,9 +10294,9 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
} else if (m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
m->signature->pinvoke = 1;
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1);
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1, "sre-method-aux");
method_aux->dllentry = rmb->dllentry ? mono_string_to_utf8_image (image, rmb->dllentry, &error) : image_strdup (image, m->name);
method_aux->dllentry = rmb->dllentry ? mono_string_to_utf8_image (image, rmb->dllentry, &error) : image_strdup (image, m->name, "sre-dllentry");
g_assert (mono_error_ok (&error));
method_aux->dll = mono_string_to_utf8_image (image, rmb->dll, &error);
g_assert (mono_error_ok (&error));
@@ -10339,9 +10339,9 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
}
}
header = image_g_malloc0 (image, MONO_SIZEOF_METHOD_HEADER + num_locals * sizeof (MonoType*));
header = image_g_malloc0 (image, MONO_SIZEOF_METHOD_HEADER + num_locals * sizeof (MonoType*), "sre-method-header");
header->code_size = code_size;
header->code = image_g_malloc (image, code_size);
header->code = image_g_malloc (image, code_size, "sre-method-code");
memcpy ((char*)header->code, code, code_size);
header->max_stack = max_stack;
header->init_locals = rmb->init_locals;
@@ -10351,7 +10351,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
MonoReflectionLocalBuilder *lb =
mono_array_get (rmb->ilgen->locals, MonoReflectionLocalBuilder*, i);
header->locals [i] = image_g_new0 (image, MonoType, 1);
header->locals [i] = image_g_new0 (image, MonoType, 1, "sre-localvar");
memcpy (header->locals [i], mono_reflection_type_get_handle ((MonoReflectionType*)lb->type), MONO_SIZEOF_TYPE);
}
@@ -10371,7 +10371,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
g_assert (container);
container->type_argc = count;
container->type_params = image_g_new0 (image, MonoGenericParamFull, count);
container->type_params = image_g_new0 (image, MonoGenericParamFull, count, "sre-generic-container-params");
container->owner.method = m;
m->is_generic = TRUE;
@@ -10415,7 +10415,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
m->wrapper_type = MONO_WRAPPER_DYNAMIC_METHOD;
mw->method_data = data = image_g_new (image, gpointer, rmb->nrefs + 1);
mw->method_data = data = image_g_new (image, gpointer, rmb->nrefs + 1, "sre-method-data");
data [0] = GUINT_TO_POINTER (rmb->nrefs);
for (i = 0; i < rmb->nrefs; ++i)
data [i + 1] = rmb->refs [i];
@@ -10426,8 +10426,8 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
/* Parameter info */
if (rmb->pinfo) {
if (!method_aux)
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1);
method_aux->param_names = image_g_new0 (image, char *, mono_method_signature (m)->param_count + 1);
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1, "sre-method-aux");
method_aux->param_names = image_g_new0 (image, char *, mono_method_signature (m)->param_count + 1, "sre-method-param-name-list");
for (i = 0; i <= m->signature->param_count; ++i) {
MonoReflectionParamBuilder *pb;
if ((pb = mono_array_get (rmb->pinfo, MonoReflectionParamBuilder*, i))) {
@@ -10444,8 +10444,8 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
const char *p2;
if (!method_aux->param_defaults) {
method_aux->param_defaults = image_g_new0 (image, guint8*, m->signature->param_count + 1);
method_aux->param_default_types = image_g_new0 (image, guint32, m->signature->param_count + 1);
method_aux->param_defaults = image_g_new0 (image, guint8*, m->signature->param_count + 1, "sre-method-param-default-value-list");
method_aux->param_default_types = image_g_new0 (image, guint32, m->signature->param_count + 1, "sre-method-param-default-type-list");
}
assembly = (MonoDynamicImage*)klass->image;
idx = encode_constant (assembly, pb->def_value, &def_type);
@@ -10453,7 +10453,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
p = assembly->blob.data + idx;
len = mono_metadata_decode_blob_size (p, &p2);
len += p2 - p;
method_aux->param_defaults [i] = image_g_malloc (image, len);
method_aux->param_defaults [i] = image_g_malloc (image, len, "sre-method-param-default-value");
method_aux->param_default_types [i] = def_type;
memcpy ((gpointer)method_aux->param_defaults [i], p, len);
}
@@ -10464,7 +10464,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
}
if (pb->cattrs) {
if (!method_aux->param_cattr)
method_aux->param_cattr = image_g_new0 (image, MonoCustomAttrInfo*, m->signature->param_count + 1);
method_aux->param_cattr = image_g_new0 (image, MonoCustomAttrInfo*, m->signature->param_count + 1, "sre-method-aux-custom-attribute");
method_aux->param_cattr [i] = mono_custom_attrs_from_builders (image, klass->image, pb->cattrs);
}
}
@@ -10479,7 +10479,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
if ((pb = mono_array_get (rmb->pinfo, MonoReflectionParamBuilder*, i))) {
if (pb->marshal_info) {
if (specs == NULL)
specs = image_g_new0 (image, MonoMarshalSpec*, sig->param_count + 1);
specs = image_g_new0 (image, MonoMarshalSpec*, sig->param_count + 1, "sre-marshal-space-list");
specs [pb->position] =
mono_marshal_spec_from_builder (image, klass->image->assembly, pb->marshal_info);
}
@@ -10487,7 +10487,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
}
if (specs != NULL) {
if (!method_aux)
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1);
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1, "sre-method-aux");
method_aux->param_marshall = specs;
}
@@ -10827,9 +10827,9 @@ mono_reflection_generic_class_initialize (MonoReflectionGenericClass *type, Mono
dgclass->count_fields = fields ? mono_array_length (fields) : 0;
dgclass->fields = mono_image_set_new0 (gclass->owner, MonoClassField, dgclass->count_fields);
dgclass->field_objects = mono_image_set_new0 (gclass->owner, MonoObject*, dgclass->count_fields);
dgclass->field_generic_types = mono_image_set_new0 (gclass->owner, MonoType*, dgclass->count_fields);
dgclass->fields = mono_image_set_new0 (gclass->owner, MonoClassField, dgclass->count_fields, "sre-generic-class-field-list");
dgclass->field_objects = mono_image_set_new0 (gclass->owner, MonoObject*, dgclass->count_fields, "sre-generic-class-field-object-list");
dgclass->field_generic_types = mono_image_set_new0 (gclass->owner, MonoType*, dgclass->count_fields, "sre-generic-class-field-generic-type-list");
for (i = 0; i < dgclass->count_fields; i++) {
MonoObject *obj = mono_array_get (fields, gpointer, i);
@@ -10855,7 +10855,7 @@ mono_reflection_generic_class_initialize (MonoReflectionGenericClass *type, Mono
if (inflated_field) {
g_free (inflated_field);
} else {
dgclass->fields [i].name = mono_image_set_strdup (gclass->owner, dgclass->fields [i].name);
dgclass->fields [i].name = mono_image_set_strdup (gclass->owner, dgclass->fields [i].name, "sre-generic-class-field-name");
}
}
@@ -10915,7 +10915,7 @@ fix_partial_generic_class (MonoClass *klass)
if (klass->method.count != gklass->method.count) {
klass->method.count = gklass->method.count;
klass->methods = mono_image_alloc (klass->image, sizeof (MonoMethod*) * (klass->method.count + 1));
klass->methods = mono_image_alloc (klass->image, sizeof (MonoMethod*) * (klass->method.count + 1), "sre-class-method-list");
for (i = 0; i < klass->method.count; i++) {
klass->methods [i] = mono_class_inflate_generic_method_full (
@@ -10925,7 +10925,7 @@ fix_partial_generic_class (MonoClass *klass)
if (klass->interface_count && klass->interface_count != gklass->interface_count) {
klass->interface_count = gklass->interface_count;
klass->interfaces = mono_image_alloc (klass->image, sizeof (MonoClass*) * gklass->interface_count);
klass->interfaces = mono_image_alloc (klass->image, sizeof (MonoClass*) * gklass->interface_count, "sre-class-inferface-list");
klass->interfaces_packed = NULL; /*make setup_interface_offsets happy*/
for (i = 0; i < gklass->interface_count; ++i) {
@@ -10940,7 +10940,7 @@ fix_partial_generic_class (MonoClass *klass)
if (klass->field.count != gklass->field.count) {
klass->field.count = gklass->field.count;
klass->fields = image_g_new0 (klass->image, MonoClassField, klass->field.count);
klass->fields = image_g_new0 (klass->image, MonoClassField, klass->field.count, "sre-class-field-list");
for (i = 0; i < klass->field.count; i++) {
klass->fields [i] = gklass->fields [i];
@@ -10980,7 +10980,7 @@ ensure_runtime_vtable (MonoClass *klass)
num = tb->ctors? mono_array_length (tb->ctors): 0;
num += tb->num_methods;
klass->method.count = num;
klass->methods = mono_image_alloc (klass->image, sizeof (MonoMethod*) * num);
klass->methods = mono_image_alloc (klass->image, sizeof (MonoMethod*) * num, "sre-class-method-list");
num = tb->ctors? mono_array_length (tb->ctors): 0;
for (i = 0; i < num; ++i)
klass->methods [i] = ctorbuilder_to_mono_method (klass, mono_array_get (tb->ctors, MonoReflectionCtorBuilder*, i));
@@ -10991,7 +10991,7 @@ ensure_runtime_vtable (MonoClass *klass)
if (tb->interfaces) {
klass->interface_count = mono_array_length (tb->interfaces);
klass->interfaces = mono_image_alloc (klass->image, sizeof (MonoClass*) * klass->interface_count);
klass->interfaces = mono_image_alloc (klass->image, sizeof (MonoClass*) * klass->interface_count, "sre-class-interface-list");
for (i = 0; i < klass->interface_count; ++i) {
MonoType *iface = mono_type_array_get_and_resolve (tb->interfaces, i);
klass->interfaces [i] = mono_class_from_mono_type (iface);
@@ -11152,9 +11152,9 @@ typebuilder_setup_fields (MonoClass *klass, MonoError *error)
return;
}
klass->fields = image_g_new0 (image, MonoClassField, klass->field.count);
klass->fields = image_g_new0 (image, MonoClassField, klass->field.count, "sre-class-field-list");
mono_class_alloc_ext (klass);
klass->ext->field_def_values = image_g_new0 (image, MonoFieldDefaultValue, klass->field.count);
klass->ext->field_def_values = image_g_new0 (image, MonoFieldDefaultValue, klass->field.count, "sre-class-field-def-values");
/*
This is, guess what, a hack.
The issue is that the runtime doesn't know how to setup the fields of a typebuider and crash.
@@ -11181,7 +11181,7 @@ typebuilder_setup_fields (MonoClass *klass, MonoError *error)
if ((fb->attrs & FIELD_ATTRIBUTE_HAS_FIELD_RVA) && (rva_data = fb->rva_data)) {
char *base = mono_array_addr (rva_data, char, 0);
size_t size = mono_array_length (rva_data);
char *data = mono_image_alloc (klass->image, size);
char *data = mono_image_alloc (klass->image, size, "sre-class-rva-data");
memcpy (data, base, size);
klass->ext->field_def_values [i].data = data;
}
@@ -11202,7 +11202,7 @@ typebuilder_setup_fields (MonoClass *klass, MonoError *error)
p = assembly->blob.data + idx;
len = mono_metadata_decode_blob_size (p, &p2);
len += p2 - p;
klass->ext->field_def_values [i].data = mono_image_alloc (image, len);
klass->ext->field_def_values [i].data = mono_image_alloc (image, len, "sre-class-field-def-values");
memcpy ((gpointer)klass->ext->field_def_values [i].data, p, len);
}
}
@@ -11223,12 +11223,12 @@ typebuilder_setup_properties (MonoClass *klass, MonoError *error)
mono_error_init (error);
if (!klass->ext)
klass->ext = image_g_new0 (image, MonoClassExt, 1);
klass->ext = image_g_new0 (image, MonoClassExt, 1, "sre-class-ext");
klass->ext->property.count = tb->properties ? mono_array_length (tb->properties) : 0;
klass->ext->property.first = 0;
properties = image_g_new0 (image, MonoProperty, klass->ext->property.count);
properties = image_g_new0 (image, MonoProperty, klass->ext->property.count, "sre-class-property-list");
klass->ext->properties = properties;
for (i = 0; i < klass->ext->property.count; ++i) {
pb = mono_array_get (tb->properties, MonoReflectionPropertyBuilder*, i);
@@ -11248,14 +11248,14 @@ typebuilder_setup_properties (MonoClass *klass, MonoError *error)
const char *p, *p2;
MonoDynamicImage *assembly = (MonoDynamicImage*)klass->image;
if (!klass->ext->prop_def_values)
klass->ext->prop_def_values = image_g_new0 (image, MonoFieldDefaultValue, klass->ext->property.count);
klass->ext->prop_def_values = image_g_new0 (image, MonoFieldDefaultValue, klass->ext->property.count, "sre-class-property-def-value-list");
properties [i].attrs |= PROPERTY_ATTRIBUTE_HAS_DEFAULT;
idx = encode_constant (assembly, pb->def_value, &klass->ext->prop_def_values [i].def_type);
/* Copy the data from the blob since it might get realloc-ed */
p = assembly->blob.data + idx;
len = mono_metadata_decode_blob_size (p, &p2);
len += p2 - p;
klass->ext->prop_def_values [i].data = mono_image_alloc (image, len);
klass->ext->prop_def_values [i].data = mono_image_alloc (image, len, "sre-class-property-def-value");
memcpy ((gpointer)klass->ext->prop_def_values [i].data, p, len);
}
}
@@ -11307,12 +11307,12 @@ typebuilder_setup_events (MonoClass *klass, MonoError *error)
mono_error_init (error);
if (!klass->ext)
klass->ext = image_g_new0 (image, MonoClassExt, 1);
klass->ext = image_g_new0 (image, MonoClassExt, 1, "sre-class-ext");
klass->ext->event.count = tb->events ? mono_array_length (tb->events) : 0;
klass->ext->event.first = 0;
events = image_g_new0 (image, MonoEvent, klass->ext->event.count);
events = image_g_new0 (image, MonoEvent, klass->ext->event.count, "sre-class-event-list");
klass->ext->events = events;
for (i = 0; i < klass->ext->event.count; ++i) {
eb = mono_array_get (tb->events, MonoReflectionEventBuilder*, i);
@@ -11331,7 +11331,7 @@ typebuilder_setup_events (MonoClass *klass, MonoError *error)
#ifndef MONO_SMALL_CONFIG
if (eb->other_methods) {
int j;
events [i].other = image_g_new0 (image, MonoMethod*, mono_array_length (eb->other_methods) + 1);
events [i].other = image_g_new0 (image, MonoMethod*, mono_array_length (eb->other_methods) + 1, "sre-class-event-other-list");
for (j = 0; j < mono_array_length (eb->other_methods); ++j) {
MonoReflectionMethodBuilder *mb =
mono_array_get (eb->other_methods,
@@ -11482,7 +11482,7 @@ mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb)
for (i = 0; i < mono_array_length (tb->subtypes); ++i) {
MonoReflectionTypeBuilder *subtb = mono_array_get (tb->subtypes, MonoReflectionTypeBuilder*, i);
mono_class_alloc_ext (klass);
klass->ext->nested_classes = g_list_prepend_image (klass->image, klass->ext->nested_classes, mono_class_from_mono_type (mono_reflection_type_get_handle ((MonoReflectionType*)subtb)));
klass->ext->nested_classes = g_list_prepend_image (klass->image, klass->ext->nested_classes, mono_class_from_mono_type (mono_reflection_type_get_handle ((MonoReflectionType*)subtb)), "sre-class-nested-classes");
}
}
@@ -11562,7 +11562,7 @@ mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam
image = &gparam->tbuilder->module->dynamic_image->image;
param = mono_image_new0 (image, MonoGenericParamFull, 1);
param = mono_image_new0 (image, MonoGenericParamFull, 1, "sre-generic-param");
param->info.name = mono_string_to_utf8_image (image, gparam->name, &error);
g_assert (mono_error_ok (&error));
@@ -11572,7 +11572,7 @@ mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam
if (!gparam->mbuilder->generic_container) {
MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)gparam->mbuilder->type;
MonoClass *klass = mono_class_from_mono_type (mono_reflection_type_get_handle ((MonoReflectionType*)tb));
gparam->mbuilder->generic_container = mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer));
gparam->mbuilder->generic_container = mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer), "sre-generic-param-mcontainer");
gparam->mbuilder->generic_container->is_method = TRUE;
/*
* Cannot set owner.method, since the MonoMethod is not created yet.
@@ -11584,7 +11584,7 @@ mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam
} else if (gparam->tbuilder) {
if (!gparam->tbuilder->generic_container) {
MonoClass *klass = mono_class_from_mono_type (mono_reflection_type_get_handle ((MonoReflectionType*)gparam->tbuilder));
gparam->tbuilder->generic_container = mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer));
gparam->tbuilder->generic_container = mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer), "sre-generic-param-tcontainer");
gparam->tbuilder->generic_container->owner.klass = klass;
}
param->param.owner = gparam->tbuilder->generic_container;
+2 -2
View File
@@ -836,7 +836,7 @@ create_allocator (int atype)
mono_mb_patch_short_branch (mb, pos);
clause = mono_image_alloc0 (mono_defaults.corlib, sizeof (MonoExceptionClause));
clause = mono_image_alloc0 (mono_defaults.corlib, sizeof (MonoExceptionClause), "sgen-exception-clause");
clause->try_offset = mono_mb_get_label (mb);
/* vtable->klass->sizes.element_size */
@@ -1048,7 +1048,7 @@ create_allocator (int atype)
mono_mb_free (mb);
mono_method_get_header (res)->init_locals = FALSE;
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (AllocatorWrapperInfo));
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (AllocatorWrapperInfo), "sgen-wrapper-info");
info->gc_name = "sgen";
info->alloc_type = atype;
mono_marshal_set_wrapper_info (res, info);
+1 -1
View File
@@ -129,7 +129,7 @@ sgen_alloc_internal_dynamic (size_t size, int type, gboolean assert_on_failure)
void *p;
if (size > allocator_sizes [NUM_ALLOCATORS - 1]) {
p = sgen_alloc_os_memory (size, SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE, NULL);
p = sgen_alloc_os_memory (size, SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE, "huge internal alloc");
if (!p)
sgen_assert_memory_alloc (NULL, size, description_for_type (type));
} else {
+3 -3
View File
@@ -229,7 +229,7 @@ get_los_section_memory (size_t size)
if (!sgen_memgov_try_alloc_space (LOS_SECTION_SIZE, SPACE_LOS))
return NULL;
section = sgen_alloc_os_memory_aligned (LOS_SECTION_SIZE, LOS_SECTION_SIZE, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, NULL);
section = sgen_alloc_os_memory_aligned (LOS_SECTION_SIZE, LOS_SECTION_SIZE, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, "LOS section");
if (!section)
return NULL;
@@ -347,7 +347,7 @@ sgen_los_alloc_large_inner (MonoVTable *vtable, size_t size)
#ifdef LOS_DUMMY
if (!los_segment)
los_segment = sgen_alloc_os_memory (LOS_SEGMENT_SIZE, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, NULL);
los_segment = sgen_alloc_os_memory (LOS_SEGMENT_SIZE, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, "LOS segment");
los_segment_index = ALIGN_UP (los_segment_index);
obj = (LOSObject*)(los_segment + los_segment_index);
@@ -368,7 +368,7 @@ sgen_los_alloc_large_inner (MonoVTable *vtable, size_t size)
alloc_size += pagesize - 1;
alloc_size &= ~(pagesize - 1);
if (sgen_memgov_try_alloc_space (alloc_size, SPACE_LOS)) {
obj = sgen_alloc_os_memory (alloc_size, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, NULL);
obj = sgen_alloc_os_memory (alloc_size, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, "LOS object");
}
} else {
obj = get_los_section_memory (size + sizeof (LOSObject));
+1 -2
View File
@@ -378,8 +378,7 @@ ms_get_empty_block (void)
*/
int alloc_num = MS_BLOCK_ALLOC_NUM;
for (;;) {
p = sgen_alloc_os_memory_aligned (MS_BLOCK_SIZE * alloc_num, MS_BLOCK_SIZE, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE,
alloc_num == 1 ? "major heap section" : NULL);
p = sgen_alloc_os_memory_aligned (MS_BLOCK_SIZE * alloc_num, MS_BLOCK_SIZE, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, "major heap section");
if (p)
break;
alloc_num >>= 1;
+2 -2
View File
@@ -305,7 +305,7 @@ sgen_alloc_os_memory (size_t size, SgenAllocFlags flags, const char *assert_desc
g_assert (!(flags & ~(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE)));
ptr = mono_valloc (0, size, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE));
ptr = mono_valloc (0, size, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE), assert_description);
sgen_assert_memory_alloc (ptr, size, assert_description);
if (ptr) {
SGEN_ATOMIC_ADD_P (total_alloc, size);
@@ -323,7 +323,7 @@ sgen_alloc_os_memory_aligned (size_t size, mword alignment, SgenAllocFlags flags
g_assert (!(flags & ~(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE)));
ptr = mono_valloc_aligned (size, alignment, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE));
ptr = mono_valloc_aligned (size, alignment, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE), assert_description);
sgen_assert_memory_alloc (ptr, size, assert_description);
if (ptr) {
SGEN_ATOMIC_ADD_P (total_alloc, size);
+8 -8
View File
@@ -497,7 +497,7 @@ decode_klass_ref (MonoAotModule *module, guint8 *buf, guint8 **endbuf)
g_assert (serial == 0);
} else {
/* Anonymous */
MonoGenericParam *par = (MonoGenericParam*)mono_image_alloc0 (module->assembly->image, sizeof (MonoGenericParamFull));
MonoGenericParam *par = (MonoGenericParam*)mono_image_alloc0 (module->assembly->image, sizeof (MonoGenericParamFull), "aot-runtime-generic-param");
par->num = num;
par->serial = serial;
// FIXME:
@@ -2515,7 +2515,7 @@ alloc0_jit_info_data (MonoDomain *domain, int size, gboolean async_context)
res = mono_domain_alloc0_lock_free (domain, size);
InterlockedExchangeAdd (&async_jit_info_size, size);
} else {
res = mono_domain_alloc0 (domain, size);
res = mono_domain_alloc0 (domain, size, "jit-info-data");
}
return res;
}
@@ -3210,7 +3210,7 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
case MONO_PATCH_INFO_SWITCH:
ji->data.table = mono_mempool_alloc0 (mp, sizeof (MonoJumpInfoBBTable));
ji->data.table->table_size = decode_value (p, &p);
table = mono_domain_alloc (mono_domain_get (), sizeof (gpointer) * ji->data.table->table_size);
table = mono_domain_alloc (mono_domain_get (), sizeof (gpointer) * ji->data.table->table_size, "aot-jump-table");
ji->data.table->table = (MonoBasicBlock**)table;
for (i = 0; i < ji->data.table->table_size; i++)
table [i] = (gpointer)(gssize)decode_value (p, &p);
@@ -3218,7 +3218,7 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
case MONO_PATCH_INFO_R4: {
guint32 val;
ji->data.target = mono_domain_alloc0 (mono_domain_get (), sizeof (float));
ji->data.target = mono_domain_alloc0 (mono_domain_get (), sizeof (float), "aot-float");
val = decode_value (p, &p);
*(float*)ji->data.target = *(float*)&val;
break;
@@ -3227,7 +3227,7 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
guint32 val [2];
guint64 v;
ji->data.target = mono_domain_alloc0 (mono_domain_get (), sizeof (double));
ji->data.target = mono_domain_alloc0 (mono_domain_get (), sizeof (double), "aot-double");
val [0] = decode_value (p, &p);
val [1] = decode_value (p, &p);
@@ -4833,7 +4833,7 @@ mono_aot_get_lazy_fetch_trampoline (guint32 slot)
*/
if (!addr)
addr = load_function (amodule, "rgctx_fetch_trampoline_general");
info = mono_domain_alloc0 (mono_get_root_domain (), sizeof (gpointer) * 2);
info = mono_domain_alloc0 (mono_get_root_domain (), sizeof (gpointer) * 2, "aot-lazy-fetch-tramp");
info [0] = GUINT_TO_POINTER (slot);
info [1] = mono_create_specific_trampoline (GUINT_TO_POINTER (slot), MONO_TRAMPOLINE_RGCTX_LAZY_FETCH, mono_get_root_domain (), NULL);
code = mono_aot_get_static_rgctx_trampoline (info, addr);
@@ -4865,7 +4865,7 @@ mono_aot_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem
}
/* Save the entries into an array */
buf = mono_domain_alloc (domain, (real_count + 1) * 2 * sizeof (gpointer));
buf = mono_domain_alloc (domain, (real_count + 1) * 2 * sizeof (gpointer), "aot-imt-entries-array");
index = 0;
for (i = 0; i < count; ++i) {
MonoIMTCheckItem *item = imt_entries [i];
@@ -4877,7 +4877,7 @@ mono_aot_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem
buf [(index * 2)] = item->key;
if (item->has_target_code) {
gpointer *p = mono_domain_alloc (domain, sizeof (gpointer));
gpointer *p = mono_domain_alloc (domain, sizeof (gpointer), "aot-imt-entry");
*p = item->value.target_code;
buf [(index * 2) + 1] = p;
} else {
+6 -6
View File
@@ -4550,7 +4550,7 @@ handle_delegate_ctor (MonoCompile *cfg, MonoClass *klass, MonoInst *target, Mono
domain_jit_info (domain)->method_code_hash = g_hash_table_new (NULL, NULL);
code_slot = g_hash_table_lookup (domain_jit_info (domain)->method_code_hash, method);
if (!code_slot) {
code_slot = mono_domain_alloc0 (domain, sizeof (gpointer));
code_slot = mono_domain_alloc0 (domain, sizeof (gpointer), "delegate-code-slot");
g_hash_table_insert (domain_jit_info (domain)->method_code_hash, method, code_slot);
}
mono_domain_unlock (domain);
@@ -7669,7 +7669,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
#endif
/* FIXME: we should really allocate this only late in the compilation process */
f = mono_domain_alloc (cfg->domain, sizeof (float));
f = mono_domain_alloc (cfg->domain, sizeof (float), "jit-ldc-float");
CHECK_OPSIZE (5);
CHECK_STACK_OVF (1);
@@ -7706,7 +7706,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
#endif
/* FIXME: we should really allocate this only late in the compilation process */
d = mono_domain_alloc (cfg->domain, sizeof (double));
d = mono_domain_alloc (cfg->domain, sizeof (double), "jit-ldc-double");
CHECK_OPSIZE (9);
CHECK_STACK_OVF (1);
@@ -9755,7 +9755,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (cfg->compile_aot)
EMIT_NEW_AOTCONST (cfg, args [2], MONO_PATCH_INFO_CASTCLASS_CACHE, NULL);
else
EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer)));
EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer), "jit-castclass-cache"));
/*The wrapper doesn't inline well so the bloat of inlining doesn't pay off.*/
@@ -9819,7 +9819,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (cfg->compile_aot)
EMIT_NEW_AOTCONST (cfg, args [2], MONO_PATCH_INFO_CASTCLASS_CACHE, NULL);
else
EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer)));
EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer), "jit-isinst-cache"));
*sp++ = mono_emit_method_call (cfg, mono_isinst, args, NULL);
ip += 5;
@@ -9891,7 +9891,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (cfg->compile_aot)
EMIT_NEW_AOTCONST (cfg, args [2], MONO_PATCH_INFO_CASTCLASS_CACHE, NULL);
else
EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer)));
EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer), "jit-castclass-cache"));
/* The wrapper doesn't inline well so the bloat of inlining doesn't pay off. */
*sp++ = emit_castclass_with_cache (cfg, klass, args, &bblock);
+2 -2
View File
@@ -1256,8 +1256,8 @@ mono_arch_init (void)
/* amd64_alu_membase_imm_size (code, X86_CMP, AMD64_R11, 0, 0, 4); */
single_step_fault_size = 4;
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), flags);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), flags);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), flags, "sdb");
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), flags, "sdb");
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
mono_aot_register_jit_icall ("mono_amd64_throw_exception", mono_amd64_throw_exception);
+2 -2
View File
@@ -907,8 +907,8 @@ mono_arch_init (void)
#else
{
#endif
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
}
+2 -2
View File
@@ -1971,13 +1971,13 @@ mono_setup_altstack (MonoJitTlsData *tls)
if (mono_mprotect (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE)) {
/* mprotect can fail for the main thread stack */
gpointer gaddr = mono_valloc (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON|MONO_MMAP_FIXED);
gpointer gaddr = mono_valloc (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON|MONO_MMAP_FIXED, "altstack-guard");
g_assert (gaddr == tls->stack_ovf_guard_base);
tls->stack_ovf_valloced = TRUE;
}
/* Setup an alternate signal stack */
tls->signal_stack = mono_valloc (0, MONO_ARCH_SIGNAL_STACK_SIZE, MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON);
tls->signal_stack = mono_valloc (0, MONO_ARCH_SIGNAL_STACK_SIZE, MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON, "alt-stack");
tls->signal_stack_size = MONO_ARCH_SIGNAL_STACK_SIZE;
g_assert (tls->signal_stack);
+1 -1
View File
@@ -2370,7 +2370,7 @@ create_map (MonoCompile *cfg)
encoded_size = endbuf - buf;
alloc_size = sizeof (GCEncodedMap) + ALIGN_TO (encoded_size, map->callsite_entry_size) + (map->callsite_entry_size * map->ncallsites) + bitmaps_size;
emap = mono_domain_alloc0 (cfg->domain, alloc_size);
emap = mono_domain_alloc0 (cfg->domain, alloc_size, "gc-map");
//emap->ref_slots = map->ref_slots;
/* Encoded fixed fields */
+10 -10
View File
@@ -158,7 +158,7 @@ set_info_templates (MonoImage *image, MonoRuntimeGenericContextTemplate *templat
/* FIXME: quadratic! */
while (length < type_argc) {
template->method_templates = g_slist_append_image (image, template->method_templates, NULL);
template->method_templates = g_slist_append_image (image, template->method_templates, NULL, "gsharing-method-templates");
length++;
}
@@ -353,7 +353,7 @@ alloc_template (MonoClass *class)
num_allocted++;
num_bytes += size;
return mono_image_alloc0 (class->image, size);
return mono_image_alloc0 (class->image, size, "gsharing-alloc-template");
}
static MonoRuntimeGenericContextInfoTemplate*
@@ -374,7 +374,7 @@ alloc_oti (MonoImage *image)
num_allocted++;
num_bytes += size;
return mono_image_alloc0 (image, size);
return mono_image_alloc0 (image, size, "gsharing-alloc-oti");
}
#define MONO_RGCTX_SLOT_USED_MARKER ((gpointer)&mono_defaults.object_class->byval_arg)
@@ -577,7 +577,7 @@ inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *co
MonoDomain *domain = mono_domain_get ();
int i;
res = mono_domain_alloc0 (domain, sizeof (MonoGSharedVtMethodInfo));
res = mono_domain_alloc0 (domain, sizeof (MonoGSharedVtMethodInfo), "gsharedvt-method-info");
/*
res->nlocals = info->nlocals;
res->locals_types = g_new0 (MonoType*, info->nlocals);
@@ -585,7 +585,7 @@ inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *co
res->locals_types [i] = mono_class_inflate_generic_type (info->locals_types [i], context);
*/
res->num_entries = oinfo->num_entries;
res->entries = mono_domain_alloc0 (domain, sizeof (MonoRuntimeGenericContextInfoTemplate) * oinfo->num_entries);
res->entries = mono_domain_alloc0 (domain, sizeof (MonoRuntimeGenericContextInfoTemplate) * oinfo->num_entries, "gsharedvt-entries");
for (i = 0; i < oinfo->num_entries; ++i) {
MonoRuntimeGenericContextInfoTemplate *otemplate = &oinfo->entries [i];
MonoRuntimeGenericContextInfoTemplate *template = &res->entries [i];
@@ -605,7 +605,7 @@ inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *co
MonoJumpInfoGSharedVtCall *res;
MonoDomain *domain = mono_domain_get ();
res = mono_domain_alloc0 (domain, sizeof (MonoJumpInfoGSharedVtCall));
res = mono_domain_alloc0 (domain, sizeof (MonoJumpInfoGSharedVtCall), "gshared-vtcall");
/* Keep the original signature */
res->sig = info->sig;
@@ -938,7 +938,7 @@ class_type_info (MonoDomain *domain, MonoClass *class, MonoRgctxInfoType info_ty
}
case MONO_RGCTX_INFO_CAST_CACHE: {
/*First slot is the cache itself, the second the vtable.*/
gpointer **cache_data = mono_domain_alloc0 (domain, sizeof (gpointer) * 2);
gpointer **cache_data = mono_domain_alloc0 (domain, sizeof (gpointer) * 2, "gshared-cast-cache");
cache_data [1] = (gpointer)class;
return cache_data;
}
@@ -1187,7 +1187,7 @@ mini_get_gsharedvt_wrapper (gboolean gsharedvt_in, gpointer addr, MonoMethodSign
num_trampolines ++;
/* Cache it */
tramp_info = mono_domain_alloc0 (domain, sizeof (GSharedVtTrampInfo));
tramp_info = mono_domain_alloc0 (domain, sizeof (GSharedVtTrampInfo), "gsharedvt-wrapper");
memcpy (tramp_info, &tinfo, sizeof (GSharedVtTrampInfo));
mono_domain_lock (domain);
@@ -1263,7 +1263,7 @@ instantiate_info (MonoDomain *domain, MonoRuntimeGenericContextInfoTemplate *oti
return mono_compile_method (mono_marshal_get_remoting_invoke_with_check (data));
#endif
case MONO_RGCTX_INFO_METHOD_DELEGATE_CODE:
return mono_domain_alloc0 (domain, sizeof (gpointer));
return mono_domain_alloc0 (domain, sizeof (gpointer), "gshared-delegate-code");
case MONO_RGCTX_INFO_CLASS_FIELD:
return data;
case MONO_RGCTX_INFO_FIELD_OFFSET: {
@@ -1799,7 +1799,7 @@ alloc_rgctx_array (MonoDomain *domain, int n, gboolean is_mrgctx)
static int mrgctx_bytes_alloced = 0;
int size = mono_class_rgctx_get_array_size (n, is_mrgctx) * sizeof (gpointer);
gpointer array = mono_domain_alloc0 (domain, size);
gpointer array = mono_domain_alloc0 (domain, size, "gshared-array");
if (!inited) {
mono_counters_register ("RGCTX num arrays alloced", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_num_alloced);
+2 -2
View File
@@ -709,8 +709,8 @@ mono_arch_init (void)
{
mono_mutex_init_recursive (&mini_arch_mutex);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
}
+2 -2
View File
@@ -622,8 +622,8 @@ mono_arch_init (void)
mono_mutex_init_recursive (&mini_arch_mutex);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
mono_aot_register_jit_icall ("mono_ppc_throw_exception", mono_ppc_throw_exception);
+2 -2
View File
@@ -1262,8 +1262,8 @@ mono_arch_init (void)
mono_mutex_init_recursive (&mini_arch_mutex);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ, "sdb");
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ, "sdb");
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
code = (guint8 *) &breakpointCode;
+5 -5
View File
@@ -116,7 +116,7 @@ mono_create_static_rgctx_trampoline (MonoMethod *m, gpointer addr)
mono_domain_lock (domain);
/* Duplicates inserted while we didn't hold the lock are OK */
info = mono_domain_alloc (domain, sizeof (RgctxTrampInfo));
info = mono_domain_alloc (domain, sizeof (RgctxTrampInfo), "rgctx-tramp-info");
info->m = m;
info->addr = addr;
g_hash_table_insert (domain_jit_info (domain)->static_rgctx_trampoline_hash, info, res);
@@ -983,7 +983,7 @@ create_delegate_trampoline_data (MonoDomain *domain, MonoClass *klass, MonoMetho
invoke = mono_get_delegate_invoke (klass);
g_assert (invoke);
tramp_data = mono_domain_alloc0 (domain, sizeof (MonoDelegateTrampInfo));
tramp_data = mono_domain_alloc0 (domain, sizeof (MonoDelegateTrampInfo), "delegate-tramp-info");
tramp_data->invoke = invoke;
tramp_data->invoke_sig = mono_method_signature (invoke);
tramp_data->impl_this = mono_arch_get_delegate_invoke_impl (mono_method_signature (invoke), TRUE);
@@ -1444,7 +1444,7 @@ mono_create_jump_trampoline (MonoDomain *domain, MonoMethod *method, gboolean ad
code = mono_create_specific_trampoline (method, MONO_TRAMPOLINE_JUMP, mono_domain_get (), &code_size);
g_assert (code_size);
ji = mono_domain_alloc0 (domain, MONO_SIZEOF_JIT_INFO);
ji = mono_domain_alloc0 (domain, MONO_SIZEOF_JIT_INFO, "jit-info");
ji->code_start = code;
ji->code_size = code_size;
ji->d.method = method;
@@ -1507,7 +1507,7 @@ mono_create_jit_trampoline_from_token (MonoImage *image, guint32 token)
MonoDomain *domain = mono_domain_get ();
guint8 *buf, *start;
buf = start = mono_domain_alloc0 (domain, 2 * sizeof (gpointer));
buf = start = mono_domain_alloc0 (domain, 2 * sizeof (gpointer), "tramp-from-token");
*(gpointer*)(gpointer)buf = image;
buf += sizeof (gpointer);
@@ -1547,7 +1547,7 @@ mono_create_delegate_trampoline_info (MonoDomain *domain, MonoClass *klass, Mono
tramp_info->invoke_impl = mono_create_specific_trampoline (tramp_info, MONO_TRAMPOLINE_DELEGATE, domain, &code_size);
g_assert (code_size);
dpair = mono_domain_alloc0 (domain, sizeof (MonoClassMethodPair));
dpair = mono_domain_alloc0 (domain, sizeof (MonoClassMethodPair), "class-method-pair");
memcpy (dpair, &pair, sizeof (MonoClassMethodPair));
/* store trampoline address */
+2 -2
View File
@@ -760,8 +760,8 @@ mono_arch_init (void)
{
mono_mutex_init_recursive (&mini_arch_mutex);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ, "sdb");
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
mono_aot_register_jit_icall ("mono_x86_throw_exception", mono_x86_throw_exception);
+12 -12
View File
@@ -3402,7 +3402,7 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
domain_jit_info (domain)->method_code_hash = g_hash_table_new (NULL, NULL);
code_slot = g_hash_table_lookup (domain_jit_info (domain)->method_code_hash, patch_info->data.method);
if (!code_slot) {
code_slot = mono_domain_alloc0 (domain, sizeof (gpointer));
code_slot = mono_domain_alloc0 (domain, sizeof (gpointer), "code-slot");
g_hash_table_insert (domain_jit_info (domain)->method_code_hash, patch_info->data.method, code_slot);
}
mono_domain_unlock (domain);
@@ -3421,7 +3421,7 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
jump_table = mono_code_manager_reserve (mono_dynamic_code_hash_lookup (domain, method)->code_mp, sizeof (gpointer) * patch_info->data.table->table_size);
} else {
if (mono_aot_only) {
jump_table = mono_domain_alloc (domain, sizeof (gpointer) * patch_info->data.table->table_size);
jump_table = mono_domain_alloc (domain, sizeof (gpointer) * patch_info->data.table->table_size, "jump-table");
} else {
jump_table = mono_domain_code_reserve (domain, sizeof (gpointer) * patch_info->data.table->table_size);
}
@@ -3680,7 +3680,7 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
break;
}
case MONO_PATCH_INFO_CASTCLASS_CACHE: {
target = mono_domain_alloc0 (domain, sizeof (gpointer));
target = mono_domain_alloc0 (domain, sizeof (gpointer), "castclass-cache");
break;
}
case MONO_PATCH_INFO_JIT_TLS_ID: {
@@ -3898,7 +3898,7 @@ mono_postprocess_patches (MonoCompile *cfg)
mono_domain_lock (domain);
jlist = g_hash_table_lookup (domain_jit_info (domain)->jump_target_hash, patch_info->data.method);
if (!jlist) {
jlist = mono_domain_alloc0 (domain, sizeof (MonoJumpList));
jlist = mono_domain_alloc0 (domain, sizeof (MonoJumpList), "jump-list");
g_hash_table_insert (domain_jit_info (domain)->jump_target_hash, patch_info->data.method, jlist);
}
jlist->list = g_slist_prepend (jlist->list, ip);
@@ -4307,7 +4307,7 @@ create_jit_info_for_trampoline (MonoMethod *wrapper, MonoTrampInfo *info)
uw_info = mono_unwind_ops_encode (info->unwind_ops, &info_len);
}
jinfo = mono_domain_alloc0 (domain, MONO_SIZEOF_JIT_INFO);
jinfo = mono_domain_alloc0 (domain, MONO_SIZEOF_JIT_INFO, "jit-info");
jinfo->d.method = wrapper;
jinfo->code_start = info->code;
jinfo->code_size = info->code_size;
@@ -4391,7 +4391,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
} else {
jinfo = mono_domain_alloc0 (cfg->domain, MONO_SIZEOF_JIT_INFO +
(num_clauses * sizeof (MonoJitExceptionInfo)) +
generic_info_size + holes_size + arch_eh_info_size + cas_size);
generic_info_size + holes_size + arch_eh_info_size + cas_size, "jit-info");
}
jinfo->d.method = cfg->method_to_register;
@@ -4416,7 +4416,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
if (cfg->method->dynamic)
gi->generic_sharing_context = g_new0 (MonoGenericSharingContext, 1);
else
gi->generic_sharing_context = mono_domain_alloc0 (cfg->domain, sizeof (MonoGenericSharingContext));
gi->generic_sharing_context = mono_domain_alloc0 (cfg->domain, sizeof (MonoGenericSharingContext), "gsharing-context");
mini_init_gsctx (cfg->method->dynamic ? NULL : cfg->domain, NULL, cfg->gsctx_context, gi->generic_sharing_context);
if ((method_to_compile->flags & METHOD_ATTRIBUTE_STATIC) ||
@@ -4448,7 +4448,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
if (cfg->method->dynamic)
gi->locations = g_malloc0 (gi->nlocs * sizeof (MonoDwarfLocListEntry));
else
gi->locations = mono_domain_alloc0 (cfg->domain, gi->nlocs * sizeof (MonoDwarfLocListEntry));
gi->locations = mono_domain_alloc0 (cfg->domain, gi->nlocs * sizeof (MonoDwarfLocListEntry), "dwarf-loc-list-entry");
i = 0;
for (l = loclist; l; l = l->next) {
memcpy (&(gi->locations [i]), l->data, sizeof (MonoDwarfLocListEntry));
@@ -4693,7 +4693,7 @@ get_gsharedvt_type (MonoType *t)
mono_image_unlock (image);
if (res)
return res;
copy = mono_image_alloc0 (image, sizeof (MonoGenericParamFull));
copy = mono_image_alloc0 (image, sizeof (MonoGenericParamFull), "gsharedvt-generic-param");
memcpy (copy, par, sizeof (MonoGenericParamFull));
} else {
copy = g_memdup (par, sizeof (MonoGenericParamFull));
@@ -4874,7 +4874,7 @@ mini_init_gsctx (MonoDomain *domain, MonoMemPool *mp, MonoGenericContext *contex
if (context && context->class_inst) {
inst = context->class_inst;
if (domain)
gsctx->var_is_vt = mono_domain_alloc0 (domain, sizeof (gboolean) * inst->type_argc);
gsctx->var_is_vt = mono_domain_alloc0 (domain, sizeof (gboolean) * inst->type_argc, "gsharing-context-var-is-vt");
else if (mp)
gsctx->var_is_vt = mono_mempool_alloc0 (mp, sizeof (gboolean) * inst->type_argc);
else
@@ -4890,7 +4890,7 @@ mini_init_gsctx (MonoDomain *domain, MonoMemPool *mp, MonoGenericContext *contex
if (context && context->method_inst) {
inst = context->method_inst;
if (domain)
gsctx->mvar_is_vt = mono_domain_alloc0 (domain, sizeof (gboolean) * inst->type_argc);
gsctx->mvar_is_vt = mono_domain_alloc0 (domain, sizeof (gboolean) * inst->type_argc, "gsharing-context-mvar-is-vt");
else if (mp)
gsctx->mvar_is_vt = mono_mempool_alloc0 (mp, sizeof (gboolean) * inst->type_argc);
else
@@ -7103,7 +7103,7 @@ mini_create_ftnptr (MonoDomain *domain, gpointer addr)
desc [1] = NULL;
# elif defined(__ppc64__) || defined(__powerpc64__)
desc = mono_domain_alloc0 (domain, 3 * sizeof (gpointer));
desc = mono_domain_alloc0 (domain, 3 * sizeof (gpointer), "ftnptr-desc");
desc [0] = addr;
desc [1] = NULL;
+15 -3
View File
@@ -25,6 +25,7 @@
#define HAVE_MORECORE 0
#define NO_MALLINFO 1
#include <mono/utils/dlmalloc.h>
#include <mono/metadata/memory-profiler.h>
/*
* Quickstart
@@ -1360,6 +1361,7 @@ static int win32munmap(void* ptr, size_t size) {
if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr ||
minfo.State != MEM_COMMIT || minfo.RegionSize > size)
return -1;
mono_profiler_vfree (cptr, size);
if (VirtualFree(cptr, 0, MEM_RELEASE) == 0)
return -1;
cptr += minfo.RegionSize;
@@ -3448,6 +3450,7 @@ static void* sys_alloc(mstate m, size_t nb) {
if (rsize > nb) { /* Fail if wraps around zero */
char* mp = (char*)(CALL_MMAP(rsize));
if (mp != CMFAIL) {
mono_profiler_valloc (mp, rsize, "dlmalloc");
tbase = mp;
tsize = rsize;
mmap_flag = IS_MMAPPED_BIT;
@@ -3567,6 +3570,7 @@ static size_t release_unused_segments(mstate m) {
unlink_large_chunk(m, tp);
}
if (CALL_MUNMAP(base, size) == 0) {
mono_profiler_vfree (base, size);
released += size;
m->footprint -= size;
/* unlink obsoleted record */
@@ -3605,6 +3609,7 @@ static int sys_trim(mstate m, size_t pad) {
/* Prefer mremap, fall back to munmap */
if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) ||
(CALL_MUNMAP(sp->base + newsize, extra) == 0)) {
mono_profiler_vfree (sp->base + newsize, extra);
released = extra;
}
}
@@ -4219,8 +4224,10 @@ void dlfree(void* mem) {
if ((prevsize & IS_MMAPPED_BIT) != 0) {
prevsize &= ~IS_MMAPPED_BIT;
psize += prevsize + MMAP_FOOT_PAD;
if (CALL_MUNMAP((char*)p - prevsize, psize) == 0)
if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) {
mono_profiler_vfree ((char*)p - prevsize, psize);
fm->footprint -= psize;
}
goto postaction;
}
else {
@@ -4443,6 +4450,7 @@ mspace create_mspace(size_t capacity, int locked) {
size_t tsize = granularity_align(rs);
char* tbase = (char*)(CALL_MMAP(tsize));
if (tbase != CMFAIL) {
mono_profiler_valloc (table, tsize, "dlmalloc");
m = init_user_mstate(tbase, tsize);
m->seg.sflags = IS_MMAPPED_BIT;
set_lock(m, locked);
@@ -4476,8 +4484,10 @@ size_t destroy_mspace(mspace msp) {
flag_t flag = sp->sflags;
sp = sp->next;
if ((flag & IS_MMAPPED_BIT) && !(flag & EXTERN_BIT) &&
CALL_MUNMAP(base, size) == 0)
CALL_MUNMAP(base, size) == 0) {
mono_profiler_vfree (base, size);
freed += size;
}
}
}
else {
@@ -4627,8 +4637,10 @@ void mspace_free(mspace msp, void* mem) {
if ((prevsize & IS_MMAPPED_BIT) != 0) {
prevsize &= ~IS_MMAPPED_BIT;
psize += prevsize + MMAP_FOOT_PAD;
if (CALL_MUNMAP((char*)p - prevsize, psize) == 0)
if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) {
mono_profiler_vfree ((char*)p - prevsize, psize);
fm->footprint -= psize;
}
goto postaction;
}
else {
+1 -1
View File
@@ -103,7 +103,7 @@ mono_thread_small_id_alloc (void)
if (hazard_table == NULL) {
hazard_table = mono_valloc (NULL,
sizeof (MonoThreadHazardPointers) * HAZARD_TABLE_MAX_SIZE,
MONO_MMAP_NONE);
MONO_MMAP_NONE, "hazard-pointer");
}
g_assert (hazard_table != NULL);
+6 -6
View File
@@ -140,9 +140,9 @@ prot_flags_for_activate (int activate)
}
static void*
mono_sgen_alloc_os_memory (size_t size, int activate)
mono_sgen_alloc_os_memory (size_t size, int activate, const char *name)
{
return mono_valloc (0, size, prot_flags_for_activate (activate));
return mono_valloc (0, size, prot_flags_for_activate (activate), name);
}
static void
@@ -153,15 +153,15 @@ mono_sgen_free_os_memory (void *addr, size_t size)
/* size must be a power of 2 */
static void*
mono_sgen_alloc_os_memory_aligned (size_t size, size_t alignment, gboolean activate)
mono_sgen_alloc_os_memory_aligned (size_t size, size_t alignment, gboolean activate, const char *name)
{
return mono_valloc_aligned (size, alignment, prot_flags_for_activate (activate));
return mono_valloc_aligned (size, alignment, prot_flags_for_activate (activate), name);
}
static gpointer
alloc_sb (Descriptor *desc)
{
gpointer sb_header = mono_sgen_alloc_os_memory_aligned (SB_SIZE, SB_SIZE, TRUE);
gpointer sb_header = mono_sgen_alloc_os_memory_aligned (SB_SIZE, SB_SIZE, TRUE, "lock-free-alloc-sb");
g_assert (sb_header == SB_HEADER_FOR_ADDR (sb_header));
DESCRIPTOR_FOR_ADDR (sb_header) = desc;
//g_print ("sb %p for %p\n", sb_header, desc);
@@ -198,7 +198,7 @@ desc_alloc (void)
Descriptor *d;
int i;
desc = mono_sgen_alloc_os_memory (desc_size * NUM_DESC_BATCH, TRUE);
desc = mono_sgen_alloc_os_memory (desc_size * NUM_DESC_BATCH, TRUE, "lock-free-alloc-descriptors");
/* Organize into linked list. */
d = desc;
+1 -1
View File
@@ -37,7 +37,7 @@ alloc_chunk (MonoLockFreeArray *arr)
{
int size = mono_pagesize ();
int num_entries = (size - (sizeof (Chunk) - arr->entry_size * MONO_ZERO_LEN_ARRAY)) / arr->entry_size;
Chunk *chunk = mono_valloc (0, size, MONO_MMAP_READ | MONO_MMAP_WRITE);
Chunk *chunk = mono_valloc (0, size, MONO_MMAP_READ | MONO_MMAP_WRITE, "lock-free-array-chunk");
g_assert (chunk);
chunk->num_entries = num_entries;
return chunk;
+2 -2
View File
@@ -258,9 +258,9 @@ codechunk_valloc (void *preferred, guint32 size)
freelist = g_slist_delete_link (freelist, freelist);
g_hash_table_insert (valloc_freelists, GUINT_TO_POINTER (size), freelist);
} else {
ptr = mono_valloc (preferred, size, MONO_PROT_RWX | ARCH_MAP_FLAGS);
ptr = mono_valloc (preferred, size, MONO_PROT_RWX | ARCH_MAP_FLAGS, "codeman");
if (!ptr && preferred)
ptr = mono_valloc (NULL, size, MONO_PROT_RWX | ARCH_MAP_FLAGS);
ptr = mono_valloc (NULL, size, MONO_PROT_RWX | ARCH_MAP_FLAGS, "codeman");
}
mono_mutex_unlock (&valloc_mutex);
return ptr;
+13 -17
View File
@@ -352,20 +352,16 @@ mono_conc_hashtable_insert (MonoConcurrentHashTable *hash_table, gpointer key, g
}
}
size_t
mono_conc_hashtable_get_memory_size (MonoConcurrentHashTable *hash_table)
{
MonoThreadHazardPointers* hp = mono_hazard_pointer_get ();
size_t size = sizeof (MonoConcurrentHashTable);
conc_table *table = get_hazardous_pointer ((gpointer volatile*)&hash_table->table, hp, 0);
if (table) {
size += sizeof (conc_table);
size += table->table_size * sizeof (key_value_pair);
}
mono_hazard_pointer_clear (hp, 0);
return size;
}
+1
View File
@@ -22,6 +22,7 @@ void mono_conc_hashtable_destroy (MonoConcurrentHashTable *hash_table) MONO_INTE
gpointer mono_conc_hashtable_lookup (MonoConcurrentHashTable *hash_table, gpointer key) MONO_INTERNAL;
gpointer mono_conc_hashtable_insert (MonoConcurrentHashTable *hash_table, gpointer key, gpointer value) MONO_INTERNAL;
gpointer mono_conc_hashtable_remove (MonoConcurrentHashTable *hash_table, gpointer key) MONO_INTERNAL;
size_t mono_conc_hashtable_get_memory_size (MonoConcurrentHashTable *hash_table) MONO_INTERNAL;
#endif
+8
View File
@@ -124,3 +124,11 @@ mono_internal_hash_table_remove (MonoInternalHashTable *table, gpointer key)
g_assert (0);
}
size_t
mono_internal_hashtable_get_memory_size (MonoInternalHashTable *table)
{
return sizeof (MonoInternalHashTable) +
sizeof (gpointer) * table->size;
}
+3
View File
@@ -73,4 +73,7 @@ mono_internal_hash_table_insert (MonoInternalHashTable *table,
void
mono_internal_hash_table_remove (MonoInternalHashTable *table, gpointer key) MONO_INTERNAL;
size_t
mono_internal_hashtable_get_memory_size (MonoInternalHashTable *table) MONO_INTERNAL;
#endif
+33 -16
View File
@@ -30,6 +30,7 @@
#include "mono-mmap.h"
#include "mono-proclib.h"
#include <mono/metadata/memory-profiler.h>
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
@@ -104,7 +105,7 @@ prot_from_flags (int flags)
}
void*
mono_valloc (void *addr, size_t length, int flags)
mono_valloc (void *addr, size_t length, int flags, const char *name)
{
void *ptr;
int mflags = MEM_RESERVE|MEM_COMMIT;
@@ -112,11 +113,13 @@ mono_valloc (void *addr, size_t length, int flags)
/* translate the flags */
ptr = VirtualAlloc (addr, length, mflags, prot);
mono_profiler_valloc (ptr, length, name);
return ptr;
}
void*
mono_valloc_aligned (size_t length, size_t alignment, int flags)
mono_valloc_aligned (size_t length, size_t alignment, int flags, const char *name)
{
int prot = prot_from_flags (flags);
char *mem = VirtualAlloc (NULL, length + alignment, MEM_RESERVE, prot);
@@ -129,14 +132,15 @@ mono_valloc_aligned (size_t length, size_t alignment, int flags)
aligned = VirtualAlloc (aligned, length, MEM_COMMIT, prot);
g_assert (aligned);
mono_profiler_valloc (aligned, length, name);
return aligned;
}
#define HAVE_VALLOC_ALIGNED
int
mono_vfree (void *addr, size_t length)
static int
mono_vfree_internal (void *addr, size_t length)
{
MEMORY_BASIC_INFORMATION mbi;
SIZE_T query_result = VirtualQuery (addr, &mbi, sizeof (mbi));
@@ -293,7 +297,7 @@ prot_from_flags (int flags)
* Returns: NULL on failure, the address of the memory area otherwise
*/
void*
mono_valloc (void *addr, size_t length, int flags)
mono_valloc (void *addr, size_t length, int flags, const char *name)
{
void *ptr;
int mflags = 0;
@@ -317,6 +321,7 @@ mono_valloc (void *addr, size_t length, int flags)
if (ptr == MAP_FAILED)
return NULL;
}
mono_profiler_valloc (ptr, length, name);
return ptr;
}
@@ -329,8 +334,8 @@ mono_valloc (void *addr, size_t length, int flags)
*
* Returns: 0 on success.
*/
int
mono_vfree (void *addr, size_t length)
static int
mono_vfree_internal (void *addr, size_t length)
{
return munmap (addr, length);
}
@@ -453,21 +458,23 @@ mono_pagesize (void)
}
void*
mono_valloc (void *addr, size_t length, int flags)
mono_valloc (void *addr, size_t length, int flags, const char *name)
{
return malloc (length);
void *res = malloc (length);
mono_profiler_valloc (res, length, name);
return res;
}
void*
mono_valloc_aligned (size_t length, size_t alignment, int flags)
mono_valloc_aligned (size_t length, size_t alignment, int flags, const char *name)
{
g_assert_not_reached ();
}
#define HAVE_VALLOC_ALIGNED
int
mono_vfree (void *addr, size_t length)
static int
mono_vfree_internal (void *addr, size_t length)
{
free (addr);
return 0;
@@ -483,6 +490,15 @@ mono_mprotect (void *addr, size_t length, int flags)
}
#endif // HAVE_MMAP
int
mono_vfree (void *addr, size_t length)
{
int res = mono_vfree_internal (addr, length);
if (!res)
mono_profiler_vfree (addr, length);
return res;
}
#if defined(HAVE_SHM_OPEN) && !defined (DISABLE_SHARED_PERFCOUNTERS)
static int use_shared_area;
@@ -709,10 +725,10 @@ mono_shared_area_instances (void **array, int count)
#ifndef HAVE_VALLOC_ALIGNED
void*
mono_valloc_aligned (size_t size, size_t alignment, int flags)
mono_valloc_aligned (size_t size, size_t alignment, int flags, const char *name)
{
/* Allocate twice the memory to be able to put the block on an aligned address */
char *mem = mono_valloc (NULL, size + alignment, flags);
char *mem = mono_valloc (NULL, size + alignment, flags, NULL);
char *aligned;
if (!mem)
@@ -721,10 +737,11 @@ mono_valloc_aligned (size_t size, size_t alignment, int flags)
aligned = aligned_address (mem, size, alignment);
if (aligned > mem)
mono_vfree (mem, aligned - mem);
mono_vfree_internal (mem, aligned - mem);
if (aligned + size < mem + size + alignment)
mono_vfree (aligned + size, (mem + size + alignment) - (aligned + size));
mono_vfree_internal (aligned + size, (mem + size + alignment) - (aligned + size));
mono_profiler_valloc (aligned, size, name);
return aligned;
}
#endif
+2 -2
View File
@@ -31,8 +31,8 @@ MONO_API int mono_file_map_fd (MonoFileMap *fmap);
MONO_API int mono_file_map_close (MonoFileMap *fmap);
MONO_API int mono_pagesize (void);
MONO_API void* mono_valloc (void *addr, size_t length, int flags);
MONO_API void* mono_valloc_aligned (size_t length, size_t alignment, int flags);
MONO_API void* mono_valloc (void *addr, size_t length, int flags, const char *name);
MONO_API void* mono_valloc_aligned (size_t length, size_t alignment, int flags, const char *name);
MONO_API int mono_vfree (void *addr, size_t length);
MONO_API void* mono_file_map (size_t length, int flags, int fd, guint64 offset, void **ret_handle);
MONO_API int mono_file_unmap (void *addr, void *handle);
+18 -1
View File
@@ -81,4 +81,21 @@ mono_property_hash_lookup (MonoPropertyHash *hash, gpointer object, guint32 prop
return NULL;
return g_hash_table_lookup (prop_hash, object);
}
static void
sum_sizes (gpointer key, gpointer value, gpointer user_data)
{
GHashTable *prop_hash = (GHashTable*)value;
size_t *size = user_data;
*size += mono_eg_hashtable_get_memory_size (prop_hash);
}
size_t
mono_property_hash_get_memory_size (MonoPropertyHash *hash)
{
size_t size = sizeof (MonoPropertyHash);
size += mono_eg_hashtable_get_memory_size (hash->hashes);
g_hash_table_foreach (hash->hashes, sum_sizes, &size);
return size;
}
+2
View File
@@ -36,6 +36,8 @@ MONO_API void mono_property_hash_remove_object (MonoPropertyHash *hash, gpointer
MONO_API gpointer mono_property_hash_lookup (MonoPropertyHash *hash, gpointer object, guint32 property);
size_t mono_property_hash_get_memory_size (MonoPropertyHash *hash);
G_END_DECLS
#endif