3 * Copyright 2012 Xamarin Inc
4 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
6 #ifndef __MONO_METADATA_CLASS_INTERNALS_H__
7 #define __MONO_METADATA_CLASS_INTERNALS_H__
9 #include <mono/metadata/class.h>
10 #include <mono/metadata/object.h>
11 #include <mono/metadata/mempool.h>
12 #include <mono/metadata/metadata-internals.h>
13 #include <mono/metadata/property-bag.h>
14 #include "mono/utils/mono-compiler.h"
15 #include "mono/utils/mono-error.h"
16 #include "mono/sgen/gc-internal-agnostic.h"
17 #include "mono/utils/mono-error-internals.h"
18 #include "mono/utils/mono-memory-model.h"
20 #define MONO_CLASS_IS_ARRAY(c) (m_class_get_rank (c))
22 #define MONO_CLASS_HAS_STATIC_METADATA(klass) (m_class_get_type_token (klass) && !m_class_get_image (klass)->dynamic && !mono_class_is_ginst (klass))
24 #define MONO_DEFAULT_SUPERTABLE_SIZE 6
26 extern gboolean mono_print_vtable
;
27 extern gboolean mono_align_small_structs
;
28 extern gint32 mono_simd_register_size
;
30 typedef struct _MonoMethodWrapper MonoMethodWrapper
;
31 typedef struct _MonoMethodInflated MonoMethodInflated
;
32 typedef struct _MonoMethodPInvoke MonoMethodPInvoke
;
33 typedef struct _MonoDynamicMethod MonoDynamicMethod
;
35 /* Properties that applies to a group of structs should better use a higher number
36 * to avoid colision with type specific properties.
38 * This prop applies to class, method, property, event, assembly and image.
40 #define MONO_PROP_DYNAMIC_CATTR 0x1000
43 #define WRAPPER(e,n) MONO_WRAPPER_ ## e,
44 #include "wrapper-types.h"
50 MONO_REMOTING_TARGET_UNKNOWN
,
51 MONO_REMOTING_TARGET_APPDOMAIN
,
52 MONO_REMOTING_TARGET_COMINTEROP
55 #define MONO_METHOD_PROP_GENERIC_CONTAINER 0
56 /* verification success bit, protected by the image lock */
57 #define MONO_METHOD_PROP_VERIFICATION_SUCCESS 1
58 /* infrequent vtable layout bits protected by the loader lock */
59 #define MONO_METHOD_PROP_INFREQUENT_BITS 2
61 /* Infrequently accessed bits of method definitions stored in the image properties.
62 * The method must not be inflated.
64 * LOCKING: Reading the bits acquires the image lock. Writing the bits assumes
65 * the loader lock is held.
67 typedef struct _MonoMethodDefInfrequentBits
{
68 unsigned int is_reabstracted
:1; /* whenever this is a reabstraction of another interface */
69 unsigned int is_covariant_override_impl
:1; /* whether this is an override with a signature different from its declared method */
70 } MonoMethodDefInfrequentBits
;
73 guint16 flags
; /* method flags */
74 guint16 iflags
; /* method implementation flags */
76 MonoClass
*klass
; /* To what class does this method belong */
77 MonoMethodSignature
*signature
;
78 /* name is useful mostly for debugging */
80 /* this is used by the inlining algorithm */
81 unsigned int inline_info
:1;
82 unsigned int inline_failure
:1;
83 unsigned int wrapper_type
:5;
84 unsigned int string_ctor
:1;
85 unsigned int save_lmf
:1;
86 unsigned int dynamic
:1; /* created & destroyed during runtime */
87 unsigned int sre_method
:1; /* created at runtime using Reflection.Emit */
88 unsigned int is_generic
:1; /* whenever this is a generic method definition */
89 unsigned int is_inflated
:1; /* whether we're a MonoMethodInflated */
90 unsigned int skip_visibility
:1; /* whenever to skip JIT visibility checks */
91 unsigned int _unused
: 2; /* unused */
95 * If is_generic is TRUE, the generic_container is stored in image->property_hash,
96 * using the key MONO_METHOD_PROP_GENERIC_CONTAINER.
100 struct _MonoMethodWrapper
{
102 MonoMethodHeader
*header
;
106 struct _MonoDynamicMethod
{
107 MonoMethodWrapper method
;
108 MonoAssembly
*assembly
;
111 struct _MonoMethodPInvoke
{
114 /* add marshal info */
115 guint16 piflags
; /* pinvoke flags */
116 guint32 implmap_idx
; /* index into IMPLMAP */
120 * Stores the default value / RVA of fields.
121 * This information is rarely needed, so it is stored separately from
124 typedef struct MonoFieldDefaultValue
{
126 * If the field is constant, pointer to the metadata constant
128 * If the field has an RVA flag, pointer to the data.
133 /* If the field is constant, the type of the constant. */
134 MonoTypeEnum def_type
;
135 } MonoFieldDefaultValue
;
138 * MonoClassField is just a runtime representation of the metadata for
139 * field, it doesn't contain the data directly. Static fields are
140 * stored in MonoVTable->data. Instance fields are allocated in the
141 * objects after the object header.
143 struct _MonoClassField
{
144 /* Type of the field */
149 /* Type where the field was defined */
153 * Offset where this field is stored; if it is an instance
154 * field, it's the offset from the start of the object, if
155 * it's static, it's from the start of the memory chunk
156 * allocated for statics for the class.
157 * For special static fields, this is set to -1 during vtable construction.
162 /* a field is ignored if it's named "_Deleted" and it has the specialname and rtspecialname flags set */
163 #define mono_field_is_deleted(field) (((field)->type->attrs & (FIELD_ATTRIBUTE_SPECIAL_NAME | FIELD_ATTRIBUTE_RT_SPECIAL_NAME)) \
164 && (strcmp (mono_field_get_name (field), "_Deleted") == 0))
166 /* a field is ignored if it's named "_Deleted" and it has the specialname and rtspecialname flags set */
167 /* Try to avoid loading the field's type */
168 #define mono_field_is_deleted_with_flags(field, flags) (((flags) & (FIELD_ATTRIBUTE_SPECIAL_NAME | FIELD_ATTRIBUTE_RT_SPECIAL_NAME)) \
169 && (strcmp (mono_field_get_name (field), "_Deleted") == 0))
172 MonoClassField
*field
;
174 MonoMarshalSpec
*mspec
;
178 MonoPropertyBagItem head
;
180 guint32 native_size
, min_align
;
182 MonoMethod
*ptr_to_str
;
183 MonoMethod
*str_to_ptr
;
184 MonoMarshalField fields
[MONO_ZERO_LEN_ARRAY
];
187 #define MONO_SIZEOF_MARSHAL_TYPE (offsetof (MonoMarshalType, fields))
189 struct _MonoProperty
{
203 #ifndef MONO_SMALL_CONFIG
209 /* type of exception being "on hold" for later processing (see exception_type) */
211 MONO_EXCEPTION_NONE
= 0,
212 MONO_EXCEPTION_INVALID_PROGRAM
= 3,
213 MONO_EXCEPTION_UNVERIFIABLE_IL
= 4,
214 MONO_EXCEPTION_MISSING_METHOD
= 5,
215 MONO_EXCEPTION_MISSING_FIELD
= 6,
216 MONO_EXCEPTION_TYPE_LOAD
= 7,
217 MONO_EXCEPTION_FILE_NOT_FOUND
= 8,
218 MONO_EXCEPTION_METHOD_ACCESS
= 9,
219 MONO_EXCEPTION_FIELD_ACCESS
= 10,
220 MONO_EXCEPTION_GENERIC_SHARING_FAILED
= 11,
221 MONO_EXCEPTION_BAD_IMAGE
= 12,
222 MONO_EXCEPTION_OBJECT_SUPPLIED
= 13, /*The exception object is already created.*/
223 MONO_EXCEPTION_OUT_OF_MEMORY
= 14,
224 MONO_EXCEPTION_INLINE_FAILED
= 15,
225 MONO_EXCEPTION_MONO_ERROR
= 16,
226 /* add other exception type */
229 /* This struct collects the info needed for the runtime use of a class,
230 * like the vtables for a domain, the GC descriptor, etc.
234 /* domain_vtables is indexed by the domain id and the size is max_domain + 1 */
235 MonoVTable
*domain_vtables
[MONO_ZERO_LEN_ARRAY
];
236 } MonoClassRuntimeInfo
;
238 #define MONO_SIZEOF_CLASS_RUNTIME_INFO (sizeof (MonoClassRuntimeInfo) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
241 MonoPropertyBagItem head
;
243 MonoProperty
*properties
;
244 guint32 first
, count
;
245 MonoFieldDefaultValue
*def_values
;
246 } MonoClassPropertyInfo
;
249 MonoPropertyBagItem head
;
251 /* Initialized by a call to mono_class_setup_events () */
253 guint32 first
, count
;
254 } MonoClassEventInfo
;
257 MONO_CLASS_DEF
= 1, /* non-generic type */
258 MONO_CLASS_GTD
, /* generic type definition */
259 MONO_CLASS_GINST
, /* generic instantiation */
260 MONO_CLASS_GPARAM
, /* generic parameter */
261 MONO_CLASS_ARRAY
, /* vector or array, bounded or not */
262 MONO_CLASS_POINTER
, /* pointer or function pointer*/
265 typedef struct _MonoClassDef MonoClassDef
;
266 typedef struct _MonoClassGtd MonoClassGtd
;
267 typedef struct _MonoClassGenericInst MonoClassGenericInst
;
268 typedef struct _MonoClassGenericParam MonoClassGenericParam
;
269 typedef struct _MonoClassArray MonoClassArray
;
270 typedef struct _MonoClassPointer MonoClassPointer
;
272 union _MonoClassSizes
{
273 int class_size
; /* size of area for static fields */
274 int element_size
; /* for array types */
275 int generic_param_token
; /* for generic param types, both var and mvar */
278 /* enabled only with small config for now: we might want to do it unconditionally */
279 #ifdef MONO_SMALL_CONFIG
280 #define COMPRESSED_INTERFACE_BITMAP 1
284 #ifdef ENABLE_CHECKED_BUILD_PRIVATE_TYPES
285 #define MONO_CLASS_DEF_PRIVATE 1
288 /* Hide _MonoClass definition in checked build mode to ensure that
289 * it is only accessed via getter and setter methods.
291 #ifndef MONO_CLASS_DEF_PRIVATE
292 #include "class-private-definition.h"
295 /* If MonoClass definition is hidden, just declare the getters.
296 * Otherwise, define them as static inline functions.
298 * In-tree profilers are allowed to use the getters. So if we're compiling
299 * with --enable-checked-build=private_types, mark the symbols with
302 #ifdef MONO_CLASS_DEF_PRIVATE
303 #define MONO_CLASS_GETTER(funcname, rettype, optref, argtype, fieldname) MONO_PROFILER_API rettype funcname (argtype *klass);
305 #define MONO_CLASS_GETTER(funcname, rettype, optref, argtype, fieldname) static inline rettype funcname (argtype *klass) { return optref klass-> fieldname ; }
307 #define MONO_CLASS_OFFSET(funcname, argtype, fieldname) /*nothing*/
308 #include "class-getters.h"
309 #undef MONO_CLASS_GETTER
310 #undef MONO_CLASS_OFFSET
312 #ifdef COMPRESSED_INTERFACE_BITMAP
313 int mono_compress_bitmap (uint8_t *dest
, const uint8_t *bitmap
, int size
);
314 int mono_class_interface_match (const uint8_t *bitmap
, int id
);
316 #define mono_class_interface_match(bmap,uiid) ((bmap) [(uiid) >> 3] & (1 << ((uiid)&7)))
319 #define MONO_CLASS_IMPLEMENTS_INTERFACE(k,uiid) (((uiid) <= m_class_get_max_interface_id (k)) && mono_class_interface_match (m_class_get_interface_bitmap (k), (uiid)))
321 #define MONO_VTABLE_AVAILABLE_GC_BITS 4
323 #ifdef DISABLE_REMOTING
324 #define mono_class_is_marshalbyref(klass) (FALSE)
325 #define mono_class_is_contextbound(klass) (FALSE)
326 #define mono_vtable_is_remote(vtable) (FALSE)
327 #define mono_vtable_set_is_remote(vtable,enable) do {} while (0)
329 #define mono_class_is_marshalbyref(klass) (m_class_get_marshalbyref (klass))
330 #define mono_class_is_contextbound(klass) (m_class_get_contextbound (klass))
331 #define mono_vtable_is_remote(vtable) ((vtable)->remote)
332 #define mono_vtable_set_is_remote(vtable,enable) do { (vtable)->remote = enable ? 1 : 0; } while (0)
336 #define mono_class_is_com_object(klass) (FALSE)
338 #define mono_class_is_com_object(klass) (m_class_is_com_object (klass))
342 MONO_API
int mono_class_interface_offset (MonoClass
*klass
, MonoClass
*itf
);
343 int mono_class_interface_offset_with_variance (MonoClass
*klass
, MonoClass
*itf
, gboolean
*non_exact_match
);
345 typedef gpointer MonoRuntimeGenericContext
;
348 /* array or string */
349 MONO_VT_FLAG_ARRAY_OR_STRING
= (1 << 0),
350 MONO_VT_FLAG_HAS_REFERENCES
= (1 << 1),
351 MONO_VT_FLAG_ARRAY_IS_PRIMITIVE
= (1 << 2),
354 /* the interface_offsets array is stored in memory before this struct */
358 * According to comments in gc_gcj.h, this should be the second word in
361 MonoGCDescriptor gc_descr
;
362 MonoDomain
*domain
; /* each object/vtable belongs to exactly one domain */
363 gpointer type
; /* System.Type type for klass */
364 guint8
*interface_bitmap
;
365 guint32 max_interface_id
;
367 /* Keep this a guint8, the jit depends on it */
368 guint8 initialized
; /* cctor has been run */
369 /* Keep this a guint8, the jit depends on it */
370 guint8 flags
; /* MonoVTableFlags */
371 guint remote
: 1; /* class is remotely activated */
372 guint init_failed
: 1; /* cctor execution failed */
373 guint has_static_fields
: 1; /* pointer to the data stored at the end of the vtable array */
374 guint gc_bits
: MONO_VTABLE_AVAILABLE_GC_BITS
; /* Those bits are reserved for the usaged of the GC */
376 guint32 imt_collisions_bitmap
;
377 MonoRuntimeGenericContext
*runtime_generic_context
;
378 /* interp virtual method table */
379 gpointer
*interp_vtable
;
380 /* do not add any fields after vtable, the structure is dynamically extended */
381 /* vtable contains function pointers to methods or their trampolines, at the
382 end there may be a slot containing the pointer to the static fields */
383 gpointer vtable
[MONO_ZERO_LEN_ARRAY
];
386 #define MONO_SIZEOF_VTABLE (sizeof (MonoVTable) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
388 #define MONO_VTABLE_IMPLEMENTS_INTERFACE(vt,uiid) (((uiid) <= (vt)->max_interface_id) && mono_class_interface_match ((vt)->interface_bitmap, (uiid)))
391 * Generic instantiation data type encoding.
395 * A particular generic instantiation:
397 * All instantiations are cached and we don't distinguish between class and method
398 * instantiations here.
400 struct _MonoGenericInst
{
401 #ifndef MONO_SMALL_CONFIG
402 gint32 id
; /* unique ID for debugging */
404 guint type_argc
: 22; /* number of type arguments */
405 guint is_open
: 1; /* if this is an open type */
406 MonoType
*type_argv
[MONO_ZERO_LEN_ARRAY
];
409 #define MONO_SIZEOF_GENERIC_INST (sizeof (MonoGenericInst) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
411 * The generic context: an instantiation of a set of class and method generic parameters.
413 * NOTE: Never allocate this directly on the heap. It have to be either allocated on the stack,
414 * or embedded within other objects. Don't store pointers to this, because it may be on the stack.
415 * If you really have to, ensure you store a pointer to the embedding object along with it.
417 struct _MonoGenericContext
{
418 /* The instantiation corresponding to the class generic parameters */
419 MonoGenericInst
*class_inst
;
420 /* The instantiation corresponding to the method generic parameters */
421 MonoGenericInst
*method_inst
;
425 * Inflated generic method.
427 struct _MonoMethodInflated
{
430 MonoMethodPInvoke pinvoke
;
432 MonoMethod
*declaring
; /* the generic method definition. */
433 MonoGenericContext context
; /* The current instantiation */
434 MonoImageSet
*owner
; /* The image set that the inflated method belongs to. */
438 * A particular instantiation of a generic type.
440 struct _MonoGenericClass
{
441 MonoClass
*container_class
; /* the generic type definition */
442 MonoGenericContext context
; /* a context that contains the type instantiation doesn't contain any method instantiation */ /* FIXME: Only the class_inst member of "context" is ever used, so this field could be replaced with just a monogenericinst */
443 guint is_dynamic
: 1; /* Contains dynamic types */
444 guint is_tb_open
: 1; /* This is the fully open instantiation for a type_builder. Quite ugly, but it's temporary.*/
445 guint need_sync
: 1; /* Only if dynamic. Need to be synchronized with its container class after its finished. */
446 MonoClass
*cached_class
; /* if present, the MonoClass corresponding to the instantiation. */
449 * The image set which owns this generic class. Memory owned by the generic class
450 * including cached_class should be allocated from the mempool of the image set,
451 * so it is easy to free.
456 /* Additional details about a MonoGenericParam */
457 /* Keep in sync with managed Mono.RuntimeStructs.GenericParamInfo */
459 MonoClass
*pklass
; /* The corresponding `MonoClass'. */
462 // See GenericParameterAttributes
467 // Constraints on type parameters
468 MonoClass
** constraints
; /* NULL means end of list */
469 } MonoGenericParamInfo
;
474 struct _MonoGenericParam
{
476 * Type or method this parameter was defined in.
478 MonoGenericContainer
*owner
;
481 * If != NULL, this is a generated generic param used by the JIT to implement generic
484 MonoType
*gshared_constraint
;
486 MonoGenericParamInfo info
;
489 typedef MonoGenericParam MonoGenericParamFull
;
492 * The generic container.
494 * Stores the type parameters of a generic type definition or a generic method definition.
496 struct _MonoGenericContainer
{
497 MonoGenericContext context
;
498 /* If we're a generic method definition in a generic type definition,
499 the generic container of the containing class. */
500 MonoGenericContainer
*parent
;
501 /* the generic type definition or the generic method definition corresponding to this container */
502 /* Union rules: If is_anonymous, image field is valid; else if is_method, method field is valid; else klass is valid. */
508 int type_argc
: 29; // Per the ECMA spec, this value is capped at 16 bits
509 /* If true, we're a generic method, otherwise a generic type definition. */
510 /* Invariant: parent != NULL => is_method */
512 /* If true, this container has no associated class/method and only the image is known. This can happen:
513 1. For the special anonymous containers kept by MonoImage.
514 2. When user code creates a generic parameter via SRE, but has not yet set an owner. */
515 int is_anonymous
: 1;
516 /* Our type parameters. If this is a special anonymous container (case 1, above), this field is not valid, use mono_metadata_create_anon_gparam () */
517 MonoGenericParamFull
*type_params
;
520 static inline MonoGenericParam
*
521 mono_generic_container_get_param (MonoGenericContainer
*gc
, int i
)
523 return (MonoGenericParam
*) &gc
->type_params
[i
];
526 static inline MonoGenericParamInfo
*
527 mono_generic_container_get_param_info (MonoGenericContainer
*gc
, int i
)
529 return &gc
->type_params
[i
].info
;
532 static inline MonoGenericContainer
*
533 mono_generic_param_owner (MonoGenericParam
*p
)
539 mono_generic_param_num (MonoGenericParam
*p
)
544 static inline MonoGenericParamInfo
*
545 mono_generic_param_info (MonoGenericParam
*p
)
547 return &((MonoGenericParamFull
*) p
)->info
;
550 static inline const char *
551 mono_generic_param_name (MonoGenericParam
*p
)
553 return ((MonoGenericParamFull
*) p
)->info
.name
;
556 static inline MonoGenericContainer
*
557 mono_type_get_generic_param_owner (MonoType
*t
)
559 return mono_generic_param_owner (t
->data
.generic_param
);
563 mono_type_get_generic_param_num (MonoType
*t
)
565 return mono_generic_param_num (t
->data
.generic_param
);
569 * Class information which might be cached by the runtime in the AOT file for
570 * example. Caching this allows us to avoid computing a generic vtable
571 * (class->vtable) in most cases, saving time and avoiding creation of lots of
572 * MonoMethod structures.
574 typedef struct MonoCachedClassInfo
{
576 guint has_finalize
: 1;
579 guint has_nested_classes
: 1;
581 guint has_references
: 1;
582 guint has_static_refs
: 1;
583 guint no_special_static_fields
: 1;
584 guint is_generic_container
: 1;
585 guint has_weak_fields
: 1;
587 MonoImage
*finalize_image
;
588 guint32 finalize_token
;
589 guint32 instance_size
;
591 guint32 packing_size
;
593 } MonoCachedClassInfo
;
596 // Name and func fields double as "inited".
597 // That is, any initialized MonoJitICallInfo must
598 // have both of them to be non-NULL.
601 gconstpointer wrapper
;
602 gconstpointer trampoline
;
603 MonoMethodSignature
*sig
;
604 const char *c_symbol
;
605 MonoMethod
*wrapper_method
;
609 mono_class_setup_supertypes (MonoClass
*klass
);
612 * Only call this function if you can ensure both @klass and @parent
613 * have supertype information initialized.
614 * This can be accomplished by mono_class_setup_supertypes or mono_class_init.
615 * If unsure, use mono_class_has_parent.
617 static inline gboolean
618 mono_class_has_parent_fast (MonoClass
*klass
, MonoClass
*parent
)
620 return (m_class_get_idepth (klass
) >= m_class_get_idepth (parent
)) && (m_class_get_supertypes (klass
) [m_class_get_idepth (parent
) - 1] == parent
);
623 static inline gboolean
624 mono_class_has_parent (MonoClass
*klass
, MonoClass
*parent
)
626 if (G_UNLIKELY (!m_class_get_supertypes (klass
)))
627 mono_class_setup_supertypes (klass
);
629 if (G_UNLIKELY (!m_class_get_supertypes (parent
)))
630 mono_class_setup_supertypes (parent
);
632 return mono_class_has_parent_fast (klass
, parent
);
636 MonoVTable
*default_vtable
;
637 MonoVTable
*xdomain_vtable
;
638 MonoClass
*proxy_class
;
639 char* proxy_class_name
;
640 uint32_t interface_count
;
641 MonoClass
*interfaces
[MONO_ZERO_LEN_ARRAY
];
644 #define MONO_SIZEOF_REMOTE_CLASS (sizeof (MonoRemoteClass) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
647 gint32 initialized_class_count
;
648 gint32 generic_vtable_count
;
649 gint32 used_class_count
;
651 gint32 class_vtable_size
;
652 gint32 class_static_data_size
;
653 gint32 generic_class_count
;
654 gint32 inflated_method_count
;
655 gint32 inflated_type_count
;
656 gint32 delegate_creations
;
657 gint32 imt_tables_size
;
658 gint32 imt_number_of_tables
;
659 gint32 imt_number_of_methods
;
660 gint32 imt_used_slots
;
661 gint32 imt_slots_with_collisions
;
662 gint32 imt_max_collisions_in_slot
;
663 gint32 imt_method_count_when_max_collisions
;
664 gint32 imt_trampolines_size
;
665 gint32 jit_info_table_insert_count
;
666 gint32 jit_info_table_remove_count
;
667 gint32 jit_info_table_lookup_count
;
668 gint32 generics_sharable_methods
;
669 gint32 generics_unsharable_methods
;
670 gint32 generics_shared_methods
;
671 gint32 gsharedvt_methods
;
676 * new structure to hold performace counters values that are exported
678 * Note: never remove fields from this structure and only add them to the end.
679 * Size of fields and type should not be changed as well.
687 /* Exceptions category */
688 gint32 exceptions_thrown
;
689 gint32 exceptions_filters
;
690 gint32 exceptions_finallys
;
691 gint32 exceptions_depth
;
692 gint32 aspnet_requests_queued
;
693 gint32 aspnet_requests
;
694 /* Memory category */
695 gint32 gc_collections0
;
696 gint32 gc_collections1
;
697 gint32 gc_collections2
;
698 gint32 gc_promotions0
;
699 gint32 gc_promotions1
;
700 gint32 gc_promotion_finalizers
;
705 gint32 gc_fin_survivors
;
706 gint32 gc_num_handles
;
710 gint64 gc_total_bytes
;
711 gint64 gc_committed_bytes
;
712 gint64 gc_reserved_bytes
;
713 gint32 gc_num_pinned
;
714 gint32 gc_sync_blocks
;
715 /* Remoting category */
716 gint32 remoting_calls
;
717 gint32 remoting_channels
;
718 gint32 remoting_proxies
;
719 gint32 remoting_classes
;
720 gint32 remoting_objects
;
721 gint32 remoting_contexts
;
722 /* Loader category */
723 gint32 loader_classes
;
724 gint32 loader_total_classes
;
725 gint32 loader_appdomains
;
726 gint32 loader_total_appdomains
;
727 gint32 loader_assemblies
;
728 gint32 loader_total_assemblies
;
729 gint32 loader_failures
;
731 gint32 loader_appdomains_uloaded
;
732 /* Threads and Locks category */
733 gint32 thread_contentions
;
734 gint32 thread_queue_len
;
735 gint32 thread_queue_max
;
736 gint32 thread_num_logical
;
737 gint32 thread_num_physical
;
738 gint32 thread_cur_recognized
;
739 gint32 thread_num_recognized
;
740 /* Interop category */
741 gint32 interop_num_ccw
;
742 gint32 interop_num_stubs
;
743 gint32 interop_num_marshals
;
744 /* Security category */
745 gint32 security_num_checks
;
746 gint32 security_num_link_checks
;
747 gint32 security_time
;
748 gint32 security_depth
;
751 gint32 threadpool_threads
;
752 gint64 threadpool_workitems
;
753 gint64 threadpool_ioworkitems
;
754 gint32 threadpool_iothreads
;
757 extern MonoPerfCounters
*mono_perfcounters
;
759 MONO_API
void mono_perfcounters_init (void);
762 * The definition of the first field in SafeHandle,
763 * Keep in sync with SafeHandle.cs, this is only used
764 * to access the `handle' parameter.
772 * Keep in sync with HandleRef.cs
779 extern MonoStats mono_stats
;
781 typedef gboolean (*MonoGetCachedClassInfo
) (MonoClass
*klass
, MonoCachedClassInfo
*res
);
783 typedef gboolean (*MonoGetClassFromName
) (MonoImage
*image
, const char *name_space
, const char *name
, MonoClass
**res
);
785 static inline gboolean
786 method_is_dynamic (MonoMethod
*method
)
788 #ifdef DISABLE_REFLECTION_EMIT
791 return method
->dynamic
;
796 mono_class_get_method_by_index (MonoClass
*klass
, int index
);
799 mono_class_get_inflated_method (MonoClass
*klass
, MonoMethod
*method
, MonoError
*error
);
802 mono_class_get_vtable_entry (MonoClass
*klass
, int offset
);
805 mono_class_get_implemented_interfaces (MonoClass
*klass
, MonoError
*error
);
808 mono_class_get_vtable_size (MonoClass
*klass
);
811 mono_class_is_open_constructed_type (MonoType
*t
);
814 mono_class_get_overrides_full (MonoImage
*image
, guint32 type_token
, MonoMethod
***overrides
, gint32
*num_overrides
, MonoGenericContext
*generic_context
, MonoError
*error
);
817 mono_class_get_cctor (MonoClass
*klass
);
820 mono_class_get_finalizer (MonoClass
*klass
);
823 mono_class_needs_cctor_run (MonoClass
*klass
, MonoMethod
*caller
);
826 mono_class_field_is_special_static (MonoClassField
*field
);
829 mono_class_field_get_special_static_type (MonoClassField
*field
);
832 mono_class_has_special_static_fields (MonoClass
*klass
);
835 mono_class_get_field_default_value (MonoClassField
*field
, MonoTypeEnum
*def_type
);
838 mono_class_get_property_from_name_internal (MonoClass
*klass
, const char *name
);
841 mono_class_get_property_default_value (MonoProperty
*property
, MonoTypeEnum
*def_type
);
844 mono_lookup_dynamic_token (MonoImage
*image
, guint32 token
, MonoGenericContext
*context
, MonoError
*error
);
847 mono_lookup_dynamic_token_class (MonoImage
*image
, guint32 token
, gboolean check_token
, MonoClass
**handle_class
, MonoGenericContext
*context
, MonoError
*error
);
850 mono_runtime_create_delegate_trampoline (MonoClass
*klass
);
853 mono_install_get_cached_class_info (MonoGetCachedClassInfo func
);
856 mono_install_get_class_from_name (MonoGetClassFromName func
);
858 MONO_PROFILER_API MonoGenericContext
*
859 mono_class_get_context (MonoClass
*klass
);
861 MONO_PROFILER_API MonoMethodSignature
*
862 mono_method_signature_checked_slow (MonoMethod
*m
, MonoError
*err
);
864 MONO_PROFILER_API MonoMethodSignature
*
865 mono_method_signature_internal_slow (MonoMethod
*m
);
868 * mono_method_signature_checked:
870 * Return the signature of the method M. On failure, returns NULL, and ERR is set.
872 static inline MonoMethodSignature
*
873 mono_method_signature_checked (MonoMethod
*m
, MonoError
*error
)
876 MonoMethodSignature
* sig
= m
->signature
;
877 return sig
? sig
: mono_method_signature_checked_slow (m
, error
);
881 * mono_method_signature_internal:
882 * \returns the signature of the method \p m. On failure, returns NULL.
884 static inline MonoMethodSignature
*
885 mono_method_signature_internal (MonoMethod
*m
)
887 MonoMethodSignature
* sig
= m
->signature
;
888 return sig
? sig
: mono_method_signature_internal_slow (m
);
892 mono_method_get_context_general (MonoMethod
*method
, gboolean uninflated
);
894 MONO_PROFILER_API MonoGenericContext
*
895 mono_method_get_context (MonoMethod
*method
);
897 /* Used by monodis, thus cannot be MONO_INTERNAL */
898 MONO_API MonoGenericContainer
*
899 mono_method_get_generic_container (MonoMethod
*method
);
902 mono_generic_class_get_context (MonoGenericClass
*gclass
);
905 mono_method_set_generic_container (MonoMethod
*method
, MonoGenericContainer
* container
);
908 mono_method_set_verification_success (MonoMethod
*method
);
911 mono_method_get_verification_success (MonoMethod
*method
);
913 const MonoMethodDefInfrequentBits
*
914 mono_method_lookup_infrequent_bits (MonoMethod
*methoddef
);
916 MonoMethodDefInfrequentBits
*
917 mono_method_get_infrequent_bits (MonoMethod
*methoddef
);
920 mono_method_get_is_reabstracted (MonoMethod
*method
);
923 mono_method_set_is_reabstracted (MonoMethod
*methoddef
);
926 mono_method_get_is_covariant_override_impl (MonoMethod
*method
);
929 mono_method_set_is_covariant_override_impl (MonoMethod
*methoddef
);
932 mono_class_inflate_generic_method_full_checked (MonoMethod
*method
, MonoClass
*klass_hint
, MonoGenericContext
*context
, MonoError
*error
);
935 mono_class_inflate_generic_method_checked (MonoMethod
*method
, MonoGenericContext
*context
, MonoError
*error
);
938 mono_metadata_get_image_set_for_class (MonoClass
*klass
);
941 mono_metadata_get_image_set_for_method (MonoMethodInflated
*method
);
943 MONO_API MonoMethodSignature
*
944 mono_metadata_get_inflated_signature (MonoMethodSignature
*sig
, MonoGenericContext
*context
);
947 mono_class_inflate_generic_type_with_mempool (MonoImage
*image
, MonoType
*type
, MonoGenericContext
*context
, MonoError
*error
);
950 mono_class_inflate_generic_type_checked (MonoType
*type
, MonoGenericContext
*context
, MonoError
*error
);
953 mono_metadata_free_inflated_signature (MonoMethodSignature
*sig
);
956 mono_inflate_generic_signature (MonoMethodSignature
*sig
, MonoGenericContext
*context
, MonoError
*error
);
959 mono_generic_param_get_base_type (MonoClass
*klass
);
963 MonoClass
*object_class
;
964 MonoClass
*object_class_array
; // used via token pasting in mono_array_class_get_cached
965 MonoClass
*byte_class
;
966 MonoClass
*void_class
;
967 MonoClass
*boolean_class
;
968 MonoClass
*sbyte_class
;
969 MonoClass
*int16_class
;
970 MonoClass
*uint16_class
;
971 MonoClass
*int32_class
;
972 MonoClass
*uint32_class
;
973 MonoClass
*int_class
;
974 MonoClass
*uint_class
;
975 MonoClass
*int64_class
;
976 MonoClass
*uint64_class
;
977 MonoClass
*single_class
;
978 MonoClass
*double_class
;
979 MonoClass
*char_class
;
980 MonoClass
*string_class
;
981 MonoClass
*enum_class
;
982 MonoClass
*array_class
;
983 MonoClass
*delegate_class
;
984 MonoClass
*multicastdelegate_class
;
985 MonoClass
*manualresetevent_class
;
986 MonoClass
*typehandle_class
;
987 MonoClass
*fieldhandle_class
;
988 MonoClass
*methodhandle_class
;
989 MonoClass
*systemtype_class
;
990 MonoClass
*runtimetype_class
;
991 MonoClass
*runtimetype_class_array
; // used via token pasting in mono_array_class_get_cached
992 MonoClass
*exception_class
;
993 MonoClass
*threadabortexception_class
;
994 MonoClass
*thread_class
;
995 MonoClass
*internal_thread_class
;
996 #ifndef DISABLE_REMOTING
997 MonoClass
*transparent_proxy_class
;
998 MonoClass
*real_proxy_class
;
999 MonoClass
*marshalbyrefobject_class
;
1000 MonoClass
*iremotingtypeinfo_class
;
1002 MonoClass
*mono_method_message_class
;
1003 MonoClass
*appdomain_class
;
1004 MonoClass
*field_info_class
;
1005 MonoClass
*method_info_class
;
1006 MonoClass
*stack_frame_class
;
1007 MonoClass
*marshal_class
;
1008 MonoClass
*typed_reference_class
;
1009 MonoClass
*argumenthandle_class
;
1010 MonoClass
*monitor_class
;
1011 MonoClass
*generic_ilist_class
;
1012 MonoClass
*generic_nullable_class
;
1013 MonoClass
*attribute_class
;
1014 MonoClass
*attribute_class_array
; // used via token pasting in mono_array_class_get_cached
1015 MonoClass
*critical_finalizer_object
; /* MAYBE NULL */
1016 MonoClass
*generic_ireadonlylist_class
;
1017 MonoClass
*generic_ienumerator_class
;
1018 #ifdef ENABLE_NETCORE
1019 MonoClass
*alc_class
;
1020 MonoClass
*appcontext_class
;
1022 #ifndef ENABLE_NETCORE
1023 MonoMethod
*threadpool_perform_wait_callback_method
;
1027 #ifdef DISABLE_REMOTING
1028 #define mono_class_is_transparent_proxy(klass) (FALSE)
1029 #define mono_class_is_real_proxy(klass) (FALSE)
1031 #define mono_class_is_transparent_proxy(klass) ((klass) == mono_defaults.transparent_proxy_class)
1032 #define mono_class_is_real_proxy(klass) ((klass) == mono_defaults.real_proxy_class)
1035 #define mono_object_is_transparent_proxy(object) (mono_class_is_transparent_proxy (mono_object_class (object)))
1038 #define GENERATE_GET_CLASS_WITH_CACHE_DECL(shortname) \
1039 MonoClass* mono_class_get_##shortname##_class (void);
1041 #define GENERATE_TRY_GET_CLASS_WITH_CACHE_DECL(shortname) \
1042 MonoClass* mono_class_try_get_##shortname##_class (void);
1044 // GENERATE_GET_CLASS_WITH_CACHE attempts mono_class_load_from_name whenever
1045 // its cache is null. i.e. potentially repeatedly, though it is expected to succeed
1048 #define GENERATE_GET_CLASS_WITH_CACHE(shortname,name_space,name) \
1050 mono_class_get_##shortname##_class (void) \
1052 static MonoClass *tmp_class; \
1053 MonoClass *klass = tmp_class; \
1055 klass = mono_class_load_from_name (mono_defaults.corlib, name_space, name); \
1056 mono_memory_barrier (); /* FIXME excessive? */ \
1057 tmp_class = klass; \
1062 // GENERATE_TRY_GET_CLASS_WITH_CACHE attempts mono_class_load_from_name approximately
1063 // only once. i.e. if it fails, it will return null and not retry.
1064 // In a race it might try a few times, but not indefinitely.
1066 // FIXME This maybe has excessive volatile/barriers.
1068 #define GENERATE_TRY_GET_CLASS_WITH_CACHE(shortname,name_space,name) \
1070 mono_class_try_get_##shortname##_class (void) \
1072 static volatile MonoClass *tmp_class; \
1073 static volatile gboolean inited; \
1074 MonoClass *klass = (MonoClass *)tmp_class; \
1075 mono_memory_barrier (); \
1077 klass = mono_class_try_load_from_name (mono_defaults.corlib, name_space, name); \
1078 tmp_class = klass; \
1079 mono_memory_barrier (); \
1085 GENERATE_TRY_GET_CLASS_WITH_CACHE_DECL (safehandle
)
1089 GENERATE_GET_CLASS_WITH_CACHE_DECL (interop_proxy
)
1090 GENERATE_GET_CLASS_WITH_CACHE_DECL (idispatch
)
1091 GENERATE_GET_CLASS_WITH_CACHE_DECL (iunknown
)
1092 GENERATE_GET_CLASS_WITH_CACHE_DECL (com_object
)
1093 GENERATE_GET_CLASS_WITH_CACHE_DECL (variant
)
1097 GENERATE_GET_CLASS_WITH_CACHE_DECL (appdomain
)
1098 GENERATE_GET_CLASS_WITH_CACHE_DECL (appdomain_setup
)
1100 GENERATE_GET_CLASS_WITH_CACHE_DECL (appdomain_unloaded_exception
)
1101 GENERATE_TRY_GET_CLASS_WITH_CACHE_DECL (appdomain_unloaded_exception
)
1103 GENERATE_GET_CLASS_WITH_CACHE_DECL (valuetype
)
1105 GENERATE_TRY_GET_CLASS_WITH_CACHE_DECL(handleref
)
1107 #ifdef ENABLE_NETCORE
1108 GENERATE_GET_CLASS_WITH_CACHE_DECL (assembly_load_context
)
1109 GENERATE_GET_CLASS_WITH_CACHE_DECL (native_library
)
1112 /* If you need a MonoType, use one of the mono_get_*_type () functions in class-inlines.h */
1113 extern MonoDefaults mono_defaults
;
1116 mono_loader_init (void);
1119 mono_loader_cleanup (void);
1122 mono_loader_lock (void);
1125 mono_loader_unlock (void);
1128 mono_loader_lock_track_ownership (gboolean track
);
1131 mono_loader_lock_is_owned_by_self (void);
1134 mono_loader_lock_if_inited (void);
1137 mono_loader_unlock_if_inited (void);
1140 mono_reflection_init (void);
1143 mono_icall_init (void);
1146 mono_icall_cleanup (void);
1149 mono_method_get_wrapper_data (MonoMethod
*method
, guint32 id
);
1152 mono_metadata_has_generic_params (MonoImage
*image
, guint32 token
);
1154 MONO_API MonoGenericContainer
*
1155 mono_metadata_load_generic_params (MonoImage
*image
, guint32 token
,
1156 MonoGenericContainer
*parent_container
,
1157 gpointer real_owner
);
1160 mono_metadata_load_generic_param_constraints_checked (MonoImage
*image
, guint32 token
,
1161 MonoGenericContainer
*container
, MonoError
*error
);
1163 // This is the "real" function for registering JIT icalls. All others are one line wrappers that call it,
1164 // i.e. filling in info or c_symbol.
1166 mono_register_jit_icall_info (MonoJitICallInfo
*info
, gconstpointer func
, const char *name
,
1167 MonoMethodSignature
*sig
, gboolean no_wrapper
, const char *c_symbol
);
1170 template <typename T
>
1172 mono_register_jit_icall_info (MonoJitICallInfo
*info
, T func
, const char *name
, MonoMethodSignature
*sig
, gboolean no_wrapper
, const char *c_symbol
)
1174 mono_register_jit_icall_info (info
, (gconstpointer
)func
, name
, sig
, no_wrapper
, c_symbol
);
1176 #endif // __cplusplus
1178 #define mono_register_jit_icall(func, sig, no_wrapper) (mono_register_jit_icall_info (&mono_get_jit_icall_info ()->func, func, #func, (sig), (no_wrapper), NULL))
1181 mono_class_set_type_load_failure (MonoClass
*klass
, const char * fmt
, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
1184 mono_class_get_exception_for_failure (MonoClass
*klass
);
1187 mono_identifier_escape_type_name_chars (const char* identifier
);
1190 mono_type_get_full_name (MonoClass
*klass
);
1193 mono_method_get_name_full (MonoMethod
*method
, gboolean signature
, gboolean ret
, MonoTypeNameFormat format
);
1195 MONO_PROFILER_API
char *
1196 mono_method_get_full_name (MonoMethod
*method
);
1199 mono_wrapper_type_to_str (guint32 wrapper_type
);
1201 MonoArrayType
*mono_dup_array_type (MonoImage
*image
, MonoArrayType
*a
);
1202 MonoMethodSignature
*mono_metadata_signature_deep_dup (MonoImage
*image
, MonoMethodSignature
*sig
);
1205 mono_image_init_name_cache (MonoImage
*image
);
1208 mono_class_get_nullable_param_internal (MonoClass
*klass
);
1210 /* object debugging functions, for use inside gdb */
1211 MONO_API
void mono_object_describe (MonoObject
*obj
);
1212 MONO_API
void mono_object_describe_fields (MonoObject
*obj
);
1213 MONO_API
void mono_value_describe_fields (MonoClass
* klass
, const char* addr
);
1214 MONO_API
void mono_class_describe_statics (MonoClass
* klass
);
1216 /* method debugging functions, for use inside gdb */
1217 MONO_API
void mono_method_print_code (MonoMethod
*method
);
1219 MONO_PROFILER_API
char *mono_signature_full_name (MonoMethodSignature
*sig
);
1221 /*Enum validation related functions*/
1223 mono_type_is_valid_enum_basetype (MonoType
* type
);
1226 mono_class_is_valid_enum (MonoClass
*klass
);
1228 MONO_PROFILER_API gboolean
1229 mono_type_is_primitive (MonoType
*type
);
1232 mono_type_get_checked (MonoImage
*image
, guint32 type_token
, MonoGenericContext
*context
, MonoError
*error
);
1235 mono_generic_class_is_generic_type_definition (MonoGenericClass
*gklass
);
1238 mono_type_get_basic_type_from_generic (MonoType
*type
);
1241 mono_method_can_access_method_full (MonoMethod
*method
, MonoMethod
*called
, MonoClass
*context_klass
);
1244 mono_method_can_access_field_full (MonoMethod
*method
, MonoClassField
*field
, MonoClass
*context_klass
);
1247 mono_class_can_access_class (MonoClass
*access_class
, MonoClass
*target_class
);
1250 mono_class_get_generic_type_definition (MonoClass
*klass
);
1253 mono_class_has_parent_and_ignore_generics (MonoClass
*klass
, MonoClass
*parent
);
1256 mono_method_get_vtable_slot (MonoMethod
*method
);
1259 mono_method_get_vtable_index (MonoMethod
*method
);
1262 mono_method_get_base_method (MonoMethod
*method
, gboolean definition
, MonoError
*error
);
1265 mono_method_search_in_array_class (MonoClass
*klass
, const char *name
, MonoMethodSignature
*sig
);
1268 mono_class_setup_interface_id (MonoClass
*klass
);
1270 MonoGenericContainer
*
1271 mono_class_get_generic_container (MonoClass
*klass
);
1274 mono_class_alloc (MonoClass
*klass
, int size
);
1277 mono_class_alloc0 (MonoClass
*klass
, int size
);
1279 #define mono_class_alloc0(klass, size) (g_cast (mono_class_alloc0 ((klass), (size))))
1282 mono_class_setup_interfaces (MonoClass
*klass
, MonoError
*error
);
1285 mono_class_get_field_from_name_full (MonoClass
*klass
, const char *name
, MonoType
*type
);
1288 mono_class_vtable_checked (MonoDomain
*domain
, MonoClass
*klass
, MonoError
*error
);
1291 mono_class_is_assignable_from_checked (MonoClass
*klass
, MonoClass
*oklass
, gboolean
*result
, MonoError
*error
);
1294 mono_class_signature_is_assignable_from (MonoClass
*klass
, MonoClass
*oklass
, gboolean
*result
, MonoError
*error
);
1297 mono_class_is_assignable_from_slow (MonoClass
*target
, MonoClass
*candidate
);
1300 mono_class_has_variant_generic_params (MonoClass
*klass
);
1303 mono_class_is_variant_compatible (MonoClass
*klass
, MonoClass
*oklass
, gboolean check_for_reference_conv
);
1306 mono_class_is_subclass_of_internal (MonoClass
*klass
, MonoClass
*klassc
, gboolean check_interfaces
);
1309 mono_class_is_assignable_from_internal (MonoClass
*klass
, MonoClass
*oklass
);
1312 mono_byref_type_is_assignable_from (MonoType
*type
, MonoType
*ctype
, gboolean signature_assignment
);
1314 gboolean
mono_is_corlib_image (MonoImage
*image
);
1317 mono_field_get_type_checked (MonoClassField
*field
, MonoError
*error
);
1320 mono_field_get_type_internal (MonoClassField
*field
);
1323 mono_class_get_fields_internal (MonoClass
* klass
, gpointer
*iter
);
1326 mono_class_get_fields_lazy (MonoClass
* klass
, gpointer
*iter
);
1329 mono_class_check_vtable_constraints (MonoClass
*klass
, GList
*in_setup
);
1332 mono_class_has_finalizer (MonoClass
*klass
);
1335 mono_unload_interface_id (MonoClass
*klass
);
1338 mono_class_get_methods_by_name (MonoClass
*klass
, const char *name
, guint32 bflags
, guint32 mlisttype
, gboolean allow_ctors
, MonoError
*error
);
1341 mono_class_full_name (MonoClass
*klass
);
1344 mono_class_inflate_generic_class_checked (MonoClass
*gklass
, MonoGenericContext
*context
, MonoError
*error
);
1346 MONO_PROFILER_API MonoClass
*
1347 mono_class_get_checked (MonoImage
*image
, guint32 type_token
, MonoError
*error
);
1350 mono_class_get_and_inflate_typespec_checked (MonoImage
*image
, guint32 type_token
, MonoGenericContext
*context
, MonoError
*error
);
1353 mono_class_from_name_checked (MonoImage
*image
, const char* name_space
, const char *name
, MonoError
*error
);
1356 mono_class_from_name_case_checked (MonoImage
*image
, const char* name_space
, const char *name
, MonoError
*error
);
1358 MONO_PROFILER_API MonoClass
*
1359 mono_class_from_mono_type_internal (MonoType
*type
);
1362 mono_field_from_token_checked (MonoImage
*image
, uint32_t token
, MonoClass
**retklass
, MonoGenericContext
*context
, MonoError
*error
);
1365 mono_ldtoken_checked (MonoImage
*image
, guint32 token
, MonoClass
**handle_class
, MonoGenericContext
*context
, MonoError
*error
);
1368 mono_get_image_for_generic_param (MonoGenericParam
*param
);
1371 mono_make_generic_name_string (MonoImage
*image
, int num
);
1374 mono_class_load_from_name (MonoImage
*image
, const char* name_space
, const char *name
);
1377 mono_class_try_load_from_name (MonoImage
*image
, const char* name_space
, const char *name
);
1380 mono_error_set_for_class_failure (MonoError
*orerror
, const MonoClass
*klass
);
1383 mono_class_has_failure (const MonoClass
*klass
);
1385 /* Kind specific accessors */
1387 mono_class_get_generic_class (MonoClass
*klass
);
1390 mono_class_try_get_generic_class (MonoClass
*klass
);
1393 mono_class_set_flags (MonoClass
*klass
, guint32 flags
);
1395 MonoGenericContainer
*
1396 mono_class_try_get_generic_container (MonoClass
*klass
);
1399 mono_class_set_generic_container (MonoClass
*klass
, MonoGenericContainer
*container
);
1402 mono_class_gtd_get_canonical_inst (MonoClass
*klass
);
1405 mono_class_get_first_method_idx (MonoClass
*klass
);
1408 mono_class_set_first_method_idx (MonoClass
*klass
, guint32 idx
);
1411 mono_class_get_first_field_idx (MonoClass
*klass
);
1414 mono_class_set_first_field_idx (MonoClass
*klass
, guint32 idx
);
1417 mono_class_get_method_count (MonoClass
*klass
);
1420 mono_class_set_method_count (MonoClass
*klass
, guint32 count
);
1423 mono_class_get_field_count (MonoClass
*klass
);
1426 mono_class_set_field_count (MonoClass
*klass
, guint32 count
);
1429 mono_class_get_marshal_info (MonoClass
*klass
);
1432 mono_class_set_marshal_info (MonoClass
*klass
, MonoMarshalType
*marshal_info
);
1435 mono_class_get_ref_info_handle (MonoClass
*klass
);
1438 mono_class_set_ref_info_handle (MonoClass
*klass
, gpointer value
);
1441 mono_class_get_exception_data (MonoClass
*klass
);
1444 mono_class_set_exception_data (MonoClass
*klass
, MonoErrorBoxed
*value
);
1447 mono_class_get_nested_classes_property (MonoClass
*klass
);
1450 mono_class_set_nested_classes_property (MonoClass
*klass
, GList
*value
);
1452 MonoClassPropertyInfo
*
1453 mono_class_get_property_info (MonoClass
*klass
);
1456 mono_class_set_property_info (MonoClass
*klass
, MonoClassPropertyInfo
*info
);
1459 mono_class_get_event_info (MonoClass
*klass
);
1462 mono_class_set_event_info (MonoClass
*klass
, MonoClassEventInfo
*info
);
1464 MonoFieldDefaultValue
*
1465 mono_class_get_field_def_values (MonoClass
*klass
);
1468 mono_class_set_field_def_values (MonoClass
*klass
, MonoFieldDefaultValue
*values
);
1471 mono_class_get_declsec_flags (MonoClass
*klass
);
1474 mono_class_set_declsec_flags (MonoClass
*klass
, guint32 value
);
1477 mono_class_set_is_com_object (MonoClass
*klass
);
1480 mono_class_set_weak_bitmap (MonoClass
*klass
, int nbits
, gsize
*bits
);
1483 mono_class_get_weak_bitmap (MonoClass
*klass
, int *nbits
);
1486 mono_class_has_dim_conflicts (MonoClass
*klass
);
1489 mono_class_set_dim_conflicts (MonoClass
*klass
, GSList
*conflicts
);
1492 mono_class_get_dim_conflicts (MonoClass
*klass
);
1495 mono_class_get_method_from_name_checked (MonoClass
*klass
, const char *name
, int param_count
, int flags
, MonoError
*error
);
1498 mono_method_has_no_body (MonoMethod
*method
);
1500 // FIXME Replace all internal callers of mono_method_get_header_checked with
1501 // mono_method_get_header_internal; the difference is in error initialization.
1503 // And then mark mono_method_get_header_checked as MONO_RT_EXTERNAL_ONLY MONO_API.
1505 // Internal callers expected to use ERROR_DECL. External callers are not.
1507 mono_method_get_header_internal (MonoMethod
*method
, MonoError
*error
);
1510 mono_class_find_enum_basetype (MonoClass
*klass
, MonoError
*error
);
1513 mono_class_set_failure (MonoClass
*klass
, MonoErrorBoxed
*boxed_error
);
1516 mono_class_set_type_load_failure_causedby_class (MonoClass
*klass
, const MonoClass
*caused_by
, const gchar
* msg
);
1518 gboolean
mono_class_get_cached_class_info (MonoClass
*klass
, MonoCachedClassInfo
*res
);
1520 MonoMethod
* mono_find_method_in_metadata (MonoClass
*klass
, const char *name
, int param_count
, int flags
);
1523 mono_class_get_object_finalize_slot (void);
1526 mono_class_get_default_finalize_method (void);
1529 mono_field_resolve_type (MonoClassField
*field
, MonoError
*error
);
1532 mono_type_has_exceptions (MonoType
*type
);
1535 mono_class_set_nonblittable (MonoClass
*klass
);
1538 mono_class_publish_gc_descriptor (MonoClass
*klass
, MonoGCDescriptor gc_descr
);
1541 mono_class_compute_gc_descriptor (MonoClass
*klass
);
1543 #ifndef DISABLE_REMOTING
1545 mono_class_contextbound_bit_offset (int* byte_offset_out
, guint8
* mask_out
);
1549 mono_class_init_checked (MonoClass
*klass
, MonoError
*error
);
1552 mono_class_enum_basetype_internal (MonoClass
*klass
);
1555 mono_method_is_constructor (MonoMethod
*method
);
1558 mono_class_has_default_constructor (MonoClass
*klass
, gboolean public_only
);
1561 mono_method_has_unmanaged_callers_only_attribute (MonoMethod
*method
);
1563 // There are many ways to do on-demand initialization.
1564 // Some allow multiple concurrent initializations. Some do not.
1565 // Some allow multiple concurrent writes to the global. Some do not.
1567 // Booleans or names capturing these factors would be desirable.
1570 // This form allows both such races, on the understanding that,
1571 // even if the initialization occurs multiple times, every result is equivalent,
1572 // and the goal is not to initialize no more than once, but for the steady state
1573 // to stop rerunning the initialization.
1575 // It may be desirable to replace this with mono_lazy_initialize, etc.
1577 // These macros cannot be wrapped in do/while as they inject "name" into invoking scope.
1579 #define MONO_STATIC_POINTER_INIT(type, name) \
1580 static type *static_ ## name; \
1582 name = static_ ## name; \
1584 /* Custom code here to initialize name */
1585 #define MONO_STATIC_POINTER_INIT_END(type, name) \
1587 /* Success, commit to static. */ \
1588 mono_atomic_store_seq (&static_ ## name, name); \
1592 static inline gboolean
1593 m_field_get_offset (MonoClassField
*field
)
1595 g_assert (m_class_is_fields_inited (field
->parent
));
1596 return field
->offset
;
1600 * Memory allocation for classes/methods
1602 * These should be used to allocate memory whose lifetime is equal to
1603 * the lifetime of the domain+class/method pair.
1606 static inline MonoMemoryManager
*
1607 m_class_get_mem_manager (MonoDomain
*domain
, MonoClass
*klass
)
1609 #ifdef ENABLE_NETCORE
1611 return mono_domain_memory_manager (domain
);
1613 return mono_domain_memory_manager (domain
);
1617 static inline void *
1618 m_class_alloc (MonoDomain
*domain
, MonoClass
*klass
, guint size
)
1620 return mono_mem_manager_alloc (m_class_get_mem_manager (domain
, klass
), size
);
1623 static inline void *
1624 m_class_alloc0 (MonoDomain
*domain
, MonoClass
*klass
, guint size
)
1626 return mono_mem_manager_alloc0 (m_class_get_mem_manager (domain
, klass
), size
);
1629 static inline MonoMemoryManager
*
1630 m_method_get_mem_manager (MonoDomain
*domain
, MonoMethod
*method
)
1632 #ifdef ENABLE_NETCORE
1634 return mono_domain_memory_manager (domain
);
1636 return mono_domain_memory_manager (domain
);
1640 static inline void *
1641 m_method_alloc (MonoDomain
*domain
, MonoMethod
*method
, guint size
)
1643 return mono_mem_manager_alloc (m_method_get_mem_manager (domain
, method
), size
);
1646 static inline void *
1647 m_method_alloc0 (MonoDomain
*domain
, MonoMethod
*method
, guint size
)
1649 return mono_mem_manager_alloc0 (m_method_get_mem_manager (domain
, method
), size
);
1652 // Enum and static storage for JIT icalls.
1653 #include "jit-icall-reg.h"
1655 /*Now that everything has been defined, let's include the inline functions */
1656 #include <mono/metadata/class-inlines.h>
1658 #endif /* __MONO_METADATA_CLASS_INTERNALS_H__ */