[sgen] Add optimized drain stack functions for the concurrent collector
[mono.git] / mono / metadata / metadata-internals.h
index f8e76526f43c07768068b88501d836c3a25065cd..27098c333868682a1010a36b4b4c223fcb56ff1f 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "mono/metadata/image.h"
 #include "mono/metadata/blob.h"
+#include "mono/metadata/cil-coff.h"
 #include "mono/metadata/mempool.h"
 #include "mono/metadata/domain-internals.h"
 #include "mono/metadata/mono-hash.h"
@@ -100,6 +101,43 @@ struct _MonoAssembly {
        guint32 skipverification:2;     /* Has SecurityPermissionFlag.SkipVerification permission */
 };
 
+typedef struct {
+       /*
+        * indexed by MonoMethodSignature 
+        * Protected by the marshal lock
+        */
+       GHashTable *delegate_invoke_cache;
+       GHashTable *delegate_begin_invoke_cache;
+       GHashTable *delegate_end_invoke_cache;
+       GHashTable *runtime_invoke_cache;
+       GHashTable *runtime_invoke_vtype_cache;
+
+       /*
+        * indexed by SignaturePointerPair
+        */
+       GHashTable *delegate_abstract_invoke_cache;
+
+       /*
+        * indexed by MonoMethod pointers
+        * Protected by the marshal lock
+        */
+       GHashTable *runtime_invoke_direct_cache;
+       GHashTable *managed_wrapper_cache;
+
+       GHashTable *native_wrapper_cache;
+       GHashTable *native_wrapper_aot_cache;
+       GHashTable *native_wrapper_check_cache;
+       GHashTable *native_wrapper_aot_check_cache;
+
+       GHashTable *native_func_wrapper_aot_cache;
+       GHashTable *remoting_invoke_cache;
+       GHashTable *synchronized_cache;
+       GHashTable *unbox_wrapper_cache;
+       GHashTable *cominterop_invoke_cache;
+       GHashTable *cominterop_wrapper_cache; /* LOCKING: marshal lock */
+       GHashTable *thunk_invoke_cache;
+} MonoWrapperCaches;
+
 typedef struct {
        const char* data;
        guint32  size;
@@ -127,6 +165,13 @@ struct _MonoTableInfo {
 
 typedef struct _MonoDllMap MonoDllMap;
 
+typedef struct {
+       gboolean (*match) (MonoImage*);
+       gboolean (*load_pe_data) (MonoImage*);
+       gboolean (*load_cli_data) (MonoImage*);
+       gboolean (*load_tables) (MonoImage*);
+} MonoImageLoader;
+
 struct _MonoImage {
        /*
         * The number of assemblies which reference this MonoImage though their 'image'
@@ -255,41 +300,17 @@ struct _MonoImage {
        /* This has a separate lock to improve scalability */
        mono_mutex_t szarray_cache_lock;
 
-       /*
-        * indexed by MonoMethodSignature 
-        */
-       GHashTable *delegate_begin_invoke_cache;
-       GHashTable *delegate_end_invoke_cache;
-       GHashTable *delegate_invoke_cache;
-       GHashTable *runtime_invoke_cache;
-       GHashTable *runtime_invoke_vtype_cache;
-
        /*
         * indexed by SignaturePointerPair
         */
-       GHashTable *delegate_abstract_invoke_cache;
        GHashTable *delegate_bound_static_invoke_cache;
        GHashTable *native_func_wrapper_cache;
 
        /*
         * indexed by MonoMethod pointers 
         */
-       GHashTable *runtime_invoke_direct_cache;
        GHashTable *runtime_invoke_vcall_cache;
-       GHashTable *managed_wrapper_cache;
-       GHashTable *native_wrapper_cache;
-       GHashTable *native_wrapper_aot_cache;
-       GHashTable *native_wrapper_check_cache;
-       GHashTable *native_wrapper_aot_check_cache;
-       GHashTable *native_func_wrapper_aot_cache;
-       GHashTable *remoting_invoke_cache;
-       GHashTable *synchronized_cache;
-       GHashTable *unbox_wrapper_cache;
-       GHashTable *cominterop_invoke_cache;
-       GHashTable *cominterop_wrapper_cache; /* LOCKING: marshal lock */
-       GHashTable *thunk_invoke_cache;
        GHashTable *wrapper_param_names;
-       GHashTable *synchronized_generic_cache;
        GHashTable *array_accessor_cache;
 
        /*
@@ -302,9 +323,6 @@ struct _MonoImage {
        GHashTable *castclass_cache;
        GHashTable *proxy_isinst_cache;
        GHashTable *rgctx_template_hash; /* LOCKING: templates lock */
-       GHashTable *delegate_invoke_generic_cache;
-       GHashTable *delegate_begin_invoke_generic_cache;
-       GHashTable *delegate_end_invoke_generic_cache;
 
        /* Contains rarely used fields of runtime structures belonging to this image */
        MonoPropertyHash *property_hash;
@@ -328,10 +346,14 @@ struct _MonoImage {
           malloc'ed regions to be freed. */
        GSList *reflection_info_unregister_classes;
 
-       /* List of image sets containing this image */
+       /* List of dependent image sets containing this image */
        /* Protected by image_sets_lock */
        GSList *image_sets;
 
+       /* Caches for wrappers that DO NOT reference generic */
+       /* arguments */
+       MonoWrapperCaches wrapper_caches;
+
        /* Caches for MonoClass-es representing anon generic params */
        MonoClass **var_cache_fast;
        MonoClass **mvar_cache_fast;
@@ -351,6 +373,9 @@ struct _MonoImage {
        /* The length of the above array */
        int gshared_types_len;
 
+       /* The loader used to load this image */
+       MonoImageLoader *loader;
+
        /*
         * No other runtime locks must be taken while holding this lock.
         * It's meant to be used only to mutate and query structures part of this image.
@@ -369,8 +394,11 @@ typedef struct {
        int nimages;
        MonoImage **images;
 
+       // Generic-specific caches
        GHashTable *gclass_cache, *ginst_cache, *gmethod_cache, *gsignature_cache;
 
+       MonoWrapperCaches wrapper_caches;
+
        mono_mutex_t    lock;
 
        /*
@@ -620,6 +648,9 @@ mono_install_image_unload_hook (MonoImageUnloadFunc func, gpointer user_data);
 void
 mono_remove_image_unload_hook (MonoImageUnloadFunc func, gpointer user_data);
 
+void
+mono_install_image_loader (const MonoImageLoader *loader);
+
 void
 mono_image_append_class_to_reflection_info_set (MonoClass *klass);
 
@@ -629,11 +660,23 @@ mono_image_set_alloc  (MonoImageSet *set, guint size);
 gpointer
 mono_image_set_alloc0 (MonoImageSet *set, guint size);
 
+void
+mono_image_set_lock (MonoImageSet *set);
+
+void
+mono_image_set_unlock (MonoImageSet *set);
+
 char*
 mono_image_set_strdup (MonoImageSet *set, const char *s);
 
 #define mono_image_set_new0(image,type,size) ((type *) mono_image_set_alloc0 (image, sizeof (type)* (size)))
 
+gboolean
+mono_image_load_cli_header (MonoImage *image, MonoCLIImageInfo *iinfo);
+
+gboolean
+mono_image_load_metadata (MonoImage *image, MonoCLIImageInfo *iinfo);
+
 MonoType*
 mono_metadata_get_shared_type (MonoType *type);
 
@@ -753,6 +796,7 @@ void mono_unload_interface_ids (MonoBitSet *bitset);
 MonoType *mono_metadata_type_dup (MonoImage *image, const MonoType *original);
 MonoMethodSignature  *mono_metadata_signature_dup_full (MonoImage *image,MonoMethodSignature *sig);
 MonoMethodSignature  *mono_metadata_signature_dup_mempool (MonoMemPool *mp, MonoMethodSignature *sig);
+MonoMethodSignature  *mono_metadata_signature_dup_add_this (MonoImage *image, MonoMethodSignature *sig, MonoClass *klass);
 
 MonoGenericInst *
 mono_get_shared_generic_inst (MonoGenericContainer *container);
@@ -803,6 +847,8 @@ MonoImage *mono_image_open_raw (const char *fname, MonoImageOpenStatus *status);
 
 MonoImage *mono_image_open_metadata_only (const char *fname, MonoImageOpenStatus *status);
 
+MonoImage *mono_image_open_from_data_internal (char *data, guint32 data_len, gboolean need_copy, MonoImageOpenStatus *status, gboolean refonly, gboolean metadata_only, const char *name);
+
 MonoException *mono_get_exception_field_access_msg (const char *msg);
 
 MonoException *mono_get_exception_method_access_msg (const char *msg);
@@ -827,5 +873,14 @@ mono_get_method_checked (MonoImage *image, guint32 token, MonoClass *klass, Mono
 guint32
 mono_metadata_localscope_from_methoddef (MonoImage *meta, guint32 index);
 
+void
+mono_wrapper_caches_free (MonoWrapperCaches *cache);
+
+MonoWrapperCaches*
+mono_method_get_wrapper_cache (MonoMethod *method);
+
+MonoWrapperCaches*
+mono_method_get_wrapper_cache (MonoMethod *method);
+
 #endif /* __MONO_METADATA_INTERNALS_H__ */