From: Vlad Brezae Date: Thu, 20 Apr 2017 11:19:47 +0000 (+0300) Subject: [metadata] Don't use static_data_array X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=mono.git;a=commitdiff_plain;h=3d1b921a195cb1146f4a6a766ecdc4eddc34ff3a [metadata] Don't use static_data_array Memory allocated with mono_gc_alloc_fixed is uncollectable both on sgen and boehm. This array serves no other purpose. It should probably be killed entirely, but it's part of the API. --- diff --git a/mono/metadata/domain-internals.h b/mono/metadata/domain-internals.h index 6b3369fd2e4..69e2a7cd689 100644 --- a/mono/metadata/domain-internals.h +++ b/mono/metadata/domain-internals.h @@ -326,11 +326,6 @@ struct _MonoDomain { /* hashtables for Reflection handles */ MonoGHashTable *type_hash; MonoGHashTable *refobject_hash; - /* - * A GC-tracked array to keep references to the static fields of types. - * See note [Domain Static Data Array]. - */ - gpointer *static_data_array; /* maps class -> type initialization exception object */ MonoGHashTable *type_init_exception_hash; /* maps delegate trampoline addr -> delegate object */ @@ -565,9 +560,6 @@ MonoImage *mono_assembly_open_from_bundle (const char *filename, MonoImageOpenStatus *status, gboolean refonly); -MONO_API void -mono_domain_add_class_static_data (MonoDomain *domain, MonoClass *klass, gpointer data, guint32 *bitmap); - MonoAssembly * mono_try_assembly_resolve (MonoDomain *domain, const char *fname, MonoAssembly *requesting, gboolean refonly, MonoError *error); diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index fb2f414570f..2e6a5217007 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -409,7 +409,6 @@ mono_domain_create (void) domain->assembly_bindings_parsed = FALSE; domain->class_vtable_array = g_ptr_array_new (); domain->proxy_vtable_hash = g_hash_table_new ((GHashFunc)mono_ptrarray_hash, (GCompareFunc)mono_ptrarray_equal); - domain->static_data_array = NULL; mono_jit_code_hash_init (&domain->jit_code_hash); domain->ldstr_table = mono_g_hash_table_new_type ((GHashFunc)mono_string_hash, (GCompareFunc)mono_string_equal, MONO_HASH_KEY_VALUE_GC, MONO_ROOT_SOURCE_DOMAIN, "domain string constants table"); domain->num_jit_info_tables = 1; @@ -1150,10 +1149,6 @@ mono_domain_free (MonoDomain *domain, gboolean force) domain->class_vtable_array = NULL; g_hash_table_destroy (domain->proxy_vtable_hash); domain->proxy_vtable_hash = NULL; - if (domain->static_data_array) { - mono_gc_free_fixed (domain->static_data_array); - domain->static_data_array = NULL; - } mono_internal_hash_table_destroy (&domain->jit_code_hash); /* @@ -1453,40 +1448,6 @@ mono_context_get_domain_id (MonoAppContext *context) return context->domain_id; } -/* LOCKING: the caller holds the lock for this domain */ -void -mono_domain_add_class_static_data (MonoDomain *domain, MonoClass *klass, gpointer data, guint32 *bitmap) -{ - /* Note [Domain Static Data Array]: - * - * Entry 0 in the array is the index of the next free slot. - * Entry 1 is the total size of the array. - */ - int next; - if (domain->static_data_array) { - int size = GPOINTER_TO_INT (domain->static_data_array [1]); - next = GPOINTER_TO_INT (domain->static_data_array [0]); - if (next >= size) { - /* 'data' is allocated by alloc_fixed */ - gpointer *new_array = (gpointer *)mono_gc_alloc_fixed (sizeof (gpointer) * (size * 2), MONO_GC_ROOT_DESCR_FOR_FIXED (size * 2), MONO_ROOT_SOURCE_DOMAIN, "static field list"); - mono_gc_memmove_aligned (new_array, domain->static_data_array, sizeof (gpointer) * size); - size *= 2; - new_array [1] = GINT_TO_POINTER (size); - mono_gc_free_fixed (domain->static_data_array); - domain->static_data_array = new_array; - } - } else { - int size = 32; - gpointer *new_array = (gpointer *)mono_gc_alloc_fixed (sizeof (gpointer) * size, MONO_GC_ROOT_DESCR_FOR_FIXED (size), MONO_ROOT_SOURCE_DOMAIN, "static field list"); - next = 2; - new_array [0] = GINT_TO_POINTER (next); - new_array [1] = GINT_TO_POINTER (size); - domain->static_data_array = new_array; - } - domain->static_data_array [next++] = data; - domain->static_data_array [0] = GINT_TO_POINTER (next); -} - /** * mono_get_corlib: * Use this function to get the \c MonoImage* for the \c mscorlib.dll assembly diff --git a/mono/metadata/object.c b/mono/metadata/object.c index ae6b5d774e3..c23c56bafb8 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -1968,7 +1968,6 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro /*g_print ("bitmap 0x%x for %s.%s (size: %d)\n", bitmap [0], klass->name_space, klass->name, class_size);*/ statics_gc_descr = mono_gc_make_descr_from_bitmap (bitmap, max_set + 1); vt->vtable [klass->vtable_size] = mono_gc_alloc_fixed (class_size, statics_gc_descr, MONO_ROOT_SOURCE_STATIC, "managed static variables"); - mono_domain_add_class_static_data (domain, klass, vt->vtable [klass->vtable_size], NULL); if (bitmap != default_bitmap) g_free (bitmap); } else { diff --git a/msvc/mono.def b/msvc/mono.def index 52e1b14888e..11039d6b3f9 100644 --- a/msvc/mono.def +++ b/msvc/mono.def @@ -243,7 +243,6 @@ mono_dl_fallback_register mono_dl_fallback_unregister mono_dl_open mono_dllmap_insert -mono_domain_add_class_static_data mono_domain_assembly_open mono_domain_create mono_domain_create_appdomain diff --git a/msvc/monosgen.def b/msvc/monosgen.def index 5c238113281..35df803f15a 100644 --- a/msvc/monosgen.def +++ b/msvc/monosgen.def @@ -243,7 +243,6 @@ mono_dl_fallback_register mono_dl_fallback_unregister mono_dl_open mono_dllmap_insert -mono_domain_add_class_static_data mono_domain_assembly_open mono_domain_create mono_domain_create_appdomain