Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / metadata / metadata.c
index 07f90955ac0938abfdf4786a00947706805854a1..7b31abe9bb9637c1968439945d74662d64d00d04 100644 (file)
 #include <mono/utils/mono-error-internals.h>
 #include <mono/utils/bsearch.h>
 #include <mono/utils/atomic.h>
+#include <mono/utils/unlocked.h>
+#include <mono/utils/mono-counters.h>
+
+static gint32 img_set_cache_hit, img_set_cache_miss, img_set_count;
+
 
 /* Auxiliary structure used for caching inflated signatures */
 typedef struct {
@@ -515,6 +520,13 @@ mono_tables_names [] = {
 
 #endif
 
+/* If TRUE (but also see DISABLE_STICT_STRONG_NAMES #define), Mono will check
+ * that the public key token, culture and version of a candidate assembly matches
+ * the requested strong name.  If FALSE, as long as the name matches, the candidate
+ * will be allowed.
+ */
+static gboolean check_strong_names_strictly = FALSE;
+
 // Amount initially reserved in each imageset's mempool.
 // FIXME: This number is arbitrary, a more practical number should be found
 #define INITIAL_IMAGE_SET_SIZE    1024
@@ -572,17 +584,17 @@ get_nrows (MonoImage *meta, int tableidx)
 }
 
 /* Reference: Partition II - 23.2.6 */
-/*
+/**
  * mono_metadata_compute_size:
- * @meta: metadata context
- * @tableindex: metadata table number
- * @result_bitfield: pointer to guint32 where to store additional info
+ * \param meta metadata context
+ * \param tableindex metadata table number
+ * \param result_bitfield pointer to \c guint32 where to store additional info
  * 
- * mono_metadata_compute_size() computes the lenght in bytes of a single
+ * \c mono_metadata_compute_size computes the length in bytes of a single
  * row in a metadata table. The size of each column is encoded in the
- * @result_bitfield return value along with the number of columns in the table.
- * the resulting bitfield should be handed to the mono_metadata_table_size()
- * and mono_metadata_table_count() macros.
+ * \p result_bitfield return value along with the number of columns in the table.
+ * the resulting bitfield should be handed to the \c mono_metadata_table_size
+ * and \c mono_metadata_table_count macros.
  * This is a Mono runtime internal only function.
  */
 int
@@ -825,21 +837,11 @@ mono_metadata_compute_size (MonoImage *meta, int tableindex, guint32 *result_bit
                        break;
 
                        /*
-                        * CustomAttributeType: TypeDef, TypeRef, MethodDef, 
-                        * MemberRef and String.  
+                        * CustomAttributeType: MethodDef, MemberRef.
                         */
                case MONO_MT_CAT_IDX:
-                       /* String is a heap, if it is wide, we know the size */
-                       /* See above, nope. 
-                       if (meta->idx_string_wide){
-                               field_size = 4;
-                               break;
-                       }*/
-                       
-                       n = MAX (get_nrows (meta, MONO_TABLE_TYPEREF),
-                                get_nrows (meta, MONO_TABLE_TYPEDEF));
-                       n = MAX (n, get_nrows (meta, MONO_TABLE_METHOD));
-                       n = MAX (n, get_nrows (meta, MONO_TABLE_MEMBERREF));
+                       n = MAX (get_nrows (meta, MONO_TABLE_METHOD),
+                                        get_nrows (meta, MONO_TABLE_MEMBERREF));
 
                        /* 3 bits to encode */
                        field_size = rtsize (meta, n, 16-3);
@@ -1047,7 +1049,7 @@ mono_metadata_string_heap (MonoImage *meta, guint32 index)
  * mono_metadata_user_string:
  * \param meta metadata context
  * \param index index into the user string heap.
- * \returns an in-memory pointer to the \p index in the user string heap ("#US").
+ * \returns an in-memory pointer to the \p index in the user string heap (<code>#US</code>).
  */
 const char *
 mono_metadata_user_string (MonoImage *meta, guint32 index)
@@ -1179,7 +1181,7 @@ mono_metadata_decode_row_col (const MonoTableInfo *t, int idx, guint col)
  * \param ptr pointer to a blob object
  * \param rptr the new position of the pointer
  *
- * This decodes a compressed size as described by 23.1.4 (a blob or user string object)
+ * This decodes a compressed size as described by 24.2.4 (#US and #Blob a blob or user string object)
  *
  * \returns the size of the blob object
  */
@@ -1275,9 +1277,10 @@ mono_metadata_decode_signed_value (const char *ptr, const char **rptr)
        return ival - 0x20000000;
 }
 
-/* 
- * Translates the given 1-based index into the Method, Field, Event, or Param tables
- * using the *Ptr tables in uncompressed metadata, if they are available.
+/**
+ * mono_metadata_translate_token_index:
+ * Translates the given 1-based index into the \c Method, \c Field, \c Event, or \c Param tables
+ * using the \c *Ptr tables in uncompressed metadata, if they are available.
  *
  * FIXME: The caller is not forced to call this function, which is error-prone, since 
  * forgetting to call it would only show up as a bug on uncompressed metadata.
@@ -1322,10 +1325,10 @@ mono_metadata_translate_token_index (MonoImage *image, int table, guint32 idx)
 /**
  * mono_metadata_decode_table_row:
  *
- *   Same as mono_metadata_decode_row, but takes an IMAGE+TABLE ID pair, and takes
+ * Same as \c mono_metadata_decode_row, but takes an \p image + \p table ID pair, and takes
  * uncompressed metadata into account, so it should be used to access the
- * Method, Field, Param and Event tables when the access is made from metadata, i.e.
- * IDX is retrieved from a metadata table, like MONO_TYPEDEF_FIELD_LIST.
+ * \c Method, \c Field, \c Param and \c Event tables when the access is made from metadata, i.e.
+ * \p idx is retrieved from a metadata table, like \c MONO_TYPEDEF_FIELD_LIST.
  */
 void
 mono_metadata_decode_table_row (MonoImage *image, int table, int idx, guint32 *res, int res_size)
@@ -1339,9 +1342,9 @@ mono_metadata_decode_table_row (MonoImage *image, int table, int idx, guint32 *r
 /**
  * mono_metadata_decode_table_row_col:
  *
- *   Same as mono_metadata_decode_row_col, but takes an IMAGE+TABLE ID pair, and takes
+ * Same as \c mono_metadata_decode_row_col, but takes an \p image + \p table ID pair, and takes
  * uncompressed metadata into account, so it should be used to access the
- * Method, Field, Param and Event tables.
+ * \c Method, \c Field, \c Param and \c Event tables.
  */
 guint32 mono_metadata_decode_table_row_col (MonoImage *image, int table, int idx, guint col)
 {
@@ -1351,13 +1354,12 @@ guint32 mono_metadata_decode_table_row_col (MonoImage *image, int table, int idx
        return mono_metadata_decode_row_col (&image->tables [table], idx, col);
 }
 
-/*
+/**
  * mono_metadata_parse_typedef_or_ref:
- * @m: a metadata context.
- * @ptr: a pointer to an encoded TypedefOrRef in @m
- * @rptr: pointer updated to match the end of the decoded stream
- *
- * Returns: a token valid in the @m metadata decoded from
+ * \param m a metadata context.
+ * \param ptr a pointer to an encoded TypedefOrRef in \p m
+ * \param rptr pointer updated to match the end of the decoded stream
+ * \returns a token valid in the \p m metadata decoded from
  * the compressed representation.
  */
 guint32
@@ -1370,16 +1372,16 @@ mono_metadata_parse_typedef_or_ref (MonoImage *m, const char *ptr, const char **
        return mono_metadata_token_from_dor (token);
 }
 
-/*
+/**
  * mono_metadata_parse_custom_mod:
- * @m: a metadata context.
- * @dest: storage where the info about the custom modifier is stored (may be NULL)
- * @ptr: a pointer to (possibly) the start of a custom modifier list
- * @rptr: pointer updated to match the end of the decoded stream
+ * \param m a metadata context.
+ * \param dest storage where the info about the custom modifier is stored (may be NULL)
+ * \param ptr a pointer to (possibly) the start of a custom modifier list
+ * \param rptr pointer updated to match the end of the decoded stream
  *
- * Checks if @ptr points to a type custom modifier compressed representation.
+ * Checks if \p ptr points to a type custom modifier compressed representation.
  *
- * Returns: #TRUE if a custom modifier was found, #FALSE if not.
+ * \returns TRUE if a custom modifier was found, FALSE if not.
  */
 int
 mono_metadata_parse_custom_mod (MonoImage *m, MonoCustomMod *dest, const char *ptr, const char **rptr)
@@ -1443,6 +1445,9 @@ mono_metadata_parse_array_internal (MonoImage *m, MonoGenericContainer *containe
        return array;
 }
 
+/**
+ * mono_metadata_parse_array:
+ */
 MonoArrayType *
 mono_metadata_parse_array (MonoImage *m, const char *ptr, const char **rptr)
 {
@@ -1453,11 +1458,11 @@ mono_metadata_parse_array (MonoImage *m, const char *ptr, const char **rptr)
        return ret;
 }
 
-/*
+/**
  * mono_metadata_free_array:
- * @array: array description
+ * \param array array description
  *
- * Frees the array description returned from mono_metadata_parse_array().
+ * Frees the array description returned from \c mono_metadata_parse_array.
  */
 void
 mono_metadata_free_array (MonoArrayType *array)
@@ -1518,7 +1523,7 @@ builtin_types[] = {
 #define NBUILTIN_TYPES() (sizeof (builtin_types) / sizeof (builtin_types [0]))
 
 static GHashTable *type_cache = NULL;
-static int next_generic_inst_id = 0;
+static gint32 next_generic_inst_id = 0;
 
 /* Protected by image_sets_mutex */
 static MonoImageSet *mscorlib_image_set;
@@ -1637,12 +1642,26 @@ mono_metadata_init (void)
 {
        int i;
 
+       /* We guard against double initialization due to how pedump in verification mode works.
+       Until runtime initialization is properly factored to work with what it needs we need workarounds like this.
+       FIXME: https://bugzilla.xamarin.com/show_bug.cgi?id=58793
+       */
+       static gboolean inited;
+
+       if (inited)
+               return;
+       inited = TRUE;
+
        type_cache = g_hash_table_new (mono_type_hash, mono_type_equal);
 
        for (i = 0; i < NBUILTIN_TYPES (); ++i)
                g_hash_table_insert (type_cache, (gpointer) &builtin_types [i], (gpointer) &builtin_types [i]);
 
        mono_os_mutex_init_recursive (&image_sets_mutex);
+
+       mono_counters_register ("ImgSet Cache Hit", MONO_COUNTER_METADATA | MONO_COUNTER_INT, &img_set_cache_hit);
+       mono_counters_register ("ImgSet Cache Miss", MONO_COUNTER_METADATA | MONO_COUNTER_INT, &img_set_cache_miss);
+       mono_counters_register ("ImgSet Count", MONO_COUNTER_METADATA | MONO_COUNTER_INT, &img_set_count);
 }
 
 /**
@@ -1664,23 +1683,23 @@ mono_metadata_cleanup (void)
 /**
  * mono_metadata_parse_type:
  * \param m metadata context
- * \param mode king of type that may be found at \p ptr
+ * \param mode kind of type that may be found at \p ptr
  * \param opt_attrs optional attributes to store in the returned type
  * \param ptr pointer to the type representation
  * \param rptr pointer updated to match the end of the decoded stream
  * \param transient whenever to allocate the result from the heap or from a mempool
  * 
  * Decode a compressed type description found at \p ptr in \p m .
- * \p mode can be one of MONO_PARSE_MOD_TYPE, MONO_PARSE_PARAM, MONO_PARSE_RET,
- * MONO_PARSE_FIELD, MONO_PARSE_LOCAL, MONO_PARSE_TYPE.
+ * \p mode can be one of \c MONO_PARSE_MOD_TYPE, \c MONO_PARSE_PARAM, \c MONO_PARSE_RET,
+ * \c MONO_PARSE_FIELD, \c MONO_PARSE_LOCAL, \c MONO_PARSE_TYPE.
  * This function can be used to decode type descriptions in method signatures,
  * field signatures, locals signatures etc.
  *
  * To parse a generic type, \c generic_container points to the current class'es
- * (the \c generic_container field in the \c MonoClass ) or the current generic method's
- * (stored in image->property_hash) generic container.
- * When we encounter any MONO_TYPE_VAR or MONO_TYPE_MVAR's, they're looked up in
- * this MonoGenericContainer.
+ * (the \c generic_container field in the <code>MonoClass</code>) or the current generic method's
+ * (stored in <code>image->property_hash</code>) generic container.
+ * When we encounter a \c MONO_TYPE_VAR or \c MONO_TYPE_MVAR, it's looked up in
+ * this \c MonoGenericContainer.
  *
  * LOCKING: Acquires the loader lock.
  *
@@ -1907,14 +1926,14 @@ mono_metadata_get_param_attrs (MonoImage *m, int def, int param_count)
 }
 
 
-/*
+/**
  * mono_metadata_parse_signature:
- * @image: metadata context
- * @token: metadata token
+ * \param image metadata context
+ * \param token metadata token
  *
- * Decode a method signature stored in the STANDALONESIG table
+ * Decode a method signature stored in the \c StandAloneSig table
  *
- * Returns: a MonoMethodSignature describing the signature.
+ * \returns a \c MonoMethodSignature describing the signature.
  */
 MonoMethodSignature*
 mono_metadata_parse_signature (MonoImage *image, guint32 token)
@@ -1961,18 +1980,18 @@ mono_metadata_parse_signature_checked (MonoImage *image, guint32 token, MonoErro
        return mono_metadata_parse_method_signature_full (image, NULL, 0, ptr, NULL, error);
 }
 
-/*
+/**
  * mono_metadata_signature_alloc:
- * @image: metadata context
- * @nparmas: number of parameters in the signature
+ * \param image metadata context
+ * \param nparams number of parameters in the signature
  *
- * Allocate a MonoMethodSignature structure with the specified number of params.
+ * Allocate a \c MonoMethodSignature structure with the specified number of params.
  * The return type and the params types need to be filled later.
  * This is a Mono runtime internal function.
  *
  * LOCKING: Assumes the loader lock is held.
  *
- * Returns: the new MonoMethodSignature structure.
+ * \returns the new \c MonoMethodSignature structure.
  */
 MonoMethodSignature*
 mono_metadata_signature_alloc (MonoImage *m, guint32 nparams)
@@ -2067,14 +2086,14 @@ mono_metadata_signature_dup_mempool (MonoMemPool *mp, MonoMethodSignature *sig)
        return mono_metadata_signature_dup_internal (NULL, mp, sig);
 }
 
-/*
+/**
  * mono_metadata_signature_dup:
- * @sig: method signature
+ * \param sig method signature
  *
- * Duplicate an existing MonoMethodSignature so it can be modified.
+ * Duplicate an existing \c MonoMethodSignature so it can be modified.
  * This is a Mono runtime internal function.
  *
- * Returns: the new MonoMethodSignature structure.
+ * \returns the new \c MonoMethodSignature structure.
  */
 MonoMethodSignature*
 mono_metadata_signature_dup (MonoMethodSignature *sig)
@@ -2196,19 +2215,19 @@ mono_metadata_parse_method_signature_full (MonoImage *m, MonoGenericContainer *c
        return method;
 }
 
-/*
+/**
  * mono_metadata_parse_method_signature:
- * @m: metadata context
- * @def: the MethodDef index or 0 for Ref signatures.
- * @ptr: pointer to the signature metadata representation
- * @rptr: pointer updated to match the end of the decoded stream
+ * \param m metadata context
+ * \param def the \c MethodDef index or 0 for \c Ref signatures.
+ * \param ptr pointer to the signature metadata representation
+ * \param rptr pointer updated to match the end of the decoded stream
  *
- * Decode a method signature stored at @ptr.
+ * Decode a method signature stored at \p ptr.
  * This is a Mono runtime internal function.
  *
  * LOCKING: Assumes the loader lock is held.
  *
- * Returns: a MonoMethodSignature describing the signature.
+ * \returns a \c MonoMethodSignature describing the signature.
  */
 MonoMethodSignature *
 mono_metadata_parse_method_signature (MonoImage *m, int def, const char *ptr, const char **rptr)
@@ -2226,11 +2245,11 @@ mono_metadata_parse_method_signature (MonoImage *m, int def, const char *ptr, co
        return ret;
 }
 
-/*
+/**
  * mono_metadata_free_method_signature:
- * @sig: signature to destroy
+ * \param sig signature to destroy
  *
- * Free the memory allocated in the signature @sig.
+ * Free the memory allocated in the signature \p sig.
  * This method needs to be robust and work also on partially-built
  * signatures, so it does extra checks.
  */
@@ -2394,6 +2413,95 @@ image_sets_unlock (void)
        mono_os_mutex_unlock (&image_sets_mutex);
 }
 
+static int
+compare_pointers (const void *a, const void *b)
+{
+       return (size_t)a - (size_t)b;
+}
+
+//1103, 1327, 1597
+#define HASH_TABLE_SIZE 1103
+static MonoImageSet *img_set_cache [HASH_TABLE_SIZE];
+
+static guint32
+mix_hash (uintptr_t source)
+{
+       unsigned int hash = source;
+
+       // Actual hash
+       hash = (((hash * 215497) >> 16) ^ ((hash * 1823231) + hash));
+
+       // Mix in highest bits on 64-bit systems only
+       if (sizeof (source) > 4)
+               hash = hash ^ (source >> 32);
+
+       return hash;
+}
+
+static guint32
+hash_images (MonoImage **images, int nimages)
+{
+       guint32 res = 0;
+       int i;
+       for (i = 0; i < nimages; ++i)
+               res += mix_hash ((size_t)images [i]);
+
+       return res;
+}
+
+static gboolean
+compare_img_set (MonoImageSet *set, MonoImage **images, int nimages)
+{
+       int j, k;
+
+       if (set->nimages != nimages)
+               return FALSE;
+
+       for (j = 0; j < nimages; ++j) {
+               for (k = 0; k < nimages; ++k)
+                       if (set->images [k] == images [j])
+                               break; // Break on match
+
+               // If we iterated all the way through set->images, images[j] was *not* found.
+               if (k == nimages)
+                       break; // Break on "image not found"
+       }
+
+       // If we iterated all the way through images without breaking, all items in images were found in set->images
+       return j == nimages;
+}
+
+
+static MonoImageSet*
+img_set_cache_get (MonoImage **images, int nimages)
+{
+       guint32 hash_code = hash_images (images, nimages);
+       int index = hash_code % HASH_TABLE_SIZE;
+       MonoImageSet *img = img_set_cache [index];
+       if (!img || !compare_img_set (img, images, nimages)) {
+               UnlockedIncrement (&img_set_cache_miss);
+               return NULL;
+       }
+       UnlockedIncrement (&img_set_cache_hit);
+       return img;
+}
+
+static void
+img_set_cache_add (MonoImageSet *set)
+{
+       guint32 hash_code = hash_images (set->images, set->nimages);
+       int index = hash_code % HASH_TABLE_SIZE;
+       img_set_cache [index] = set;    
+}
+
+static void
+img_set_cache_remove (MonoImageSet *is)
+{
+       guint32 hash_code = hash_images (is->images, is->nimages);
+       int index = hash_code % HASH_TABLE_SIZE;
+       if (img_set_cache [index] == is)
+               img_set_cache [index] = NULL;
+}
 /*
  * get_image_set:
  *
@@ -2415,6 +2523,10 @@ get_image_set (MonoImage **images, int nimages)
        if (nimages == 0)
                return mscorlib_image_set;
 
+       set = img_set_cache_get (images, nimages);
+       if (set)
+               return set;
+
        image_sets_lock ();
 
        if (!image_sets)
@@ -2445,14 +2557,17 @@ get_image_set (MonoImage **images, int nimages)
                        }
 
                        // If we iterated all the way through images without breaking, all items in images were found in set->images
-                       if (j == nimages)
-                               break; // Break on "found a set with equal members"
+                       if (j == nimages) {
+                               // Break on "found a set with equal members".
+                               // This happens in case of a hash collision with a previously cached set.
+                               break;
+                       }
                }
 
                l = l->next;
        }
 
-       // If we iterated all the way through l without breaking, the imageset does not already exist and we shuold create it
+       // If we iterated all the way through l without breaking, the imageset does not already exist and we should create it
        if (!l) {
                set = g_new0 (MonoImageSet, 1);
                set->nimages = nimages;
@@ -2460,7 +2575,7 @@ get_image_set (MonoImage **images, int nimages)
                mono_os_mutex_init_recursive (&set->lock);
                for (i = 0; i < nimages; ++i)
                        set->images [i] = images [i];
-               set->gclass_cache = g_hash_table_new_full (mono_generic_class_hash, mono_generic_class_equal, NULL, (GDestroyNotify)free_generic_class);
+               set->gclass_cache = mono_conc_hashtable_new_full (mono_generic_class_hash, mono_generic_class_equal, NULL, (GDestroyNotify)free_generic_class);
                set->ginst_cache = g_hash_table_new_full (mono_metadata_generic_inst_hash, mono_metadata_generic_inst_equal, NULL, (GDestroyNotify)free_generic_inst);
                set->gmethod_cache = g_hash_table_new_full (inflated_method_hash, inflated_method_equal, NULL, (GDestroyNotify)free_inflated_method);
                set->gsignature_cache = g_hash_table_new_full (inflated_signature_hash, inflated_signature_equal, NULL, (GDestroyNotify)free_inflated_signature);
@@ -2469,8 +2584,12 @@ get_image_set (MonoImage **images, int nimages)
                        set->images [i]->image_sets = g_slist_prepend (set->images [i]->image_sets, set);
 
                g_ptr_array_add (image_sets, set);
+               UnlockedIncrement (&img_set_count); /* locked by image_sets_lock () */
        }
 
+       /* Cache the set. If there was a cache collision, the previously cached value will be replaced. */
+       img_set_cache_add (set);
+
        if (nimages == 1 && images [0] == mono_defaults.corlib) {
                mono_memory_barrier ();
                mscorlib_image_set = set;
@@ -2486,7 +2605,7 @@ delete_image_set (MonoImageSet *set)
 {
        int i;
 
-       g_hash_table_destroy (set->gclass_cache);
+       mono_conc_hashtable_destroy (set->gclass_cache);
        g_hash_table_destroy (set->ginst_cache);
        g_hash_table_destroy (set->gmethod_cache);
        g_hash_table_destroy (set->gsignature_cache);
@@ -2502,6 +2621,8 @@ delete_image_set (MonoImageSet *set)
 
        image_sets_unlock ();
 
+       img_set_cache_remove (set);
+
        if (set->mempool)
                mono_mempool_destroy (set->mempool);
        g_free (set->images);
@@ -2845,7 +2966,7 @@ mono_metadata_clean_for_image (MonoImage *image)
                MonoImageSet *set = (MonoImageSet *)l->data;
 
                mono_image_set_lock (set);
-               g_hash_table_foreach_steal (set->gclass_cache, steal_gclass_in_image, &gclass_data);
+               mono_conc_hashtable_foreach_steal (set->gclass_cache, steal_gclass_in_image, &gclass_data);
                g_hash_table_foreach_steal (set->ginst_cache, steal_ginst_in_image, &ginst_data);
                g_hash_table_foreach_remove (set->gmethod_cache, inflated_method_in_image, image);
                g_hash_table_foreach_remove (set->gsignature_cache, inflated_signature_in_image, image);
@@ -2964,6 +3085,18 @@ mono_metadata_get_image_set_for_method (MonoMethodInflated *method)
        return set;
 }
 
+static gboolean
+type_is_gtd (MonoType *type)
+{
+       switch (type->type) {
+       case MONO_TYPE_CLASS:
+       case MONO_TYPE_VALUETYPE:
+               return mono_class_is_gtd (type->data.klass);
+       default:
+               return FALSE;
+       }
+}
+
 /*
  * mono_metadata_get_generic_inst:
  *
@@ -2991,6 +3124,13 @@ mono_metadata_get_generic_inst (int type_argc, MonoType **type_argv)
        ginst->type_argc = type_argc;
        memcpy (ginst->type_argv, type_argv, type_argc * sizeof (MonoType *));
 
+       for (i = 0; i < type_argc; ++i) {
+               MonoType *t = ginst->type_argv [i];
+               if (type_is_gtd (t)) {
+                       ginst->type_argv [i] = mono_class_gtd_get_canonical_inst (t->data.klass);
+               }
+       }
+
        return mono_metadata_get_canonical_generic_inst (ginst);
 }
 
@@ -3031,7 +3171,7 @@ mono_metadata_get_canonical_generic_inst (MonoGenericInst *candidate)
                int size = MONO_SIZEOF_GENERIC_INST + type_argc * sizeof (MonoType *);
                ginst = (MonoGenericInst *)mono_image_set_alloc0 (set, size);
 #ifndef MONO_SMALL_CONFIG
-               ginst->id = ++next_generic_inst_id;
+               ginst->id = InterlockedIncrement (&next_generic_inst_id);
 #endif
                ginst->is_open = is_open;
                ginst->type_argc = type_argc;
@@ -3087,17 +3227,13 @@ mono_metadata_lookup_generic_class (MonoClass *container_class, MonoGenericInst
 
        collect_data_free (&data);
 
-       mono_image_set_lock (set);
-
-       gclass = (MonoGenericClass *)g_hash_table_lookup (set->gclass_cache, &helper);
+       gclass = (MonoGenericClass *)mono_conc_hashtable_lookup (set->gclass_cache, &helper);
 
        /* A tripwire just to keep us honest */
        g_assert (!helper.cached_class);
 
-       if (gclass) {
-               mono_image_set_unlock (set);
+       if (gclass)
                return gclass;
-       }
 
        gclass = mono_image_set_new0 (set, MonoGenericClass, 1);
        if (is_dynamic)
@@ -3111,11 +3247,17 @@ mono_metadata_lookup_generic_class (MonoClass *container_class, MonoGenericInst
        if (inst == mono_class_get_generic_container (container_class)->context.class_inst && !is_tb_open)
                gclass->cached_class = container_class;
 
-       g_hash_table_insert (set->gclass_cache, gclass, gclass);
+       mono_image_set_lock (set);
+
+       MonoGenericClass *gclass2 = mono_conc_hashtable_insert (set->gclass_cache, gclass, gclass);
+       if (!gclass2)
+               gclass2 = gclass;
+
+       // g_hash_table_insert (set->gclass_cache, gclass, gclass);
 
        mono_image_set_unlock (set);
 
-       return gclass;
+       return gclass2;
 }
 
 /*
@@ -3552,11 +3694,11 @@ do_mono_metadata_parse_type (MonoType *type, MonoImage *m, MonoGenericContainer
        return TRUE;
 }
 
-/*
+/**
  * mono_metadata_free_type:
- * @type: type to free
+ * \param type type to free
  *
- * Free the memory allocated for type @type which is allocated on the heap.
+ * Free the memory allocated for type \p type which is allocated on the heap.
  */
 void
 mono_metadata_free_type (MonoType *type)
@@ -3898,15 +4040,15 @@ fail:
 
 }
 
-/*
+/**
  * mono_metadata_parse_mh:
- * @generic_context: generics context
- * @ptr: pointer to the method header.
+ * \param generic_context generics context
+ * \param ptr pointer to the method header.
  *
- * Decode the method header at @ptr, including pointer to the IL code,
+ * Decode the method header at \p ptr, including pointer to the IL code,
  * info about local variables and optional exception tables.
  *
- * Returns: a transient MonoMethodHeader allocated from the heap.
+ * \returns a transient \c MonoMethodHeader allocated from the heap.
  */
 MonoMethodHeader *
 mono_metadata_parse_mh (MonoImage *m, const char *ptr)
@@ -3917,9 +4059,9 @@ mono_metadata_parse_mh (MonoImage *m, const char *ptr)
        return header;
 }
 
-/*
+/**
  * mono_metadata_free_mh:
- * @mh: a method header
+ * \param mh a method header
  *
  * Free the memory allocated for the method header.
  */
@@ -3939,17 +4081,17 @@ mono_metadata_free_mh (MonoMethodHeader *mh)
        }
 }
 
