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;
62 struct _MonoMethodNormal {
64 MonoMethodHeader *header;
67 struct _MonoMethodWrapper {
68 MonoMethodNormal method;
72 struct _MonoMethodInflated {
73 MonoMethodNormal nmethod;
74 MonoGenericContext *context;
75 MonoMethod *declaring;
78 struct _MonoMethodPInvoke {
81 /* add marshal info */
82 guint16 piflags; /* pinvoke flags */
83 guint16 implmap_idx; /* index into IMPLMAP */
87 MonoType *generic_type;
88 gpointer reflection_info;
92 * MonoClassField is just a runtime representation of the metadata for
93 * field, it doesn't contain the data directly. Static fields are
94 * stored in MonoVTable->data. Instance fields are allocated in the
95 * objects after the object header.
97 struct _MonoClassField {
98 /* Type of the field */
101 /* If this is an instantiated generic type, this is the
102 * "original" type, ie. the MONO_TYPE_VAR or MONO_TYPE_GENERICINST
103 * it was instantiated from.
105 MonoInflatedField *generic_info;
108 * Offset where this field is stored; if it is an instance
109 * field, it's the offset from the start of the object, if
110 * it's static, it's from the start of the memory chunk
111 * allocated for statics for the class.
118 * If the field is constant, pointer to the metadata constant
120 * If the field has an RVA flag, pointer to the data.
125 /* Type where the field was defined */
129 * If the field is constant, the type of the constant.
131 MonoTypeEnum def_type;
134 /* a field is ignored if it's named "_Deleted" and it has the specialname and rtspecialname flags set */
135 #define mono_field_is_deleted(field) ((field)->name[0] == '_' && ((field)->type->attrs & 0x600) && (strcmp ((field)->name, "_Deleted") == 0))
138 MonoClassField *field;
140 MonoMarshalSpec *mspec;
146 MonoMarshalField fields [MONO_ZERO_LEN_ARRAY];
149 struct _MonoProperty {
170 /* The underlying type of the enum */
171 MonoType *enum_basetype;
172 /* element class for arrays and enum */
173 MonoClass *element_class;
174 /* used for subtype checks */
175 MonoClass *cast_class;
176 /* array dimension */
180 /* We use init_pending to detect cyclic calls to mono_class_init */
181 guint init_pending : 1;
183 /* A class contains static and non static data. Static data can be
184 * of the same type as the class itselfs, but it does not influence
185 * the instance size of the class. To avoid cyclic calls to
186 * mono_class_init (from mono_class_instance_size ()) we first
187 * initialise all non static fields. After that we set size_inited
188 * to 1, because we know the instance size now. After that we
189 * initialise all static fields.
191 guint size_inited : 1;
192 guint valuetype : 1; /* derives from System.ValueType */
193 guint enumtype : 1; /* derives from System.Enum */
194 guint blittable : 1; /* class is blittable */
195 guint unicode : 1; /* class uses unicode char when marshalled */
196 guint wastypebuilder : 1; /* class was created at runtime from a TypeBuilder */
199 guint packing_size : 4;
201 guint ghcimpl : 1; /* class has its own GetHashCode impl */
202 guint has_finalize : 1; /* class has its own Finalize impl */
203 guint marshalbyref : 1; /* class is a MarshalByRefObject */
204 guint contextbound : 1; /* class is a ContextBoundObject */
205 guint delegate : 1; /* class is a Delegate */
206 guint gc_descr_inited : 1; /* gc_descr is initialized */
207 guint dummy : 1; /* temporary hack */
210 MonoClass *nested_in;
211 GList *nested_classes;
215 const char *name_space;
217 guint interface_count;
218 guint interface_id; /* unique inderface id (for interfaces) */
219 guint max_interface_id;
220 gint *interface_offsets;
221 MonoClass **interfaces;
223 /* for fast subtype checks */
225 MonoClass **supertypes;
228 * Computed object instance size, total.
232 int vtable_size; /* number of slots */
235 * From the TypeDef table
241 } field, method, property, event;
243 /* loaded on demand */
244 MonoMarshalType *marshal_info;
247 * Field information: Type and location from object base
249 MonoClassField *fields;
251 MonoProperty *properties;
255 MonoMethod **methods;
257 /* used as the type of the this argument and when passing the arg by value */
261 MonoGenericInst *generic_inst;
262 MonoGenericParam *gen_params;
263 guint16 num_gen_params;
265 void *reflection_info;
270 MonoMethod *ptr_to_str;
271 MonoMethod *str_to_ptr;
273 MonoVTable *cached_vtable;
280 * According to comments in gc_gcj.h, this should be the second word in
284 MonoDomain *domain; /* each object/vtable belongs to exactly one domain */
285 guint32 max_interface_id;
286 gpointer *interface_offsets;
287 gpointer data; /* to store static class data */
288 gpointer type; /* System.Type type for klass */
289 guint remote : 1; /* class is remotely activated */
290 guint initialized : 1; /* cctor has been run */
291 /* do not add any fields after vtable, the structure is dynamically extended */
292 gpointer vtable [MONO_ZERO_LEN_ARRAY];
296 * Generic instantiation data type encoding.
298 struct _MonoGenericInst {
299 MonoGenericContext *context;
304 MonoType *generic_type;
305 MonoDynamicGenericInst *dynamic_info;
307 MonoType **type_argv;
309 guint initialized : 1;
310 guint init_pending : 1;
311 guint is_dynamic : 1;
314 struct _MonoDynamicGenericInst {
316 MonoMethod **methods;
320 MonoClassField *fields;
321 int count_properties;
322 MonoProperty *properties;
327 struct _MonoGenericMethod {
328 gpointer reflection_info;
330 MonoType **mtype_argv;
334 struct _MonoGenericContext {
335 MonoGenericInst *ginst;
336 MonoGenericMethod *gmethod;
339 struct _MonoGenericParam {
345 MonoClass** constraints; /* NULL means end of list */
351 gconstpointer wrapper;
352 MonoMethodSignature *sig;
355 #define mono_class_has_parent(klass,parent) (((klass)->idepth >= (parent)->idepth) && ((klass)->supertypes [(parent)->idepth - 1] == (parent)))
358 gulong new_object_count;
359 gulong initialized_class_count;
360 gulong used_class_count;
361 gulong class_vtable_size;
362 gulong class_static_data_size;
363 gulong generic_instance_count;
364 gulong inflated_method_count;
365 gulong inflated_type_count;
366 gulong generics_metadata_size;
369 extern MonoStats mono_stats;
371 typedef gpointer (*MonoTrampoline) (MonoMethod *method);
373 typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token);
376 mono_classes_init (void);
379 mono_class_layout_fields (MonoClass *klass);
382 mono_class_setup_vtable (MonoClass *klass, MonoMethod **overrides, int onum);
385 mono_class_setup_mono_type (MonoClass *klass);
388 mono_class_setup_parent (MonoClass *klass, MonoClass *parent);
391 mono_class_setup_supertypes (MonoClass *klass);
394 mono_class_is_open_constructed_type (MonoType *t);
397 mono_class_get_overrides (MonoImage *image, guint32 type_token, gint32 *num_overrides);
400 mono_class_needs_cctor_run (MonoClass *klass, MonoMethod *caller);
403 mono_install_trampoline (MonoTrampoline func);
406 mono_install_remoting_trampoline (MonoTrampoline func);
409 mono_lookup_dynamic_token (MonoImage *image, guint32 token);
412 mono_install_lookup_dynamic_token (MonoLookupDynamicToken func);
416 MonoClass *object_class;
417 MonoClass *byte_class;
418 MonoClass *void_class;
419 MonoClass *boolean_class;
420 MonoClass *sbyte_class;
421 MonoClass *int16_class;
422 MonoClass *uint16_class;
423 MonoClass *int32_class;
424 MonoClass *uint32_class;
425 MonoClass *int_class;
426 MonoClass *uint_class;
427 MonoClass *int64_class;
428 MonoClass *uint64_class;
429 MonoClass *single_class;
430 MonoClass *double_class;
431 MonoClass *char_class;
432 MonoClass *string_class;
433 MonoClass *enum_class;
434 MonoClass *array_class;
435 MonoClass *delegate_class;
436 MonoClass *multicastdelegate_class;
437 MonoClass *asyncresult_class;
438 MonoClass *waithandle_class;
439 MonoClass *typehandle_class;
440 MonoClass *fieldhandle_class;
441 MonoClass *methodhandle_class;
442 MonoClass *monotype_class;
443 MonoClass *exception_class;
444 MonoClass *threadabortexception_class;
445 MonoClass *thread_class;
446 MonoClass *transparent_proxy_class;
447 MonoClass *real_proxy_class;
448 MonoClass *mono_method_message_class;
449 MonoClass *appdomain_class;
450 MonoClass *field_info_class;
451 MonoClass *method_info_class;
452 MonoClass *stringbuilder_class;
453 MonoClass *math_class;
454 MonoClass *stack_frame_class;
455 MonoClass *stack_trace_class;
456 MonoClass *marshal_class;
457 MonoClass *iserializeable_class;
458 MonoClass *serializationinfo_class;
459 MonoClass *streamingcontext_class;
460 MonoClass *typed_reference_class;
461 MonoClass *argumenthandle_class;
462 MonoClass *marshalbyrefobject_class;
463 MonoClass *monitor_class;
464 MonoClass *iremotingtypeinfo_class;
467 extern MonoDefaults mono_defaults;
470 mono_loader_init (void);
473 mono_loader_lock (void);
476 mono_loader_unlock (void);
479 mono_init_icall (void);
482 mono_method_get_wrapper_data (MonoMethod *method, guint32 id);
485 mono_install_stack_walk (MonoStackWalkImpl func);
487 MonoGenericParam *mono_metadata_load_generic_params (MonoImage *image, guint32 token, guint32 *num);
490 mono_create_icall_signature (const char *sigstr);
493 mono_register_jit_icall (gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean is_save);
496 mono_register_jit_icall_wrapper (MonoJitICallInfo *info, gconstpointer wrapper);
499 mono_find_jit_icall_by_name (const char *name);
502 mono_find_jit_icall_by_addr (gconstpointer addr);
504 #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */