#include <mono/utils/mono-counters.h>
#include "mini.h"
+
+#define ALLOW_PARTIAL_SHARING TRUE
+//#define ALLOW_PARTIAL_SHARING FALSE
#if 0
#define DEBUG(...) __VA_ARGS__
static int num_oti_allocted;
static int num_oti_bytes;
+static gboolean partial_supported = TRUE;
+
static inline gboolean
partial_sharing_supported (void)
{
- return TRUE;
+ if (!ALLOW_PARTIAL_SHARING)
+ return FALSE;
+ /* Enable this when AOT compiling or running in full-aot mode */
+ if (mono_aot_only)
+ return TRUE;
+ if (partial_supported)
+ return TRUE;
+ return FALSE;
}
static int
gsharedvt_supported = supported;
}
+void
+mono_set_partial_sharing_supported (gboolean supported)
+{
+ partial_supported = supported;
+}
+
/*
* mono_class_generic_sharing_enabled:
* @class: a class
key.param.param.gshared_constraint = constraint;
g_assert (mono_generic_param_info (par));
- /* image might not be set for sre */
- if (par->owner && par->owner->image) {
- image = par->owner->image;
+ image = get_image_for_generic_param(par);
- /*
- * Need a cache to ensure the newly created gparam
- * is unique wrt T/CONSTRAINT.
- */
- mono_image_lock (image);
- if (!image->gshared_types) {
- image->gshared_types_len = MONO_TYPE_INTERNAL;
- image->gshared_types = g_new0 (GHashTable*, image->gshared_types_len);
- }
- if (!image->gshared_types [constraint->type])
- image->gshared_types [constraint->type] = g_hash_table_new (shared_gparam_hash, shared_gparam_equal);
- res = g_hash_table_lookup (image->gshared_types [constraint->type], &key);
- mono_image_unlock (image);
- if (res)
- return res;
- copy = mono_image_alloc0 (image, sizeof (MonoGSharedGenericParam));
- memcpy (©->param, par, sizeof (MonoGenericParamFull));
- name = get_shared_gparam_name (constraint->type, ((MonoGenericParamFull*)copy)->info.name);
- copy->param.info.name = mono_image_strdup (image, name);
- g_free (name);
- } else {
- /* mono_generic_param_name () expects this to be a MonoGenericParamFull */
- copy = g_new0 (MonoGSharedGenericParam, 1);
- memcpy (©->param, par, sizeof (MonoGenericParam));
- }
- copy->param.param.owner = NULL;
- // FIXME:
- copy->param.param.image = image ? image : mono_defaults.corlib;
+ /*
+ * Need a cache to ensure the newly created gparam
+ * is unique wrt T/CONSTRAINT.
+ */
+ mono_image_lock (image);
+ if (!image->gshared_types) {
+ image->gshared_types_len = MONO_TYPE_INTERNAL;
+ image->gshared_types = g_new0 (GHashTable*, image->gshared_types_len);
+ }
+ if (!image->gshared_types [constraint->type])
+ image->gshared_types [constraint->type] = g_hash_table_new (shared_gparam_hash, shared_gparam_equal);
+ res = g_hash_table_lookup (image->gshared_types [constraint->type], &key);
+ mono_image_unlock (image);
+ if (res)
+ return res;
+ copy = mono_image_alloc0 (image, sizeof (MonoGSharedGenericParam));
+ memcpy (©->param, par, sizeof (MonoGenericParamFull));
+ name = get_shared_gparam_name (constraint->type, ((MonoGenericParamFull*)copy)->info.name);
+ copy->param.info.name = mono_image_strdup (image, name);
+ g_free (name);
+
+ copy->param.param.owner = par->owner;
copy->param.param.gshared_constraint = constraint;
copy->parent = par;