-/*
+/**
  * mono_method_header_get_code:
- * @header: a MonoMethodHeader pointer
- * @code_size: memory location for returning the code size
- * @max_stack: memory location for returning the max stack
+ * \param header a \c MonoMethodHeader pointer
+ * \param code_size memory location for returning the code size
+ * \param max_stack memory location for returning the max stack
  *
  * Method header accessor to retreive info about the IL code properties:
  * a pointer to the IL code itself, the size of the code and the max number
  * of stack slots used by the code.
  *
- * Returns: pointer to the IL code represented by the method header.
+ * \returns pointer to the IL code represented by the method header.
  */
 const unsigned char*
 mono_method_header_get_code (MonoMethodHeader *header, guint32* code_size, guint32* max_stack)
@@ -3961,17 +4103,17 @@ mono_method_header_get_code (MonoMethodHeader *header, guint32* code_size, guint
        return header->code;
 }
 
-/*
+/**
  * mono_method_header_get_locals:
- * @header: a MonoMethodHeader pointer
- * @num_locals: memory location for returning the number of local variables
- * @init_locals: memory location for returning the init_locals flag
+ * \param header a \c MonoMethodHeader pointer
+ * \param num_locals memory location for returning the number of local variables
+ * \param init_locals memory location for returning the init_locals flag
  *
  * Method header accessor to retreive info about the local variables:
  * an array of local types, the number of locals and whether the locals
  * are supposed to be initialized to 0 on method entry
  *
- * Returns: pointer to an array of types of the local variables
+ * \returns pointer to an array of types of the local variables
  */
 MonoType**
 mono_method_header_get_locals (MonoMethodHeader *header, guint32* num_locals, gboolean *init_locals)
@@ -3997,19 +4139,19 @@ mono_method_header_get_num_clauses (MonoMethodHeader *header)
        return header->num_clauses;
 }
 
-/*
+/**
  * mono_method_header_get_clauses:
- * @header: a MonoMethodHeader pointer
- * @method: MonoMethod the header belongs to
- * @iter: pointer to a iterator
- * @clause: pointer to a MonoExceptionClause structure which will be filled with the info
+ * \param header a \c MonoMethodHeader pointer
+ * \param method \c MonoMethod the header belongs to
+ * \param iter pointer to a iterator
+ * \param clause pointer to a \c MonoExceptionClause structure which will be filled with the info
  *
- * Get the info about the exception clauses in the method. Set *iter to NULL to
+ * Get the info about the exception clauses in the method. Set \c *iter to NULL to
  * initiate the iteration, then call the method repeatedly until it returns FALSE.
  * At each iteration, the structure pointed to by clause if filled with the
  * exception clause information.
  *
- * Returns: TRUE if clause was filled with info, FALSE if there are no more exception
+ * \returns TRUE if clause was filled with info, FALSE if there are no more exception
  * clauses.
  */
 int
@@ -4074,15 +4216,15 @@ mono_metadata_parse_param (MonoImage *m, const char *ptr, const char **rptr)
        return type;
 }
 
-/*
+/**
  * mono_metadata_token_from_dor:
- * @dor_token: A TypeDefOrRef coded index
+ * \param dor_token A \c TypeDefOrRef coded index
  *
- * dor_token is a TypeDefOrRef coded index: it contains either
- * a TypeDef, TypeRef or TypeSpec in the lower bits, and the upper
+ * \p dor_token is a \c TypeDefOrRef coded index: it contains either
+ * a \c TypeDef, \c TypeRef or \c TypeSpec in the lower bits, and the upper
  * bits contain an index into the table.
  *
- * Returns: an expanded token
+ * \returns an expanded token
  */
 guint32
 mono_metadata_token_from_dor (guint32 dor_index)
@@ -4247,8 +4389,8 @@ search_ptr_table (MonoImage *image, int table, int idx)
  * \param meta metadata context
  * \param index FieldDef token
  *
- * \returns the 1-based index into the TypeDef table of the type that
- * declared the field described by \p index , or 0 if not found.
+ * \returns the 1-based index into the \c TypeDef table of the type that
+ * declared the field described by \p index, or 0 if not found.
  */
 guint32
 mono_metadata_typedef_from_field (MonoImage *meta, guint32 index)
@@ -4273,13 +4415,12 @@ mono_metadata_typedef_from_field (MonoImage *meta, guint32 index)
        return loc.result + 1;
 }
 
-/*
+/**
  * mono_metadata_typedef_from_method:
- * @meta: metadata context
- * @index: MethodDef token
- *
- * Returns: the 1-based index into the TypeDef table of the type that
- * declared the method described by @index.  0 if not found.
+ * \param meta metadata context
+ * \param index \c MethodDef token
+ * \returns the 1-based index into the \c TypeDef table of the type that
+ * declared the method described by \p index.  0 if not found.
  */
 guint32
 mono_metadata_typedef_from_method (MonoImage *meta, guint32 index)
@@ -4385,20 +4526,20 @@ mono_metadata_interfaces_from_typedef_full (MonoImage *meta, guint32 index, Mono
        return TRUE;
 }
 
-/*
- * @meta: metadata context
- * @index: typedef token
- * @count: Out parameter used to store the number of interfaces
+/**
+ * mono_metadata_interfaces_from_typedef:
+ * \param meta metadata context
+ * \param index typedef token
+ * \param count Out parameter used to store the number of interfaces
  * 
- * The array of interfaces that the @index typedef token implements is returned in
- * @interfaces. The number of elements in the array is returned in @count. The returned
- * array is g_malloc'd and the caller must free it.
+ * The array of interfaces that the \p index typedef token implements is returned in
+ * \p interfaces. The number of elements in the array is returned in \p count. The returned
+ * array is allocated with \c g_malloc and the caller must free it.
  *
  * LOCKING: Acquires the loader lock .
  *
- * Returns: the interface array on success, NULL on failure.
+ * \returns the interface array on success, NULL on failure.
  */
