Author: mprobst
Date: 2007-12-07 10:46:46 -0500 (Fri, 07 Dec 2007)
New Revision: 90945

Modified:
   branches/mono-1-2-6/mono/man/ChangeLog
   branches/mono-1-2-6/mono/man/mono.1
   branches/mono-1-2-6/mono/mono/metadata/ChangeLog
   branches/mono-1-2-6/mono/mono/metadata/class-internals.h
   branches/mono-1-2-6/mono/mono/metadata/class.c
   branches/mono-1-2-6/mono/mono/metadata/object.c
   branches/mono-1-2-6/mono/mono/mini/ChangeLog
   branches/mono-1-2-6/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.

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

        * mono.1: Added a short paragraph on the MONO_GENERIC_SHARING
        environment variable.


Modified: branches/mono-1-2-6/mono/man/ChangeLog
===================================================================
--- branches/mono-1-2-6/mono/man/ChangeLog      2007-12-07 15:44:25 UTC (rev 
90944)
+++ branches/mono-1-2-6/mono/man/ChangeLog      2007-12-07 15:46:46 UTC (rev 
90945)
@@ -1,3 +1,8 @@
+2007-12-07  Mark Probst  <[EMAIL PROTECTED]>
+
+       * mono.1: Added a short paragraph on the MONO_GENERIC_SHARING
+       environment variable.
+
 2007-11-21  Marek Habersack  <[EMAIL PROTECTED]>
 
        * mconfig.1: modify to reflect parameter changes in mconfig.

Modified: branches/mono-1-2-6/mono/man/mono.1
===================================================================
--- branches/mono-1-2-6/mono/man/mono.1 2007-12-07 15:44:25 UTC (rev 90944)
+++ branches/mono-1-2-6/mono/man/mono.1 2007-12-07 15:46:46 UTC (rev 90945)
@@ -907,6 +907,13 @@
 as it forces all of the commands send to X11 server to be done
 synchronously.   The default mode of operation is asynchronous which
 makes it hard to isolate the root of certain problems.
+.TP
+.I "MONO_GENERIC_SHARING"
+This controls for which classes to enable generic code sharing in
+principle.  Permissible values are "all", "corlib" and "none".  The
+default is "none", meaning that sharing can only happen for corlib
+classes.  Note that to enable generation of shared code the "gshared"
+compiler option has to be set as well.
 .SH VALGRIND
 If you want to use Valgrind, you will find the file `mono.supp'
 useful, it contains the suppressions for the GC which trigger

Modified: branches/mono-1-2-6/mono/mono/metadata/ChangeLog
===================================================================
--- branches/mono-1-2-6/mono/mono/metadata/ChangeLog    2007-12-07 15:44:25 UTC 
(rev 90944)
+++ branches/mono-1-2-6/mono/mono/metadata/ChangeLog    2007-12-07 15:46:46 UTC 
(rev 90945)
@@ -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-11-22  Martin Baulig  <[EMAIL PROTECTED]>
 
        * mono-debug.h (MONO_DEBUGGER_VERSION): Bump to 66.

Modified: branches/mono-1-2-6/mono/mono/metadata/class-internals.h
===================================================================
--- branches/mono-1-2-6/mono/mono/metadata/class-internals.h    2007-12-07 
15:44:25 UTC (rev 90944)
+++ branches/mono-1-2-6/mono/mono/metadata/class-internals.h    2007-12-07 
15:46:46 UTC (rev 90945)
@@ -569,6 +569,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);
@@ -872,5 +878,8 @@
 gboolean
 mono_generic_class_is_generic_type_definition (MonoGenericClass *gklass) 
MONO_INTERNAL;
 
+gboolean
+mono_class_generic_sharing_enabled (MonoClass *class) MONO_INTERNAL;
+
 #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */
 

Modified: branches/mono-1-2-6/mono/mono/metadata/class.c
===================================================================
--- branches/mono-1-2-6/mono/mono/metadata/class.c      2007-12-07 15:44:25 UTC 
(rev 90944)
+++ branches/mono-1-2-6/mono/mono/metadata/class.c      2007-12-07 15:46:46 UTC 
(rev 90945)
@@ -6334,3 +6334,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_NONE;
+       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: branches/mono-1-2-6/mono/mono/metadata/object.c
===================================================================
--- branches/mono-1-2-6/mono/mono/metadata/object.c     2007-12-07 15:44:25 UTC 
(rev 90944)
+++ branches/mono-1-2-6/mono/mono/metadata/object.c     2007-12-07 15:46:46 UTC 
(rev 90945)
@@ -1572,7 +1572,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: branches/mono-1-2-6/mono/mono/mini/ChangeLog
===================================================================
--- branches/mono-1-2-6/mono/mono/mini/ChangeLog        2007-12-07 15:44:25 UTC 
(rev 90944)
+++ branches/mono-1-2-6/mono/mono/mini/ChangeLog        2007-12-07 15:46:46 UTC 
(rev 90945)
@@ -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-11-22  Martin Baulig  <[EMAIL PROTECTED]>
 
        * debug-debugger.h

Modified: branches/mono-1-2-6/mono/mono/mini/mini.c
===================================================================
--- branches/mono-1-2-6/mono/mono/mini/mini.c   2007-12-07 15:44:25 UTC (rev 
90944)
+++ branches/mono-1-2-6/mono/mono/mini/mini.c   2007-12-07 15:46:46 UTC (rev 
90945)
@@ -10671,7 +10671,8 @@
        MonoJitInfo *jinfo;
        int dfn = 0, i, code_size_ratio;
        gboolean deadce_has_run = FALSE;
-       gboolean try_generic_shared = (opts & MONO_OPT_GSHARED) && 
mono_method_is_generic_sharable_impl (method);
+       gboolean try_generic_shared = mono_class_generic_sharing_enabled 
(method->klass) &&
+               (opts & MONO_OPT_GSHARED) && 
mono_method_is_generic_sharable_impl (method);
        MonoGenericContext *shared_context;
 
        mono_jit_stats.methods_compiled++;

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

Reply via email to