+Tue Jul 24 15:15:19 CEST 2007 Paolo Molaro <lupus@ximian.com>
+
+ * loader.c, class-internals.h, reflection.c: removed the per-method
+ generics hashtable: we use the global one through the call of
+ mono_class_inflate_generic_method ().
+
Mon Jul 23 19:43:14 CEST 2007 Paolo Molaro <lupus@ximian.com>
* class.c, metadata.c, class-internals.h: introduce yet another
/* If we're a generic method definition in a generic type definition,
the generic container of the containing class. */
MonoGenericContainer *parent;
- /* If we're a generic method definition, caches all their instantiations. */
- GHashTable *method_hash;
/* the generic type definition or the generic method definition corresponding to this container */
union {
MonoClass *klass;
MonoTableInfo *tables = image->tables;
MonoGenericContext new_context;
MonoGenericInst *inst;
- MonoGenericContainer *container = NULL;
const char *ptr;
guint32 cols [MONO_METHODSPEC_SIZE];
guint32 token, nindex, param_count;
method = ((MonoMethodInflated *) method)->declaring;
}
- container = method->generic_container;
- g_assert (container);
-
new_context.class_inst = klass->generic_class ? klass->generic_class->context.class_inst : NULL;
/*
new_context.method_inst = inst;
- if (!container->method_hash)
- container->method_hash = g_hash_table_new (
- (GHashFunc)mono_metadata_generic_context_hash, (GEqualFunc)mono_metadata_generic_context_equal);
-
- inflated = g_hash_table_lookup (container->method_hash, &new_context);
- if (inflated)
- return inflated;
-
- mono_stats.generics_metadata_size += param_count * sizeof (MonoType);
-
inflated = mono_class_inflate_generic_method_full (method, klass, &new_context);
- g_hash_table_insert (container->method_hash, mono_method_get_context (inflated), inflated);
return inflated;
}
return piinfo->addr;
}
+/*
+ * LOCKING: assumes the loader lock to be taken.
+ */
static MonoMethod *
mono_get_method_from_token (MonoImage *image, guint32 token, MonoClass *klass,
MonoGenericContext *context, gboolean *used_context)
MonoMethod *method, *inflated;
MonoMethodInflated *imethod;
MonoReflectionMethodBuilder *mb = NULL;
- MonoGenericContainer *container;
MonoGenericContext tmp_context;
MonoGenericInst *ginst;
MonoType **type_argv;
if (count != mono_array_length (types))
return NULL;
- container = method->generic_container;
- g_assert (container);
-
- if (!container->method_hash)
- container->method_hash = g_hash_table_new (
- (GHashFunc) mono_metadata_generic_context_hash,
- (GCompareFunc) mono_metadata_generic_context_equal);
-
type_argv = g_new0 (MonoType *, count);
for (i = 0; i < count; i++) {
MonoReflectionType *garg = mono_array_get (types, gpointer, i);
tmp_context.class_inst = klass->generic_class ? klass->generic_class->context.class_inst : NULL;
tmp_context.method_inst = ginst;
- inflated = g_hash_table_lookup (container->method_hash, &tmp_context);
- if (inflated)
- return mono_method_get_object (mono_object_domain (rmethod), inflated, NULL);
-
inflated = mono_class_inflate_generic_method (method, &tmp_context);
imethod = (MonoMethodInflated *) inflated;
MOVING_GC_REGISTER (&imethod->reflection_info);
imethod->reflection_info = rmethod;
- g_hash_table_insert (container->method_hash, mono_method_get_context (inflated), inflated);
-
return mono_method_get_object (mono_object_domain (rmethod), inflated, NULL);
}