-
 MonoClass**
 mono_metadata_interfaces_from_typedef (MonoImage *meta, guint32 index, guint *count)
 {
@@ -4414,14 +4555,13 @@ mono_metadata_interfaces_from_typedef (MonoImage *meta, guint32 index, guint *co
                return NULL;
 }
 
-/*
+/**
  * mono_metadata_nested_in_typedef:
- * @meta: metadata context
- * @index: typedef token
- * 
- * Returns: the 1-based index into the TypeDef table of the type
- * where the type described by @index is nested.
- * Returns 0 if @index describes a non-nested type.
+ * \param meta metadata context
+ * \param index typedef token
+ * \returns the 1-based index into the TypeDef table of the type
+ * where the type described by \p index is nested.
+ * Returns 0 if \p index describes a non-nested type.
  */
 guint32
 mono_metadata_nested_in_typedef (MonoImage *meta, guint32 index)
@@ -4443,14 +4583,13 @@ mono_metadata_nested_in_typedef (MonoImage *meta, guint32 index)
        return mono_metadata_decode_row_col (tdef, loc.result, MONO_NESTED_CLASS_ENCLOSING) | MONO_TOKEN_TYPE_DEF;
 }
 
-/*
+/**
  * mono_metadata_nesting_typedef:
- * @meta: metadata context
- * @index: typedef token
- * 
- * Returns: the 1-based index into the TypeDef table of the first type
- * that is nested inside the type described by @index. The search starts at
- * @start_index.  returns 0 if no such type is found.
+ * \param meta metadata context
+ * \param index typedef token
+ * \returns the 1-based index into the \c TypeDef table of the first type
+ * that is nested inside the type described by \p index. The search starts at
+ * \p start_index. Returns 0 if no such type is found.
  */
 guint32
 mono_metadata_nesting_typedef (MonoImage *meta, guint32 index, guint32 start_index)
@@ -4477,13 +4616,12 @@ mono_metadata_nesting_typedef (MonoImage *meta, guint32 index, guint32 start_ind
                return start;
 }
 
-/*
+/**
  * mono_metadata_packing_from_typedef:
- * @meta: metadata context
- * @index: token representing a type
- * 
- * Returns: the info stored in the ClassLAyout table for the given typedef token
- * into the @packing and @size pointers.
+ * \param meta metadata context
+ * \param index token representing a type
+ * \returns the info stored in the \c ClassLayout table for the given typedef token
+ * into the \p packing and \p size pointers.
  * Returns 0 if the info is not found.
  */
 guint32
@@ -4513,13 +4651,12 @@ mono_metadata_packing_from_typedef (MonoImage *meta, guint32 index, guint32 *pac
        return loc.result + 1;
 }
 
-/*
+/**
  * mono_metadata_custom_attrs_from_index:
- * @meta: metadata context
- * @index: token representing the parent
- * 
- * Returns: the 1-based index into the CustomAttribute table of the first 
- * attribute which belongs to the metadata object described by @index.
+ * \param meta metadata context
+ * \param index token representing the parent
+ * \returns: the 1-based index into the \c CustomAttribute table of the first 
+ * attribute which belongs to the metadata object described by \p index.
  * Returns 0 if no such attribute is found.
  */
 guint32
@@ -4548,14 +4685,13 @@ mono_metadata_custom_attrs_from_index (MonoImage *meta, guint32 index)
        return loc.result + 1;
 }
 
-/*
+/**
  * mono_metadata_declsec_from_index:
- * @meta: metadata context
- * @index: token representing the parent
- * 
- * Returns: the 0-based index into the DeclarativeSecurity table of the first 
- * attribute which belongs to the metadata object described by @index.
- * Returns -1 if no such attribute is found.
+ * \param meta metadata context
+ * \param index token representing the parent
+ * \returns the 0-based index into the \c DeclarativeSecurity table of the first 
+ * attribute which belongs to the metadata object described by \p index.
+ * Returns \c -1 if no such attribute is found.
  */
 guint32
 mono_metadata_declsec_from_index (MonoImage *meta, guint32 index)
@@ -4651,11 +4787,10 @@ mono_type_set_alignment (MonoTypeEnum type, int align)
        }
 }
 
-/*
+/**
  * mono_type_size:
- * @t: the type to return the size of
- *
- * Returns: the number of bytes required to hold an instance of this
+ * \param t the type to return the size of
+ * \returns The number of bytes required to hold an instance of this
  * type in memory
  */
 int
@@ -4757,11 +4892,10 @@ mono_type_size (MonoType *t, int *align)
        return 0;
 }
 
-/*
+/**
  * mono_type_stack_size:
- * @t: the type to return the size it uses on the stack
- *
- * Returns: the number of bytes required to hold an instance of this
+ * \param t the type to return the size it uses on the stack
+ * \returns The number of bytes required to hold an instance of this
  * type on the runtime stack
  */
 int
@@ -4893,6 +5027,9 @@ mono_type_generic_inst_is_valuetype (MonoType *type)
        return type->data.generic_class->container_class->valuetype;
 }
 
