From 5bf47304ad5d3a3dd3ddfabb7dcae186a0e66d71 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 12 Jul 2005 18:11:12 +0000 Subject: [PATCH] 2005-07-12 Zoltan Varga * class.c (mono_class_layout_fields): Fix calculation of has_references for generic types. svn path=/trunk/mono/; revision=47236 --- mono/metadata/ChangeLog | 7 ++++++- mono/metadata/class.c | 29 +++++++++++++++++------------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/mono/metadata/ChangeLog b/mono/metadata/ChangeLog index 739b564e8b8..3ae6b73608b 100644 --- a/mono/metadata/ChangeLog +++ b/mono/metadata/ChangeLog @@ -1,3 +1,8 @@ +2005-07-12 Zoltan Varga + + * class.c (mono_class_layout_fields): Fix calculation of has_references + for generic types. + 2005-07-12 Martin Baulig Applying a patch from Michal Moskal . @@ -21,7 +26,7 @@ * class.c (mono_class_layout_fields): Fix calculation of has_references for generic types. - + * class.c (inflate_generic_class): Fix a leak. (mono_class_init): Fix calculation of gchimpl and has_finalize fields for generic types. diff --git a/mono/metadata/class.c b/mono/metadata/class.c index c9d51ab8436..220752553f6 100644 --- a/mono/metadata/class.c +++ b/mono/metadata/class.c @@ -777,6 +777,20 @@ mono_class_layout_fields (MonoClass *class) gc_aware_layout = TRUE; } + for (i = 0; i < top; i++) { + MonoType *ftype; + + field = &class->fields [i]; + + ftype = mono_type_get_underlying_type (field->type); + if (MONO_TYPE_IS_REFERENCE (ftype) || IS_GC_REFERENCE (ftype) || ((MONO_TYPE_ISSTRUCT (ftype) && mono_class_from_mono_type (ftype)->has_references))) { + if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) + class->has_static_refs = TRUE; + else + class->has_references = TRUE; + } + } + /* * Compute field layout and total size (not considering static fields) */ @@ -801,6 +815,7 @@ mono_class_layout_fields (MonoClass *class) for (pass = 0; pass < passes; ++pass) { for (i = 0; i < top; i++){ int size, align; + field = &class->fields [i]; if (mono_field_is_deleted (field)) @@ -840,10 +855,6 @@ mono_class_layout_fields (MonoClass *class) field->offset += align - 1; field->offset &= ~(align - 1); real_size = field->offset + size; - if (MONO_TYPE_IS_REFERENCE (field->type) || IS_GC_REFERENCE (field->type)) - class->has_references = TRUE; - else if (MONO_TYPE_ISSTRUCT (field->type) && mono_class_from_mono_type (field->type)->has_references) - class->has_references = TRUE; } class->instance_size = MAX (real_size, class->instance_size); @@ -858,6 +869,7 @@ mono_class_layout_fields (MonoClass *class) real_size = 0; for (i = 0; i < top; i++) { int size, align; + field = &class->fields [i]; /* @@ -870,10 +882,6 @@ mono_class_layout_fields (MonoClass *class) if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) continue; - if (MONO_TYPE_IS_REFERENCE (field->type) || IS_GC_REFERENCE (field->type)) - class->has_references = TRUE; - else if (field->type->type == MONO_TYPE_VALUETYPE && field->type->data.klass->has_references) - class->has_references = TRUE; size = mono_type_size (field->type, &align); /* @@ -900,6 +908,7 @@ mono_class_layout_fields (MonoClass *class) */ for (i = 0; i < top; i++){ int size, align; + field = &class->fields [i]; if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC) || field->type->attrs & FIELD_ATTRIBUTE_LITERAL) @@ -907,10 +916,6 @@ mono_class_layout_fields (MonoClass *class) if (mono_field_is_deleted (field)) continue; - if (MONO_TYPE_IS_REFERENCE (field->type) || IS_GC_REFERENCE (field->type)) - class->has_static_refs = TRUE; - else if (field->type->type == MONO_TYPE_VALUETYPE && field->type->data.klass->has_references) - class->has_static_refs = TRUE; size = mono_type_size (field->type, &align); field->offset = class->class_size; field->offset += align - 1; -- 2.25.1