[runtime] Don't allocate domain-level static slots for special static fields.
authorAlex Rønne Petersen <alexrp@xamarin.com>
Thu, 3 Sep 2015 18:00:31 +0000 (20:00 +0200)
committerAlex Rønne Petersen <alexrp@xamarin.com>
Thu, 3 Sep 2015 22:34:22 +0000 (00:34 +0200)
This didn't cause any harm, but resulted in a bit of unnecessary GC work and
memory usage.

mono/metadata/class.c
mono/metadata/debug-helpers.c
mono/metadata/object.c

index a36a0fca930c3e345c8c024db587525566d52fa6..64b01300f07a407ce3985a93b513ec7cb0d62274 100644 (file)
@@ -2066,6 +2066,9 @@ mono_class_layout_fields (MonoClass *class)
                        continue;
                if (mono_field_is_deleted (field))
                        continue;
+               // Special static fields do not need a domain-level static slot
+               if (mono_class_field_is_special_static (field))
+                       continue;
 
                if (mono_type_has_exceptions (field->type)) {
                        mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, NULL);
index e8acbe99d1cfc46f07fdd46247b42c996ca15d57..ef60d033af07236171f6704ca121aae2ffb54f21 100644 (file)
@@ -1040,6 +1040,9 @@ mono_class_describe_statics (MonoClass* klass)
                                continue;
                        if (!(field->type->attrs & (FIELD_ATTRIBUTE_STATIC | FIELD_ATTRIBUTE_HAS_FIELD_RVA)))
                                continue;
+                       // Special static fields don't have a domain-level static slot
+                       if (mono_class_field_is_special_static (field))
+                               continue;
 
                        field_ptr = (const char*)addr + field->offset;
 
index 2d7c948b918ebf82b4d43cc768844b9eb6b49c11..7604585dcadebda52d74e5f561295e6373758d6e 100644 (file)
@@ -725,8 +725,8 @@ compute_class_bitmap (MonoClass *class, gsize *bitmap, int size, int offset, int
                        if (field->type->byref)
                                break;
 
-                       if (static_fields && field->offset == -1)
-                               /* special static */
+                       // Special static fields do not have a domain-level static slot
+                       if (static_fields && mono_class_field_is_special_static (field))
                                continue;
 
                        pos = field->offset / sizeof (gpointer);