From 85f6a2b5691121b0e2a12cc7a292bbec96cdfb0b Mon Sep 17 00:00:00 2001 From: zoltan Date: Fri, 26 Feb 2010 20:04:35 +0000 Subject: [PATCH] 2010-02-26 Zoltan Varga * class.c (mono_class_generic_sharing_enabled): Move this to generic-sharing.c. git-svn-id: svn+ssh://mono-cvs.ximian.com/source/trunk/mono@152577 e3ebcda4-bce8-0310-ba0a-eca2169e7518 --- mono/metadata/ChangeLog | 3 ++ mono/metadata/class.c | 70 ----------------------------------------- mono/metadata/generic-sharing.c | 70 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 70 deletions(-) diff --git a/mono/metadata/ChangeLog b/mono/metadata/ChangeLog index 95879a3a5..792257cc2 100644 --- a/mono/metadata/ChangeLog +++ b/mono/metadata/ChangeLog @@ -1,5 +1,8 @@ 2010-02-26 Zoltan Varga + * class.c (mono_class_generic_sharing_enabled): Move this to + generic-sharing.c. + * image.c: Add an unload hook which is called before an image is unloaded. * generic-sharing.c: Use the unload hook to unregister per-image data, to avoid diff --git a/mono/metadata/class.c b/mono/metadata/class.c index 4614e886f..a7d9a05bf 100644 --- a/mono/metadata/class.c +++ b/mono/metadata/class.c @@ -8718,76 +8718,6 @@ mono_generic_class_is_generic_type_definition (MonoGenericClass *gklass) return gklass->context.class_inst == gklass->container_class->generic_container->context.class_inst; } -static gboolean gshared_supported; - -void -mono_set_generic_sharing_supported (gboolean supported) -{ - gshared_supported = supported; -} - -/* - * 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 (gshared_supported) - generic_sharing = MONO_GENERIC_SHARING_ALL; - else - generic_sharing = MONO_GENERIC_SHARING_NONE; - - if ((option = g_getenv ("MONO_GENERIC_SHARING"))) { - if (strcmp (option, "corlib") == 0) - generic_sharing = MONO_GENERIC_SHARING_CORLIB; - else if (strcmp (option, "collections") == 0) - generic_sharing = MONO_GENERIC_SHARING_COLLECTIONS; - 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); - } - - if (!gshared_supported) - generic_sharing = MONO_GENERIC_SHARING_NONE; - - 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; - case MONO_GENERIC_SHARING_COLLECTIONS: - if (class->image != mono_defaults.corlib) - return FALSE; - while (class->nested_in) - class = class->nested_in; - return g_str_has_prefix (class->name_space, "System.Collections.Generic"); - default: - g_assert_not_reached (); - } - return FALSE; -} - /* * mono_class_setup_interface_id: * diff --git a/mono/metadata/generic-sharing.c b/mono/metadata/generic-sharing.c index 53dc09ac5..7b034ee9e 100644 --- a/mono/metadata/generic-sharing.c +++ b/mono/metadata/generic-sharing.c @@ -1538,3 +1538,73 @@ mono_domain_lookup_shared_generic (MonoDomain *domain, MonoMethod *open_method) return ji; } + +static gboolean gshared_supported; + +void +mono_set_generic_sharing_supported (gboolean supported) +{ + gshared_supported = supported; +} + +/* + * 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 (gshared_supported) + generic_sharing = MONO_GENERIC_SHARING_ALL; + else + generic_sharing = MONO_GENERIC_SHARING_NONE; + + if ((option = g_getenv ("MONO_GENERIC_SHARING"))) { + if (strcmp (option, "corlib") == 0) + generic_sharing = MONO_GENERIC_SHARING_CORLIB; + else if (strcmp (option, "collections") == 0) + generic_sharing = MONO_GENERIC_SHARING_COLLECTIONS; + 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); + } + + if (!gshared_supported) + generic_sharing = MONO_GENERIC_SHARING_NONE; + + 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; + case MONO_GENERIC_SHARING_COLLECTIONS: + if (class->image != mono_defaults.corlib) + return FALSE; + while (class->nested_in) + class = class->nested_in; + return g_str_has_prefix (class->name_space, "System.Collections.Generic"); + default: + g_assert_not_reached (); + } + return FALSE; +} -- 2.11.4.GIT