[mono/mono] d51c9f1a: [runtime]Don't expand variant generic interfaces on arrays.

"Rodrigo Kumpera ([email protected])" <[email protected]> Wed, 13 Nov 2013 20:55:38 +0000
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <00000142533f7a88-544267b4-36a6-433e-9719-af5bb92fb06e-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/73f194612821...d51c9f1a4f0a

   Commit: d51c9f1a4f0a8867f8987312940617b31e0c6d2a
   Author: Rodrigo Kumpera <[email protected]> (kumpera)
     Date: 2013-11-13 20:54:27 GMT
      URL: https://github.com/mono/mono/commit/d51c9f1a4f0a8867f8987312940617b31e0c6d2a

[runtime]Don't expand variant generic interfaces on arrays.

We don't need to expand variant interfaces in 4.5 as they work
just fine.

This saves us from loading a lot of extra metadata and inflating
spurious classes.

Changed paths:
  M mono/metadata/class.c

Modified: mono/metadata/class.c
===================================================================
@@ -2923,9 +2923,12 @@ class Input<T> {}
 	 * We collect the types needed to build the
 	 * instantiations in interfaces at intervals of 3/5, because 3/5 are
 	 * the generic interfaces needed to implement.
+	 *
+	 * On 4.5, as an optimization, we don't expand ref classes for the variant generic interfaces
+	 * (IEnumerator, IReadOnlyList and IReadOnlyColleciton). The regular dispatch code can handle those cases.
 	 */
-	nifaces = generic_ireadonlylist_class ? 5 : 3;
 	if (eclass->valuetype) {
+		nifaces = generic_ireadonlylist_class ? 5 : 3;
 		fill_valuetype_array_derived_types (valuetype_types, eclass, original_rank);
 
 		/* IList, ICollection, IEnumerable, IReadOnlyList`1 */
@@ -2947,6 +2950,7 @@ class Input<T> {}
 		int idepth = eclass->idepth;
 		if (!internal_enumerator)
 			idepth--;
+		nifaces = generic_ireadonlylist_class ? 2 : 3;
 
 		// FIXME: This doesn't seem to work/required for generic params
 		if (!(eclass->this_arg.type == MONO_TYPE_VAR || eclass->this_arg.type == MONO_TYPE_MVAR || (eclass->image->dynamic && !eclass->wastypebuilder)))
@@ -3010,10 +3014,16 @@ class Input<T> {}
 
 		interfaces [i + 0] = inflate_class_one_arg (mono_defaults.generic_ilist_class, iface);
 		interfaces [i + 1] = inflate_class_one_arg (generic_icollection_class, iface);
-		interfaces [i + 2] = inflate_class_one_arg (generic_ienumerable_class, iface);
-		if (generic_ireadonlylist_class) {
-			interfaces [i + 3] = inflate_class_one_arg (generic_ireadonlylist_class, iface);
-			interfaces [i + 4] = inflate_class_one_arg (generic_ireadonlycollection_class, iface);
+
+		if (eclass->valuetype) {
+			interfaces [i + 2] = inflate_class_one_arg (generic_ienumerable_class, iface);
+			if (generic_ireadonlylist_class) {
+				interfaces [i + 3] = inflate_class_one_arg (generic_ireadonlylist_class, iface);
+				interfaces [i + 4] = inflate_class_one_arg (generic_ireadonlycollection_class, iface);
+			}
+		} else {
+			if (!generic_ireadonlylist_class)
+				interfaces [i + 2] = inflate_class_one_arg (generic_ienumerable_class, iface);
 		}
 	}
 	if (internal_enumerator) {


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches