+/*
+ * Copyright 2012 Xamarin Inc
+ */
#ifndef __MONO_METADATA_CLASS_INTERBALS_H__
#define __MONO_METADATA_CLASS_INTERBALS_H__
*/
#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"
#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
/*
* 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 */
/* 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 */
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_* */
#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;
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 */
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.
gconstpointer wrapper;
gconstpointer trampoline;
MonoMethodSignature *sig;
+ const char *c_symbol;
} MonoJitICallInfo;
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;
#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;
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;
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);
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;
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;
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;
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;
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
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;
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;
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;
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__ */