[threadpool-ms] Remove recursivity of active_threads_lock
[mono.git] / mono / metadata / image.c
index 7045f4d05efec256289609edc29edbb0c1a65bfc..56403f3463a61b24e0fc601a4b9fbb761ec78eae 100644 (file)
@@ -679,7 +679,7 @@ mono_image_init (MonoImage *image)
                                       g_direct_hash,
                                       class_key_extract,
                                       class_next_value);
-       image->field_cache = mono_conc_hashtable_new (&image->lock, NULL, NULL);
+       image->field_cache = mono_conc_hashtable_new (NULL, NULL);
 
        image->typespec_cache = g_hash_table_new (NULL, NULL);
        image->memberref_signatures = g_hash_table_new (NULL, NULL);
@@ -1145,7 +1145,7 @@ register_image (MonoImage *image)
 }
 
 MonoImage *
-mono_image_open_from_data_with_name (char *data, guint32 data_len, gboolean need_copy, MonoImageOpenStatus *status, gboolean refonly, const char *name)
+mono_image_open_from_data_internal (char *data, guint32 data_len, gboolean need_copy, MonoImageOpenStatus *status, gboolean refonly, gboolean metadata_only, const char *name)
 {
        MonoCLIImageInfo *iinfo;
        MonoImage *image;
@@ -1175,6 +1175,7 @@ mono_image_open_from_data_with_name (char *data, guint32 data_len, gboolean need
        iinfo = g_new0 (MonoCLIImageInfo, 1);
        image->image_info = iinfo;
        image->ref_only = refonly;
+       image->metadata_only = metadata_only;
 
        image = do_mono_image_load (image, status, TRUE, TRUE);
        if (image == NULL)
@@ -1183,6 +1184,12 @@ mono_image_open_from_data_with_name (char *data, guint32 data_len, gboolean need
        return register_image (image);
 }
 
+MonoImage *
+mono_image_open_from_data_with_name (char *data, guint32 data_len, gboolean need_copy, MonoImageOpenStatus *status, gboolean refonly, const char *name)
+{
+       return mono_image_open_from_data_internal (data, data_len, need_copy, status, refonly, FALSE, name);
+}
+
 MonoImage *
 mono_image_open_from_data_full (char *data, guint32 data_len, gboolean need_copy, MonoImageOpenStatus *status, gboolean refonly)
 {
@@ -1491,6 +1498,34 @@ free_hash (GHashTable *hash)
                g_hash_table_destroy (hash);
 }
 
+void
+mono_wrapper_caches_free (MonoWrapperCaches *cache)
+{
+       free_hash (cache->delegate_invoke_cache);
+       free_hash (cache->delegate_begin_invoke_cache);
+       free_hash (cache->delegate_end_invoke_cache);
+       free_hash (cache->runtime_invoke_cache);
+       free_hash (cache->runtime_invoke_vtype_cache);
+       
+       free_hash (cache->delegate_abstract_invoke_cache);
+
+       free_hash (cache->runtime_invoke_direct_cache);
+       free_hash (cache->managed_wrapper_cache);
+
+       free_hash (cache->native_wrapper_cache);
+       free_hash (cache->native_wrapper_aot_cache);
+       free_hash (cache->native_wrapper_check_cache);
+       free_hash (cache->native_wrapper_aot_check_cache);
+
+       free_hash (cache->native_func_wrapper_aot_cache);
+       free_hash (cache->remoting_invoke_cache);
+       free_hash (cache->synchronized_cache);
+       free_hash (cache->unbox_wrapper_cache);
+       free_hash (cache->cominterop_invoke_cache);
+       free_hash (cache->cominterop_wrapper_cache);
+       free_hash (cache->thunk_invoke_cache);
+}
+
 /*
  * Returns whether mono_image_close_finish() must be called as well.
  * We must unload images in two steps because clearing the domain in
@@ -1650,24 +1685,7 @@ mono_image_close_except_pools (MonoImage *image)
        free_hash (image->native_func_wrapper_cache);
        free_hash (image->typespec_cache);
 
-       free_hash (image->wrapper_caches.native_wrapper_cache);
-       free_hash (image->wrapper_caches.native_wrapper_aot_cache);
-       free_hash (image->wrapper_caches.native_wrapper_check_cache);
-       free_hash (image->wrapper_caches.native_wrapper_aot_check_cache);
-       free_hash (image->wrapper_caches.managed_wrapper_cache);
-       free_hash (image->wrapper_caches.delegate_begin_invoke_cache);
-       free_hash (image->wrapper_caches.delegate_end_invoke_cache);
-       free_hash (image->wrapper_caches.delegate_invoke_cache);
-       free_hash (image->wrapper_caches.delegate_abstract_invoke_cache);
-       free_hash (image->wrapper_caches.remoting_invoke_cache);
-       free_hash (image->wrapper_caches.runtime_invoke_cache);
-       free_hash (image->wrapper_caches.runtime_invoke_vtype_cache);
-       free_hash (image->wrapper_caches.runtime_invoke_direct_cache);
-       free_hash (image->wrapper_caches.synchronized_cache);
-       free_hash (image->wrapper_caches.unbox_wrapper_cache);
-       free_hash (image->wrapper_caches.cominterop_invoke_cache);
-       free_hash (image->wrapper_caches.cominterop_wrapper_cache);
-       free_hash (image->wrapper_caches.thunk_invoke_cache);
+       mono_wrapper_caches_free (&image->wrapper_caches);
 
        for (i = 0; i < image->gshared_types_len; ++i)
                free_hash (image->gshared_types [i]);