Skip to content

Commit

Permalink
2004-08-16 Martin Baulig <martin@ximian.com>
Browse files Browse the repository at this point in the history
	* metadata.c (do_mono_metadata_parse_generic_inst): Store the
	MonoGenericInst, not the MonoType in the `generic_inst_cache'.

svn path=/trunk/mono/; revision=32368
  • Loading branch information
Martin Baulig committed Aug 16, 2004
1 parent fefcf73 commit a493e00
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
5 changes: 5 additions & 0 deletions mono/metadata/ChangeLog
@@ -1,3 +1,8 @@
2004-08-16 Martin Baulig <martin@ximian.com>

* metadata.c (do_mono_metadata_parse_generic_inst): Store the
MonoGenericInst, not the MonoType in the `generic_inst_cache'.

2004-08-14 Martin Baulig <martin@ximian.com>

* class.c (dup_type): Also copy the `byref' field.
Expand Down
13 changes: 8 additions & 5 deletions mono/metadata/class.c
Expand Up @@ -276,7 +276,7 @@ inflate_generic_type (MonoType *type, MonoGenericContext *context)
}
case MONO_TYPE_GENERICINST: {
MonoGenericInst *oginst = type->data.generic_inst;
MonoGenericInst *nginst;
MonoGenericInst *nginst, *cached;
MonoType *nt;
int i;

Expand All @@ -301,13 +301,16 @@ inflate_generic_type (MonoType *type, MonoGenericContext *context)
nginst->context->ginst = nginst;

mono_loader_lock ();
nt = g_hash_table_lookup (oginst->klass->image->generic_inst_cache, nginst);
cached = g_hash_table_lookup (oginst->klass->image->generic_inst_cache, nginst);

if (nt) {
if (cached) {
g_free (nginst->type_argv);
g_free (nginst);
mono_loader_unlock ();
return dup_type (nt, type);

nt = dup_type (type, type);
nt->data.generic_inst = cached;
return nt;
}

nginst->dynamic_info = NULL;
Expand All @@ -322,7 +325,7 @@ inflate_generic_type (MonoType *type, MonoGenericContext *context)

nt = dup_type (type, type);
nt->data.generic_inst = nginst;
g_hash_table_insert (oginst->klass->image->generic_inst_cache, nginst, nt);
g_hash_table_insert (oginst->klass->image->generic_inst_cache, nginst, nginst);
mono_loader_unlock ();
return nt;
}
Expand Down
10 changes: 3 additions & 7 deletions mono/metadata/metadata.c
Expand Up @@ -1446,7 +1446,7 @@ static void
do_mono_metadata_parse_generic_inst (MonoType *type, MonoImage *m, const char *ptr, const char **rptr)
{
MonoGenericInst *ginst = g_new0 (MonoGenericInst, 1);
MonoType *cached;
MonoGenericInst *cached;
int i, count;

type->data.generic_inst = ginst;
Expand Down Expand Up @@ -1502,14 +1502,10 @@ do_mono_metadata_parse_generic_inst (MonoType *type, MonoImage *m, const char *p
g_free (ginst->type_argv);
g_free (ginst);

type->data.generic_inst = cached->data.generic_inst;
type->data.generic_inst = cached;
return;
} else {
cached = g_new0 (MonoType, 1);
cached->type = MONO_TYPE_GENERICINST;
cached->data.generic_inst = ginst;

g_hash_table_insert (m->generic_inst_cache, ginst, cached);
g_hash_table_insert (m->generic_inst_cache, ginst, ginst);

mono_stats.generic_instance_count++;
mono_stats.generics_metadata_size += sizeof (MonoGenericInst) +
Expand Down
18 changes: 10 additions & 8 deletions mono/metadata/reflection.c
Expand Up @@ -7221,7 +7221,7 @@ do_mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_a
{
MonoClass *klass;
MonoReflectionTypeBuilder *tb = NULL;
MonoGenericInst *ginst;
MonoGenericInst *ginst, *cached;
MonoDomain *domain;
MonoType *geninst;
int icount, i;
Expand Down Expand Up @@ -7268,20 +7268,22 @@ do_mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_a
ginst->generic_type = kginst->generic_type;
}

geninst = g_hash_table_lookup (klass->image->generic_inst_cache, ginst);
if (geninst) {
geninst = g_new0 (MonoType, 1);
geninst->type = MONO_TYPE_GENERICINST;

cached = g_hash_table_lookup (klass->image->generic_inst_cache, ginst);
if (cached) {
g_free (ginst);
mono_loader_unlock ();
geninst->data.generic_inst = cached;
return geninst;
}

geninst->data.generic_inst = ginst;

ginst->context = g_new0 (MonoGenericContext, 1);
ginst->context->ginst = ginst;

geninst = g_new0 (MonoType, 1);
geninst->type = MONO_TYPE_GENERICINST;
geninst->data.generic_inst = ginst;

if (!strcmp (((MonoObject *) type)->vtable->klass->name, "TypeBuilder")) {
tb = (MonoReflectionTypeBuilder *) type;

Expand Down Expand Up @@ -7316,7 +7318,7 @@ do_mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_a

mono_class_create_generic (ginst);

g_hash_table_insert (klass->image->generic_inst_cache, ginst, geninst);
g_hash_table_insert (klass->image->generic_inst_cache, ginst, ginst);

mono_loader_unlock ();

Expand Down

0 comments on commit a493e00

Please sign in to comment.