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, gboolean do_il_offset, 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,
30 MONO_WRAPPER_XDOMAIN_INVOKE,
31 MONO_WRAPPER_XDOMAIN_DISPATCH,
34 MONO_WRAPPER_SYNCHRONIZED,
35 MONO_WRAPPER_DYNAMIC_METHOD,
37 MONO_WRAPPER_CASTCLASS,
38 MONO_WRAPPER_PROXY_ISINST,
39 MONO_WRAPPER_STELEMREF,
44 MONO_REMOTING_TARGET_UNKNOWN,
45 MONO_REMOTING_TARGET_APPDOMAIN
49 guint16 flags; /* method flags */
50 guint16 iflags; /* method implementation flags */
53 MonoMethodSignature *signature;
54 gpointer info; /* runtime info */
55 /* name is useful mostly for debugging */
57 /* this is used by the inlining algorithm */
58 unsigned int inline_info:1;
59 unsigned int uses_this:1;
60 unsigned int wrapper_type:5;
61 unsigned int string_ctor:1;
62 unsigned int save_lmf:1;
63 unsigned int dynamic:1; /* created & destroyed during runtime */
67 struct _MonoMethodNormal {
69 MonoGenericContainer *generic_container;
70 MonoMethodHeader *header;
73 struct _MonoMethodWrapper {
74 MonoMethodNormal method;
78 struct _MonoMethodInflated {
79 MonoMethodNormal nmethod;
80 MonoGenericContext *context;
81 MonoMethod *declaring;
84 struct _MonoMethodPInvoke {
87 /* add marshal info */
88 guint16 piflags; /* pinvoke flags */
89 guint16 implmap_idx; /* index into IMPLMAP */
93 MonoType *generic_type;
94 gpointer reflection_info;
98 * MonoClassField is just a runtime representation of the metadata for
99 * field, it doesn't contain the data directly. Static fields are
100 * stored in MonoVTable->data. Instance fields are allocated in the
101 * objects after the object header.
103 struct _MonoClassField {
104 /* Type of the field */
107 /* If this is an instantiated generic type, this is the
108 * "original" type, ie. the MONO_TYPE_VAR or MONO_TYPE_GENERICINST
109 * it was instantiated from.
111 MonoInflatedField *generic_info;
114 * Offset where this field is stored; if it is an instance
115 * field, it's the offset from the start of the object, if
116 * it's static, it's from the start of the memory chunk
117 * allocated for statics for the class.
124 * If the field is constant, pointer to the metadata constant
126 * If the field has an RVA flag, pointer to the data.
131 /* Type where the field was defined */
135 * If the field is constant, the type of the constant.
137 MonoTypeEnum def_type;
140 /* a field is ignored if it's named "_Deleted" and it has the specialname and rtspecialname flags set */
141 #define mono_field_is_deleted(field) ((field)->name[0] == '_' && ((field)->type->attrs & 0x600) && (strcmp ((field)->name, "_Deleted") == 0))
144 MonoClassField *field;
146 MonoMarshalSpec *mspec;
152 MonoMarshalField fields [MONO_ZERO_LEN_ARRAY];
155 struct _MonoProperty {
176 /* The underlying type of the enum */
177 MonoType *enum_basetype;
178 /* element class for arrays and enum */
179 MonoClass *element_class;
180 /* used for subtype checks */
181 MonoClass *cast_class;
182 /* array dimension */
186 /* We use init_pending to detect cyclic calls to mono_class_init */
187 guint init_pending : 1;
189 /* A class contains static and non static data. Static data can be
190 * of the same type as the class itselfs, but it does not influence
191 * the instance size of the class. To avoid cyclic calls to
192 * mono_class_init (from mono_class_instance_size ()) we first
193 * initialise all non static fields. After that we set size_inited
194 * to 1, because we know the instance size now. After that we
195 * initialise all static fields.
197 guint size_inited : 1;
198 guint valuetype : 1; /* derives from System.ValueType */
199 guint enumtype : 1; /* derives from System.Enum */
200 guint blittable : 1; /* class is blittable */
201 guint unicode : 1; /* class uses unicode char when marshalled */
202 guint wastypebuilder : 1; /* class was created at runtime from a TypeBuilder */
205 guint packing_size : 4;
207 guint ghcimpl : 1; /* class has its own GetHashCode impl */
208 guint has_finalize : 1; /* class has its own Finalize impl */
209 guint marshalbyref : 1; /* class is a MarshalByRefObject */
210 guint contextbound : 1; /* class is a ContextBoundObject */
211 guint delegate : 1; /* class is a Delegate */
212 guint gc_descr_inited : 1; /* gc_descr is initialized */
213 guint dummy : 1; /* temporary hack */
216 MonoClass *nested_in;
217 GList *nested_classes;
221 const char *name_space;
223 guint interface_count;
224 guint interface_id; /* unique inderface id (for interfaces) */
225 guint max_interface_id;
226 gint *interface_offsets;
227 MonoClass **interfaces;
229 /* for fast subtype checks */
231 MonoClass **supertypes;
234 * Computed object instance size, total.
238 int vtable_size; /* number of slots */
241 * From the TypeDef table
247 } field, method, property, event;
249 /* loaded on demand */
250 MonoMarshalType *marshal_info;
253 * Field information: Type and location from object base
255 MonoClassField *fields;
257 MonoProperty *properties;
261 MonoMethod **methods;
263 /* used as the type of the this argument and when passing the arg by value */
267 MonoGenericInst *generic_inst;
268 MonoGenericContainer *generic_container;
270 void *reflection_info;
275 MonoMethod *ptr_to_str;
276 MonoMethod *str_to_ptr;
278 MonoVTable *cached_vtable;
285 * According to comments in gc_gcj.h, this should be the second word in
289 MonoDomain *domain; /* each object/vtable belongs to exactly one domain */
290 guint32 max_interface_id;
291 gpointer *interface_offsets;
292 gpointer data; /* to store static class data */
293 gpointer type; /* System.Type type for klass */
294 guint remote : 1; /* class is remotely activated */
295 guint initialized : 1; /* cctor has been run */
296 /* do not add any fields after vtable, the structure is dynamically extended */
297 gpointer vtable [MONO_ZERO_LEN_ARRAY];
301 * Generic instantiation data type encoding.
303 struct _MonoGenericInst {
304 MonoGenericContainer *container;
305 MonoGenericContext *context;
310 MonoType *generic_type;
311 MonoDynamicGenericInst *dynamic_info;
313 MonoType **type_argv;
315 guint initialized : 1;
316 guint init_pending : 1;
317 guint is_dynamic : 1;
320 struct _MonoDynamicGenericInst {
322 MonoMethod **methods;
326 MonoClassField *fields;
327 int count_properties;
328 MonoProperty *properties;
333 struct _MonoGenericMethod {
334 MonoGenericContainer *container;
335 gpointer reflection_info;
337 MonoType **mtype_argv;
341 struct _MonoGenericContext {
342 MonoGenericContainer *container;
343 MonoGenericInst *ginst;
344 MonoGenericMethod *gmethod;
347 struct _MonoGenericContainer {
348 MonoGenericContainer *parent;
349 MonoGenericContext *context;
350 GHashTable *method_hash;
354 int is_signature : 1;
355 MonoGenericParam *type_params;
358 struct _MonoGenericParam {
359 MonoGenericContainer *owner;
365 MonoClass** constraints; /* NULL means end of list */
371 gconstpointer wrapper;
372 MonoMethodSignature *sig;
375 #define mono_class_has_parent(klass,parent) (((klass)->idepth >= (parent)->idepth) && ((klass)->supertypes [(parent)->idepth - 1] == (parent)))
378 gulong new_object_count;
379 gulong initialized_class_count;
380 gulong used_class_count;
381 gulong class_vtable_size;
382 gulong class_static_data_size;
383 gulong generic_instance_count;
384 gulong inflated_method_count;
385 gulong inflated_type_count;
386 gulong generics_metadata_size;
390 extern MonoStats mono_stats;
392 typedef gpointer (*MonoTrampoline) (MonoMethod *method);
393 typedef gpointer (*MonoRemotingTrampoline) (MonoMethod *method, MonoRemotingTarget target);
395 typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token);
398 mono_classes_init (void);
401 mono_class_layout_fields (MonoClass *klass);
404 mono_class_setup_vtable (MonoClass *klass, MonoMethod **overrides, int onum);
407 mono_class_setup_mono_type (MonoClass *klass);
410 mono_class_setup_parent (MonoClass *klass, MonoClass *parent);
413 mono_class_setup_supertypes (MonoClass *klass);
416 mono_class_get_implemented_interfaces (MonoClass *klass);
419 mono_class_is_open_constructed_type (MonoType *t);
422 mono_class_get_overrides (MonoImage *image, guint32 type_token, gint32 *num_overrides);
425 mono_class_needs_cctor_run (MonoClass *klass, MonoMethod *caller);
428 mono_install_trampoline (MonoTrampoline func);
431 mono_install_remoting_trampoline (MonoRemotingTrampoline func);
434 mono_lookup_dynamic_token (MonoImage *image, guint32 token);
437 mono_install_lookup_dynamic_token (MonoLookupDynamicToken func);
440 mono_class_create_generic (MonoGenericInst *ginst);
443 mono_class_create_generic_2 (MonoGenericInst *ginst);
447 MonoClass *object_class;
448 MonoClass *byte_class;
449 MonoClass *void_class;
450 MonoClass *boolean_class;
451 MonoClass *sbyte_class;
452 MonoClass *int16_class;
453 MonoClass *uint16_class;
454 MonoClass *int32_class;
455 MonoClass *uint32_class;
456 MonoClass *int_class;
457 MonoClass *uint_class;
458 MonoClass *int64_class;
459 MonoClass *uint64_class;
460 MonoClass *single_class;
461 MonoClass *double_class;
462 MonoClass *char_class;
463 MonoClass *string_class;
464 MonoClass *enum_class;
465 MonoClass *array_class;
466 MonoClass *delegate_class;
467 MonoClass *multicastdelegate_class;
468 MonoClass *asyncresult_class;
469 MonoClass *waithandle_class;
470 MonoClass *typehandle_class;
471 MonoClass *fieldhandle_class;
472 MonoClass *methodhandle_class;
473 MonoClass *monotype_class;
474 MonoClass *exception_class;
475 MonoClass *threadabortexception_class;
476 MonoClass *thread_class;
477 MonoClass *transparent_proxy_class;
478 MonoClass *real_proxy_class;
479 MonoClass *mono_method_message_class;
480 MonoClass *appdomain_class;
481 MonoClass *field_info_class;
482 MonoClass *method_info_class;
483 MonoClass *stringbuilder_class;
484 MonoClass *math_class;
485 MonoClass *stack_frame_class;
486 MonoClass *stack_trace_class;
487 MonoClass *marshal_class;
488 MonoClass *iserializeable_class;
489 MonoClass *serializationinfo_class;
490 MonoClass *streamingcontext_class;
491 MonoClass *typed_reference_class;
492 MonoClass *argumenthandle_class;
493 MonoClass *marshalbyrefobject_class;
494 MonoClass *monitor_class;
495 MonoClass *iremotingtypeinfo_class;
498 extern MonoDefaults mono_defaults;
501 mono_loader_init (void);
504 mono_loader_lock (void);
507 mono_loader_unlock (void);
510 mono_init_icall (void);
513 mono_method_get_wrapper_data (MonoMethod *method, guint32 id);
516 mono_install_stack_walk (MonoStackWalkImpl func);
518 MonoGenericContainer *mono_metadata_load_generic_params (MonoImage *image, guint32 token);
521 mono_create_icall_signature (const char *sigstr);
524 mono_register_jit_icall (gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean is_save);
527 mono_register_jit_icall_wrapper (MonoJitICallInfo *info, gconstpointer wrapper);
530 mono_find_jit_icall_by_name (const char *name);
533 mono_find_jit_icall_by_addr (gconstpointer addr);
535 #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */