Merge pull request #2780 from alexanderkyte/seq_point_optimize
[mono.git] / mono / metadata / metadata-internals.h
1
2 #ifndef __MONO_METADATA_INTERNALS_H__
3 #define __MONO_METADATA_INTERNALS_H__
4
5 #include "mono/metadata/image.h"
6 #include "mono/metadata/blob.h"
7 #include "mono/metadata/cil-coff.h"
8 #include "mono/metadata/mempool.h"
9 #include "mono/metadata/domain-internals.h"
10 #include "mono/metadata/mono-hash.h"
11 #include "mono/utils/mono-compiler.h"
12 #include "mono/utils/mono-dl.h"
13 #include "mono/utils/monobitset.h"
14 #include "mono/utils/mono-property-hash.h"
15 #include "mono/utils/mono-value-hash.h"
16 #include <mono/utils/mono-error.h>
17 #include "mono/utils/mono-conc-hashtable.h"
18
19 struct _MonoType {
20         union {
21                 MonoClass *klass; /* for VALUETYPE and CLASS */
22                 MonoType *type;   /* for PTR */
23                 MonoArrayType *array; /* for ARRAY */
24                 MonoMethodSignature *method;
25                 MonoGenericParam *generic_param; /* for VAR and MVAR */
26                 MonoGenericClass *generic_class; /* for GENERICINST */
27         } data;
28         unsigned int attrs    : 16; /* param attributes or field flags */
29         MonoTypeEnum type     : 8;
30         unsigned int num_mods : 6;  /* max 64 modifiers follow at the end */
31         unsigned int byref    : 1;
32         unsigned int pinned   : 1;  /* valid when included in a local var signature */
33         MonoCustomMod modifiers [MONO_ZERO_LEN_ARRAY]; /* this may grow */
34 };
35
36 #define MONO_SIZEOF_TYPE (offsetof (struct _MonoType, modifiers))
37
38 #define MONO_SECMAN_FLAG_INIT(x)                (x & 0x2)
39 #define MONO_SECMAN_FLAG_GET_VALUE(x)           (x & 0x1)
40 #define MONO_SECMAN_FLAG_SET_VALUE(x,y)         do { x = ((y) ? 0x3 : 0x2); } while (0)
41
42 #define MONO_PUBLIC_KEY_TOKEN_LENGTH    17
43
44 #define MONO_PROCESSOR_ARCHITECTURE_NONE 0
45 #define MONO_PROCESSOR_ARCHITECTURE_MSIL 1
46 #define MONO_PROCESSOR_ARCHITECTURE_X86 2
47 #define MONO_PROCESSOR_ARCHITECTURE_IA64 3
48 #define MONO_PROCESSOR_ARCHITECTURE_AMD64 4
49 #define MONO_PROCESSOR_ARCHITECTURE_ARM 5
50
51 struct _MonoAssemblyName {
52         const char *name;
53         const char *culture;
54         const char *hash_value;
55         const mono_byte* public_key;
56         // string of 16 hex chars + 1 NULL
57         mono_byte public_key_token [MONO_PUBLIC_KEY_TOKEN_LENGTH];
58         uint32_t hash_alg;
59         uint32_t hash_len;
60         uint32_t flags;
61         uint16_t major, minor, build, revision, arch;
62 };
63
64 struct MonoTypeNameParse {
65         char *name_space;
66         char *name;
67         MonoAssemblyName assembly;
68         GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
69         GPtrArray *type_arguments;
70         GList *nested;
71 };
72
73 struct _MonoAssembly {
74         /* 
75          * The number of appdomains which have this assembly loaded plus the number of 
76          * assemblies referencing this assembly through an entry in their image->references
77          * arrays. The latter is needed because entries in the image->references array
78          * might point to assemblies which are only loaded in some appdomains, and without
79          * the additional reference, they can be freed at any time.
80          * The ref_count is initially 0.
81          */
82         int ref_count; /* use atomic operations only */
83         char *basedir;
84         MonoAssemblyName aname;
85         MonoImage *image;
86         GSList *friend_assembly_names; /* Computed by mono_assembly_load_friends () */
87         guint8 friend_assembly_names_inited;
88         guint8 in_gac;
89         guint8 dynamic;
90         guint8 corlib_internal;
91         gboolean ref_only;
92         guint8 wrap_non_exception_throws;
93         guint8 wrap_non_exception_throws_inited;
94         guint8 jit_optimizer_disabled;
95         guint8 jit_optimizer_disabled_inited;
96         /* security manager flags (one bit is for lazy initialization) */
97         guint32 ecma:2;         /* Has the ECMA key */
98         guint32 aptc:2;         /* Has the [AllowPartiallyTrustedCallers] attributes */
99         guint32 fulltrust:2;    /* Has FullTrust permission */
100         guint32 unmanaged:2;    /* Has SecurityPermissionFlag.UnmanagedCode permission */
101         guint32 skipverification:2;     /* Has SecurityPermissionFlag.SkipVerification permission */
102 };
103
104 typedef struct {
105         /*
106          * indexed by MonoMethodSignature 
107          * Protected by the marshal lock
108          */
109         GHashTable *delegate_invoke_cache;
110         GHashTable *delegate_begin_invoke_cache;
111         GHashTable *delegate_end_invoke_cache;
112         GHashTable *runtime_invoke_cache;
113         GHashTable *runtime_invoke_vtype_cache;
114         GHashTable *runtime_invoke_sig_cache;
115
116         /*
117          * indexed by SignaturePointerPair
118          */
119         GHashTable *delegate_abstract_invoke_cache;
120
121         /*
122          * indexed by MonoMethod pointers
123          * Protected by the marshal lock
124          */
125         GHashTable *runtime_invoke_direct_cache;
126         GHashTable *managed_wrapper_cache;
127
128         GHashTable *native_wrapper_cache;
129         GHashTable *native_wrapper_aot_cache;
130         GHashTable *native_wrapper_check_cache;
131         GHashTable *native_wrapper_aot_check_cache;
132
133         GHashTable *native_func_wrapper_aot_cache;
134         GHashTable *remoting_invoke_cache;
135         GHashTable *synchronized_cache;
136         GHashTable *unbox_wrapper_cache;
137         GHashTable *cominterop_invoke_cache;
138         GHashTable *cominterop_wrapper_cache; /* LOCKING: marshal lock */
139         GHashTable *thunk_invoke_cache;
140 } MonoWrapperCaches;
141
142 typedef struct {
143         const char* data;
144         guint32  size;
145 } MonoStreamHeader;
146
147 struct _MonoTableInfo {
148         const char *base;
149         guint       rows     : 24;
150         guint       row_size : 8;
151
152         /*
153          * Tables contain up to 9 columns and the possible sizes of the
154          * fields in the documentation are 1, 2 and 4 bytes.  So we
155          * can encode in 2 bits the size.
156          *
157          * A 32 bit value can encode the resulting size
158          *
159          * The top eight bits encode the number of columns in the table.
160          * we only need 4, but 8 is aligned no shift required. 
161          */
162         guint32   size_bitfield;
163 };
164
165 #define REFERENCE_MISSING ((gpointer) -1)
166
167 typedef struct _MonoDllMap MonoDllMap;
168
169 typedef struct {
170         gboolean (*match) (MonoImage*);
171         gboolean (*load_pe_data) (MonoImage*);
172         gboolean (*load_cli_data) (MonoImage*);
173         gboolean (*load_tables) (MonoImage*);
174 } MonoImageLoader;
175
176 struct _MonoImage {
177         /*
178          * The number of assemblies which reference this MonoImage though their 'image'
179          * field plus the number of images which reference this MonoImage through their 
180          * 'modules' field, plus the number of threads holding temporary references to
181          * this image between calls of mono_image_open () and mono_image_close ().
182          */
183         int   ref_count;
184
185         /* If the raw data was allocated from a source such as mmap, the allocator may store resource tracking information here. */
186         void *raw_data_handle;
187         char *raw_data;
188         guint32 raw_data_len;
189         guint8 raw_buffer_used    : 1;
190         guint8 raw_data_allocated : 1;
191         guint8 fileio_used : 1;
192
193 #ifdef HOST_WIN32
194         /* Module was loaded using LoadLibrary. */
195         guint8 is_module_handle : 1;
196
197         /* Module entry point is _CorDllMain. */
198         guint8 has_entry_point : 1;
199 #endif
200
201         /* Whenever this is a dynamically emitted module */
202         guint8 dynamic : 1;
203
204         /* Whenever this is a reflection only image */
205         guint8 ref_only : 1;
206
207         /* Whenever this image contains uncompressed metadata */
208         guint8 uncompressed_metadata : 1;
209
210         /* Whenever this image contains metadata only without PE data */
211         guint8 metadata_only : 1;
212
213         guint8 checked_module_cctor : 1;
214         guint8 has_module_cctor : 1;
215
216         guint8 idx_string_wide : 1;
217         guint8 idx_guid_wide : 1;
218         guint8 idx_blob_wide : 1;
219
220         /* Whenever this image is considered as platform code for the CoreCLR security model */
221         guint8 core_clr_platform_code : 1;
222
223         /* The path to the file for this image. */
224         char *name;
225
226         /* The assembly name reported in the file for this image (expected to be NULL for a netmodule) */
227         const char *assembly_name;
228
229         /* The module name reported in the file for this image (could be NULL for a malformed file) */
230         const char *module_name;
231
232         char *version;
233         gint16 md_version_major, md_version_minor;
234         char *guid;
235         void *image_info;
236         MonoMemPool         *mempool; /*protected by the image lock*/
237
238         char                *raw_metadata;
239                             
240         MonoStreamHeader     heap_strings;
241         MonoStreamHeader     heap_us;
242         MonoStreamHeader     heap_blob;
243         MonoStreamHeader     heap_guid;
244         MonoStreamHeader     heap_tables;
245         MonoStreamHeader     heap_pdb;
246                             
247         const char          *tables_base;
248
249         /**/
250         MonoTableInfo        tables [MONO_TABLE_NUM];
251
252         /*
253          * references is initialized only by using the mono_assembly_open
254          * function, and not by using the lowlevel mono_image_open.
255          *
256          * It is NULL terminated.
257          */
258         MonoAssembly **references;
259         int nreferences;
260
261         /* Code files in the assembly. */
262         MonoImage **modules;
263         guint32 module_count;
264         gboolean *modules_loaded;
265
266         /*
267          * Files in the assembly. Items are either NULL or alias items in modules, so this does not impact ref_count.
268          * Protected by the image lock.
269          */
270         MonoImage **files;
271
272         gpointer aot_module;
273
274         guint8 aotid[16];
275
276         /*
277          * The Assembly this image was loaded from.
278          */
279         MonoAssembly *assembly;
280
281         /*
282          * Indexed by method tokens and typedef tokens.
283          */
284         GHashTable *method_cache; /*protected by the image lock*/
285         MonoInternalHashTable class_cache;
286
287         /* Indexed by memberref + methodspec tokens */
288         GHashTable *methodref_cache; /*protected by the image lock*/
289
290         /*
291          * Indexed by fielddef and memberref tokens
292          */
293         MonoConcurrentHashTable *field_cache; /*protected by the image lock*/
294
295         /* indexed by typespec tokens. */
296         GHashTable *typespec_cache; /* protected by the image lock */
297         /* indexed by token */
298         GHashTable *memberref_signatures;
299         GHashTable *helper_signatures;
300
301         /* Indexed by blob heap indexes */
302         GHashTable *method_signatures;
303
304         /*
305          * Indexes namespaces to hash tables that map class name to typedef token.
306          */
307         GHashTable *name_cache;  /*protected by the image lock*/
308
309         /*
310          * Indexed by MonoClass
311          */
312         GHashTable *array_cache;
313         GHashTable *ptr_cache;
314
315         GHashTable *szarray_cache;
316         /* This has a separate lock to improve scalability */
317         mono_mutex_t szarray_cache_lock;
318
319         /*
320          * indexed by SignaturePointerPair
321          */
322         GHashTable *delegate_bound_static_invoke_cache;
323         GHashTable *native_func_wrapper_cache;
324
325         /*
326          * indexed by MonoMethod pointers 
327          */
328         GHashTable *runtime_invoke_vcall_cache;
329         GHashTable *wrapper_param_names;
330         GHashTable *array_accessor_cache;
331
332         /*
333          * indexed by MonoClass pointers
334          */
335         GHashTable *ldfld_wrapper_cache;
336         GHashTable *ldflda_wrapper_cache;
337         GHashTable *stfld_wrapper_cache;
338         GHashTable *isinst_cache;
339
340         GHashTable *icall_wrapper_cache;
341         GHashTable *castclass_cache;
342         GHashTable *proxy_isinst_cache;
343         GHashTable *rgctx_template_hash; /* LOCKING: templates lock */
344
345         /* Contains rarely used fields of runtime structures belonging to this image */
346         MonoPropertyHash *property_hash;
347
348         void *reflection_info;
349
350         /*
351          * user_info is a public field and is not touched by the
352          * metadata engine
353          */
354         void *user_info;
355
356         /* dll map entries */
357         MonoDllMap *dll_map;
358
359         /* interfaces IDs from this image */
360         /* protected by the classes lock */
361         MonoBitSet *interface_bitset;
362
363         /* when the image is being closed, this is abused as a list of
364            malloc'ed regions to be freed. */
365         GSList *reflection_info_unregister_classes;
366
367         /* List of dependent image sets containing this image */
368         /* Protected by image_sets_lock */
369         GSList *image_sets;
370
371         /* Caches for wrappers that DO NOT reference generic */
372         /* arguments */
373         MonoWrapperCaches wrapper_caches;
374
375         /* Caches for MonoClass-es representing anon generic params */
376         MonoClass **var_cache_fast;
377         MonoClass **mvar_cache_fast;
378         GHashTable *var_cache_slow;
379         GHashTable *mvar_cache_slow;
380         GHashTable *var_cache_constrained;
381         GHashTable *mvar_cache_constrained;
382
383         /* Maps malloc-ed char* pinvoke scope -> MonoDl* */
384         GHashTable *pinvoke_scopes;
385
386         /* Maps malloc-ed char* pinvoke scope -> malloced-ed char* filename */
387         GHashTable *pinvoke_scope_filenames;
388
389         /* Indexed by MonoGenericParam pointers */
390         GHashTable **gshared_types;
391         /* The length of the above array */
392         int gshared_types_len;
393
394         /* The loader used to load this image */
395         MonoImageLoader *loader;
396
397         // Containers for MonoGenericParams associated with this image but not with any specific class or method. Created on demand.
398         // This could happen, for example, for MonoTypes associated with TypeSpec table entries.
399         MonoGenericContainer *anonymous_generic_class_container;
400         MonoGenericContainer *anonymous_generic_method_container;
401
402         /*
403          * No other runtime locks must be taken while holding this lock.
404          * It's meant to be used only to mutate and query structures part of this image.
405          */
406         mono_mutex_t    lock;
407 };
408
409 /*
410  * Generic instances depend on many images, and they need to be deleted if one
411  * of the images they depend on is unloaded. For example,
412  * List<Foo> depends on both List's image and Foo's image.
413  * A MonoImageSet is the owner of all generic instances depending on the same set of
414  * images.
415  */
416 typedef struct {
417         int nimages;
418         MonoImage **images;
419
420         // Generic-specific caches
421         GHashTable *gclass_cache, *ginst_cache, *gmethod_cache, *gsignature_cache;
422
423         MonoWrapperCaches wrapper_caches;
424
425         mono_mutex_t    lock;
426
427         /*
428          * Memory for generic instances owned by this image set should be allocated from
429          * this mempool, using the mono_image_set_alloc family of functions.
430          */
431         MonoMemPool         *mempool;
432 } MonoImageSet;
433
434 enum {
435         MONO_SECTION_TEXT,
436         MONO_SECTION_RSRC,
437         MONO_SECTION_RELOC,
438         MONO_SECTION_MAX
439 };
440
441 typedef struct {
442         GHashTable *hash;
443         char *data;
444         guint32 alloc_size; /* malloced bytes */
445         guint32 index;
446         guint32 offset; /* from start of metadata */
447 } MonoDynamicStream;
448
449 typedef struct {
450         guint32 alloc_rows;
451         guint32 rows;
452         guint8  row_size; /*  calculated later with column_sizes */
453         guint8  columns;
454         guint32 next_idx;
455         guint32 *values; /* rows * columns */
456 } MonoDynamicTable;
457
458 /* "Dynamic" assemblies and images arise from System.Reflection.Emit */
459 struct _MonoDynamicAssembly {
460         MonoAssembly assembly;
461         char *strong_name;
462         guint32 strong_name_size;
463         guint8 run;
464         guint8 save;
465         MonoDomain *domain;
466 };
467
468 struct _MonoDynamicImage {
469         MonoImage image;
470         guint32 meta_size;
471         guint32 text_rva;
472         guint32 metadata_rva;
473         guint32 image_base;
474         guint32 cli_header_offset;
475         guint32 iat_offset;
476         guint32 idt_offset;
477         guint32 ilt_offset;
478         guint32 imp_names_offset;
479         struct {
480                 guint32 rva;
481                 guint32 size;
482                 guint32 offset;
483                 guint32 attrs;
484         } sections [MONO_SECTION_MAX];
485         GHashTable *typespec;
486         GHashTable *typeref;
487         GHashTable *handleref;
488         MonoGHashTable *handleref_managed;
489         MonoGHashTable *tokens;
490         GHashTable *blob_cache;
491         GHashTable *standalonesig_cache;
492         GList *array_methods;
493         GPtrArray *gen_params;
494         MonoGHashTable *token_fixups;
495         GHashTable *method_to_table_idx;
496         GHashTable *field_to_table_idx;
497         GHashTable *method_aux_hash;
498         GHashTable *vararg_aux_hash;
499         MonoGHashTable *generic_def_objects;
500         MonoGHashTable *methodspec;
501         /*
502          * Maps final token values to the object they describe.
503          */
504         MonoGHashTable *remapped_tokens;
505         gboolean run;
506         gboolean save;
507         gboolean initial_image;
508         guint32 pe_kind, machine;
509         char *strong_name;
510         guint32 strong_name_size;
511         char *win32_res;
512         guint32 win32_res_size;
513         guint8 *public_key;
514         int public_key_len;
515         MonoDynamicStream sheap;
516         MonoDynamicStream code; /* used to store method headers and bytecode */
517         MonoDynamicStream resources; /* managed embedded resources */
518         MonoDynamicStream us;
519         MonoDynamicStream blob;
520         MonoDynamicStream tstream;
521         MonoDynamicStream guid;
522         MonoDynamicTable tables [MONO_TABLE_NUM];
523         MonoClass *wrappers_type; /*wrappers are bound to this type instead of <Module>*/
524 };
525
526 /* Contains information about assembly binding */
527 typedef struct _MonoAssemblyBindingInfo {
528         char *name;
529         char *culture;
530         guchar public_key_token [MONO_PUBLIC_KEY_TOKEN_LENGTH];
531         int major;
532         int minor;
533         AssemblyVersionSet old_version_bottom;
534         AssemblyVersionSet old_version_top;
535         AssemblyVersionSet new_version;
536         guint has_old_version_bottom : 1;
537         guint has_old_version_top : 1;
538         guint has_new_version : 1;
539         guint is_valid : 1;
540         gint32 domain_id; /*Needed to unload per-domain binding*/
541 } MonoAssemblyBindingInfo;
542
543 struct _MonoMethodHeader {
544         const unsigned char  *code;
545 #ifdef MONO_SMALL_CONFIG
546         guint16      code_size;
547 #else
548         guint32      code_size;
549 #endif
550         guint16      max_stack   : 15;
551         unsigned int is_transient: 1; /* mono_metadata_free_mh () will actually free this header */
552         unsigned int num_clauses : 15;
553         /* if num_locals != 0, then the following apply: */
554         unsigned int init_locals : 1;
555         guint16      num_locals;
556         MonoExceptionClause *clauses;
557         MonoType    *locals [MONO_ZERO_LEN_ARRAY];
558 };
559
560 typedef struct {
561         guint32      code_size;
562         gboolean     has_clauses;
563 } MonoMethodHeaderSummary;
564
565 #define MONO_SIZEOF_METHOD_HEADER (sizeof (struct _MonoMethodHeader) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
566
567 struct _MonoMethodSignature {
568         MonoType     *ret;
569 #ifdef MONO_SMALL_CONFIG
570         guint8        param_count;
571         gint8         sentinelpos;
572         unsigned int  generic_param_count : 5;
573 #else
574         guint16       param_count;
575         gint16        sentinelpos;
576         unsigned int  generic_param_count : 16;
577 #endif
578         unsigned int  call_convention     : 6;
579         unsigned int  hasthis             : 1;
580         unsigned int  explicit_this       : 1;
581         unsigned int  pinvoke             : 1;
582         unsigned int  is_inflated         : 1;
583         unsigned int  has_type_parameters : 1;
584         MonoType     *params [MONO_ZERO_LEN_ARRAY];
585 };
586
587 /*
588  * AOT cache configuration loaded from config files.
589  * Doesn't really belong here.
590  */
591 typedef struct {
592         /*
593          * Enable aot caching for applications whose main assemblies are in
594          * this list.
595          */
596         GSList *apps;
597         GSList *assemblies;
598         char *aot_options;
599 } MonoAotCacheConfig;
600
601 #define MONO_SIZEOF_METHOD_SIGNATURE (sizeof (struct _MonoMethodSignature) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
602
603 static inline gboolean
604 image_is_dynamic (MonoImage *image)
605 {
606 #ifdef DISABLE_REFLECTION_EMIT
607         return FALSE;
608 #else
609         return image->dynamic;
610 #endif
611 }
612
613 static inline gboolean
614 assembly_is_dynamic (MonoAssembly *assembly)
615 {
616 #ifdef DISABLE_REFLECTION_EMIT
617         return FALSE;
618 #else
619         return assembly->dynamic;
620 #endif
621 }
622
623 /* for use with allocated memory blocks (assumes alignment is to 8 bytes) */
624 guint mono_aligned_addr_hash (gconstpointer ptr);
625
626 void
627 mono_image_check_for_module_cctor (MonoImage *image);
628
629 gpointer
630 mono_image_alloc  (MonoImage *image, guint size);
631
632 gpointer
633 mono_image_alloc0 (MonoImage *image, guint size);
634
635 #define mono_image_new0(image,type,size) ((type *) mono_image_alloc0 (image, sizeof (type)* (size)))
636
637 char*
638 mono_image_strdup (MonoImage *image, const char *s);
639
640 GList*
641 g_list_prepend_image (MonoImage *image, GList *list, gpointer data);
642
643 GSList*
644 g_slist_append_image (MonoImage *image, GSList *list, gpointer data);
645
646 void
647 mono_image_lock (MonoImage *image);
648
649 void
650 mono_image_unlock (MonoImage *image);
651
652 gpointer
653 mono_image_property_lookup (MonoImage *image, gpointer subject, guint32 property);
654
655 void
656 mono_image_property_insert (MonoImage *image, gpointer subject, guint32 property, gpointer value);
657
658 void
659 mono_image_property_remove (MonoImage *image, gpointer subject);
660
661 gboolean
662 mono_image_close_except_pools (MonoImage *image);
663
664 void
665 mono_image_close_finish (MonoImage *image);
666
667 typedef void  (*MonoImageUnloadFunc) (MonoImage *image, gpointer user_data);
668
669 void
670 mono_install_image_unload_hook (MonoImageUnloadFunc func, gpointer user_data);
671
672 void
673 mono_remove_image_unload_hook (MonoImageUnloadFunc func, gpointer user_data);
674
675 void
676 mono_install_image_loader (const MonoImageLoader *loader);
677
678 void
679 mono_image_append_class_to_reflection_info_set (MonoClass *klass);
680
681 gpointer
682 mono_image_set_alloc  (MonoImageSet *set, guint size);
683
684 gpointer
685 mono_image_set_alloc0 (MonoImageSet *set, guint size);
686
687 void
688 mono_image_set_lock (MonoImageSet *set);
689
690 void
691 mono_image_set_unlock (MonoImageSet *set);
692
693 char*
694 mono_image_set_strdup (MonoImageSet *set, const char *s);
695
696 #define mono_image_set_new0(image,type,size) ((type *) mono_image_set_alloc0 (image, sizeof (type)* (size)))
697
698 gboolean
699 mono_image_load_cli_header (MonoImage *image, MonoCLIImageInfo *iinfo);
700
701 gboolean
702 mono_image_load_metadata (MonoImage *image, MonoCLIImageInfo *iinfo);
703
704 MonoType*
705 mono_metadata_get_shared_type (MonoType *type);
706
707 void
708 mono_metadata_clean_for_image (MonoImage *image);
709
710 void
711 mono_metadata_clean_generic_classes_for_image (MonoImage *image);
712
713 MONO_API void
714 mono_metadata_cleanup (void);
715
716 const char *   mono_meta_table_name              (int table);
717 void           mono_metadata_compute_table_bases (MonoImage *meta);
718
719 gboolean
720 mono_metadata_interfaces_from_typedef_full  (MonoImage             *image,
721                                                                                          guint32                table_index,
722                                                                                          MonoClass           ***interfaces,
723                                                                                          guint                 *count,
724                                                                                          gboolean               heap_alloc_result,
725                                                                                          MonoGenericContext    *context,
726                                                                                          MonoError *error);
727
728 MONO_API MonoMethodSignature *
729 mono_metadata_parse_method_signature_full   (MonoImage             *image,
730                                              MonoGenericContainer  *generic_container,
731                                              int                     def,
732                                              const char             *ptr,
733                                              const char            **rptr,
734                                              MonoError *error);
735
736 MONO_API MonoMethodHeader *
737 mono_metadata_parse_mh_full                 (MonoImage             *image,
738                                              MonoGenericContainer  *container,
739                                              const char            *ptr,
740                                                  MonoError *error);
741
742 MonoMethodSignature  *mono_metadata_parse_signature_checked (MonoImage *image, 
743                                                              uint32_t    token,
744                                                              MonoError *error);
745
746 gboolean
747 mono_method_get_header_summary (MonoMethod *method, MonoMethodHeaderSummary *summary);
748
749 int* mono_metadata_get_param_attrs          (MonoImage *m, int def, int param_count);
750 gboolean mono_metadata_method_has_param_attrs (MonoImage *m, int def);
751
752 guint
753 mono_metadata_generic_context_hash          (const MonoGenericContext *context);
754
755 gboolean
756 mono_metadata_generic_context_equal         (const MonoGenericContext *g1,
757                                              const MonoGenericContext *g2);
758
759 MonoGenericInst *
760 mono_metadata_parse_generic_inst            (MonoImage             *image,
761                                              MonoGenericContainer  *container,
762                                              int                    count,
763                                              const char            *ptr,
764                                              const char           **rptr,
765                                                  MonoError *error);
766
767 MonoGenericInst *
768 mono_metadata_get_generic_inst              (int                    type_argc,
769                                              MonoType             **type_argv);
770
771 MonoGenericClass *
772 mono_metadata_lookup_generic_class          (MonoClass             *gclass,
773                                              MonoGenericInst       *inst,
774                                              gboolean               is_dynamic);
775
776 MonoGenericInst * mono_metadata_inflate_generic_inst  (MonoGenericInst *ginst, MonoGenericContext *context, MonoError *error);
777
778 guint
779 mono_metadata_generic_param_hash (MonoGenericParam *p);
780
781 gboolean
782 mono_metadata_generic_param_equal (MonoGenericParam *p1, MonoGenericParam *p2);
783
784 void mono_dynamic_stream_reset  (MonoDynamicStream* stream);
785 MONO_API void mono_assembly_addref       (MonoAssembly *assembly);
786 void mono_assembly_load_friends (MonoAssembly* ass);
787 gboolean mono_assembly_has_skip_verification (MonoAssembly* ass);
788
789 void mono_assembly_release_gc_roots (MonoAssembly *assembly);
790 gboolean mono_assembly_close_except_image_pools (MonoAssembly *assembly);
791 void mono_assembly_close_finish (MonoAssembly *assembly);
792
793
794 gboolean mono_public_tokens_are_equal (const unsigned char *pubt1, const unsigned char *pubt2);
795
796 void mono_config_parse_publisher_policy (const char *filename, MonoAssemblyBindingInfo *binding_info);
797 void mono_config_parse_assembly_bindings (const char *filename, int major, int minor, void *user_data,
798                                           void (*infocb)(MonoAssemblyBindingInfo *info, void *user_data));
799
800 gboolean
801 mono_assembly_name_parse_full                (const char           *name,
802                                               MonoAssemblyName     *aname,
803                                               gboolean save_public_key,
804                                               gboolean *is_version_defined,
805                                                   gboolean *is_token_defined);
806
807 MONO_API guint32 mono_metadata_get_generic_param_row (MonoImage *image, guint32 token, guint32 *owner);
808
809 void mono_unload_interface_ids (MonoBitSet *bitset);
810
811
812 MonoType *mono_metadata_type_dup (MonoImage *image, const MonoType *original);
813 MonoMethodSignature  *mono_metadata_signature_dup_full (MonoImage *image,MonoMethodSignature *sig);
814 MonoMethodSignature  *mono_metadata_signature_dup_mempool (MonoMemPool *mp, MonoMethodSignature *sig);
815 MonoMethodSignature  *mono_metadata_signature_dup_add_this (MonoImage *image, MonoMethodSignature *sig, MonoClass *klass);
816
817 MonoGenericInst *
818 mono_get_shared_generic_inst (MonoGenericContainer *container);
819
820 int
821 mono_type_stack_size_internal (MonoType *t, int *align, gboolean allow_open);
822
823 MONO_API void            mono_type_get_desc (GString *res, MonoType *type, mono_bool include_namespace);
824
825 gboolean
826 mono_metadata_type_equal_full (MonoType *t1, MonoType *t2, gboolean signature_only);
827
828 MonoMarshalSpec *
829 mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image, const char *ptr);
830
831 guint          mono_metadata_generic_inst_hash (gconstpointer data);
832 gboolean       mono_metadata_generic_inst_equal (gconstpointer ka, gconstpointer kb);
833
834 MONO_API void
835 mono_metadata_field_info_with_mempool (
836                                           MonoImage *meta, 
837                                       guint32       table_index,
838                                       guint32      *offset,
839                                       guint32      *rva,
840                                       MonoMarshalSpec **marshal_spec);
841
842 MonoClassField*
843 mono_metadata_get_corresponding_field_from_generic_type_definition (MonoClassField *field);
844
845 MonoEvent*
846 mono_metadata_get_corresponding_event_from_generic_type_definition (MonoEvent *event);
847
848 MonoProperty*
849 mono_metadata_get_corresponding_property_from_generic_type_definition (MonoProperty *property);
850
851 guint32
852 mono_metadata_signature_size (MonoMethodSignature *sig);
853
854 guint mono_metadata_str_hash (gconstpointer v1);
855
856 gboolean mono_image_load_pe_data (MonoImage *image);
857
858 gboolean mono_image_load_cli_data (MonoImage *image);
859
860 void mono_image_load_names (MonoImage *image);
861
862 MonoImage *mono_image_open_raw (const char *fname, MonoImageOpenStatus *status);
863
864 MonoImage *mono_image_open_metadata_only (const char *fname, MonoImageOpenStatus *status);
865
866 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);
867
868 MonoException *mono_get_exception_field_access_msg (const char *msg);
869
870 MonoException *mono_get_exception_method_access_msg (const char *msg);
871
872 MonoMethod* method_from_method_def_or_ref (MonoImage *m, guint32 tok, MonoGenericContext *context, MonoError *error);
873
874 MonoMethod *mono_get_method_constrained_with_method (MonoImage *image, MonoMethod *method, MonoClass *constrained_class, MonoGenericContext *context, MonoError *error);
875 MonoMethod *mono_get_method_constrained_checked (MonoImage *image, guint32 token, MonoClass *constrained_class, MonoGenericContext *context, MonoMethod **cil_method, MonoError *error);
876
877 void mono_type_set_alignment (MonoTypeEnum type, int align);
878
879 MonoAotCacheConfig *mono_get_aot_cache_config (void);
880 MonoType *
881 mono_type_create_from_typespec_checked (MonoImage *image, guint32 type_spec, MonoError *error);
882
883 MonoMethodSignature*
884 mono_method_get_signature_checked (MonoMethod *method, MonoImage *image, guint32 token, MonoGenericContext *context, MonoError *error);
885         
886 MonoMethod *
887 mono_get_method_checked (MonoImage *image, guint32 token, MonoClass *klass, MonoGenericContext *context, MonoError *error);
888
889 guint32
890 mono_metadata_localscope_from_methoddef (MonoImage *meta, guint32 index);
891
892 void
893 mono_wrapper_caches_free (MonoWrapperCaches *cache);
894
895 MonoWrapperCaches*
896 mono_method_get_wrapper_cache (MonoMethod *method);
897
898 MonoWrapperCaches*
899 mono_method_get_wrapper_cache (MonoMethod *method);
900
901 MonoType*
902 mono_metadata_parse_type_checked (MonoImage *m, MonoGenericContainer *container, short opt_attrs, gboolean transient, const char *ptr, const char **rptr, MonoError *error);
903
904 MonoGenericContainer *
905 get_anonymous_container_for_image (MonoImage *image, gboolean is_mvar);
906
907 char *
908 mono_image_set_description (MonoImageSet *);
909
910 MonoImageSet *
911 mono_find_image_set_owner (void *ptr);
912
913 #endif /* __MONO_METADATA_INTERNALS_H__ */
914