Tue Sep 11 16:08:08 CEST 2007 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / metadata / metadata-internals.h
index 16c556db1062321cbf78e7b970b07aa64876653e..000d226da5f9984ea3af82a5cb87fa780c90cabb 100644 (file)
@@ -8,6 +8,7 @@
 #include "mono/metadata/domain-internals.h"
 #include "mono/utils/mono-hash.h"
 #include "mono/utils/mono-compiler.h"
+#include "mono/utils/mono-dl.h"
 #include "mono/utils/monobitset.h"
 
 struct _MonoAssembly {
@@ -22,7 +23,7 @@ struct _MonoAssembly {
        int ref_count; /* use atomic operations only */
        char *basedir;
        MonoAssemblyName aname;
-       GModule *aot_module;
+       MonoDl *aot_module;
        MonoImage *image;
        GSList *friend_assembly_names;
        guint8 in_gac;
@@ -59,25 +60,40 @@ struct _MonoTableInfo {
        guint32   size_bitfield;
 };
 
+#define REFERENCE_MISSING ((gpointer) -1)
+
+typedef struct _MonoDllMap MonoDllMap;
+
 struct _MonoImage {
        /*
         * The number of assemblies which reference this MonoImage though their 'image'
         * field plus the number of images which reference this MonoImage through their 
-        * 'modules' field. Initially 0.
+        * 'modules' field, plus the number of threads holding temporary references to
+        * this image between calls of mono_image_open () and mono_image_close ().
         */
        int   ref_count;
        FILE *file_descr;
        /* if file_descr is NULL the image was loaded from raw data */
        char *raw_data;
        guint32 raw_data_len;
-       guint8 raw_data_allocated;
+       guint8 raw_data_allocated : 1;
 
        /* Whenever this is a dynamically emitted module */
-       guint8 dynamic;
+       guint8 dynamic : 1;
 
        /* Whenever this is a reflection only image */
-       guint8 ref_only;
+       guint8 ref_only : 1;
+
+       /* Whenever this image contains uncompressed metadata */
+       guint8 uncompressed_metadata : 1;
+
+       guint8 checked_module_cctor : 1;
+       guint8 has_module_cctor : 1;
 
+       guint8 idx_string_wide : 1;
+       guint8 idx_guid_wide : 1;
+       guint8 idx_blob_wide : 1;
+                           
        char *name;
        const char *assembly_name;
        const char *module_name;
@@ -89,8 +105,6 @@ struct _MonoImage {
 
        char                *raw_metadata;
                            
-       guint8               idx_string_wide, idx_guid_wide, idx_blob_wide;
-                           
        MonoStreamHeader     heap_strings;
        MonoStreamHeader     heap_us;
        MonoStreamHeader     heap_blob;
@@ -112,6 +126,7 @@ struct _MonoImage {
 
        MonoImage **modules;
        guint32 module_count;
+       gboolean *modules_loaded;
 
        MonoImage **files;
 
@@ -124,7 +139,7 @@ struct _MonoImage {
         * Indexed by method tokens and typedef tokens.
         */
        GHashTable *method_cache;
-       GHashTable *class_cache;
+       MonoInternalHashTable class_cache;
        /*
         * Indexed by fielddef and memberref tokens
         */
@@ -145,10 +160,10 @@ struct _MonoImage {
        GHashTable *name_cache;
 
        /*
-        * Indexed by ((rank << 24) | (typedef & 0xffffff)), which limits us to a
-        * maximal rank of 255
+        * Indexed by MonoClass
         */
        GHashTable *array_cache;
+       GHashTable *ptr_cache;
 
        /*
         * indexed by MonoMethodSignature 
@@ -166,6 +181,20 @@ struct _MonoImage {
        GHashTable *remoting_invoke_cache;
        GHashTable *synchronized_cache;
        GHashTable *unbox_wrapper_cache;
+       GHashTable *cominterop_invoke_cache;
+       GHashTable *cominterop_wrapper_cache;
+
+       /*
+        * indexed by MonoClass pointers
+        */
+       GHashTable *ldfld_wrapper_cache;
+       GHashTable *ldflda_wrapper_cache;
+       GHashTable *ldfld_remote_wrapper_cache;
+       GHashTable *stfld_wrapper_cache;
+       GHashTable *stfld_remote_wrapper_cache;
+       GHashTable *isinst_cache;
+       GHashTable *castclass_cache;
+       GHashTable *proxy_isinst_cache;
 
        void *reflection_info;
 
@@ -176,7 +205,7 @@ struct _MonoImage {
        void *user_info;
 
        /* dll map entries */
-       GHashTable *dll_map;
+       MonoDllMap *dll_map;
 
        /* interfaces IDs from this image */
        MonoBitSet *interface_bitset;
@@ -291,6 +320,15 @@ struct _MonoMethodHeader {
 /* for use with allocated memory blocks (assumes alignment is to 8 bytes) */
 guint mono_aligned_addr_hash (gconstpointer ptr) MONO_INTERNAL;
 
+void
+mono_image_check_for_module_cctor (MonoImage *image) MONO_INTERNAL;
+
+void
+mono_metadata_clean_for_image (MonoImage *image) MONO_INTERNAL;
+
+void
+mono_metadata_cleanup (void);
+
 const char *   mono_meta_table_name              (int table) MONO_INTERNAL;
 void           mono_metadata_compute_table_bases (MonoImage *meta) MONO_INTERNAL;
 
@@ -335,11 +373,11 @@ mono_metadata_parse_mh_full                 (MonoImage             *image,
 int* mono_metadata_get_param_attrs          (MonoImage *m, int def);
 
 guint
-mono_metadata_generic_method_hash           (MonoGenericMethod     *gmethod) MONO_INTERNAL;
+mono_metadata_generic_context_hash          (const MonoGenericContext *context) MONO_INTERNAL;
 
 gboolean
-mono_metadata_generic_method_equal          (MonoGenericMethod     *g1,
-                                            MonoGenericMethod     *g2) MONO_INTERNAL;
+mono_metadata_generic_context_equal         (const MonoGenericContext *g1,
+                                            const MonoGenericContext *g2) MONO_INTERNAL;
 
 MonoGenericInst *
 mono_metadata_parse_generic_inst            (MonoImage             *image,
@@ -349,17 +387,21 @@ mono_metadata_parse_generic_inst            (MonoImage             *image,
                                             const char           **rptr) MONO_INTERNAL;
 
 MonoGenericInst *
-mono_metadata_lookup_generic_inst           (MonoGenericInst       *ginst) MONO_INTERNAL;
+mono_metadata_get_generic_inst              (int                   type_argc,
+                                            MonoType             **type_argv) MONO_INTERNAL;
 
 MonoGenericClass *
-mono_metadata_lookup_generic_class          (MonoGenericClass      *gclass) MONO_INTERNAL;
+mono_metadata_lookup_generic_class          (MonoClass            *gclass,
+                                            MonoGenericInst       *inst,
+                                            gboolean               is_dynamic) MONO_INTERNAL;
 
 MonoGenericInst *
 mono_metadata_inflate_generic_inst          (MonoGenericInst       *ginst,
                                             MonoGenericContext    *context) MONO_INTERNAL;
 
-void mono_dynamic_stream_reset (MonoDynamicStream* stream) MONO_INTERNAL;
-void mono_assembly_addref      (MonoAssembly *assembly) MONO_INTERNAL;
+void mono_dynamic_stream_reset  (MonoDynamicStream* stream) MONO_INTERNAL;
+void mono_assembly_addref       (MonoAssembly *assembly) MONO_INTERNAL;
+void mono_assembly_load_friends (MonoAssembly* ass);
 
 void mono_config_parse_publisher_policy (const char *filename, MonoAssemblyBindingInfo *binding_info) MONO_INTERNAL;
 
@@ -373,5 +415,11 @@ 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;
+
+MonoGenericInst *
+mono_get_shared_generic_inst (MonoGenericContainer *container) MONO_INTERNAL;
+
 #endif /* __MONO_METADATA_INTERNALS_H__ */