Author: mprobst
Date: 2007-12-07 08:39:31 -0500 (Fri, 07 Dec 2007)
New Revision: 90929

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/class-internals.h
   trunk/mono/mono/metadata/class.c
   trunk/mono/mono/metadata/object.c
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/mini.c
Log:
2007-12-07  Mark Probst  <[EMAIL PROTECTED]>

        * class.c, class-internals.h: Introduce an environment variable
        (MONO_GENERIC_SHARING) through which the extent of generic code
        sharing can be controlled (share all classes, share only corlib
        classes, or share nothing).

        * object.c: Only create runtime generic context for classes for
        which sharing is enabled.

2007-12-07  Mark Probst  <[EMAIL PROTECTED]>

        * mini.c: Don't compile methods with sharing enabled if their
        classes are disabled for sharing.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2007-12-07 13:34:30 UTC (rev 90928)
+++ trunk/mono/mono/metadata/ChangeLog  2007-12-07 13:39:31 UTC (rev 90929)
@@ -1,3 +1,13 @@
+2007-12-07  Mark Probst  <[EMAIL PROTECTED]>
+
+       * class.c, class-internals.h: Introduce an environment variable
+       (MONO_GENERIC_SHARING) through which the extent of generic code
+       sharing can be controlled (share all classes, share only corlib
+       classes, or share nothing).
+
+       * object.c: Only create runtime generic context for classes for
+       which sharing is enabled.
+
 2007-12-06  Rodrigo Kumpera  <[EMAIL PROTECTED]>
 
        * verify.c (do_ldelem): refactor it to work with ldelem.any.

Modified: trunk/mono/mono/metadata/class-internals.h
===================================================================
--- trunk/mono/mono/metadata/class-internals.h  2007-12-07 13:34:30 UTC (rev 
90928)
+++ trunk/mono/mono/metadata/class-internals.h  2007-12-07 13:39:31 UTC (rev 
90929)
@@ -574,6 +574,12 @@
        void       *handle;
 } MonoHandleRef;
 
+enum {
+       MONO_GENERIC_SHARING_NONE,
+       MONO_GENERIC_SHARING_CORLIB,
+       MONO_GENERIC_SHARING_ALL
+};
+
 extern MonoStats mono_stats MONO_INTERNAL;
 
 typedef gpointer (*MonoTrampoline)       (MonoMethod *method);
@@ -886,5 +892,8 @@
 MonoType*
 mono_type_get_basic_type_from_generic (MonoType *type) MONO_INTERNAL;
 
+gboolean
+mono_class_generic_sharing_enabled (MonoClass *class) MONO_INTERNAL;
+
 #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */
 

Modified: trunk/mono/mono/metadata/class.c
===================================================================
--- trunk/mono/mono/metadata/class.c    2007-12-07 13:34:30 UTC (rev 90928)
+++ trunk/mono/mono/metadata/class.c    2007-12-07 13:39:31 UTC (rev 90929)
@@ -6391,3 +6391,48 @@
 {
        return gklass->context.class_inst == 
gklass->container_class->generic_container->context.class_inst;
 }
+
+/*
+ * mono_class_generic_sharing_enabled:
+ * @class: a class
+ *
+ * Returns whether generic sharing is enabled for class.
+ *
+ * This is a stop-gap measure to slowly introduce generic sharing
+ * until we have all the issues sorted out, at which time this
+ * function will disappear and generic sharing will always be enabled.
+ */
+gboolean
+mono_class_generic_sharing_enabled (MonoClass *class)
+{
+       static int generic_sharing = MONO_GENERIC_SHARING_CORLIB;
+       static gboolean inited = FALSE;
+
+       if (!inited) {
+               const char *option;
+
+               if ((option = g_getenv ("MONO_GENERIC_SHARING"))) {
+                       if (strcmp (option, "corlib") == 0)
+                               generic_sharing = MONO_GENERIC_SHARING_CORLIB;
+                       else if (strcmp (option, "all") == 0)
+                               generic_sharing = MONO_GENERIC_SHARING_ALL;
+                       else if (strcmp (option, "none") == 0)
+                               generic_sharing = MONO_GENERIC_SHARING_NONE;
+                       else
+                               g_warning ("Unknown generic sharing option 
`%s'.", option);
+               }
+
+               inited = TRUE;
+       }
+
+       switch (generic_sharing) {
+       case MONO_GENERIC_SHARING_NONE:
+               return FALSE;
+       case MONO_GENERIC_SHARING_ALL:
+               return TRUE;
+       case MONO_GENERIC_SHARING_CORLIB :
+               return class->image == mono_defaults.corlib;
+       default:
+               g_assert_not_reached ();
+       }
+}

Modified: trunk/mono/mono/metadata/object.c
===================================================================
--- trunk/mono/mono/metadata/object.c   2007-12-07 13:34:30 UTC (rev 90928)
+++ trunk/mono/mono/metadata/object.c   2007-12-07 13:39:31 UTC (rev 90929)
@@ -1600,7 +1600,7 @@
                }
        }
 
-       if (class->generic_class)
+       if (class->generic_class && mono_class_generic_sharing_enabled (class))
                mono_class_setup_runtime_generic_context (class, domain);
 
        mono_domain_unlock (domain);

Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2007-12-07 13:34:30 UTC (rev 90928)
+++ trunk/mono/mono/mini/ChangeLog      2007-12-07 13:39:31 UTC (rev 90929)
@@ -1,3 +1,8 @@
+2007-12-07  Mark Probst  <[EMAIL PROTECTED]>
+
+       * mini.c: Don't compile methods with sharing enabled if their
+       classes are disabled for sharing.
+
 2007-12-06  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * inssel.brg: Add a missing sign extension to the GETCHR and array 
access

Modified: trunk/mono/mono/mini/mini.c
===================================================================
--- trunk/mono/mono/mini/mini.c 2007-12-07 13:34:30 UTC (rev 90928)
+++ trunk/mono/mono/mini/mini.c 2007-12-07 13:39:31 UTC (rev 90929)
@@ -11098,9 +11098,11 @@
  
        if (compile_aot)
                /* We are passed the original generic method definition */
-               try_generic_shared = (opts & MONO_OPT_GSHARED) && 
(method->generic_container || method->klass->generic_container);
+               try_generic_shared = mono_class_generic_sharing_enabled 
(method->klass) &&
+                       (opts & MONO_OPT_GSHARED) && (method->generic_container 
|| method->klass->generic_container);
        else
-               try_generic_shared = (opts & MONO_OPT_GSHARED) && 
mono_method_is_generic_sharable_impl (method);
+               try_generic_shared = mono_class_generic_sharing_enabled 
(method->klass) &&
+                       (opts & MONO_OPT_GSHARED) && 
mono_method_is_generic_sharable_impl (method);
 
        if (opts & MONO_OPT_GSHARED) {
                if (try_generic_shared)

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

Reply via email to