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
,
45 MONO_REMOTING_TARGET_UNKNOWN
,
46 MONO_REMOTING_TARGET_APPDOMAIN
50 guint16 flags
; /* method flags */
51 guint16 iflags
; /* method implementation flags */
54 MonoMethodSignature
*signature
;
55 gpointer info
; /* runtime info */
56 /* name is useful mostly for debugging */
58 /* this is used by the inlining algorithm */
59 unsigned int inline_info
:1;
60 unsigned int uses_this
:1;
61 unsigned int wrapper_type
:5;
62 unsigned int string_ctor
:1;
63 unsigned int save_lmf
:1;
64 unsigned int dynamic
:1; /* created & destroyed during runtime */
65 unsigned int is_inflated
:1;
69 struct _MonoMethodNormal
{
71 MonoGenericContainer
*generic_container
;
72 MonoMethodHeader
*header
;
75 struct _MonoMethodWrapper
{
76 MonoMethodNormal method
;
80 struct _MonoMethodInflated
{
81 MonoMethodNormal nmethod
;
82 MonoGenericContext
*context
;
83 MonoMethod
*declaring
;
84 MonoMethodInflated
*inflated
;
87 struct _MonoMethodPInvoke
{
90 /* add marshal info */
91 guint16 piflags
; /* pinvoke flags */
92 guint16 implmap_idx
; /* index into IMPLMAP */
96 MonoType
*generic_type
;
97 gpointer reflection_info
;
101 * MonoClassField is just a runtime representation of the metadata for
102 * field, it doesn't contain the data directly. Static fields are
103 * stored in MonoVTable->data. Instance fields are allocated in the
104 * objects after the object header.
106 struct _MonoClassField
{
107 /* Type of the field */
110 /* If this is an instantiated generic type, this is the
111 * "original" type, ie. the MONO_TYPE_VAR or MONO_TYPE_GENERICINST
112 * it was instantiated from.
114 MonoInflatedField
*generic_info
;
117 * Offset where this field is stored; if it is an instance
118 * field, it's the offset from the start of the object, if
119 * it's static, it's from the start of the memory chunk
120 * allocated for statics for the class.
127 * If the field is constant, pointer to the metadata constant
129 * If the field has an RVA flag, pointer to the data.
134 /* Type where the field was defined */
138 * If the field is constant, the type of the constant.
140 MonoTypeEnum def_type
;
143 /* a field is ignored if it's named "_Deleted" and it has the specialname and rtspecialname flags set */
144 #define mono_field_is_deleted(field) ((field)->name[0] == '_' && ((field)->type->attrs & 0x600) && (strcmp ((field)->name, "_Deleted") == 0))
147 MonoClassField
*field
;
149 MonoMarshalSpec
*mspec
;
155 MonoMethod
*ptr_to_str
;
156 MonoMethod
*str_to_ptr
;
157 MonoMarshalField fields
[MONO_ZERO_LEN_ARRAY
];
160 struct _MonoProperty
{
181 /* The underlying type of the enum */
182 MonoType
*enum_basetype
;
183 /* element class for arrays and enum */
184 MonoClass
*element_class
;
185 /* used for subtype checks */
186 MonoClass
*cast_class
;
187 /* array dimension */
191 /* We use init_pending to detect cyclic calls to mono_class_init */
192 guint init_pending
: 1;
194 /* A class contains static and non static data. Static data can be
195 * of the same type as the class itselfs, but it does not influence
196 * the instance size of the class. To avoid cyclic calls to
197 * mono_class_init (from mono_class_instance_size ()) we first
198 * initialise all non static fields. After that we set size_inited
199 * to 1, because we know the instance size now. After that we
200 * initialise all static fields.
202 guint size_inited
: 1;
203 guint valuetype
: 1; /* derives from System.ValueType */
204 guint enumtype
: 1; /* derives from System.Enum */
205 guint blittable
: 1; /* class is blittable */
206 guint unicode
: 1; /* class uses unicode char when marshalled */
207 guint wastypebuilder
: 1; /* class was created at runtime from a TypeBuilder */
210 guint packing_size
: 4;
212 guint ghcimpl
: 1; /* class has its own GetHashCode impl */
213 guint has_finalize
: 1; /* class has its own Finalize impl */
214 guint marshalbyref
: 1; /* class is a MarshalByRefObject */
215 guint contextbound
: 1; /* class is a ContextBoundObject */
216 guint delegate
: 1; /* class is a Delegate */
217 guint gc_descr_inited
: 1; /* gc_descr is initialized */
218 guint dummy
: 1; /* temporary hack */
219 guint32 declsec_flags
; /* declarative security attributes flags */
222 MonoClass
*nested_in
;
223 GList
*nested_classes
;
227 const char *name_space
;
229 /* for fast subtype checks */
230 MonoClass
**supertypes
;
233 guint16 interface_count
;
234 guint16 interface_id
; /* unique inderface id (for interfaces) */
235 guint16 max_interface_id
;
236 gint
*interface_offsets
;
237 MonoClass
**interfaces
;
240 * Computed object instance size, total.
244 int vtable_size
; /* number of slots */
247 * From the TypeDef table
253 } field
, method
, property
, event
;
255 /* loaded on demand */
256 MonoMarshalType
*marshal_info
;
259 * Field information: Type and location from object base
261 MonoClassField
*fields
;
263 MonoProperty
*properties
;
267 MonoMethod
**methods
;
269 /* used as the type of the this argument and when passing the arg by value */
273 MonoGenericClass
*generic_class
;
274 MonoGenericContainer
*generic_container
;
276 void *reflection_info
;
281 MonoVTable
*cached_vtable
;
288 * According to comments in gc_gcj.h, this should be the second word in
292 MonoDomain
*domain
; /* each object/vtable belongs to exactly one domain */
293 gpointer
*interface_offsets
;
294 gpointer data
; /* to store static class data */
295 gpointer type
; /* System.Type type for klass */
296 guint16 max_interface_id
;
298 guint remote
: 1; /* class is remotely activated */
299 guint initialized
: 1; /* cctor has been run */
300 /* do not add any fields after vtable, the structure is dynamically extended */
301 gpointer vtable
[MONO_ZERO_LEN_ARRAY
];
305 * Generic instantiation data type encoding.
307 struct _MonoGenericInst
{
309 guint type_argc
: 22;
311 guint is_reference
: 1;
312 MonoType
**type_argv
;
315 struct _MonoGenericClass
{
316 MonoGenericInst
*inst
;
317 MonoClass
*container_class
;
318 MonoGenericContext
*context
;
321 guint count_ifaces
: 29;
322 guint is_dynamic
: 1;
326 struct _MonoDynamicGenericClass
{
327 MonoGenericClass generic_class
;
329 MonoMethod
**methods
;
333 MonoClassField
*fields
;
334 int count_properties
;
335 MonoProperty
*properties
;
341 struct _MonoGenericMethod
{
342 MonoGenericInst
*inst
;
343 MonoGenericContainer
*container
;
344 gpointer reflection_info
;
347 struct _MonoGenericContext
{
348 MonoGenericContainer
*container
;
349 MonoGenericClass
*gclass
;
350 MonoGenericMethod
*gmethod
;
353 struct _MonoGenericContainer
{
354 MonoGenericContext context
;
355 MonoGenericContainer
*parent
;
356 GHashTable
*method_hash
;
360 int is_signature
: 1;
361 MonoGenericParam
*type_params
;
364 struct _MonoGenericParam
{
365 MonoGenericContainer
*owner
;
371 MonoClass
** constraints
; /* NULL means end of list */
377 gconstpointer wrapper
;
378 MonoMethodSignature
*sig
;
381 #define mono_class_has_parent(klass,parent) (((klass)->idepth >= (parent)->idepth) && ((klass)->supertypes [(parent)->idepth - 1] == (parent)))
384 gulong new_object_count
;
385 gulong initialized_class_count
;
386 gulong used_class_count
;
387 gulong class_vtable_size
;
388 gulong class_static_data_size
;
389 gulong generic_instance_count
;
390 gulong generic_class_count
;
391 gulong inflated_method_count
;
392 gulong inflated_method_count_2
;
393 gulong inflated_type_count
;
394 gulong generics_metadata_size
;
398 extern MonoStats mono_stats
;
400 typedef gpointer (*MonoTrampoline
) (MonoMethod
*method
);
401 typedef gpointer (*MonoRemotingTrampoline
) (MonoMethod
*method
, MonoRemotingTarget target
);
403 typedef gpointer (*MonoLookupDynamicToken
) (MonoImage
*image
, guint32 token
);
406 mono_classes_init (void);
409 mono_class_layout_fields (MonoClass
*klass
);
412 mono_class_setup_vtable (MonoClass
*klass
, MonoMethod
**overrides
, int onum
);
415 mono_class_setup_mono_type (MonoClass
*klass
);
418 mono_class_setup_parent (MonoClass
*klass
, MonoClass
*parent
);
421 mono_class_setup_supertypes (MonoClass
*klass
);
424 mono_class_get_implemented_interfaces (MonoClass
*klass
);
427 mono_class_is_open_constructed_type (MonoType
*t
);
430 mono_class_get_overrides (MonoImage
*image
, guint32 type_token
, gint32
*num_overrides
);
433 mono_class_needs_cctor_run (MonoClass
*klass
, MonoMethod
*caller
);
436 mono_install_trampoline (MonoTrampoline func
);
439 mono_install_remoting_trampoline (MonoRemotingTrampoline func
);
442 mono_lookup_dynamic_token (MonoImage
*image
, guint32 token
);
445 mono_install_lookup_dynamic_token (MonoLookupDynamicToken func
);
448 mono_class_create_generic (MonoGenericClass
*gclass
);
452 MonoClass
*object_class
;
453 MonoClass
*byte_class
;
454 MonoClass
*void_class
;
455 MonoClass
*boolean_class
;
456 MonoClass
*sbyte_class
;
457 MonoClass
*int16_class
;
458 MonoClass
*uint16_class
;
459 MonoClass
*int32_class
;
460 MonoClass
*uint32_class
;
461 MonoClass
*int_class
;
462 MonoClass
*uint_class
;
463 MonoClass
*int64_class
;
464 MonoClass
*uint64_class
;
465 MonoClass
*single_class
;
466 MonoClass
*double_class
;
467 MonoClass
*char_class
;
468 MonoClass
*string_class
;
469 MonoClass
*enum_class
;
470 MonoClass
*array_class
;
471 MonoClass
*delegate_class
;
472 MonoClass
*multicastdelegate_class
;
473 MonoClass
*asyncresult_class
;
474 MonoClass
*waithandle_class
;
475 MonoClass
*typehandle_class
;
476 MonoClass
*fieldhandle_class
;
477 MonoClass
*methodhandle_class
;
478 MonoClass
*monotype_class
;
479 MonoClass
*exception_class
;
480 MonoClass
*threadabortexception_class
;
481 MonoClass
*thread_class
;
482 MonoClass
*transparent_proxy_class
;
483 MonoClass
*real_proxy_class
;
484 MonoClass
*mono_method_message_class
;
485 MonoClass
*appdomain_class
;
486 MonoClass
*field_info_class
;
487 MonoClass
*method_info_class
;
488 MonoClass
*stringbuilder_class
;
489 MonoClass
*math_class
;
490 MonoClass
*stack_frame_class
;
491 MonoClass
*stack_trace_class
;
492 MonoClass
*marshal_class
;
493 MonoClass
*iserializeable_class
;
494 MonoClass
*serializationinfo_class
;
495 MonoClass
*streamingcontext_class
;
496 MonoClass
*typed_reference_class
;
497 MonoClass
*argumenthandle_class
;
498 MonoClass
*marshalbyrefobject_class
;
499 MonoClass
*monitor_class
;
500 MonoClass
*iremotingtypeinfo_class
;
501 MonoClass
*runtimesecurityframe_class
;
504 extern MonoDefaults mono_defaults
;
507 mono_loader_init (void);
510 mono_loader_lock (void);
513 mono_loader_unlock (void);
516 mono_icall_init (void);
519 mono_icall_cleanup (void);
522 mono_method_get_wrapper_data (MonoMethod
*method
, guint32 id
);
525 mono_install_stack_walk (MonoStackWalkImpl func
);
527 MonoGenericContainer
*mono_metadata_load_generic_params (MonoImage
*image
, guint32 token
,
528 MonoGenericContainer
*parent_container
);
531 mono_create_icall_signature (const char *sigstr
);
534 mono_register_jit_icall (gconstpointer func
, const char *name
, MonoMethodSignature
*sig
, gboolean is_save
);
537 mono_register_jit_icall_wrapper (MonoJitICallInfo
*info
, gconstpointer wrapper
);
540 mono_find_jit_icall_by_name (const char *name
);
543 mono_find_jit_icall_by_addr (gconstpointer addr
);
546 mono_class_inflate_generic_signature (MonoImage
*image
, MonoMethodSignature
*sig
, MonoGenericContext
*context
);
549 mono_get_shared_generic_class (MonoGenericContainer
*container
, gboolean is_dynamic
);
551 #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */