1 #ifndef __MONO_METADATA_CLASS_INTERBALS_H__
2 #define __MONO_METADATA_CLASS_INTERBALS_H__
4 #include <mono/metadata/class.h>
5 #include <mono/io-layer/io-layer.h>
7 #define MONO_CLASS_IS_ARRAY(c) ((c)->rank)
9 #define MONO_DEFAULT_SUPERTABLE_SIZE 6
11 extern gboolean mono_print_vtable;
13 typedef void (*MonoStackWalkImpl) (MonoStackWalk func, gpointer user_data);
15 typedef struct _MonoMethodNormal MonoMethodNormal;
16 typedef struct _MonoMethodWrapper MonoMethodWrapper;
17 typedef struct _MonoMethodInflated MonoMethodInflated;
18 typedef struct _MonoMethodPInvoke MonoMethodPInvoke;
22 MONO_WRAPPER_DELEGATE_INVOKE,
23 MONO_WRAPPER_DELEGATE_BEGIN_INVOKE,
24 MONO_WRAPPER_DELEGATE_END_INVOKE,
25 MONO_WRAPPER_RUNTIME_INVOKE,
26 MONO_WRAPPER_NATIVE_TO_MANAGED,
27 MONO_WRAPPER_MANAGED_TO_NATIVE,
28 MONO_WRAPPER_REMOTING_INVOKE,
29 MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK,
32 MONO_WRAPPER_SYNCHRONIZED,
33 MONO_WRAPPER_DYNAMIC_METHOD,
35 MONO_WRAPPER_CASTCLASS,
36 MONO_WRAPPER_PROXY_ISINST,
37 MONO_WRAPPER_STELEMREF,
42 guint16 flags; /* method flags */
43 guint16 iflags; /* method implementation flags */
46 MonoMethodSignature *signature;
48 gpointer info; /* runtime info */
49 gpointer remoting_tramp;
51 /* name is useful mostly for debugging */
53 /* this is used by the inlining algorithm */
54 unsigned int inline_info:1;
55 unsigned int uses_this:1;
56 unsigned int wrapper_type:5;
57 unsigned int string_ctor:1;
58 unsigned int save_lmf:1;
59 unsigned int dynamic:1; /* created & destroyed during runtime */
63 struct _MonoMethodNormal {
65 MonoGenericParam *gen_params;
66 MonoMethodHeader *header;
69 struct _MonoMethodWrapper {
70 MonoMethodNormal method;
74 struct _MonoMethodInflated {
75 MonoMethodNormal nmethod;
76 MonoGenericContext *context;
77 MonoMethod *declaring;
80 struct _MonoMethodPInvoke {
83 /* add marshal info */
84 guint16 piflags; /* pinvoke flags */
85 guint16 implmap_idx; /* index into IMPLMAP */
89 MonoType *generic_type;
90 gpointer reflection_info;
94 * MonoClassField is just a runtime representation of the metadata for
95 * field, it doesn't contain the data directly. Static fields are
96 * stored in MonoVTable->data. Instance fields are allocated in the
97 * objects after the object header.
99 struct _MonoClassField {
100 /* Type of the field */
103 /* If this is an instantiated generic type, this is the
104 * "original" type, ie. the MONO_TYPE_VAR or MONO_TYPE_GENERICINST
105 * it was instantiated from.
107 MonoInflatedField *generic_info;
110 * Offset where this field is stored; if it is an instance
111 * field, it's the offset from the start of the object, if
112 * it's static, it's from the start of the memory chunk
113 * allocated for statics for the class.
120 * If the field is constant, pointer to the metadata constant
122 * If the field has an RVA flag, pointer to the data.
127 /* Type where the field was defined */
131 * If the field is constant, the type of the constant.
133 MonoTypeEnum def_type;
136 /* a field is ignored if it's named "_Deleted" and it has the specialname and rtspecialname flags set */
137 #define mono_field_is_deleted(field) ((field)->name[0] == '_' && ((field)->type->attrs & 0x600) && (strcmp ((field)->name, "_Deleted") == 0))
140 MonoClassField *field;
142 MonoMarshalSpec *mspec;
148 MonoMarshalField fields [MONO_ZERO_LEN_ARRAY];
151 struct _MonoProperty {
172 /* The underlying type of the enum */
173 MonoType *enum_basetype;
174 /* element class for arrays and enum */
175 MonoClass *element_class;
176 /* used for subtype checks */
177 MonoClass *cast_class;
178 /* array dimension */
182 /* We use init_pending to detect cyclic calls to mono_class_init */
183 guint init_pending : 1;
185 /* A class contains static and non static data. Static data can be
186 * of the same type as the class itselfs, but it does not influence
187 * the instance size of the class. To avoid cyclic calls to
188 * mono_class_init (from mono_class_instance_size ()) we first
189 * initialise all non static fields. After that we set size_inited
190 * to 1, because we know the instance size now. After that we
191 * initialise all static fields.
193 guint size_inited : 1;
194 guint valuetype : 1; /* derives from System.ValueType */
195 guint enumtype : 1; /* derives from System.Enum */
196 guint blittable : 1; /* class is blittable */
197 guint unicode : 1; /* class uses unicode char when marshalled */
198 guint wastypebuilder : 1; /* class was created at runtime from a TypeBuilder */
201 guint packing_size : 4;
203 guint ghcimpl : 1; /* class has its own GetHashCode impl */
204 guint has_finalize : 1; /* class has its own Finalize impl */
205 guint marshalbyref : 1; /* class is a MarshalByRefObject */
206 guint contextbound : 1; /* class is a ContextBoundObject */
207 guint delegate : 1; /* class is a Delegate */
208 guint gc_descr_inited : 1; /* gc_descr is initialized */
209 guint dummy : 1; /* temporary hack */
212 MonoClass *nested_in;
213 GList *nested_classes;
217 const char *name_space;
219 guint interface_count;
220 guint interface_id; /* unique inderface id (for interfaces) */
221 guint max_interface_id;
222 gint *interface_offsets;
223 MonoClass **interfaces;
225 /* for fast subtype checks */
227 MonoClass **supertypes;
230 * Computed object instance size, total.
234 int vtable_size; /* number of slots */
237 * From the TypeDef table
243 } field, method, property, event;
245 /* loaded on demand */
246 MonoMarshalType *marshal_info;
249 * Field information: Type and location from object base
251 MonoClassField *fields;
253 MonoProperty *properties;
257 MonoMethod **methods;
259 /* used as the type of the this argument and when passing the arg by value */
263 MonoGenericInst *generic_inst;
264 MonoGenericParam *gen_params;
265 guint16 num_gen_params;
267 void *reflection_info;
272 MonoMethod *ptr_to_str;
273 MonoMethod *str_to_ptr;
275 MonoVTable *cached_vtable;
282 * According to comments in gc_gcj.h, this should be the second word in
286 MonoDomain *domain; /* each object/vtable belongs to exactly one domain */
287 guint32 max_interface_id;
288 gpointer *interface_offsets;
289 gpointer data; /* to store static class data */
290 gpointer type; /* System.Type type for klass */
291 guint remote : 1; /* class is remotely activated */
292 guint initialized : 1; /* cctor has been run */
293 /* do not add any fields after vtable, the structure is dynamically extended */
294 gpointer vtable [MONO_ZERO_LEN_ARRAY];
298 * Generic instantiation data type encoding.
300 struct _MonoGenericInst {
301 MonoGenericContext *context;
306 MonoType *generic_type;
307 MonoDynamicGenericInst *dynamic_info;
309 MonoType **type_argv;
311 guint initialized : 1;
312 guint init_pending : 1;
313 guint is_dynamic : 1;
316 struct _MonoDynamicGenericInst {
318 MonoMethod **methods;
322 MonoClassField *fields;
323 int count_properties;
324 MonoProperty *properties;
329 struct _MonoGenericMethod {
330 gpointer reflection_info;
332 MonoType **mtype_argv;
336 struct _MonoGenericContext {
337 MonoGenericInst *ginst;
338 MonoGenericMethod *gmethod;
341 struct _MonoGenericParam {
347 MonoClass** constraints; /* NULL means end of list */
353 gconstpointer wrapper;
354 MonoMethodSignature *sig;
357 #define mono_class_has_parent(klass,parent) (((klass)->idepth >= (parent)->idepth) && ((klass)->supertypes [(parent)->idepth - 1] == (parent)))
360 gulong new_object_count;
361 gulong initialized_class_count;
362 gulong used_class_count;
363 gulong class_vtable_size;
364 gulong class_static_data_size;
365 gulong generic_instance_count;
366 gulong inflated_method_count;
367 gulong inflated_type_count;
368 gulong generics_metadata_size;
372 extern MonoStats mono_stats;
374 typedef gpointer (*MonoTrampoline) (MonoMethod *method);
376 typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token);
379 mono_classes_init (void);
382 mono_class_layout_fields (MonoClass *klass);
385 mono_class_setup_vtable (MonoClass *klass, MonoMethod **overrides, int onum);
388 mono_class_setup_mono_type (MonoClass *klass);
391 mono_class_setup_parent (MonoClass *klass, MonoClass *parent);
394 mono_class_setup_supertypes (MonoClass *klass);
397 mono_class_is_open_constructed_type (MonoType *t);
400 mono_class_get_overrides (MonoImage *image, guint32 type_token, gint32 *num_overrides);
403 mono_class_needs_cctor_run (MonoClass *klass, MonoMethod *caller);
406 mono_install_trampoline (MonoTrampoline func);
409 mono_install_remoting_trampoline (MonoTrampoline func);
412 mono_lookup_dynamic_token (MonoImage *image, guint32 token);
415 mono_install_lookup_dynamic_token (MonoLookupDynamicToken func);
419 MonoClass *object_class;
420 MonoClass *byte_class;
421 MonoClass *void_class;
422 MonoClass *boolean_class;
423 MonoClass *sbyte_class;
424 MonoClass *int16_class;
425 MonoClass *uint16_class;
426 MonoClass *int32_class;
427 MonoClass *uint32_class;
428 MonoClass *int_class;
429 MonoClass *uint_class;
430 MonoClass *int64_class;
431 MonoClass *uint64_class;
432 MonoClass *single_class;
433 MonoClass *double_class;
434 MonoClass *char_class;
435 MonoClass *string_class;
436 MonoClass *enum_class;
437 MonoClass *array_class;
438 MonoClass *delegate_class;
439 MonoClass *multicastdelegate_class;
440 MonoClass *asyncresult_class;
441 MonoClass *waithandle_class;
442 MonoClass *typehandle_class;
443 MonoClass *fieldhandle_class;
444 MonoClass *methodhandle_class;
445 MonoClass *monotype_class;
446 MonoClass *exception_class;
447 MonoClass *threadabortexception_class;
448 MonoClass *thread_class;
449 MonoClass *transparent_proxy_class;
450 MonoClass *real_proxy_class;
451 MonoClass *mono_method_message_class;
452 MonoClass *appdomain_class;
453 MonoClass *field_info_class;
454 MonoClass *method_info_class;
455 MonoClass *stringbuilder_class;
456 MonoClass *math_class;
457 MonoClass *stack_frame_class;
458 MonoClass *stack_trace_class;
459 MonoClass *marshal_class;
460 MonoClass *iserializeable_class;
461 MonoClass *serializationinfo_class;
462 MonoClass *streamingcontext_class;
463 MonoClass *typed_reference_class;
464 MonoClass *argumenthandle_class;
465 MonoClass *marshalbyrefobject_class;
466 MonoClass *monitor_class;
467 MonoClass *iremotingtypeinfo_class;
470 extern MonoDefaults mono_defaults;
473 mono_loader_init (void);
476 mono_loader_lock (void);
479 mono_loader_unlock (void);
482 mono_init_icall (void);
485 mono_method_get_wrapper_data (MonoMethod *method, guint32 id);
488 mono_install_stack_walk (MonoStackWalkImpl func);
490 MonoGenericParam *mono_metadata_load_generic_params (MonoImage *image, guint32 token, guint32 *num);
493 mono_create_icall_signature (const char *sigstr);
496 mono_register_jit_icall (gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean is_save);
499 mono_register_jit_icall_wrapper (MonoJitICallInfo *info, gconstpointer wrapper);
502 mono_find_jit_icall_by_name (const char *name);
505 mono_find_jit_icall_by_addr (gconstpointer addr);
507 #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */