[2020-02] Fix leak in assembly-specific dllmap lookups (#21053)
[mono-project.git] / mono / metadata / class-private-definition.h
blob9191bd0353f00e76bd455e978e1fcdffced1790f
1 /**
2 * \file Definitions of struct _MonoClass members
4 * NOTE: This file should NOT be included directly.
5 */
7 #if defined(MONO_CLASS_DEF_PRIVATE) && !defined(REALLY_INCLUDE_CLASS_DEF)
8 #error struct _MonoClass definition should not be accessed directly
9 #endif
11 #ifndef __MONO_METADATA_CLASS_PRIVATE_DEFINITION_H__
12 #define __MONO_METADATA_CLASS_PRIVATE_DEFINITION_H__
14 struct _MonoClass {
15 /* element class for arrays and enum basetype for enums */
16 MonoClass *element_class;
17 /* used for subtype checks */
18 MonoClass *cast_class;
20 /* for fast subtype checks */
21 MonoClass **supertypes;
22 guint16 idepth;
24 /* array dimension */
25 guint8 rank;
27 /* One of the values from MonoTypeKind */
28 guint8 class_kind;
30 int instance_size; /* object instance size */
32 guint inited : 1;
34 /* A class contains static and non static data. Static data can be
35 * of the same type as the class itselfs, but it does not influence
36 * the instance size of the class. To avoid cyclic calls to
37 * mono_class_init_internal (from mono_class_instance_size ()) we first
38 * initialise all non static fields. After that we set size_inited
39 * to 1, because we know the instance size now. After that we
40 * initialise all static fields.
43 /* ALL BITFIELDS SHOULD BE WRITTEN WHILE HOLDING THE LOADER LOCK */
44 guint size_inited : 1;
45 guint valuetype : 1; /* derives from System.ValueType */
46 guint enumtype : 1; /* derives from System.Enum */
47 guint blittable : 1; /* class is blittable */
48 guint unicode : 1; /* class uses unicode char when marshalled */
49 guint wastypebuilder : 1; /* class was created at runtime from a TypeBuilder */
50 guint is_array_special_interface : 1; /* gtd or ginst of once of the magic interfaces that arrays implement */
51 guint is_byreflike : 1; /* class is a valuetype and has System.Runtime.CompilerServices.IsByRefLikeAttribute */
53 /* next byte */
54 guint8 min_align;
56 /* next byte */
57 guint packing_size : 4;
58 guint ghcimpl : 1; /* class has its own GetHashCode impl */
59 guint has_finalize : 1; /* class has its own Finalize impl */
60 #ifndef DISABLE_REMOTING
61 guint marshalbyref : 1; /* class is a MarshalByRefObject */
62 guint contextbound : 1; /* class is a ContextBoundObject */
63 #endif
64 /* next byte */
65 guint delegate : 1; /* class is a Delegate */
66 guint gc_descr_inited : 1; /* gc_descr is initialized */
67 guint has_cctor : 1; /* class has a cctor */
68 guint has_references : 1; /* it has GC-tracked references in the instance */
69 guint has_static_refs : 1; /* it has static fields that are GC-tracked */
70 guint no_special_static_fields : 1; /* has no thread/context static fields */
71 /* directly or indirectly derives from ComImport attributed class.
72 * this means we need to create a proxy for instances of this class
73 * for COM Interop. set this flag on loading so all we need is a quick check
74 * during object creation rather than having to traverse supertypes
76 guint is_com_object : 1;
77 guint nested_classes_inited : 1; /* Whenever nested_class is initialized */
79 /* next byte*/
80 guint interfaces_inited : 1; /* interfaces is initialized */
81 guint simd_type : 1; /* class is a simd intrinsic type */
82 guint has_finalize_inited : 1; /* has_finalize is initialized */
83 guint fields_inited : 1; /* setup_fields () has finished */
84 guint has_failure : 1; /* See mono_class_get_exception_data () for a MonoErrorBoxed with the details */
85 guint has_weak_fields : 1; /* class has weak reference fields */
86 guint has_dim_conflicts : 1; /* Class has conflicting default interface methods */
88 MonoClass *parent;
89 MonoClass *nested_in;
91 MonoImage *image;
92 const char *name;
93 const char *name_space;
95 guint32 type_token;
96 int vtable_size; /* number of slots */
98 guint16 interface_count;
99 guint32 interface_id; /* unique inderface id (for interfaces) */
100 guint32 max_interface_id;
102 guint16 interface_offsets_count;
103 MonoClass **interfaces_packed;
104 guint16 *interface_offsets_packed;
105 guint8 *interface_bitmap;
107 MonoClass **interfaces;
109 union _MonoClassSizes sizes;
112 * Field information: Type and location from object base
114 MonoClassField *fields;
116 MonoMethod **methods;
118 /* used as the type of the this argument and when passing the arg by value */
119 MonoType this_arg;
120 MonoType _byval_arg;
122 MonoGCDescriptor gc_descr;
124 MonoClassRuntimeInfo *runtime_info;
126 /* Generic vtable. Initialized by a call to mono_class_setup_vtable () */
127 MonoMethod **vtable;
129 /* Infrequently used items. See class-accessors.c: InfrequentDataKind for what goes into here. */
130 MonoPropertyBag infrequent_data;
133 struct _MonoClassDef {
134 MonoClass klass;
135 guint32 flags;
137 * From the TypeDef table
139 guint32 first_method_idx;
140 guint32 first_field_idx;
141 guint32 method_count, field_count;
142 /* next element in the class_cache hash list (in MonoImage) */
143 MonoClass *next_class_cache;
146 struct _MonoClassGtd {
147 MonoClassDef klass;
148 MonoGenericContainer *generic_container;
149 /* The canonical GENERICINST where we instantiate a generic type definition with its own generic parameters.*/
150 /* Suppose we have class T`2<A,B> {...}. canonical_inst is the GTD T`2 applied to A and B. */
151 MonoType canonical_inst;
154 struct _MonoClassGenericInst {
155 MonoClass klass;
156 MonoGenericClass *generic_class;
159 struct _MonoClassGenericParam {
160 MonoClass klass;
163 struct _MonoClassArray {
164 MonoClass klass;
165 guint32 method_count;
168 struct _MonoClassPointer {
169 MonoClass klass;
173 #endif