Merge pull request #4169 from evincarofautumn/fix-xmm-scanning-mac-x86
[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          * This count is incremented during these situations:
179          *   - An assembly references this MonoImage though its 'image' field
180          *   - This MonoImage is present in the 'files' field of an image
181          *   - This MonoImage is present in the 'modules' field of an image
182          *   - A thread is holding a temporary reference to this MonoImage between
183          *     calls to mono_image_open and mono_image_close ()
184          */
185         int   ref_count;
186
187         /* If the raw data was allocated from a source such as mmap, the allocator may store resource tracking information here. */
188         void *raw_data_handle;
189         char *raw_data;
190         guint32 raw_data_len;
191         guint8 raw_buffer_used    : 1;
192         guint8 raw_data_allocated : 1;
193         guint8 fileio_used : 1;
194
195 #ifdef HOST_WIN32
196         /* Module was loaded using LoadLibrary. */
197         guint8 is_module_handle : 1;
198
199         /* Module entry point is _CorDllMain. */
200         guint8 has_entry_point : 1;
201 #endif
202
203         /* Whenever this is a dynamically emitted module */
204         guint8 dynamic : 1;
205
206         /* Whenever this is a reflection only image */
207         guint8 ref_only : 1;
208
209         /* Whenever this image contains uncompressed metadata */
210         guint8 uncompressed_metadata : 1;
211
212         /* Whenever this image contains metadata only without PE data */
213         guint8 metadata_only : 1;
214
215         guint8 checked_module_cctor : 1;
216         guint8 has_module_cctor : 1;
217
218         guint8 idx_string_wide : 1;
219         guint8 idx_guid_wide : 1;
220         guint8 idx_blob_wide : 1;
221
222         /* Whenever this image is considered as platform code for the CoreCLR security model */
223         guint8 core_clr_platform_code : 1;
224
225         /* The path to the file for this image. */
226         char *name;
227
228         /* The assembly name reported in the file for this image (expected to be NULL for a netmodule) */
229         const char *assembly_name;
230
231         /* The module name reported in the file for this image (could be NULL for a malformed file) */
232         const char *module_name;
233
234         char *version;
235         gint16 md_version_major, md_version_minor;
236         char *guid;
237         void *image_info;
238         MonoMemPool         *mempool; /*protected by the image lock*/
239
240         char                *raw_metadata;
241                             
242         MonoStreamHeader     heap_strings;
243         MonoStreamHeader     heap_us;
244         MonoStreamHeader     heap_blob;
245         MonoStreamHeader     heap_guid;
246         MonoStreamHeader     heap_tables;
247         MonoStreamHeader     heap_pdb;
248                             
249         const char          *tables_base;
250
251         /* For PPDB files */
252         guint64 referenced_tables;
253         int *referenced_table_rows;
254
255         /**/
256         MonoTableInfo        tables [MONO_TABLE_NUM];
257
258         /*
259          * references is initialized only by using the mono_assembly_open
260          * function, and not by using the lowlevel mono_image_open.
261          *
262          * It is NULL terminated.
263          */
264         MonoAssembly **references;
265         int nreferences;
266
267         /* Code files in the assembly. The main assembly has a "file" table and also a "module"
268          * table, where the module table is a subset of the file table. We track both lists,
269          * and because we can lazy-load them at different times we reference-increment both.
270          */
271         MonoImage **modules;
272         guint32 module_count;
273         gboolean *modules_loaded;
274
275         MonoImage **files;
276         guint32 file_count;
277
278         gpointer aot_module;
279
280         guint8 aotid[16];
281
282         /*
283          * The Assembly this image was loaded from.
284          */
285         MonoAssembly *assembly;
286
287         /*
288          * Indexed by method tokens and typedef tokens.
289          */
290         GHashTable *method_cache; /*protected by the image lock*/
291         MonoInternalHashTable class_cache;
292
293         /* Indexed by memberref + methodspec tokens */
294         GHashTable *methodref_cache; /*protected by the image lock*/
295
296         /*
297          * Indexed by fielddef and memberref tokens
298          */
299         MonoConcurrentHashTable *field_cache; /*protected by the image lock*/
300
301         /* indexed by typespec tokens. */
302         GHashTable *typespec_cache; /* protected by the image lock */
303         /* indexed by token */
304         GHashTable *memberref_signatures;
305         GHashTable *helper_signatures;
306
307         /* Indexed by blob heap indexes */
308         GHashTable *method_signatures;
309
310         /*
311          * Indexes namespaces to hash tables that map class name to typedef token.
312          */
313         GHashTable *name_cache;  /*protected by the image lock*/
314
315         /*
316          * Indexed by MonoClass
317          */
318         GHashTable *array_cache;
319         GHashTable *ptr_cache;
320
321         GHashTable *szarray_cache;
322         /* This has a separate lock to improve scalability */
323         mono_mutex_t szarray_cache_lock;
324
325         /*
326          * indexed by SignaturePointerPair
327          */
328         GHashTable *delegate_bound_static_invoke_cache;
329         GHashTable *native_func_wrapper_cache;
330
331         /*
332          * indexed by MonoMethod pointers 
333          */
334         GHashTable *runtime_invoke_vcall_cache;
335         GHashTable *wrapper_param_names;
336         GHashTable *array_accessor_cache;
337
338         /*
339          * indexed by MonoClass pointers
340          */
341         GHashTable *ldfld_wrapper_cache;
342         GHashTable *ldflda_wrapper_cache;
343         GHashTable *stfld_wrapper_cache;
344         GHashTable *isinst_cache;
345
346         GHashTable *icall_wrapper_cache;
347         GHashTable *castclass_cache;
348         GHashTable *proxy_isinst_cache;
349         GHashTable *rgctx_template_hash; /* LOCKING: templates lock */
350
351         /* Contains rarely used fields of runtime structures belonging to this image */
352         MonoPropertyHash *property_hash;
353
354         void *reflection_info;
355
356         /*
357          * user_info is a public field and is not touched by the
358          * metadata engine
359          */
360         void *user_info;
361
362         /* dll map entries */
363         MonoDllMap *dll_map;
364
365         /* interfaces IDs from this image */
366         /* protected by the classes lock */
367         MonoBitSet *interface_bitset;
368
369         /* when the image is being closed, this is abused as a list of
370            malloc'ed regions to be freed. */
371         GSList *reflection_info_unregister_classes;
372
373         /* List of dependent image sets containing this image */
374         /* Protected by image_sets_lock */
375         GSList *image_sets;
376
377         /* Caches for wrappers that DO NOT reference generic */
378         /* arguments */
379         MonoWrapperCaches wrapper_caches;
380
381         /* Caches for MonoClass-es representing anon generic params */
382         MonoClass **var_cache_fast;
383         MonoClass **mvar_cache_fast;
384         GHashTable *var_cache_slow;
385         GHashTable *mvar_cache_slow;
386         GHashTable *var_cache_constrained;
387         GHashTable *mvar_cache_constrained;
388
389         /* Maps malloc-ed char* pinvoke scope -> MonoDl* */
390         GHashTable *pinvoke_scopes;
391
392         /* Maps malloc-ed char* pinvoke scope -> malloced-ed char* filename */
393         GHashTable *pinvoke_scope_filenames;
394
395         /* Indexed by MonoGenericParam pointers */
396         GHashTable **gshared_types;
397         /* The length of the above array */
398         int gshared_types_len;
399
400         /* The loader used to load this image */
401         MonoImageLoader *loader;
402
403         // Containers for MonoGenericParams associated with this image but not with any specific class or method. Created on demand.
404         // This could happen, for example, for MonoTypes associated with TypeSpec table entries.
405         MonoGenericContainer *anonymous_generic_class_container;
406         MonoGenericContainer *anonymous_generic_method_container;
407
408         /*
409          * No other runtime locks must be taken while holding this lock.
410          * It's meant to be used only to mutate and query structures part of this image.
411          */
412         mono_mutex_t    lock;
413 };
414
415 /*
416  * Generic instances depend on many images, and they need to be deleted if one
417  * of the images they depend on is unloaded. For example,
418  * List<Foo> depends on both List's image and Foo's image.
419  * A MonoImageSet is the owner of all generic instances depending on the same set of
420  * images.
421  */
422 typedef struct {
423         int nimages;
424         MonoImage **images;
425
426         // Generic-specific caches
427         GHashTable *gclass_cache, *ginst_cache, *gmethod_cache, *gsignature_cache;
428
429         MonoWrapperCaches wrapper_caches;
430
431         mono_mutex_t    lock;
432
433         /*
434          * Memory for generic instances owned by this image set should be allocated from
435          * this mempool, using the mono_image_set_alloc family of functions.
436          */
437         MonoMemPool         *mempool;
438 } MonoImageSet;
439
440 enum {
441         MONO_SECTION_TEXT,
442         MONO_SECTION_RSRC,
443         MONO_SECTION_RELOC,
444         MONO_SECTION_MAX
445 };
446
447 typedef struct {
448         GHashTable *hash;
449         char *data;
450         guint32 alloc_size; /* malloced bytes */
451         guint32 index;
452         guint32 offset; /* from start of metadata */
453 } MonoDynamicStream;
454
455 typedef struct {
456         guint32 alloc_rows;
457         guint32 rows;
458         guint8  row_size; /*  calculated later with column_sizes */
459         guint8  columns;
460         guint32 next_idx;
461         guint32 *values; /* rows * columns */
462 } MonoDynamicTable;
463
464 /* "Dynamic" assemblies and images arise from System.Reflection.Emit */
465 struct _MonoDynamicAssembly {
466         MonoAssembly assembly;
467         char *strong_name;
468         guint32 strong_name_size;
469         guint8 run;
470         guint8 save;
471         MonoDomain *domain;
472 };
473
474 struct _MonoDynamicImage {
475         MonoImage image;
476         guint32 meta_size;
477         guint32 text_rva;
478         guint32 metadata_rva;
479         guint32 image_base;
480         guint32 cli_header_offset;
481         guint32 iat_offset;
482         guint32 idt_offset;
483         guint32 ilt_offset;
484         guint32 imp_names_offset;
485         struct {
486                 guint32 rva;
487                 guint32 size;
488                 guint32 offset;
489                 guint32 attrs;
490         } sections [MONO_SECTION_MAX];
491         GHashTable *typespec;
492         GHashTable *typeref;
493         GHashTable *handleref;
494         MonoGHashTable *handleref_managed;
495         MonoGHashTable *tokens;
496         GHashTable *blob_cache;
497         GHashTable *standalonesig_cache;
498         GList *array_methods;
499         GPtrArray *gen_params;
500         MonoGHashTable *token_fixups;
501         GHashTable *method_to_table_idx;
502         GHashTable *field_to_table_idx;
503         GHashTable *method_aux_hash;
504         GHashTable *vararg_aux_hash;
505         MonoGHashTable *generic_def_objects;
506         /*
507          * Maps final token values to the object they describe.
508          */
509         MonoGHashTable *remapped_tokens;
510         gboolean run;
511         gboolean save;
512         gboolean initial_image;
513         guint32 pe_kind, machine;
514         char *strong_name;
515         guint32 strong_name_size;
516         char *win32_res;
517         guint32 win32_res_size;
518         guint8 *public_key;
519         int public_key_len;
520         MonoDynamicStream sheap;
521         MonoDynamicStream code; /* used to store method headers and bytecode */
522         MonoDynamicStream resources; /* managed embedded resources */
523         MonoDynamicStream us;
524         MonoDynamicStream blob;
525         MonoDynamicStream tstream;
526         MonoDynamicStream guid;
527         MonoDynamicTable tables [MONO_TABLE_NUM];
528         MonoClass *wrappers_type; /*wrappers are bound to this type instead of <Module>*/
529 };
530
531 /* Contains information about assembly binding */
532 typedef struct _MonoAssemblyBindingInfo {
533         char *name;
534         char *culture;
535         guchar public_key_token [MONO_PUBLIC_KEY_TOKEN_LENGTH];
536         int major;
537         int minor;
538         AssemblyVersionSet old_version_bottom;
539         AssemblyVersionSet old_version_top;
540         AssemblyVersionSet new_version;
541         guint has_old_version_bottom : 1;
542         guint has_old_version_top : 1;
543         guint has_new_version : 1;
544         guint is_valid : 1;
545         gint32 domain_id; /*Needed to unload per-domain binding*/
546 } MonoAssemblyBindingInfo;
547
548 struct _MonoMethodHeader {
549         const unsigned char  *code;
550 #ifdef MONO_SMALL_CONFIG
551         guint16      code_size;
552 #else
553         guint32      code_size;
554 #endif
555         guint16      max_stack   : 15;
556         unsigned int is_transient: 1; /* mono_metadata_free_mh () will actually free this header */
557         unsigned int num_clauses : 15;
558         /* if num_locals != 0, then the following apply: */
559         unsigned int init_locals : 1;
560         guint16      num_locals;
561         MonoExceptionClause *clauses;
562         MonoType    *locals [MONO_ZERO_LEN_ARRAY];
563 };
564
565 typedef struct {
566         guint32      code_size;
567         gboolean     has_clauses;
568 } MonoMethodHeaderSummary;
569
570 #define MONO_SIZEOF_METHOD_HEADER (sizeof (struct _MonoMethodHeader) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
571
572 struct _MonoMethodSignature {
573         MonoType     *ret;
574 #ifdef MONO_SMALL_CONFIG
575         guint8        param_count;
576         gint8         sentinelpos;
577         unsigned int  generic_param_count : 5;
578 #else
579         guint16       param_count;
580         gint16        sentinelpos;
581         unsigned int  generic_param_count : 16;
582 #endif
583         unsigned int  call_convention     : 6;
584         unsigned int  hasthis             : 1;
585         unsigned int  explicit_this       : 1;
586         unsigned int  pinvoke             : 1;
587         unsigned int  is_inflated         : 1;
588         unsigned int  has_type_parameters : 1;
589         MonoType     *params [MONO_ZERO_LEN_ARRAY];
590 };
591
592 /*
593  * AOT cache configuration loaded from config files.
594  * Doesn't really belong here.
595  */
596 typedef struct {
597         /*
598          * Enable aot caching for applications whose main assemblies are in
599          * this list.
600          */
601         GSList *apps;
602         GSList *assemblies;
603         char *aot_options;
604 } MonoAotCacheConfig;
605
606 #define MONO_SIZEOF_METHOD_SIGNATURE (sizeof (struct _MonoMethodSignature) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
607
608 static inline gboolean
609 image_is_dynamic (MonoImage *image)
610 {
611 #ifdef DISABLE_REFLECTION_EMIT
612         return FALSE;
613 #else
614         return image->dynamic;
615 #endif
616 }
617
618 static inline gboolean
619 assembly_is_dynamic (MonoAssembly *assembly)
620 {
621 #ifdef DISABLE_REFLECTION_EMIT
622         return FALSE;
623 #else
624         return assembly->dynamic;
625 #endif
626 }
627
628 /* for use with allocated memory blocks (assumes alignment is to 8 bytes) */
629 guint mono_aligned_addr_hash (gconstpointer ptr);
630
631 void
632 mono_image_check_for_module_cctor (MonoImage *image);
633
634 gpointer
635 mono_image_alloc  (MonoImage *image, guint size);
636
637 gpointer
638 mono_image_alloc0 (MonoImage *image, guint size);
639
640 #define mono_image_new0(image,type,size) ((type *) mono_image_alloc0 (image, sizeof (type)* (size)))
641
642 char*
643 mono_image_strdup (MonoImage *image, const char *s);
644
645 char*
646 mono_image_strdup_vprintf (MonoImage *image, const char *format, va_list args);
647
648 char*
649 mono_image_strdup_printf (MonoImage *image, const char *format, ...) MONO_ATTR_FORMAT_PRINTF(2,3);;
650
651 GList*
652 g_list_prepend_image (MonoImage *image, GList *list, gpointer data);
653
654 GSList*
655 g_slist_append_image (MonoImage *image, GSList *list, gpointer data);
656
657 void
658 mono_image_lock (MonoImage *image);
659
660 void
661 mono_image_unlock (MonoImage *image);
662
663 gpointer
664 mono_image_property_lookup (MonoImage *image, gpointer subject, guint32 property);
665
666 void
667 mono_image_property_insert (MonoImage *image, gpointer subject, guint32 property, gpointer value);
668
669 void
670 mono_image_property_remove (MonoImage *image, gpointer subject);
671
672 gboolean
673 mono_image_close_except_pools (MonoImage *image);
674
675 void
676 mono_image_close_finish (MonoImage *image);
677
678 typedef void  (*MonoImageUnloadFunc) (MonoImage *image, gpointer user_data);
679
680 void
681 mono_install_image_unload_hook (MonoImageUnloadFunc func, gpointer user_data);
682
683 void
684 mono_remove_image_unload_hook (MonoImageUnloadFunc func, gpointer user_data);
685
686 void
687 mono_install_image_loader (const MonoImageLoader *loader);
688
689 void
690 mono_image_append_class_to_reflection_info_set (MonoClass *klass);
691
692 gpointer
693 mono_image_set_alloc  (MonoImageSet *set, guint size);
694
695 gpointer
696 mono_image_set_alloc0 (MonoImageSet *set, guint size);
697
698 void
699 mono_image_set_lock (MonoImageSet *set);
700
701 void
702 mono_image_set_unlock (MonoImageSet *set);
703
704 char*
705 mono_image_set_strdup (MonoImageSet *set, const char *s);
706
707 #define mono_image_set_new0(image,type,size) ((type *) mono_image_set_alloc0 (image, sizeof (type)* (size)))
708
709 gboolean
710 mono_image_load_cli_header (MonoImage *image, MonoCLIImageInfo *iinfo);
711
712 gboolean
713 mono_image_load_metadata (MonoImage *image, MonoCLIImageInfo *iinfo);
714
715 MonoType*
716 mono_metadata_get_shared_type (MonoType *type);
717
718 void
719 mono_metadata_clean_for_image (MonoImage *image);
720
721 void
722 mono_metadata_clean_generic_classes_for_image (MonoImage *image);
723
724 MONO_API void
725 mono_metadata_cleanup (void);
726
727 const char *   mono_meta_table_name              (int table);
728 void           mono_metadata_compute_table_bases (MonoImage *meta);
729
730 gboolean
731 mono_metadata_interfaces_from_typedef_full  (MonoImage             *image,
732                                                                                          guint32                table_index,
733                                                                                          MonoClass           ***interfaces,
734                                                                                          guint                 *count,
735                                                                                          gboolean               heap_alloc_result,
736                                                                                          MonoGenericContext    *context,
737                                                                                          MonoError *error);
738
739 MONO_API MonoMethodSignature *
740 mono_metadata_parse_method_signature_full   (MonoImage             *image,
741                                              MonoGenericContainer  *generic_container,
742                                              int                     def,
743                                              const char             *ptr,
744                                              const char            **rptr,
745                                              MonoError *error);
746
747 MONO_API MonoMethodHeader *
748 mono_metadata_parse_mh_full                 (MonoImage             *image,
749                                              MonoGenericContainer  *container,
750                                              const char            *ptr,
751                                                  MonoError *error);
752
753 MonoMethodSignature  *mono_metadata_parse_signature_checked (MonoImage *image, 
754                                                              uint32_t    token,
755                                                              MonoError *error);
756
757 gboolean
758 mono_method_get_header_summary (MonoMethod *method, MonoMethodHeaderSummary *summary);
759
760 int* mono_metadata_get_param_attrs          (MonoImage *m, int def, int param_count);
761 gboolean mono_metadata_method_has_param_attrs (MonoImage *m, int def);
762
763 guint
764 mono_metadata_generic_context_hash          (const MonoGenericContext *context);
765
766 gboolean
767 mono_metadata_generic_context_equal         (const MonoGenericContext *g1,
768                                              const MonoGenericContext *g2);
769
770 MonoGenericInst *
771 mono_metadata_parse_generic_inst            (MonoImage             *image,
772                                              MonoGenericContainer  *container,
773                                              int                    count,
774                                              const char            *ptr,
775                                              const char           **rptr,
776                                                  MonoError *error);
777
778 MonoGenericInst *
779 mono_metadata_get_generic_inst              (int                    type_argc,
780                                              MonoType             **type_argv);
781
782 MonoGenericInst *
783 mono_metadata_get_canonical_generic_inst    (MonoGenericInst *candidate);
784
785 MonoGenericClass *
786 mono_metadata_lookup_generic_class          (MonoClass             *gclass,
787                                              MonoGenericInst       *inst,
788                                              gboolean               is_dynamic);
789
790 MonoGenericInst * mono_metadata_inflate_generic_inst  (MonoGenericInst *ginst, MonoGenericContext *context, MonoError *error);
791
792 guint
793 mono_metadata_generic_param_hash (MonoGenericParam *p);
794
795 gboolean
796 mono_metadata_generic_param_equal (MonoGenericParam *p1, MonoGenericParam *p2);
797
798 void mono_dynamic_stream_reset  (MonoDynamicStream* stream);
799 MONO_API void mono_assembly_addref       (MonoAssembly *assembly);
800 void mono_assembly_load_friends (MonoAssembly* ass);
801 gboolean mono_assembly_has_skip_verification (MonoAssembly* ass);
802
803 void mono_assembly_release_gc_roots (MonoAssembly *assembly);
804 gboolean mono_assembly_close_except_image_pools (MonoAssembly *assembly);
805 void mono_assembly_close_finish (MonoAssembly *assembly);
806
807
808 gboolean mono_public_tokens_are_equal (const unsigned char *pubt1, const unsigned char *pubt2);
809
810 void mono_config_parse_publisher_policy (const char *filename, MonoAssemblyBindingInfo *binding_info);
811 void mono_config_parse_assembly_bindings (const char *filename, int major, int minor, void *user_data,
812                                           void (*infocb)(MonoAssemblyBindingInfo *info, void *user_data));
813
814 gboolean
815 mono_assembly_name_parse_full                (const char           *name,
816                                               MonoAssemblyName     *aname,
817                                               gboolean save_public_key,
818                                               gboolean *is_version_defined,
819                                                   gboolean *is_token_defined);
820
821 gboolean
822 mono_assembly_fill_assembly_name_full (MonoImage *image, MonoAssemblyName *aname, gboolean copyBlobs);
823
824
825 MONO_API guint32 mono_metadata_get_generic_param_row (MonoImage *image, guint32 token, guint32 *owner);
826
827 void mono_unload_interface_ids (MonoBitSet *bitset);
828
829
830 MonoType *mono_metadata_type_dup (MonoImage *image, const MonoType *original);
831 MonoMethodSignature  *mono_metadata_signature_dup_full (MonoImage *image,MonoMethodSignature *sig);
832 MonoMethodSignature  *mono_metadata_signature_dup_mempool (MonoMemPool *mp, MonoMethodSignature *sig);
833 MonoMethodSignature  *mono_metadata_signature_dup_add_this (MonoImage *image, MonoMethodSignature *sig, MonoClass *klass);
834
835 MonoGenericInst *
836 mono_get_shared_generic_inst (MonoGenericContainer *container);
837
838 int
839 mono_type_stack_size_internal (MonoType *t, int *align, gboolean allow_open);
840
841 MONO_API void            mono_type_get_desc (GString *res, MonoType *type, mono_bool include_namespace);
842
843 gboolean
844 mono_metadata_type_equal_full (MonoType *t1, MonoType *t2, gboolean signature_only);
845
846 MonoMarshalSpec *
847 mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image, const char *ptr);
848
849 guint          mono_metadata_generic_inst_hash (gconstpointer data);
850 gboolean       mono_metadata_generic_inst_equal (gconstpointer ka, gconstpointer kb);
851
852 MONO_API void
853 mono_metadata_field_info_with_mempool (
854                                           MonoImage *meta, 
855                                       guint32       table_index,
856                                       guint32      *offset,
857                                       guint32      *rva,
858                                       MonoMarshalSpec **marshal_spec);
859
860 MonoClassField*
861 mono_metadata_get_corresponding_field_from_generic_type_definition (MonoClassField *field);
862
863 MonoEvent*
864 mono_metadata_get_corresponding_event_from_generic_type_definition (MonoEvent *event);
865
866 MonoProperty*
867 mono_metadata_get_corresponding_property_from_generic_type_definition (MonoProperty *property);
868
869 guint32
870 mono_metadata_signature_size (MonoMethodSignature *sig);
871
872 guint mono_metadata_str_hash (gconstpointer v1);
873
874 gboolean mono_image_load_pe_data (MonoImage *image);
875
876 gboolean mono_image_load_cli_data (MonoImage *image);
877
878 void mono_image_load_names (MonoImage *image);
879
880 MonoImage *mono_image_open_raw (const char *fname, MonoImageOpenStatus *status);
881
882 MonoImage *mono_image_open_metadata_only (const char *fname, MonoImageOpenStatus *status);
883
884 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);
885
886 MonoException *mono_get_exception_field_access_msg (const char *msg);
887
888 MonoException *mono_get_exception_method_access_msg (const char *msg);
889
890 MonoMethod* method_from_method_def_or_ref (MonoImage *m, guint32 tok, MonoGenericContext *context, MonoError *error);
891
892 MonoMethod *mono_get_method_constrained_with_method (MonoImage *image, MonoMethod *method, MonoClass *constrained_class, MonoGenericContext *context, MonoError *error);
893 MonoMethod *mono_get_method_constrained_checked (MonoImage *image, guint32 token, MonoClass *constrained_class, MonoGenericContext *context, MonoMethod **cil_method, MonoError *error);
894
895 void mono_type_set_alignment (MonoTypeEnum type, int align);
896
897 MonoAotCacheConfig *mono_get_aot_cache_config (void);
898 MonoType *
899 mono_type_create_from_typespec_checked (MonoImage *image, guint32 type_spec, MonoError *error);
900
901 MonoMethodSignature*
902 mono_method_get_signature_checked (MonoMethod *method, MonoImage *image, guint32 token, MonoGenericContext *context, MonoError *error);
903         
904 MonoMethod *
905 mono_get_method_checked (MonoImage *image, guint32 token, MonoClass *klass, MonoGenericContext *context, MonoError *error);
906
907 guint32
908 mono_metadata_localscope_from_methoddef (MonoImage *meta, guint32 index);
909
910 void
911 mono_wrapper_caches_free (MonoWrapperCaches *cache);
912
913 MonoWrapperCaches*
914 mono_method_get_wrapper_cache (MonoMethod *method);
915
916 MonoWrapperCaches*
917 mono_method_get_wrapper_cache (MonoMethod *method);
918
919 MonoType*
920 mono_metadata_parse_type_checked (MonoImage *m, MonoGenericContainer *container, short opt_attrs, gboolean transient, const char *ptr, const char **rptr, MonoError *error);
921
922 MonoGenericContainer *
923 get_anonymous_container_for_image (MonoImage *image, gboolean is_mvar);
924
925 char *
926 mono_image_set_description (MonoImageSet *);
927
928 MonoImageSet *
929 mono_find_image_set_owner (void *ptr);
930
931 void
932 mono_loader_register_module (const char *name, MonoDl *module);
933
934 #endif /* __MONO_METADATA_INTERNALS_H__ */
935