+/**
+ * mono_metadata_generic_class_is_valuetype:
+ */
 gboolean
 mono_metadata_generic_class_is_valuetype (MonoGenericClass *gclass)
 {
@@ -4967,11 +5104,10 @@ mono_metadata_str_hash (gconstpointer v1)
        return hash;
 } 
 
-/*
+/**
  * mono_metadata_type_hash:
- * @t1: a type
- *
- * Computes an hash value for @t1 to be used in GHashTable.
+ * \param t1 a type
+ * Computes a hash value for \p t1 to be used in \c GHashTable.
  * The returned hash is guaranteed to be the same across executions.
  */
 guint
@@ -5189,6 +5325,9 @@ do_mono_metadata_type_equal (MonoType *t1, MonoType *t2, gboolean signature_only
        return FALSE;
 }
 
+/**
+ * mono_metadata_type_equal:
+ */
 gboolean
 mono_metadata_type_equal (MonoType *t1, MonoType *t2)
 {
@@ -5286,6 +5425,9 @@ mono_metadata_type_dup (MonoImage *image, const MonoType *o)
        return r;
 }
 
+/**
+ * mono_signature_hash:
+ */
 guint
 mono_signature_hash (MonoMethodSignature *sig)
 {
@@ -5329,20 +5471,17 @@ mono_metadata_encode_value (guint32 value, char *buf, char **endbuf)
                *endbuf = p;
 }
 
-/*
+/**
  * mono_metadata_field_info:
- * @meta: the Image the field is defined in
- * @index: the index in the field table representing the field
- * @offset: a pointer to an integer where to store the offset that 
- * may have been specified for the field in a FieldLayout table
- * @rva: a pointer to the RVA of the field data in the image that
- * may have been defined in a FieldRVA table
- * @marshal_spec: a pointer to the marshal spec that may have been 
- * defined for the field in a FieldMarshal table.
- *
- * Gather info for field @index that may have been defined in the FieldLayout, 
- * FieldRVA and FieldMarshal tables.
- * Either of offset, rva and marshal_spec can be NULL if you're not interested 
+ * \param meta the Image the field is defined in
+ * \param index the index in the field table representing the field
+ * \param offset a pointer to an integer where to store the offset that  may have been specified for the field in a FieldLayout table
+ * \param rva a pointer to the RVA of the field data in the image that may have been defined in a \c FieldRVA table
+ * \param marshal_spec a pointer to the marshal spec that may have been defined for the field in a \c FieldMarshal table.
+ *
+ * Gather info for field \p index that may have been defined in the \c FieldLayout, 
+ * \c FieldRVA and \c FieldMarshal tables.
+ * Either of \p offset, \p rva and \p marshal_spec can be NULL if you're not interested 
  * in the data.
  */
 void
@@ -5407,15 +5546,15 @@ mono_metadata_field_info_full (MonoImage *meta, guint32 index, guint32 *offset,
 
 }
 
-/*
+/**
  * mono_metadata_get_constant_index:
- * @meta: the Image the field is defined in
- * @index: the token that may have a row defined in the constants table
- * @hint: possible position for the row
+ * \param meta the Image the field is defined in
+ * \param index the token that may have a row defined in the constants table
+ * \param hint possible position for the row
  *
- * @token must be a FieldDef, ParamDef or PropertyDef token.
+ * \p token must be a \c FieldDef, \c ParamDef or \c PropertyDef token.
  *
- * Returns: the index into the Constants table or 0 if not found.
+ * \returns the index into the \c Constants table or 0 if not found.
  */
 guint32
 mono_metadata_get_constant_index (MonoImage *meta, guint32 token, guint32 hint)
@@ -5455,14 +5594,13 @@ mono_metadata_get_constant_index (MonoImage *meta, guint32 token, guint32 hint)
        return 0;
 }
 
-/*
+/**
  * mono_metadata_events_from_typedef:
- * @meta: metadata context
- * @index: 0-based index (in the TypeDef table) describing a type
- *
- * Returns: the 0-based index in the Event table for the events in the
+ * \param meta metadata context
+ * \param index 0-based index (in the \c TypeDef table) describing a type
+ * \returns the 0-based index in the \c Event table for the events in the
  * type. The last event that belongs to the type (plus 1) is stored
- * in the @end_idx pointer.
+ * in the \p end_idx pointer.
  */
 guint32
 mono_metadata_events_from_typedef (MonoImage *meta, guint32 index, guint *end_idx)
@@ -5494,14 +5632,13 @@ mono_metadata_events_from_typedef (MonoImage *meta, guint32 index, guint *end_id
        return start - 1;
 }
 
-/*
+/**
  * mono_metadata_methods_from_event:
- * @meta: metadata context
- * @index: 0-based index (in the Event table) describing a event
- *
- * Returns: the 0-based index in the MethodDef table for the methods in the
+ * \param meta metadata context
+ * \param index 0-based index (in the \c Event table) describing a event
+ * \returns the 0-based index in the \c MethodDef table for the methods in the
  * event. The last method that belongs to the event (plus 1) is stored
- * in the @end_idx pointer.
+ * in the \p end_idx pointer.
  */
 guint32
 mono_metadata_methods_from_event   (MonoImage *meta, guint32 index, guint *end_idx)
@@ -5546,14 +5683,13 @@ mono_metadata_methods_from_event   (MonoImage *meta, guint32 index, guint *end_i
        return start;
 }
 
-/*
+/**
  * mono_metadata_properties_from_typedef:
- * @meta: metadata context
- * @index: 0-based index (in the TypeDef table) describing a type
- *
- * Returns: the 0-based index in the Property table for the properties in the
+ * \param meta metadata context
+ * \param index 0-based index (in the \c TypeDef table) describing a type
+ * \returns the 0-based index in the \c Property table for the properties in the
  * type. The last property that belongs to the type (plus 1) is stored
- * in the @end_idx pointer.
+ * in the \p end_idx pointer.
  */
 guint32
 mono_metadata_properties_from_typedef (MonoImage *meta, guint32 index, guint *end_idx)
@@ -5585,14 +5721,13 @@ mono_metadata_properties_from_typedef (MonoImage *meta, guint32 index, guint *en
        return start - 1;
 }
 
-/*
+/**
  * mono_metadata_methods_from_property:
- * @meta: metadata context
- * @index: 0-based index (in the PropertyDef table) describing a property
- *
- * Returns: the 0-based index in the MethodDef table for the methods in the
+ * \param meta metadata context
+ * \param index 0-based index (in the \c PropertyDef table) describing a property
+ * \returns the 0-based index in the \c MethodDef table for the methods in the
  * property. The last method that belongs to the property (plus 1) is stored
- * in the @end_idx pointer.
+ * in the \p end_idx pointer.
  */
 guint32
 mono_metadata_methods_from_property   (MonoImage *meta, guint32 index, guint *end_idx)
