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