Reduce TLS accesses. (#11487)
[mono-project.git] / mono / metadata / metadata-internals.h
blob3d9ef75f84b7c20a32ef6f2acdaa55bb8be994e7
1 /**
2 * \file
3 */
5 #ifndef __MONO_METADATA_INTERNALS_H__
6 #define __MONO_METADATA_INTERNALS_H__
8 #include "mono/utils/mono-forward-internal.h"
9 #include "mono/metadata/image.h"
10 #include "mono/metadata/blob.h"
11 #include "mono/metadata/cil-coff.h"
12 #include "mono/metadata/mempool.h"
13 #include "mono/metadata/domain-internals.h"
14 #include "mono/metadata/mono-hash.h"
15 #include "mono/utils/mono-compiler.h"
16 #include "mono/utils/mono-dl.h"
17 #include "mono/utils/monobitset.h"
18 #include "mono/utils/mono-property-hash.h"
19 #include "mono/utils/mono-value-hash.h"
20 #include <mono/utils/mono-error.h>
21 #include "mono/utils/mono-conc-hashtable.h"
23 struct _MonoType {
24 union {
25 MonoClass *klass; /* for VALUETYPE and CLASS */
26 MonoType *type; /* for PTR */
27 MonoArrayType *array; /* for ARRAY */
28 MonoMethodSignature *method;
29 MonoGenericParam *generic_param; /* for VAR and MVAR */
30 MonoGenericClass *generic_class; /* for GENERICINST */
31 } data;
32 unsigned int attrs : 16; /* param attributes or field flags */
33 MonoTypeEnum type : 8;
34 unsigned int has_cmods : 1;
35 unsigned int byref : 1;
36 unsigned int pinned : 1; /* valid when included in a local var signature */
39 typedef struct {
40 MonoType unmodified;
41 MonoCustomModContainer cmods;
42 } MonoTypeWithModifiers;
44 MonoCustomModContainer *
45 mono_type_get_cmods (const MonoType *t);
47 // Note: sizeof (MonoType) is dangerous. It can copy the num_mods
48 // field without copying the variably sized array. This leads to
49 // memory unsafety on the stack and/or heap, when we try to traverse
50 // this array.
52 // Use mono_sizeof_monotype
53 // to get the size of the memory to copy.
54 #define MONO_SIZEOF_TYPE sizeof (MonoType)
56 size_t
57 mono_sizeof_type_with_mods (uint8_t num_mods);
59 size_t
60 mono_sizeof_type (const MonoType *ty);
62 #define MONO_SECMAN_FLAG_INIT(x) (x & 0x2)
63 #define MONO_SECMAN_FLAG_GET_VALUE(x) (x & 0x1)
64 #define MONO_SECMAN_FLAG_SET_VALUE(x,y) do { x = ((y) ? 0x3 : 0x2); } while (0)
66 #define MONO_PUBLIC_KEY_TOKEN_LENGTH 17
68 #define MONO_PROCESSOR_ARCHITECTURE_NONE 0
69 #define MONO_PROCESSOR_ARCHITECTURE_MSIL 1
70 #define MONO_PROCESSOR_ARCHITECTURE_X86 2
71 #define MONO_PROCESSOR_ARCHITECTURE_IA64 3
72 #define MONO_PROCESSOR_ARCHITECTURE_AMD64 4
73 #define MONO_PROCESSOR_ARCHITECTURE_ARM 5
75 struct _MonoAssemblyName {
76 const char *name;
77 const char *culture;
78 const char *hash_value;
79 const mono_byte* public_key;
80 // string of 16 hex chars + 1 NULL
81 mono_byte public_key_token [MONO_PUBLIC_KEY_TOKEN_LENGTH];
82 uint32_t hash_alg;
83 uint32_t hash_len;
84 uint32_t flags;
85 uint16_t major, minor, build, revision, arch;
88 struct MonoTypeNameParse {
89 char *name_space;
90 char *name;
91 MonoAssemblyName assembly;
92 GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
93 GPtrArray *type_arguments;
94 GList *nested;
98 typedef enum MonoAssemblyContextKind {
99 /* Default assembly context: Load(String) and assembly references */
100 MONO_ASMCTX_DEFAULT = 0,
101 /* Reflection-only only context: ReflectionOnlyLoad and ReeflectionOnlyLoadFrom */
102 MONO_ASMCTX_REFONLY = 1,
103 /* LoadFrom context: LoadFrom() and references */
104 MONO_ASMCTX_LOADFROM = 2,
105 /* Individual assembly context (.NET Framework docs call this "not in
106 * any context"): LoadFile(String) and Load(byte[]) are here.
108 MONO_ASMCTX_INDIVIDUAL = 3,
110 MONO_ASMCTX_LAST = 3
111 } MonoAssemblyContextKind;
113 typedef struct _MonoAssemblyContext {
114 MonoAssemblyContextKind kind;
115 } MonoAssemblyContext;
117 struct _MonoAssembly {
119 * The number of appdomains which have this assembly loaded plus the number of
120 * assemblies referencing this assembly through an entry in their image->references
121 * arrays. The latter is needed because entries in the image->references array
122 * might point to assemblies which are only loaded in some appdomains, and without
123 * the additional reference, they can be freed at any time.
124 * The ref_count is initially 0.
126 int ref_count; /* use atomic operations only */
127 char *basedir;
128 MonoAssemblyName aname;
129 MonoImage *image;
130 GSList *friend_assembly_names; /* Computed by mono_assembly_load_friends () */
131 guint8 friend_assembly_names_inited;
132 guint8 in_gac;
133 guint8 dynamic;
134 guint8 corlib_internal;
135 MonoAssemblyContext context;
136 guint8 wrap_non_exception_throws;
137 guint8 wrap_non_exception_throws_inited;
138 guint8 jit_optimizer_disabled;
139 guint8 jit_optimizer_disabled_inited;
140 /* security manager flags (one bit is for lazy initialization) */
141 guint32 ecma:2; /* Has the ECMA key */
142 guint32 aptc:2; /* Has the [AllowPartiallyTrustedCallers] attributes */
143 guint32 fulltrust:2; /* Has FullTrust permission */
144 guint32 unmanaged:2; /* Has SecurityPermissionFlag.UnmanagedCode permission */
145 guint32 skipverification:2; /* Has SecurityPermissionFlag.SkipVerification permission */
148 typedef struct {
150 * indexed by MonoMethodSignature
151 * Protected by the marshal lock
153 GHashTable *delegate_invoke_cache;
154 GHashTable *delegate_begin_invoke_cache;
155 GHashTable *delegate_end_invoke_cache;
156 GHashTable *runtime_invoke_signature_cache;
157 GHashTable *runtime_invoke_sig_cache;
160 * indexed by SignaturePointerPair
162 GHashTable *delegate_abstract_invoke_cache;
165 * indexed by MonoMethod pointers
166 * Protected by the marshal lock
168 GHashTable *runtime_invoke_method_cache;
169 GHashTable *managed_wrapper_cache;
171 GHashTable *native_wrapper_cache;
172 GHashTable *native_wrapper_aot_cache;
173 GHashTable *native_wrapper_check_cache;
174 GHashTable *native_wrapper_aot_check_cache;
176 GHashTable *native_func_wrapper_aot_cache;
177 GHashTable *remoting_invoke_cache;
178 GHashTable *synchronized_cache;
179 GHashTable *unbox_wrapper_cache;
180 GHashTable *cominterop_invoke_cache;
181 GHashTable *cominterop_wrapper_cache; /* LOCKING: marshal lock */
182 GHashTable *thunk_invoke_cache;
183 } MonoWrapperCaches;
185 typedef struct {
186 const char* data;
187 guint32 size;
188 } MonoStreamHeader;
190 struct _MonoTableInfo {
191 const char *base;
192 guint rows : 24;
193 guint row_size : 8;
196 * Tables contain up to 9 columns and the possible sizes of the
197 * fields in the documentation are 1, 2 and 4 bytes. So we
198 * can encode in 2 bits the size.
200 * A 32 bit value can encode the resulting size
202 * The top eight bits encode the number of columns in the table.
203 * we only need 4, but 8 is aligned no shift required.
205 guint32 size_bitfield;
208 #define REFERENCE_MISSING ((gpointer) -1)
210 typedef struct _MonoDllMap MonoDllMap;
212 typedef struct {
213 gboolean (*match) (MonoImage*);
214 gboolean (*load_pe_data) (MonoImage*);
215 gboolean (*load_cli_data) (MonoImage*);
216 gboolean (*load_tables) (MonoImage*);
217 } MonoImageLoader;
219 struct _MonoImage {
221 * This count is incremented during these situations:
222 * - An assembly references this MonoImage though its 'image' field
223 * - This MonoImage is present in the 'files' field of an image
224 * - This MonoImage is present in the 'modules' field of an image
225 * - A thread is holding a temporary reference to this MonoImage between
226 * calls to mono_image_open and mono_image_close ()
228 int ref_count;
230 /* If the raw data was allocated from a source such as mmap, the allocator may store resource tracking information here. */
231 void *raw_data_handle;
232 char *raw_data;
233 guint32 raw_data_len;
234 guint8 raw_buffer_used : 1;
235 guint8 raw_data_allocated : 1;
236 guint8 fileio_used : 1;
238 #ifdef HOST_WIN32
239 /* Module was loaded using LoadLibrary. */
240 guint8 is_module_handle : 1;
242 /* Module entry point is _CorDllMain. */
243 guint8 has_entry_point : 1;
244 #endif
246 /* Whenever this is a dynamically emitted module */
247 guint8 dynamic : 1;
249 /* Whenever this is a reflection only image */
250 guint8 ref_only : 1;
252 /* Whenever this image contains uncompressed metadata */
253 guint8 uncompressed_metadata : 1;
255 /* Whenever this image contains metadata only without PE data */
256 guint8 metadata_only : 1;
258 /* Whether this image belongs to load-from context */
259 guint8 load_from_context: 1;
261 guint8 checked_module_cctor : 1;
262 guint8 has_module_cctor : 1;
264 guint8 idx_string_wide : 1;
265 guint8 idx_guid_wide : 1;
266 guint8 idx_blob_wide : 1;
268 /* Whenever this image is considered as platform code for the CoreCLR security model */
269 guint8 core_clr_platform_code : 1;
271 /* The path to the file for this image. */
272 char *name;
274 /* The assembly name reported in the file for this image (expected to be NULL for a netmodule) */
275 const char *assembly_name;
277 /* The module name reported in the file for this image (could be NULL for a malformed file) */
278 const char *module_name;
280 char *version;
281 gint16 md_version_major, md_version_minor;
282 char *guid;
283 MonoCLIImageInfo *image_info;
284 MonoMemPool *mempool; /*protected by the image lock*/
286 char *raw_metadata;
288 MonoStreamHeader heap_strings;
289 MonoStreamHeader heap_us;
290 MonoStreamHeader heap_blob;
291 MonoStreamHeader heap_guid;
292 MonoStreamHeader heap_tables;
293 MonoStreamHeader heap_pdb;
295 const char *tables_base;
297 /* For PPDB files */
298 guint64 referenced_tables;
299 int *referenced_table_rows;
301 /**/
302 MonoTableInfo tables [MONO_TABLE_NUM];
305 * references is initialized only by using the mono_assembly_open
306 * function, and not by using the lowlevel mono_image_open.
308 * It is NULL terminated.
310 MonoAssembly **references;
311 int nreferences;
313 /* Code files in the assembly. The main assembly has a "file" table and also a "module"
314 * table, where the module table is a subset of the file table. We track both lists,
315 * and because we can lazy-load them at different times we reference-increment both.
317 MonoImage **modules;
318 guint32 module_count;
319 gboolean *modules_loaded;
321 MonoImage **files;
322 guint32 file_count;
324 MonoAotModule *aot_module;
326 guint8 aotid[16];
329 * The Assembly this image was loaded from.
331 MonoAssembly *assembly;
334 * Indexed by method tokens and typedef tokens.
336 GHashTable *method_cache; /*protected by the image lock*/
337 MonoInternalHashTable class_cache;
339 /* Indexed by memberref + methodspec tokens */
340 GHashTable *methodref_cache; /*protected by the image lock*/
343 * Indexed by fielddef and memberref tokens
345 MonoConcurrentHashTable *field_cache; /*protected by the image lock*/
347 /* indexed by typespec tokens. */
348 MonoConcurrentHashTable *typespec_cache; /* protected by the image lock */
349 /* indexed by token */
350 GHashTable *memberref_signatures;
351 GHashTable *helper_signatures;
353 /* Indexed by blob heap indexes */
354 GHashTable *method_signatures;
357 * Indexes namespaces to hash tables that map class name to typedef token.
359 GHashTable *name_cache; /*protected by the image lock*/
362 * Indexed by MonoClass
364 GHashTable *array_cache;
365 GHashTable *ptr_cache;
367 GHashTable *szarray_cache;
368 /* This has a separate lock to improve scalability */
369 mono_mutex_t szarray_cache_lock;
372 * indexed by SignaturePointerPair
374 GHashTable *delegate_bound_static_invoke_cache;
375 GHashTable *native_func_wrapper_cache;
378 * indexed by MonoMethod pointers
380 GHashTable *wrapper_param_names;
381 GHashTable *array_accessor_cache;
384 * indexed by MonoClass pointers
386 GHashTable *ldfld_wrapper_cache;
387 GHashTable *ldflda_wrapper_cache;
388 GHashTable *stfld_wrapper_cache;
389 GHashTable *isinst_cache;
391 GHashTable *icall_wrapper_cache;
392 GHashTable *castclass_cache;
393 GHashTable *proxy_isinst_cache;
394 GHashTable *rgctx_template_hash; /* LOCKING: templates lock */
396 /* Contains rarely used fields of runtime structures belonging to this image */
397 MonoPropertyHash *property_hash;
399 void *reflection_info;
402 * user_info is a public field and is not touched by the
403 * metadata engine
405 void *user_info;
407 /* dll map entries */
408 MonoDllMap *dll_map;
410 /* interfaces IDs from this image */
411 /* protected by the classes lock */
412 MonoBitSet *interface_bitset;
414 /* when the image is being closed, this is abused as a list of
415 malloc'ed regions to be freed. */
416 GSList *reflection_info_unregister_classes;
418 /* List of dependent image sets containing this image */
419 /* Protected by image_sets_lock */
420 GSList *image_sets;
422 /* Caches for wrappers that DO NOT reference generic */
423 /* arguments */
424 MonoWrapperCaches wrapper_caches;
426 /* Pre-allocated anon generic params for the first N generic
427 * parameters, for a small N */
428 MonoGenericParam *var_gparam_cache_fast;
429 MonoGenericParam *mvar_gparam_cache_fast;
430 /* Anon generic parameters past N, if needed */
431 MonoConcurrentHashTable *var_gparam_cache;
432 MonoConcurrentHashTable *mvar_gparam_cache;
434 /* Maps malloc-ed char* pinvoke scope -> MonoDl* */
435 GHashTable *pinvoke_scopes;
437 /* Maps malloc-ed char* pinvoke scope -> malloced-ed char* filename */
438 GHashTable *pinvoke_scope_filenames;
440 /* Indexed by MonoGenericParam pointers */
441 GHashTable **gshared_types;
442 /* The length of the above array */
443 int gshared_types_len;
445 /* The loader used to load this image */
446 MonoImageLoader *loader;
448 // Containers for MonoGenericParams associated with this image but not with any specific class or method. Created on demand.
449 // This could happen, for example, for MonoTypes associated with TypeSpec table entries.
450 MonoGenericContainer *anonymous_generic_class_container;
451 MonoGenericContainer *anonymous_generic_method_container;
453 gboolean weak_fields_inited;
454 /* Contains 1 based indexes */
455 GHashTable *weak_field_indexes;
458 * No other runtime locks must be taken while holding this lock.
459 * It's meant to be used only to mutate and query structures part of this image.
461 mono_mutex_t lock;
465 * Generic instances depend on many images, and they need to be deleted if one
466 * of the images they depend on is unloaded. For example,
467 * List<Foo> depends on both List's image and Foo's image.
468 * A MonoImageSet is the owner of all generic instances depending on the same set of
469 * images.
471 typedef struct {
472 int nimages;
473 MonoImage **images;
475 // Generic-specific caches
476 GHashTable *ginst_cache, *gmethod_cache, *gsignature_cache;
477 MonoConcurrentHashTable *gclass_cache;
479 /* mirror caches of ones already on MonoImage. These ones contain generics */
480 GHashTable *szarray_cache, *array_cache, *ptr_cache;
482 MonoWrapperCaches wrapper_caches;
484 mono_mutex_t lock;
487 * Memory for generic instances owned by this image set should be allocated from
488 * this mempool, using the mono_image_set_alloc family of functions.
490 MonoMemPool *mempool;
491 } MonoImageSet;
493 enum {
494 MONO_SECTION_TEXT,
495 MONO_SECTION_RSRC,
496 MONO_SECTION_RELOC,
497 MONO_SECTION_MAX
500 typedef struct {
501 GHashTable *hash;
502 char *data;
503 guint32 alloc_size; /* malloced bytes */
504 guint32 index;
505 guint32 offset; /* from start of metadata */
506 } MonoDynamicStream;
508 typedef struct {
509 guint32 alloc_rows;
510 guint32 rows;
511 guint8 row_size; /* calculated later with column_sizes */
512 guint8 columns;
513 guint32 next_idx;
514 guint32 *values; /* rows * columns */
515 } MonoDynamicTable;
517 /* "Dynamic" assemblies and images arise from System.Reflection.Emit */
518 struct _MonoDynamicAssembly {
519 MonoAssembly assembly;
520 char *strong_name;
521 guint32 strong_name_size;
522 guint8 run;
523 guint8 save;
524 MonoDomain *domain;
527 struct _MonoDynamicImage {
528 MonoImage image;
529 guint32 meta_size;
530 guint32 text_rva;
531 guint32 metadata_rva;
532 guint32 image_base;
533 guint32 cli_header_offset;
534 guint32 iat_offset;
535 guint32 idt_offset;
536 guint32 ilt_offset;
537 guint32 imp_names_offset;
538 struct {
539 guint32 rva;
540 guint32 size;
541 guint32 offset;
542 guint32 attrs;
543 } sections [MONO_SECTION_MAX];
544 GHashTable *typespec;
545 GHashTable *typeref;
546 GHashTable *handleref;
547 MonoGHashTable *tokens;
548 GHashTable *blob_cache;
549 GHashTable *standalonesig_cache;
550 GList *array_methods;
551 GPtrArray *gen_params;
552 MonoGHashTable *token_fixups;
553 GHashTable *method_to_table_idx;
554 GHashTable *field_to_table_idx;
555 GHashTable *method_aux_hash;
556 GHashTable *vararg_aux_hash;
557 MonoGHashTable *generic_def_objects;
559 * Maps final token values to the object they describe.
561 MonoGHashTable *remapped_tokens;
562 gboolean run;
563 gboolean save;
564 gboolean initial_image;
565 guint32 pe_kind, machine;
566 char *strong_name;
567 guint32 strong_name_size;
568 char *win32_res;
569 guint32 win32_res_size;
570 guint8 *public_key;
571 int public_key_len;
572 MonoDynamicStream sheap;
573 MonoDynamicStream code; /* used to store method headers and bytecode */
574 MonoDynamicStream resources; /* managed embedded resources */
575 MonoDynamicStream us;
576 MonoDynamicStream blob;
577 MonoDynamicStream tstream;
578 MonoDynamicStream guid;
579 MonoDynamicTable tables [MONO_TABLE_NUM];
580 MonoClass *wrappers_type; /*wrappers are bound to this type instead of <Module>*/
583 /* Contains information about assembly binding */
584 typedef struct _MonoAssemblyBindingInfo {
585 char *name;
586 char *culture;
587 guchar public_key_token [MONO_PUBLIC_KEY_TOKEN_LENGTH];
588 int major;
589 int minor;
590 AssemblyVersionSet old_version_bottom;
591 AssemblyVersionSet old_version_top;
592 AssemblyVersionSet new_version;
593 guint has_old_version_bottom : 1;
594 guint has_old_version_top : 1;
595 guint has_new_version : 1;
596 guint is_valid : 1;
597 gint32 domain_id; /*Needed to unload per-domain binding*/
598 } MonoAssemblyBindingInfo;
600 struct _MonoMethodHeader {
601 const unsigned char *code;
602 #ifdef MONO_SMALL_CONFIG
603 guint16 code_size;
604 #else
605 guint32 code_size;
606 #endif
607 guint16 max_stack : 15;
608 unsigned int is_transient: 1; /* mono_metadata_free_mh () will actually free this header */
609 unsigned int num_clauses : 15;
610 /* if num_locals != 0, then the following apply: */
611 unsigned int init_locals : 1;
612 guint16 num_locals;
613 MonoExceptionClause *clauses;
614 MonoBitSet *volatile_args;
615 MonoBitSet *volatile_locals;
616 MonoType *locals [MONO_ZERO_LEN_ARRAY];
619 typedef struct {
620 const unsigned char *code;
621 guint32 code_size;
622 guint16 max_stack;
623 gboolean has_clauses;
624 gboolean has_locals;
625 } MonoMethodHeaderSummary;
627 #define MONO_SIZEOF_METHOD_HEADER (sizeof (struct _MonoMethodHeader) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
629 struct _MonoMethodSignature {
630 MonoType *ret;
631 #ifdef MONO_SMALL_CONFIG
632 guint8 param_count;
633 gint8 sentinelpos;
634 unsigned int generic_param_count : 5;
635 #else
636 guint16 param_count;
637 gint16 sentinelpos;
638 unsigned int generic_param_count : 16;
639 #endif
640 unsigned int call_convention : 6;
641 unsigned int hasthis : 1;
642 unsigned int explicit_this : 1;
643 unsigned int pinvoke : 1;
644 unsigned int is_inflated : 1;
645 unsigned int has_type_parameters : 1;
646 MonoType *params [MONO_ZERO_LEN_ARRAY];
650 * AOT cache configuration loaded from config files.
651 * Doesn't really belong here.
653 typedef struct {
655 * Enable aot caching for applications whose main assemblies are in
656 * this list.
658 GSList *apps;
659 GSList *assemblies;
660 char *aot_options;
661 } MonoAotCacheConfig;
663 #define MONO_SIZEOF_METHOD_SIGNATURE (sizeof (struct _MonoMethodSignature) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
665 static inline gboolean
666 image_is_dynamic (MonoImage *image)
668 #ifdef DISABLE_REFLECTION_EMIT
669 return FALSE;
670 #else
671 return image->dynamic;
672 #endif
675 static inline gboolean
676 assembly_is_dynamic (MonoAssembly *assembly)
678 #ifdef DISABLE_REFLECTION_EMIT
679 return FALSE;
680 #else
681 return assembly->dynamic;
682 #endif
685 /* for use with allocated memory blocks (assumes alignment is to 8 bytes) */
686 guint mono_aligned_addr_hash (gconstpointer ptr);
688 void
689 mono_image_check_for_module_cctor (MonoImage *image);
691 gpointer
692 mono_image_alloc (MonoImage *image, guint size);
694 gpointer
695 mono_image_alloc0 (MonoImage *image, guint size);
697 #define mono_image_new0(image,type,size) ((type *) mono_image_alloc0 (image, sizeof (type)* (size)))
699 char*
700 mono_image_strdup (MonoImage *image, const char *s);
702 char*
703 mono_image_strdup_vprintf (MonoImage *image, const char *format, va_list args);
705 char*
706 mono_image_strdup_printf (MonoImage *image, const char *format, ...) MONO_ATTR_FORMAT_PRINTF(2,3);;
708 GList*
709 mono_g_list_prepend_image (MonoImage *image, GList *list, gpointer data);
711 GSList*
712 mono_g_slist_append_image (MonoImage *image, GSList *list, gpointer data);
714 void
715 mono_image_lock (MonoImage *image);
717 void
718 mono_image_unlock (MonoImage *image);
720 gpointer
721 mono_image_property_lookup (MonoImage *image, gpointer subject, guint32 property);
723 void
724 mono_image_property_insert (MonoImage *image, gpointer subject, guint32 property, gpointer value);
726 void
727 mono_image_property_remove (MonoImage *image, gpointer subject);
729 gboolean
730 mono_image_close_except_pools (MonoImage *image);
732 void
733 mono_image_close_finish (MonoImage *image);
735 typedef void (*MonoImageUnloadFunc) (MonoImage *image, gpointer user_data);
737 void
738 mono_install_image_unload_hook (MonoImageUnloadFunc func, gpointer user_data);
740 void
741 mono_remove_image_unload_hook (MonoImageUnloadFunc func, gpointer user_data);
743 void
744 mono_install_image_loader (const MonoImageLoader *loader);
746 void
747 mono_image_append_class_to_reflection_info_set (MonoClass *klass);
749 gpointer
750 mono_image_set_alloc (MonoImageSet *set, guint size);
752 gpointer
753 mono_image_set_alloc0 (MonoImageSet *set, guint size);
755 void
756 mono_image_set_lock (MonoImageSet *set);
758 void
759 mono_image_set_unlock (MonoImageSet *set);
761 char*
762 mono_image_set_strdup (MonoImageSet *set, const char *s);
764 #define mono_image_set_new0(image,type,size) ((type *) mono_image_set_alloc0 (image, sizeof (type)* (size)))
766 gboolean
767 mono_image_load_cli_header (MonoImage *image, MonoCLIImageInfo *iinfo);
769 gboolean
770 mono_image_load_metadata (MonoImage *image, MonoCLIImageInfo *iinfo);
772 const char*
773 mono_metadata_string_heap_checked (MonoImage *meta, uint32_t table_index, MonoError *error);
774 const char*
775 mono_metadata_blob_heap_checked (MonoImage *meta, uint32_t table_index, MonoError *error);
776 gboolean
777 mono_metadata_decode_row_checked (const MonoImage *image, const MonoTableInfo *t, int idx, uint32_t *res, int res_size, MonoError *error);
779 MonoType*
780 mono_metadata_get_shared_type (MonoType *type);
782 void
783 mono_metadata_clean_for_image (MonoImage *image);
785 void
786 mono_metadata_clean_generic_classes_for_image (MonoImage *image);
788 MONO_API void
789 mono_metadata_cleanup (void);
791 const char * mono_meta_table_name (int table);
792 void mono_metadata_compute_table_bases (MonoImage *meta);
794 gboolean
795 mono_metadata_interfaces_from_typedef_full (MonoImage *image,
796 guint32 table_index,
797 MonoClass ***interfaces,
798 guint *count,
799 gboolean heap_alloc_result,
800 MonoGenericContext *context,
801 MonoError *error);
803 MONO_API MonoMethodSignature *
804 mono_metadata_parse_method_signature_full (MonoImage *image,
805 MonoGenericContainer *generic_container,
806 int def,
807 const char *ptr,
808 const char **rptr,
809 MonoError *error);
811 MONO_API MonoMethodHeader *
812 mono_metadata_parse_mh_full (MonoImage *image,
813 MonoGenericContainer *container,
814 const char *ptr,
815 MonoError *error);
817 MonoMethodSignature *mono_metadata_parse_signature_checked (MonoImage *image,
818 uint32_t token,
819 MonoError *error);
821 gboolean
822 mono_method_get_header_summary (MonoMethod *method, MonoMethodHeaderSummary *summary);
824 int* mono_metadata_get_param_attrs (MonoImage *m, int def, int param_count);
825 gboolean mono_metadata_method_has_param_attrs (MonoImage *m, int def);
827 guint
828 mono_metadata_generic_context_hash (const MonoGenericContext *context);
830 gboolean
831 mono_metadata_generic_context_equal (const MonoGenericContext *g1,
832 const MonoGenericContext *g2);
834 MonoGenericInst *
835 mono_metadata_parse_generic_inst (MonoImage *image,
836 MonoGenericContainer *container,
837 int count,
838 const char *ptr,
839 const char **rptr,
840 MonoError *error);
842 MonoGenericInst *
843 mono_metadata_get_generic_inst (int type_argc,
844 MonoType **type_argv);
846 MonoGenericInst *
847 mono_metadata_get_canonical_generic_inst (MonoGenericInst *candidate);
849 MonoGenericClass *
850 mono_metadata_lookup_generic_class (MonoClass *gclass,
851 MonoGenericInst *inst,
852 gboolean is_dynamic);
854 MonoGenericInst * mono_metadata_inflate_generic_inst (MonoGenericInst *ginst, MonoGenericContext *context, MonoError *error);
856 guint
857 mono_metadata_generic_param_hash (MonoGenericParam *p);
859 gboolean
860 mono_metadata_generic_param_equal (MonoGenericParam *p1, MonoGenericParam *p2);
862 void mono_dynamic_stream_reset (MonoDynamicStream* stream);
863 MONO_API void mono_assembly_addref (MonoAssembly *assembly);
864 void mono_assembly_load_friends (MonoAssembly* ass);
865 gboolean mono_assembly_has_skip_verification (MonoAssembly* ass);
867 void mono_assembly_release_gc_roots (MonoAssembly *assembly);
868 gboolean mono_assembly_close_except_image_pools (MonoAssembly *assembly);
869 void mono_assembly_close_finish (MonoAssembly *assembly);
872 gboolean mono_public_tokens_are_equal (const unsigned char *pubt1, const unsigned char *pubt2);
874 void mono_config_parse_publisher_policy (const char *filename, MonoAssemblyBindingInfo *binding_info);
875 void mono_config_parse_assembly_bindings (const char *filename, int major, int minor, void *user_data,
876 void (*infocb)(MonoAssemblyBindingInfo *info, void *user_data));
878 gboolean
879 mono_assembly_name_parse_full (const char *name,
880 MonoAssemblyName *aname,
881 gboolean save_public_key,
882 gboolean *is_version_defined,
883 gboolean *is_token_defined);
885 gboolean
886 mono_assembly_fill_assembly_name_full (MonoImage *image, MonoAssemblyName *aname, gboolean copyBlobs);
889 MONO_API guint32 mono_metadata_get_generic_param_row (MonoImage *image, guint32 token, guint32 *owner);
891 MonoGenericParam*
892 mono_metadata_create_anon_gparam (MonoImage *image, gint32 param_num, gboolean is_mvar);
894 void mono_unload_interface_ids (MonoBitSet *bitset);
897 MonoType *mono_metadata_type_dup (MonoImage *image, const MonoType *original);
898 MonoType *mono_metadata_type_dup_with_cmods (MonoImage *image, const MonoType *original, const MonoType *cmods_source);
900 MonoMethodSignature *mono_metadata_signature_dup_full (MonoImage *image,MonoMethodSignature *sig);
901 MonoMethodSignature *mono_metadata_signature_dup_mempool (MonoMemPool *mp, MonoMethodSignature *sig);
902 MonoMethodSignature *mono_metadata_signature_dup_add_this (MonoImage *image, MonoMethodSignature *sig, MonoClass *klass);
904 MonoGenericInst *
905 mono_get_shared_generic_inst (MonoGenericContainer *container);
908 mono_type_stack_size_internal (MonoType *t, int *align, gboolean allow_open);
910 MONO_API void mono_type_get_desc (GString *res, MonoType *type, mono_bool include_namespace);
912 gboolean
913 mono_metadata_type_equal_full (MonoType *t1, MonoType *t2, gboolean signature_only);
915 MonoMarshalSpec *
916 mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image, const char *ptr);
918 guint mono_metadata_generic_inst_hash (gconstpointer data);
919 gboolean mono_metadata_generic_inst_equal (gconstpointer ka, gconstpointer kb);
921 MONO_API void
922 mono_metadata_field_info_with_mempool (
923 MonoImage *meta,
924 guint32 table_index,
925 guint32 *offset,
926 guint32 *rva,
927 MonoMarshalSpec **marshal_spec);
929 MonoClassField*
930 mono_metadata_get_corresponding_field_from_generic_type_definition (MonoClassField *field);
932 MonoEvent*
933 mono_metadata_get_corresponding_event_from_generic_type_definition (MonoEvent *event);
935 MonoProperty*
936 mono_metadata_get_corresponding_property_from_generic_type_definition (MonoProperty *property);
938 guint32
939 mono_metadata_signature_size (MonoMethodSignature *sig);
941 guint mono_metadata_str_hash (gconstpointer v1);
943 gboolean mono_image_load_pe_data (MonoImage *image);
945 gboolean mono_image_load_cli_data (MonoImage *image);
947 void mono_image_load_names (MonoImage *image);
949 MonoImage *mono_image_open_raw (const char *fname, MonoImageOpenStatus *status);
951 MonoImage *mono_image_open_metadata_only (const char *fname, MonoImageOpenStatus *status);
953 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);
955 MonoException *mono_get_exception_field_access_msg (const char *msg);
957 MonoException *mono_get_exception_method_access_msg (const char *msg);
959 MonoMethod* mono_method_from_method_def_or_ref (MonoImage *m, guint32 tok, MonoGenericContext *context, MonoError *error);
961 MonoMethod *mono_get_method_constrained_with_method (MonoImage *image, MonoMethod *method, MonoClass *constrained_class, MonoGenericContext *context, MonoError *error);
962 MonoMethod *mono_get_method_constrained_checked (MonoImage *image, guint32 token, MonoClass *constrained_class, MonoGenericContext *context, MonoMethod **cil_method, MonoError *error);
964 void mono_type_set_alignment (MonoTypeEnum type, int align);
966 MonoAotCacheConfig *mono_get_aot_cache_config (void);
967 MonoType *
968 mono_type_create_from_typespec_checked (MonoImage *image, guint32 type_spec, MonoError *error);
970 MonoMethodSignature*
971 mono_method_get_signature_checked (MonoMethod *method, MonoImage *image, guint32 token, MonoGenericContext *context, MonoError *error);
973 MonoMethod *
974 mono_get_method_checked (MonoImage *image, guint32 token, MonoClass *klass, MonoGenericContext *context, MonoError *error);
976 guint32
977 mono_metadata_localscope_from_methoddef (MonoImage *meta, guint32 index);
979 void
980 mono_wrapper_caches_free (MonoWrapperCaches *cache);
982 MonoWrapperCaches*
983 mono_method_get_wrapper_cache (MonoMethod *method);
985 MonoWrapperCaches*
986 mono_method_get_wrapper_cache (MonoMethod *method);
988 MonoType*
989 mono_metadata_parse_type_checked (MonoImage *m, MonoGenericContainer *container, short opt_attrs, gboolean transient, const char *ptr, const char **rptr, MonoError *error);
991 MonoGenericContainer *
992 mono_get_anonymous_container_for_image (MonoImage *image, gboolean is_mvar);
994 char *
995 mono_image_set_description (MonoImageSet *);
997 MonoImageSet *
998 mono_find_image_set_owner (void *ptr);
1000 MONO_API void
1001 mono_loader_register_module (const char *name, MonoDl *module);
1003 gboolean
1004 mono_assembly_is_problematic_version (const char *name, guint16 major, guint16 minor, guint16 build, guint16 revision);
1006 void
1007 mono_ginst_get_desc (GString *str, MonoGenericInst *ginst);
1009 void
1010 mono_loader_set_strict_strong_names (gboolean enabled);
1012 gboolean
1013 mono_loader_get_strict_strong_names (void);
1015 gboolean
1016 mono_type_in_image (MonoType *type, MonoImage *image);
1018 gboolean
1019 mono_type_is_valid_generic_argument (MonoType *type);
1021 MonoAssemblyContextKind
1022 mono_asmctx_get_kind (const MonoAssemblyContext *ctx);
1024 #define MONO_CLASS_IS_INTERFACE_INTERNAL(c) ((mono_class_get_flags (c) & TYPE_ATTRIBUTE_INTERFACE) || mono_type_is_generic_parameter (m_class_get_byval_arg (c)))
1026 #endif /* __MONO_METADATA_INTERNALS_H__ */