@@ -5637,6 +5772,9 @@ mono_metadata_methods_from_property   (MonoImage *meta, guint32 index, guint *en
        return start;
 }
 
+/**
+ * mono_metadata_implmap_from_method:
+ */
 guint32
 mono_metadata_implmap_from_method (MonoImage *meta, guint32 method_idx)
 {
@@ -5659,11 +5797,12 @@ mono_metadata_implmap_from_method (MonoImage *meta, guint32 method_idx)
 }
 
 /**
- * @image: context where the image is created
- * @type_spec:  typespec token
- * @deprecated use mono_type_create_from_typespec_checked that has proper error handling
+ * mono_type_create_from_typespec:
+ * \param image context where the image is created
+ * \param type_spec  typespec token
+ * \deprecated use \c mono_type_create_from_typespec_checked that has proper error handling
  *
- * Creates a MonoType representing the TypeSpec indexed by the @type_spec
+ * Creates a \c MonoType representing the \c TypeSpec indexed by the \p type_spec
  * token.
  */
 MonoType *
@@ -5688,9 +5827,7 @@ mono_type_create_from_typespec_checked (MonoImage *image, guint32 type_spec, Mon
 
        error_init (error);
 
-       mono_image_lock (image);
-       type = (MonoType *)g_hash_table_lookup (image->typespec_cache, GUINT_TO_POINTER (type_spec));
-       mono_image_unlock (image);
+       type = (MonoType *)mono_conc_hashtable_lookup (image->typespec_cache, GUINT_TO_POINTER (type_spec));
        if (type)
                return type;
 
@@ -5714,12 +5851,12 @@ mono_type_create_from_typespec_checked (MonoImage *image, guint32 type_spec, Mon
        mono_metadata_free_type (type);
 
        mono_image_lock (image);
-       type = (MonoType *)g_hash_table_lookup (image->typespec_cache, GUINT_TO_POINTER (type_spec));
+
        /* We might leak some data in the image mempool if found */
-       if (!type) {
-               g_hash_table_insert (image->typespec_cache, GUINT_TO_POINTER (type_spec), type2);
+       type = mono_conc_hashtable_insert (image->typespec_cache, GUINT_TO_POINTER (type_spec), type2);
+       if (!type)
                type = type2;
-       }
+
        mono_image_unlock (image);
 
        return type;
@@ -5738,6 +5875,9 @@ mono_image_strndup (MonoImage *image, const char *data, guint len)
        return res;
 }
 
+/**
+ * mono_metadata_parse_marshal_spec:
+ */
 MonoMarshalSpec *
 mono_metadata_parse_marshal_spec (MonoImage *image, const char *ptr)
 {
@@ -5828,6 +5968,9 @@ mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image
        return res;
 }
 
+/**
+ * mono_metadata_free_marshal_spec:
+ */
 void 
 mono_metadata_free_marshal_spec (MonoMarshalSpec *spec)
 {
@@ -5840,13 +5983,10 @@ mono_metadata_free_marshal_spec (MonoMarshalSpec *spec)
 
 /**
  * mono_type_to_unmanaged:
- *
- * Returns: A MonoMarshalNative enumeration value (MONO_NATIVE_) value
+ * The value pointed to by \p conv will contain the kind of marshalling required for this
+ * particular type one of the \c MONO_MARSHAL_CONV_ enumeration values.
+ * \returns A \c MonoMarshalNative enumeration value (<code>MONO_NATIVE_</code>) value
  * describing the underlying native reprensetation of the type.
- * 
- * In addition the value pointed by
- * "conv" will contain the kind of marshalling required for this
- * particular type one of the MONO_MARSHAL_CONV_ enumeration values.
  */
 guint32
 mono_type_to_unmanaged (MonoType *type, MonoMarshalSpec *mspec, gboolean as_field,
@@ -6037,6 +6177,9 @@ handle_enum:
        return MONO_NATIVE_MAX;
 }
 
+/**
+ * mono_metadata_get_marshal_info:
+ */
 const char*
 mono_metadata_get_marshal_info (MonoImage *meta, guint32 idx, gboolean is_field)
 {
@@ -6415,7 +6558,6 @@ mono_get_shared_generic_inst (MonoGenericContainer *container)
 /**
  * mono_type_is_byref:
  * \param type the \c MonoType operated on
- *
  * \returns TRUE if \p type represents a type passed by reference,
  * FALSE otherwise.
  */
@@ -6428,8 +6570,8 @@ mono_type_is_byref (MonoType *type)
 /**
  * mono_type_get_type:
  * \param type the \c MonoType operated on
- * \returns the IL type value for \p type. This is one of the MonoTypeEnum
- * enum members like MONO_TYPE_I4 or MONO_TYPE_STRING.
+ * \returns the IL type value for \p type. This is one of the \c MonoTypeEnum
+ * enum members like \c MONO_TYPE_I4 or \c MONO_TYPE_STRING.
  */
 int
 mono_type_get_type (MonoType *type)
@@ -6455,7 +6597,7 @@ mono_type_get_signature (MonoType *type)
  * mono_type_get_class:
  * \param type the \c MonoType operated on
  * It is only valid to call this function if \p type is a \c MONO_TYPE_CLASS or a
- * \c MONO_TYPE_VALUETYPE . For more general functionality, use mono_class_from_mono_type(),
+ * \c MONO_TYPE_VALUETYPE . For more general functionality, use \c mono_class_from_mono_type,
  * instead.
  * \returns the \c MonoClass pointer that describes the class that \p type represents.
  */
@@ -6494,6 +6636,9 @@ mono_type_get_ptr_type (MonoType *type)
        return type->data.type;
 }
 
+/**
+ * mono_type_get_modifiers:
+ */
 MonoClass*
 mono_type_get_modifiers (MonoType *type, gboolean *is_required, gpointer *iter)
 {
@@ -6583,7 +6728,7 @@ mono_signature_get_return_type (MonoMethodSignature *sig)
  * A \c void* pointer must be initialized to NULL to start the iteration
  * and its address is passed to this function repeteadly until it returns
  * NULL.
- * \returns: the next parameter type of the method signature \p sig,
+ * \returns the next parameter type of the method signature \p sig,
  * NULL when finished.
  */
 MonoType*
@@ -6786,3 +6931,15 @@ mono_find_image_set_owner (void *ptr)
 
        return owner;
 }
+
+void
+mono_loader_set_strict_strong_names (gboolean enabled)
+{
+       check_strong_names_strictly = enabled;
+}
+
+gboolean
+mono_loader_get_strict_strong_names (void)
+{
+       return check_strong_names_strictly;
+}