2008-08-20 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / metadata / metadata-internals.h
index 57798197851f91653239f6789393250f43ed74b8..95d824a508e5db7de216e08679d892057d1d7896 100644 (file)
 #include "mono/utils/mono-compiler.h"
 #include "mono/utils/mono-dl.h"
 #include "mono/utils/monobitset.h"
+#include "mono/utils/mono-property-hash.h"
+#include "mono/utils/mono-value-hash.h"
+
+#define MONO_SECMAN_FLAG_INIT(x)               (x & 0x2)
+#define MONO_SECMAN_FLAG_GET_VALUE(x)          (x & 0x1)
+#define MONO_SECMAN_FLAG_SET_VALUE(x,y)                do { x = ((y) ? 0x3 : 0x2); } while (0)
 
 struct _MonoAssembly {
        /* 
@@ -23,7 +29,6 @@ struct _MonoAssembly {
        int ref_count; /* use atomic operations only */
        char *basedir;
        MonoAssemblyName aname;
-       MonoDl *aot_module;
        MonoImage *image;
        GSList *friend_assembly_names;
        guint8 in_gac;
@@ -35,6 +40,7 @@ struct _MonoAssembly {
        guint32 aptc:2;         /* Has the [AllowPartiallyTrustedCallers] attributes */
        guint32 fulltrust:2;    /* Has FullTrust permission */
        guint32 unmanaged:2;    /* Has SecurityPermissionFlag.UnmanagedCode permission */
+       guint32 skipverification:2;     /* Has SecurityPermissionFlag.SkipVerification permission */
 };
 
 typedef struct {
@@ -72,12 +78,19 @@ struct _MonoImage {
         * 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_buffer_used    : 1;
        guint8 raw_data_allocated : 1;
 
+#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 */
        guint8 dynamic : 1;
 
@@ -130,6 +143,8 @@ struct _MonoImage {
 
        MonoImage **files;
 
+       gpointer aot_module;
+
        /*
         * The Assembly this image was loaded from.
         */
@@ -138,8 +153,12 @@ struct _MonoImage {
        /*
         * Indexed by method tokens and typedef tokens.
         */
-       GHashTable *method_cache;
+       MonoValueHashTable *method_cache;
        MonoInternalHashTable class_cache;
+
+       /* Indexed by memberref + methodspec tokens */
+       GHashTable *methodref_cache;
+
        /*
         * Indexed by fielddef and memberref tokens
         */
@@ -171,11 +190,17 @@ struct _MonoImage {
        GHashTable *delegate_begin_invoke_cache;
        GHashTable *delegate_end_invoke_cache;
        GHashTable *delegate_invoke_cache;
+       GHashTable *runtime_invoke_cache;
+
+       /*
+        * indexed by SignatureMethodPair
+        */
+       GHashTable *delegate_abstract_invoke_cache;
 
        /*
         * indexed by MonoMethod pointers 
         */
-       GHashTable *runtime_invoke_cache;
+       GHashTable *runtime_invoke_direct_cache;
        GHashTable *managed_wrapper_cache;
        GHashTable *native_wrapper_cache;
        GHashTable *remoting_invoke_cache;
@@ -183,18 +208,27 @@ struct _MonoImage {
        GHashTable *unbox_wrapper_cache;
        GHashTable *cominterop_invoke_cache;
        GHashTable *cominterop_wrapper_cache;
+       GHashTable *static_rgctx_invoke_cache; /* LOCKING: marshal lock */
+       GHashTable *thunk_invoke_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;
+       GHashTable *rgctx_template_hash; /* LOCKING: templates lock */
+
+       /*
+        * indexed by token and MonoGenericContext pointer
+        */
+       GHashTable *generic_class_cache;
+
+       /* Contains rarely used fields of runtime structures belonging to this image */
+       MonoPropertyHash *property_hash;
 
        void *reflection_info;
 
@@ -271,6 +305,8 @@ struct _MonoDynamicImage {
        GHashTable *method_to_table_idx;
        GHashTable *field_to_table_idx;
        GHashTable *method_aux_hash;
+       MonoGHashTable *generic_def_objects;
+       MonoGHashTable *methodspec;
        gboolean run;
        gboolean save;
        gboolean initial_image;
@@ -279,6 +315,8 @@ struct _MonoDynamicImage {
        guint32 strong_name_size;
        char *win32_res;
        guint32 win32_res_size;
+       guint8 *public_key;
+       int public_key_len;
        MonoDynamicStream sheap;
        MonoDynamicStream code; /* used to store method headers and bytecode */
        MonoDynamicStream resources; /* managed embedded resources */
@@ -387,7 +425,8 @@ 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          (MonoClass            *gclass,
@@ -398,8 +437,12 @@ 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) MONO_INTERNAL;
+gboolean mono_assembly_has_skip_verification (MonoAssembly* ass) MONO_INTERNAL;
+
+gboolean mono_public_tokens_are_equal (const unsigned char *pubt1, const unsigned char *pubt2) MONO_INTERNAL;
 
 void mono_config_parse_publisher_policy (const char *filename, MonoAssemblyBindingInfo *binding_info) MONO_INTERNAL;
 
@@ -407,17 +450,48 @@ gboolean
 mono_assembly_name_parse_full               (const char           *name,
                                              MonoAssemblyName     *aname,
                                              gboolean save_public_key,
-                                             gboolean *is_version_defined) MONO_INTERNAL;
+                                             gboolean *is_version_defined,
+                                                 gboolean *is_token_defined) MONO_INTERNAL;
 
 guint32 mono_metadata_get_generic_param_row (MonoImage *image, guint32 token, guint32 *owner);
 
 void mono_unload_interface_ids (MonoBitSet *bitset) MONO_INTERNAL;
 
 
-MonoType *mono_metadata_type_dup_mp (MonoImage *image, const MonoType *original) 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;
 
 MonoGenericInst *
 mono_get_shared_generic_inst (MonoGenericContainer *container) MONO_INTERNAL;
 
+int
+mono_type_stack_size_internal (MonoType *t, int *align, gboolean allow_open) MONO_INTERNAL;
+
+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;;
+
+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, 
+                                         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;
+
 #endif /* __MONO_METADATA_INTERNALS_H__ */