X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fclass-internals.h;h=2fd7709a37e098147453d2fcad0eda41203d3f1f;hb=f605c6478e5e6dd8bca797f8bf3be82c4175eaba;hp=698aa28554628c5734d3a487b41cc6cc7753b0a4;hpb=5a35198e2fdb794d48af81d80e783644a29d7291;p=mono.git diff --git a/mono/metadata/class-internals.h b/mono/metadata/class-internals.h index 698aa285546..2fd7709a37e 100644 --- a/mono/metadata/class-internals.h +++ b/mono/metadata/class-internals.h @@ -1,3 +1,6 @@ +/* + * Copyright 2012 Xamarin Inc + */ #ifndef __MONO_METADATA_CLASS_INTERBALS_H__ #define __MONO_METADATA_CLASS_INTERBALS_H__ @@ -28,6 +31,13 @@ typedef struct _MonoMethodPInvoke MonoMethodPInvoke; */ #define MONO_PROP_DYNAMIC_CATTR 0x1000 +#ifdef ENABLE_ICALL_EXPORT +#pragma GCC diagnostic ignored "-Wmissing-prototypes" +#define ICALL_EXPORT +#else +#define ICALL_EXPORT static +#endif + typedef enum { #define WRAPPER(e,n) MONO_WRAPPER_ ## e, #include "wrapper-types.h" @@ -213,48 +223,6 @@ typedef struct { #define MONO_SIZEOF_CLASS_RUNTIME_INFO (sizeof (MonoClassRuntimeInfo) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P) -enum { - MONO_RGCTX_INFO_STATIC_DATA, - MONO_RGCTX_INFO_KLASS, - MONO_RGCTX_INFO_VTABLE, - MONO_RGCTX_INFO_TYPE, - MONO_RGCTX_INFO_REFLECTION_TYPE, - MONO_RGCTX_INFO_METHOD, - MONO_RGCTX_INFO_GENERIC_METHOD_CODE, - MONO_RGCTX_INFO_CLASS_FIELD, - MONO_RGCTX_INFO_METHOD_RGCTX, - MONO_RGCTX_INFO_METHOD_CONTEXT, - MONO_RGCTX_INFO_REMOTING_INVOKE_WITH_CHECK, - MONO_RGCTX_INFO_METHOD_DELEGATE_CODE, - MONO_RGCTX_INFO_CAST_CACHE -}; - -typedef struct _MonoRuntimeGenericContextOtherInfoTemplate { - int info_type; - gpointer data; - struct _MonoRuntimeGenericContextOtherInfoTemplate *next; -} MonoRuntimeGenericContextOtherInfoTemplate; - -typedef struct { - MonoClass *next_subclass; - MonoRuntimeGenericContextOtherInfoTemplate *other_infos; - GSList *method_templates; -} MonoRuntimeGenericContextTemplate; - -typedef struct { - MonoVTable *class_vtable; /* must be the first element */ - MonoGenericInst *method_inst; - gpointer infos [MONO_ZERO_LEN_ARRAY]; -} MonoMethodRuntimeGenericContext; - -#define MONO_SIZEOF_METHOD_RUNTIME_GENERIC_CONTEXT (sizeof (MonoMethodRuntimeGenericContext) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P) - -#define MONO_RGCTX_SLOT_MAKE_RGCTX(i) (i) -#define MONO_RGCTX_SLOT_MAKE_MRGCTX(i) ((i) | 0x80000000) -#define MONO_RGCTX_SLOT_INDEX(s) ((s) & 0x7fffffff) -#define MONO_RGCTX_SLOT_IS_MRGCTX(s) (((s) & 0x80000000) ? TRUE : FALSE) - - #define MONO_CLASS_PROP_EXCEPTION_DATA 0 /* @@ -314,6 +282,7 @@ struct _MonoClass { * to 1, because we know the instance size now. After that we * initialise all static fields. */ + /* size_inited is accessed without locks, so it needs a memory barrier */ guint size_inited : 1; guint valuetype : 1; /* derives from System.ValueType */ guint enumtype : 1; /* derives from System.Enum */ @@ -328,8 +297,10 @@ struct _MonoClass { /* next byte */ guint ghcimpl : 1; /* class has its own GetHashCode impl */ guint has_finalize : 1; /* class has its own Finalize impl */ +#ifndef DISABLE_REMOTING guint marshalbyref : 1; /* class is a MarshalByRefObject */ guint contextbound : 1; /* class is a ContextBoundObject */ +#endif guint delegate : 1; /* class is a Delegate */ guint gc_descr_inited : 1; /* gc_descr is initialized */ guint has_cctor : 1; /* class has a cctor */ @@ -350,6 +321,8 @@ struct _MonoClass { guint is_inflated : 1; /* class is a generic instance */ /* next byte */ guint has_finalize_inited : 1; /* has_finalize is initialized */ + guint fields_inited : 1; /* fields is initialized */ + guint setup_fields_called : 1; /* to prevent infinite loops in setup_fields */ guint8 exception_type; /* MONO_EXCEPTION_* */ @@ -443,6 +416,28 @@ int mono_class_interface_match (const uint8_t *bitmap, int id) MONO_INTERNAL; #define MONO_CLASS_IMPLEMENTS_INTERFACE(k,uiid) (((uiid) <= (k)->max_interface_id) && mono_class_interface_match ((k)->interface_bitmap, (uiid))) +#define MONO_VTABLE_AVAILABLE_GC_BITS 4 + +#ifdef DISABLE_REMOTING +#define mono_class_is_marshalbyref(klass) (FALSE) +#define mono_class_is_contextbound(klass) (FALSE) +#define mono_vtable_is_remote(vtable) (FALSE) +#define mono_vtable_set_is_remote(vtable,enable) do {} while (0) +#else +#define mono_class_is_marshalbyref(klass) ((klass)->marshalbyref) +#define mono_class_is_contextbound(klass) ((klass)->contextbound) +#define mono_vtable_is_remote(vtable) ((vtable)->remote) +#define mono_vtable_set_is_remote(vtable,enable) do { (vtable)->remote = enable ? 1 : 0; } while (0) +#endif + +#ifdef DISABLE_COM +#define mono_class_is_com_object(klass) (FALSE) +#define mono_class_set_is_com_object(klass) do {} while (0) +#else +#define mono_class_is_com_object(klass) ((klass)->is_com_object) +#define mono_class_set_is_com_object(klass) do { (klass)->is_com_object = 1; } while (0) +#endif + int mono_class_interface_offset (MonoClass *klass, MonoClass *itf); int mono_class_interface_offset_with_variance (MonoClass *klass, MonoClass *itf, gboolean *non_exact_match) MONO_INTERNAL; @@ -466,6 +461,8 @@ struct MonoVTable { guint initialized : 1; /* cctor has been run */ guint init_failed : 1; /* cctor execution failed */ guint has_static_fields : 1; /* pointer to the data stored at the end of the vtable array */ + guint gc_bits : MONO_VTABLE_AVAILABLE_GC_BITS; /* Those bits are reserved for the usaged of the GC */ + guint32 imt_collisions_bitmap; MonoRuntimeGenericContext *runtime_generic_context; /* do not add any fields after vtable, the structure is dynamically extended */ @@ -564,6 +561,8 @@ struct _MonoDynamicGenericClass { struct _MonoGenericParam { MonoGenericContainer *owner; /* Type or method this parameter was defined in. */ guint16 num; + /* For internal runtime use, used to make different versions of the same param */ + guint16 serial; /* * If owner is NULL, or owner is 'owned' by this gparam, * then this is the image whose mempool this struct was allocated from. @@ -657,6 +656,7 @@ typedef struct { gconstpointer wrapper; gconstpointer trampoline; MonoMethodSignature *sig; + const char *c_symbol; } MonoJitICallInfo; typedef struct { @@ -669,7 +669,35 @@ typedef struct { char *msg; /* If kind == BAD_IMAGE */ } MonoLoaderError; -#define mono_class_has_parent(klass,parent) (((klass)->idepth >= (parent)->idepth) && ((klass)->supertypes [(parent)->idepth - 1] == (parent))) +void +mono_class_setup_supertypes (MonoClass *klass) MONO_INTERNAL; + +void +mono_class_setup_fields_locking (MonoClass *class) MONO_INTERNAL; + +/* WARNING + * Only call this function if you can ensure both @klass and @parent + * have supertype information initialized. + * This can be accomplished by mono_class_setup_supertypes or mono_class_init. + * If unsure, use mono_class_has_parent. + */ +static inline gboolean +mono_class_has_parent_fast (MonoClass *klass, MonoClass *parent) +{ + return (klass->idepth >= parent->idepth) && (klass->supertypes [parent->idepth - 1] == parent); +} + +static inline gboolean +mono_class_has_parent (MonoClass *klass, MonoClass *parent) +{ + if (G_UNLIKELY (!klass->supertypes)) + mono_class_setup_supertypes (klass); + + if (G_UNLIKELY (!parent->supertypes)) + mono_class_setup_supertypes (parent); + + return mono_class_has_parent_fast (klass, parent); +} typedef struct { MonoVTable *default_vtable; @@ -682,11 +710,8 @@ typedef struct { #define MONO_SIZEOF_REMOTE_CLASS (sizeof (MonoRemoteClass) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P) -MonoRemoteClass* -mono_remote_class (MonoDomain *domain, MonoString *class_name, MonoClass *proxy_class) MONO_INTERNAL; - typedef struct { - gulong new_object_count; + guint64 new_object_count; gulong initialized_class_count; gulong generic_vtable_count; gulong used_class_count; @@ -718,6 +743,7 @@ typedef struct { gulong generics_sharable_methods; gulong generics_unsharable_methods; gulong generics_shared_methods; + gulong gsharedvt_methods; gulong minor_gc_count; gulong major_gc_count; gulong minor_gc_time_usecs; @@ -851,7 +877,7 @@ extern MonoStats mono_stats MONO_INTERNAL; typedef gpointer (*MonoTrampoline) (MonoMethod *method); typedef gpointer (*MonoJumpTrampoline) (MonoDomain *domain, MonoMethod *method, gboolean add_sync_wrapper); typedef gpointer (*MonoRemotingTrampoline) (MonoDomain *domain, MonoMethod *method, MonoRemotingTarget target); -typedef gpointer (*MonoDelegateTrampoline) (MonoClass *klass); +typedef gpointer (*MonoDelegateTrampoline) (MonoDomain *domain, MonoClass *klass); typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token, gboolean valid_token, MonoClass **handle_class, MonoGenericContext *context); @@ -886,9 +912,6 @@ mono_class_setup_mono_type (MonoClass *klass) MONO_INTERNAL; void mono_class_setup_parent (MonoClass *klass, MonoClass *parent) MONO_INTERNAL; -void -mono_class_setup_supertypes (MonoClass *klass) MONO_INTERNAL; - MonoMethod* mono_class_get_method_by_index (MonoClass *class, int index) MONO_INTERNAL; @@ -941,9 +964,6 @@ mono_install_trampoline (MonoTrampoline func) MONO_INTERNAL; void mono_install_jump_trampoline (MonoJumpTrampoline func) MONO_INTERNAL; -void -mono_install_remoting_trampoline (MonoRemotingTrampoline func) MONO_INTERNAL; - void mono_install_delegate_trampoline (MonoDelegateTrampoline func) MONO_INTERNAL; @@ -1017,6 +1037,9 @@ mono_class_inflate_generic_type_checked (MonoType *type, MonoGenericContext *con void mono_metadata_free_inflated_signature (MonoMethodSignature *sig); +MonoMethodSignature* +mono_inflate_generic_signature (MonoMethodSignature *sig, MonoGenericContext *context, MonoError *error) MONO_INTERNAL; + typedef struct { MonoImage *corlib; MonoClass *object_class; @@ -1051,8 +1074,12 @@ typedef struct { MonoClass *threadabortexception_class; MonoClass *thread_class; MonoClass *internal_thread_class; +#ifndef DISABLE_REMOTING MonoClass *transparent_proxy_class; MonoClass *real_proxy_class; + MonoClass *marshalbyrefobject_class; + MonoClass *iremotingtypeinfo_class; +#endif MonoClass *mono_method_message_class; MonoClass *appdomain_class; MonoClass *field_info_class; @@ -1062,31 +1089,45 @@ typedef struct { MonoClass *stack_frame_class; MonoClass *stack_trace_class; MonoClass *marshal_class; - MonoClass *iserializeable_class; - MonoClass *serializationinfo_class; - MonoClass *streamingcontext_class; MonoClass *typed_reference_class; MonoClass *argumenthandle_class; - MonoClass *marshalbyrefobject_class; MonoClass *monitor_class; - MonoClass *iremotingtypeinfo_class; MonoClass *runtimesecurityframe_class; MonoClass *executioncontext_class; MonoClass *internals_visible_class; MonoClass *generic_ilist_class; MonoClass *generic_nullable_class; +#ifndef DISABLE_COM MonoClass *variant_class; MonoClass *com_object_class; MonoClass *com_interop_proxy_class; MonoClass *iunknown_class; MonoClass *idispatch_class; +#endif MonoClass *safehandle_class; MonoClass *handleref_class; MonoClass *attribute_class; MonoClass *customattribute_data_class; MonoClass *critical_finalizer_object; + MonoClass *generic_ireadonlylist_class; } MonoDefaults; +#ifdef DISABLE_REMOTING +#define mono_class_is_transparent_proxy(klass) (FALSE) +#define mono_class_is_real_proxy(klass) (FALSE) +#define mono_object_is_transparent_proxy(object) (FALSE) +#else +MonoRemoteClass* +mono_remote_class (MonoDomain *domain, MonoString *class_name, MonoClass *proxy_class) MONO_INTERNAL; + +void +mono_install_remoting_trampoline (MonoRemotingTrampoline func) MONO_INTERNAL; + +#define mono_class_is_transparent_proxy(klass) ((klass) == mono_defaults.transparent_proxy_class) +#define mono_class_is_real_proxy(klass) ((klass) == mono_defaults.real_proxy_class) +#define mono_object_is_transparent_proxy(object) (((MonoObject*)object)->vtable->klass == mono_defaults.transparent_proxy_class) +#endif + extern MonoDefaults mono_defaults MONO_INTERNAL; void @@ -1169,6 +1210,9 @@ mono_create_icall_signature (const char *sigstr) MONO_INTERNAL; MonoJitICallInfo * mono_register_jit_icall (gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean is_save) MONO_INTERNAL; +MonoJitICallInfo * +mono_register_jit_icall_full (gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean is_save, const char *c_symbol) MONO_INTERNAL; + void mono_register_jit_icall_wrapper (MonoJitICallInfo *info, gconstpointer wrapper) MONO_INTERNAL; @@ -1181,6 +1225,9 @@ mono_find_jit_icall_by_addr (gconstpointer addr) MONO_LLVM_INTERNAL; GHashTable* mono_get_jit_icall_info (void) MONO_INTERNAL; +const char* +mono_lookup_jit_icall_symbol (const char *name) MONO_INTERNAL; + gboolean mono_class_set_failure (MonoClass *klass, guint32 ex_type, void *ex_data) MONO_INTERNAL; @@ -1236,6 +1283,9 @@ mono_method_can_access_method_full (MonoMethod *method, MonoMethod *called, Mono gboolean mono_method_can_access_field_full (MonoMethod *method, MonoClassField *field, MonoClass *context_klass) MONO_INTERNAL; +gboolean +mono_class_can_access_class (MonoClass *access_class, MonoClass *target_class) MONO_INTERNAL; + MonoClass * mono_class_get_generic_type_definition (MonoClass *klass) MONO_INTERNAL; @@ -1298,4 +1348,10 @@ mono_class_has_finalizer (MonoClass *klass) MONO_INTERNAL; void mono_unload_interface_id (MonoClass *class) MONO_INTERNAL; +GPtrArray* +mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bflags, gboolean ignore_case, gboolean allow_ctors, MonoException **ex) MONO_INTERNAL; + +char* +mono_class_full_name (MonoClass *klass) MONO_INTERNAL; + #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */