2009-07-30 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / metadata / metadata-internals.h
index bcbba56f3cec5a813f50a88aa6075a7327bc241b..e27ffc770a1a527888ae2215d7dc4d2c3d9ea6ce 100644 (file)
@@ -29,9 +29,9 @@ struct _MonoAssembly {
        int ref_count; /* use atomic operations only */
        char *basedir;
        MonoAssemblyName aname;
-       MonoDl *aot_module;
        MonoImage *image;
-       GSList *friend_assembly_names;
+       GSList *friend_assembly_names; /* Computed by mono_assembly_load_friends () */
+       guint8 friend_assembly_names_inited;
        guint8 in_gac;
        guint8 dynamic;
        guint8 corlib_internal;
@@ -79,6 +79,7 @@ struct _MonoImage {
         * this image between calls of mono_image_open () and mono_image_close ().
         */
        int   ref_count;
+       void *raw_data_handle;
        char *raw_data;
        guint32 raw_data_len;
        guint8 raw_buffer_used    : 1;
@@ -87,6 +88,9 @@ struct _MonoImage {
 #ifdef PLATFORM_WIN32
        /* Module was loaded using LoadLibrary. */
        guint8 is_module_handle : 1;
+
+       /* Module entry point is _CorDllMain. */
+       guint8 has_entry_point : 1;
 #endif
 
        /* Whenever this is a dynamically emitted module */
@@ -104,6 +108,9 @@ struct _MonoImage {
        guint8 idx_string_wide : 1;
        guint8 idx_guid_wide : 1;
        guint8 idx_blob_wide : 1;
+
+       /* Whenever this image is considered as platform code for the CoreCLR security model */
+       guint8 core_clr_platform_code : 1;
                            
        char *name;
        const char *assembly_name;
@@ -112,7 +119,7 @@ struct _MonoImage {
        gint16 md_version_major, md_version_minor;
        char *guid;
        void *image_info;
-       MonoMemPool         *mempool;
+       MonoMemPool         *mempool; /*protected by the image lock*/
 
        char                *raw_metadata;
                            
@@ -141,6 +148,8 @@ struct _MonoImage {
 
        MonoImage **files;
 
+       gpointer aot_module;
+
        /*
         * The Assembly this image was loaded from.
         */
@@ -149,11 +158,11 @@ struct _MonoImage {
        /*
         * Indexed by method tokens and typedef tokens.
         */
-       MonoValueHashTable *method_cache;
+       MonoValueHashTable *method_cache; /*protected by the image lock*/
        MonoInternalHashTable class_cache;
 
        /* Indexed by memberref + methodspec tokens */
-       GHashTable *methodref_cache;
+       GHashTable *methodref_cache; /*protected by the image lock*/
 
        /*
         * Indexed by fielddef and memberref tokens
@@ -172,7 +181,7 @@ struct _MonoImage {
        /*
         * Indexes namespaces to hash tables that map class name to typedef token.
         */
-       GHashTable *name_cache;
+       GHashTable *name_cache;  /*protected by the image lock*/
 
        /*
         * Indexed by MonoClass
@@ -180,6 +189,10 @@ struct _MonoImage {
        GHashTable *array_cache;
        GHashTable *ptr_cache;
 
+       GHashTable *szarray_cache;
+       /* This has a separate lock to improve scalability */
+       CRITICAL_SECTION szarray_cache_lock;
+
        /*
         * indexed by MonoMethodSignature 
         */
@@ -197,14 +210,15 @@ struct _MonoImage {
         * 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 *remoting_invoke_cache;
        GHashTable *synchronized_cache;
        GHashTable *unbox_wrapper_cache;
        GHashTable *cominterop_invoke_cache;
-       GHashTable *cominterop_wrapper_cache;
-       GHashTable *static_rgctx_invoke_cache; /* LOCKING: marshal lock */
+       GHashTable *cominterop_wrapper_cache; /* LOCKING: marshal lock */
        GHashTable *thunk_invoke_cache;
 
        /*
@@ -239,6 +253,12 @@ struct _MonoImage {
 
        /* interfaces IDs from this image */
        MonoBitSet *interface_bitset;
+
+       /*
+        * 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.
+        */
+       CRITICAL_SECTION    lock;
 };
 
 enum {
@@ -295,6 +315,7 @@ struct _MonoDynamicImage {
        GHashTable *handleref;
        MonoGHashTable *tokens;
        GHashTable *blob_cache;
+       GHashTable *standalonesig_cache;
        GList *array_methods;
        GPtrArray *gen_params;
        MonoGHashTable *token_fixups;
@@ -302,6 +323,7 @@ struct _MonoDynamicImage {
        GHashTable *field_to_table_idx;
        GHashTable *method_aux_hash;
        MonoGHashTable *generic_def_objects;
+       MonoGHashTable *methodspec;
        gboolean run;
        gboolean save;
        gboolean initial_image;
@@ -320,6 +342,7 @@ struct _MonoDynamicImage {
        MonoDynamicStream tstream;
        MonoDynamicStream guid;
        MonoDynamicTable tables [MONO_TABLE_NUM];
+       MonoClass *wrappers_type; /*wrappers are bound to this type instead of <Module>*/
 };
 
 /* Contains information about assembly binding */
@@ -356,6 +379,40 @@ guint mono_aligned_addr_hash (gconstpointer ptr) MONO_INTERNAL;
 void
 mono_image_check_for_module_cctor (MonoImage *image) MONO_INTERNAL;
 
+gpointer
+mono_image_alloc  (MonoImage *image, guint size) MONO_INTERNAL;
+
+gpointer
+mono_image_alloc0 (MonoImage *image, guint size) MONO_INTERNAL;
+
+char*
+mono_image_strdup (MonoImage *image, const char *s) MONO_INTERNAL;
+
+GList*
+g_list_prepend_image (MonoImage *image, GList *list, gpointer data) MONO_INTERNAL;
+
+GSList*
+g_slist_append_image (MonoImage *image, GSList *list, gpointer data) MONO_INTERNAL;
+
+void
+mono_image_lock (MonoImage *image) MONO_INTERNAL;
+
+void
+mono_image_unlock (MonoImage *image) MONO_INTERNAL;
+
+gpointer
+mono_image_property_lookup (MonoImage *image, gpointer subject, guint32 property) MONO_INTERNAL;
+
+void
+mono_image_property_insert (MonoImage *image, gpointer subject, guint32 property, gpointer value) MONO_INTERNAL;
+
+void
+mono_image_property_remove (MonoImage *image, gpointer subject) MONO_INTERNAL;
+
+
+MonoType*
+mono_metadata_get_shared_type (MonoType *type) MONO_INTERNAL;
+
 void
 mono_metadata_clean_for_image (MonoImage *image) MONO_INTERNAL;
 
@@ -453,8 +510,9 @@ guint32 mono_metadata_get_generic_param_row (MonoImage *image, guint32 token, gu
 void mono_unload_interface_ids (MonoBitSet *bitset) MONO_INTERNAL;
 
 
-MonoType *mono_metadata_type_dup (MonoMemPool *mp, const MonoType *original) MONO_INTERNAL;
-MonoMethodSignature  *mono_metadata_signature_dup_full (MonoMemPool *mp,MonoMethodSignature *sig) MONO_INTERNAL;
+MonoType *mono_metadata_type_dup (MonoImage *image, const MonoType *original) MONO_INTERNAL;
+MonoMethodSignature  *mono_metadata_signature_dup_full (MonoImage *image,MonoMethodSignature *sig) MONO_INTERNAL;
+MonoMethodSignature  *mono_metadata_signature_dup_mempool (MonoMemPool *mp, MonoMethodSignature *sig) MONO_INTERNAL;
 
 MonoGenericInst *
 mono_get_shared_generic_inst (MonoGenericContainer *container) MONO_INTERNAL;
@@ -466,16 +524,38 @@ gboolean
 mono_metadata_type_equal_full (MonoType *t1, MonoType *t2, gboolean signature_only) MONO_INTERNAL;
 
 MonoMarshalSpec *
-mono_metadata_parse_marshal_spec_with_mempool (MonoMemPool *mp, const char *ptr) MONO_INTERNAL;;
+mono_metadata_parse_marshal_spec_full (MonoImage *image, const char *ptr) MONO_INTERNAL;
+
+guint         mono_metadata_generic_inst_hash (gconstpointer data) MONO_INTERNAL;
+gboolean       mono_metadata_generic_inst_equal (gconstpointer ka, gconstpointer kb) MONO_INTERNAL;
 
 void
-mono_metadata_field_info_with_mempool (MonoMemPool *mp, 
+mono_metadata_field_info_with_mempool (
                                          MonoImage *meta, 
                                      guint32       table_index,
                                      guint32      *offset,
                                      guint32      *rva,
                                      MonoMarshalSpec **marshal_spec);
 
+MonoClassField*
+mono_metadata_get_corresponding_field_from_generic_type_definition (MonoClassField *field) MONO_INTERNAL;
+
+MonoEvent*
+mono_metadata_get_corresponding_event_from_generic_type_definition (MonoEvent *event) MONO_INTERNAL;
+
+MonoProperty*
+mono_metadata_get_corresponding_property_from_generic_type_definition (MonoProperty *property) MONO_INTERNAL;
+
+guint32
+mono_metadata_signature_size (MonoMethodSignature *sig) MONO_INTERNAL;
+
+gboolean mono_image_load_pe_data (MonoImage *image) MONO_INTERNAL;
+
+gboolean mono_image_load_cli_data (MonoImage *image) MONO_INTERNAL;
+
+void mono_image_load_names (MonoImage *image) MONO_INTERNAL;
+
+MonoImage *mono_image_open_raw (const char *fname, MonoImageOpenStatus *status) MONO_INTERNAL;
 
 #endif /* __MONO_METADATA_INTERNALS_H__ */