#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 {
/*
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;
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 {
* 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 */
+ void *raw_data_handle;
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;
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;
gint16 md_version_major, md_version_minor;
char *guid;
void *image_info;
- MonoMemPool *mempool;
+ MonoMemPool *mempool; /*protected by the image lock*/
char *raw_metadata;
MonoImage **modules;
guint32 module_count;
+ gboolean *modules_loaded;
MonoImage **files;
+ gpointer aot_module;
+
/*
* The Assembly this image was loaded from.
*/
/*
* Indexed by method tokens and typedef tokens.
*/
- GHashTable *method_cache;
- GHashTable *class_cache;
+ MonoValueHashTable *method_cache; /*protected by the image lock*/
+ MonoInternalHashTable class_cache;
+
+ /* Indexed by memberref + methodspec tokens */
+ GHashTable *methodref_cache; /*protected by the image lock*/
+
/*
* Indexed by fielddef and memberref tokens
*/
/*
* 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
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
*/
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 *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 *cominterop_wrapper_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;
/* 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 {
GHashTable *handleref;
MonoGHashTable *tokens;
GHashTable *blob_cache;
+ GHashTable *standalonesig_cache;
GList *array_methods;
GPtrArray *gen_params;
MonoGHashTable *token_fixups;
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;
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 */
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 */
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;
+
void
mono_metadata_cleanup (void);
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,
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) 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;
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 (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;
+
+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_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 (
+ 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__ */