From 37742c470fc2821787f474afcab0ed7bd070234c Mon Sep 17 00:00:00 2001 From: Paolo Molaro Date: Tue, 23 Jan 2007 17:12:20 +0000 Subject: Tue Jan 23 18:09:21 CET 2007 Paolo Molaro * class.c, object.c: restrict GC-tracked fields to UIntPtr fields used inside corlib, so we provide better type info to the GC and also allow broken packing as in bug #80580. svn path=/trunk/mono/; revision=71524 --- mono/metadata/ChangeLog | 7 +++++++ mono/metadata/class.c | 18 +++++++----------- mono/metadata/object.c | 8 ++++++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/mono/metadata/ChangeLog b/mono/metadata/ChangeLog index 1d9178ed57a..e1156a9d2cf 100644 --- a/mono/metadata/ChangeLog +++ b/mono/metadata/ChangeLog @@ -1,4 +1,11 @@ +Tue Jan 23 18:09:21 CET 2007 Paolo Molaro + + * class.c, object.c: restrict GC-tracked fields to + UIntPtr fields used inside corlib, so we provide better + type info to the GC and also allow broken packing as in + bug #80580. + Mon Jan 22 11:24:27 CET 2007 Paolo Molaro * sgen-gc.c: removed duplicated function. diff --git a/mono/metadata/class.c b/mono/metadata/class.c index 1ddcd922000..8595fae0112 100644 --- a/mono/metadata/class.c +++ b/mono/metadata/class.c @@ -1020,7 +1020,7 @@ mono_class_has_references (MonoClass *klass) #ifdef HAVE_SGEN_GC #define IS_GC_REFERENCE(t) FALSE #else -#define IS_GC_REFERENCE(t) ((t)->type == MONO_TYPE_U || (t)->type == MONO_TYPE_I || (t)->type == MONO_TYPE_PTR) +#define IS_GC_REFERENCE(t) ((t)->type == MONO_TYPE_U && class->image == mono_defaults.corlib) #endif /* @@ -1065,6 +1065,9 @@ mono_class_layout_fields (MonoClass *class) if (class->image != mono_defaults.corlib && class->byval_arg.type != MONO_TYPE_VALUETYPE) gc_aware_layout = TRUE; + /* from System.dll, used in metadata/process.h */ + if (strcmp (class->name, "ProcessStartInfo") == 0) + gc_aware_layout = FALSE; } /* Compute klass->has_references */ @@ -1143,15 +1146,9 @@ mono_class_layout_fields (MonoClass *class) if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) continue; + ftype = mono_type_get_underlying_type (field->type); if (gc_aware_layout) { - /* - * We process fields with reference type in the first pass, - * and fields with non-reference type in the second pass. - * We use IS_POINTER instead of IS_REFERENCE because in - * some internal structures, we store GC_MALLOCed memory - * in IntPtr fields... - */ - if (MONO_TYPE_IS_POINTER (field->type)) { + if (MONO_TYPE_IS_REFERENCE (ftype) || IS_GC_REFERENCE (ftype) || ((MONO_TYPE_ISSTRUCT (ftype) && mono_class_has_references (mono_class_from_mono_type (ftype))))) { if (pass == 1) continue; } else { @@ -1173,8 +1170,7 @@ mono_class_layout_fields (MonoClass *class) /* if the field has managed references, we need to force-align it * see bug #77788 */ - ftype = mono_type_get_underlying_type (field->type); - if (MONO_TYPE_IS_REFERENCE (ftype) || ((MONO_TYPE_ISSTRUCT (ftype) && mono_class_has_references (mono_class_from_mono_type (ftype))))) + if (MONO_TYPE_IS_REFERENCE (ftype) || IS_GC_REFERENCE (ftype) || ((MONO_TYPE_ISSTRUCT (ftype) && mono_class_has_references (mono_class_from_mono_type (ftype))))) align = sizeof (gpointer); class->min_align = MAX (align, class->min_align); diff --git a/mono/metadata/object.c b/mono/metadata/object.c index 7189dbe6e35..98f9f88dfac 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -593,13 +593,17 @@ compute_class_bitmap (MonoClass *class, gsize *bitmap, int size, int offset, int type = mono_type_get_underlying_type (field->type); switch (type->type) { - /* FIXME: _I and _U and _PTR should be removed eventually */ case MONO_TYPE_I: - case MONO_TYPE_U: case MONO_TYPE_PTR: case MONO_TYPE_FNPTR: + break; + /* only UIntPtr is allowed to be GC-tracked and only in mscorlib */ + case MONO_TYPE_U: #ifdef HAVE_SGEN_GC break; +#else + if (class->image != mono_defaults.corlib) + break; #endif case MONO_TYPE_STRING: case MONO_TYPE_SZARRAY: -- cgit v1.2.3