-/*
+/**
+ * \file
* Copyright 2012 Xamarin Inc
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <mono/metadata/object.h>
#include <mono/metadata/mempool.h>
#include <mono/metadata/metadata-internals.h>
-#include <mono/io-layer/io-layer.h>
+#include <mono/metadata/property-bag.h>
#include "mono/utils/mono-compiler.h"
#include "mono/utils/mono-error.h"
#include "mono/sgen/gc-internal-agnostic.h"
typedef struct _MonoMethodWrapper MonoMethodWrapper;
typedef struct _MonoMethodInflated MonoMethodInflated;
typedef struct _MonoMethodPInvoke MonoMethodPInvoke;
+typedef struct _MonoDynamicMethod MonoDynamicMethod;
/* Properties that applies to a group of structs should better use a higher number
* to avoid colision with type specific properties.
#ifdef ENABLE_ICALL_EXPORT
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#define ICALL_DECL_EXPORT MONO_API
#define ICALL_EXPORT MONO_API
#else
+#define ICALL_DECL_EXPORT
#define ICALL_EXPORT static
#endif
void *method_data;
};
+struct _MonoDynamicMethod {
+ MonoMethodWrapper method;
+ MonoAssembly *assembly;
+};
+
struct _MonoMethodPInvoke {
MonoMethod method;
gpointer addr;
/* add marshal info */
guint16 piflags; /* pinvoke flags */
- guint16 implmap_idx; /* index into IMPLMAP */
+ guint32 implmap_idx; /* index into IMPLMAP */
};
/*
} MonoMarshalField;
typedef struct {
+ MonoPropertyBagItem head;
+
guint32 native_size, min_align;
guint32 num_fields;
MonoMethod *ptr_to_str;
#define MONO_SIZEOF_CLASS_RUNTIME_INFO (sizeof (MonoClassRuntimeInfo) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
-#define MONO_CLASS_PROP_EXCEPTION_DATA 0
-
-/*
- * This structure contains the rarely used fields of MonoClass
- * Since using just one field causes the whole structure to be allocated, it should
- * be used for fields which are only used in like 5% of all classes.
- */
typedef struct {
- struct {
-#if MONO_SMALL_CONFIG
- guint16 first, count;
-#else
- guint32 first, count;
-#endif
- } property, event;
+ MonoPropertyBagItem head;
- /* Initialized by a call to mono_class_setup_properties () */
MonoProperty *properties;
+ guint32 first, count;
+ MonoFieldDefaultValue *def_values;
+} MonoClassPropertyInfo;
+
+typedef struct {
+ MonoPropertyBagItem head;
/* Initialized by a call to mono_class_setup_events () */
MonoEvent *events;
-
- guint32 declsec_flags; /* declarative security attributes flags */
-
- /* Default values/RVA for fields and properties */
- /* Accessed using mono_class_get_field_default_value () / mono_field_get_data () */
- MonoFieldDefaultValue *field_def_values;
- MonoFieldDefaultValue *prop_def_values;
-
- GList *nested_classes;
-} MonoClassExt;
+ guint32 first, count;
+} MonoClassEventInfo;
typedef enum {
MONO_CLASS_DEF = 1, /* non-generic type */
* 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 */
+
+ /* ALL BITFIELDS SHOULD BE WRITTEN WHILE HOLDING THE LOADER LOCK */
guint size_inited : 1;
guint valuetype : 1; /* derives from System.ValueType */
guint enumtype : 1; /* derives from System.Enum */
guint blittable : 1; /* class is blittable */
guint unicode : 1; /* class uses unicode char when marshalled */
guint wastypebuilder : 1; /* class was created at runtime from a TypeBuilder */
+ guint is_array_special_interface : 1; /* gtd or ginst of once of the magic interfaces that arrays implement */
+
/* next byte */
guint8 min_align;
guint simd_type : 1; /* class is a simd intrinsic type */
guint has_finalize_inited : 1; /* has_finalize is initialized */
guint fields_inited : 1; /* setup_fields () has finished */
- guint has_failure : 1; /* See MONO_CLASS_PROP_EXCEPTION_DATA for a MonoErrorBoxed with the details */
+ guint has_failure : 1; /* See mono_class_get_exception_data () for a MonoErrorBoxed with the details */
MonoClass *parent;
MonoClass *nested_in;
int generic_param_token; /* for generic param types, both var and mvar */
} sizes;
- /* A GC handle pointing to the corresponding type builder/generic param builder */
- guint32 ref_info_handle;
-
- /* loaded on demand */
- MonoMarshalType *marshal_info;
-
/*
* Field information: Type and location from object base
*/
/* Generic vtable. Initialized by a call to mono_class_setup_vtable () */
MonoMethod **vtable;
- /* Rarely used fields of classes */
- MonoClassExt *ext;
+ /* Infrequently used items. See class-accessors.c: InfrequentDataKind for what goes into here. */
+ MonoPropertyBag infrequent_data;
};
typedef struct {
typedef struct {
MonoClassDef class;
MonoGenericContainer *generic_container;
+ /* The canonical GENERICINST where we instantiate a generic type definition with its own generic parameters.*/
+ /* Suppose we have class T`2<A,B> {...}. canonical_inst is the GTD T`2 applied to A and B. */
+ MonoType canonical_inst;
} MonoClassGtd;
typedef struct {
#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
guint8 *interface_bitmap;
guint32 max_interface_id;
guint8 rank;
+ /* Keep this a guint8, the jit depends on it */
+ guint8 initialized; /* cctor has been run */
guint remote : 1; /* class is remotely activated */
- 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 */
*/
struct _MonoGenericInst {
#ifndef MONO_SMALL_CONFIG
- guint id; /* unique ID for debugging */
+ gint32 id; /* unique ID for debugging */
#endif
guint type_argc : 22; /* number of type arguments */
guint is_open : 1; /* if this is an open type */
#define MONO_SIZEOF_REMOTE_CLASS (sizeof (MonoRemoteClass) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
typedef struct {
- guint64 new_object_count;
- size_t initialized_class_count;
- size_t generic_vtable_count;
- size_t used_class_count;
- size_t method_count;
- size_t class_vtable_size;
- size_t class_static_data_size;
- size_t generic_instance_count;
- size_t generic_class_count;
- size_t inflated_method_count;
- size_t inflated_method_count_2;
- size_t inflated_type_count;
- size_t generics_metadata_size;
- size_t delegate_creations;
- size_t imt_tables_size;
- size_t imt_number_of_tables;
- size_t imt_number_of_methods;
- size_t imt_used_slots;
- size_t imt_slots_with_collisions;
- size_t imt_max_collisions_in_slot;
- size_t imt_method_count_when_max_collisions;
- size_t imt_trampolines_size;
- size_t jit_info_table_insert_count;
- size_t jit_info_table_remove_count;
- size_t jit_info_table_lookup_count;
- size_t generics_sharable_methods;
- size_t generics_unsharable_methods;
- size_t generics_shared_methods;
- size_t gsharedvt_methods;
- size_t minor_gc_count;
- size_t major_gc_count;
- size_t minor_gc_time_usecs;
- size_t major_gc_time_usecs;
+ gint32 initialized_class_count;
+ gint32 generic_vtable_count;
+ gint32 used_class_count;
+ gint32 method_count;
+ gint32 class_vtable_size;
+ gint32 class_static_data_size;
+ gint32 generic_class_count;
+ gint32 inflated_method_count;
+ gint32 inflated_type_count;
+ gint32 delegate_creations;
+ gint32 imt_tables_size;
+ gint32 imt_number_of_tables;
+ gint32 imt_number_of_methods;
+ gint32 imt_used_slots;
+ gint32 imt_slots_with_collisions;
+ gint32 imt_max_collisions_in_slot;
+ gint32 imt_method_count_when_max_collisions;
+ gint32 imt_trampolines_size;
+ gint32 jit_info_table_insert_count;
+ gint32 jit_info_table_remove_count;
+ gint32 jit_info_table_lookup_count;
+ gint32 generics_sharable_methods;
+ gint32 generics_unsharable_methods;
+ gint32 generics_shared_methods;
+ gint32 gsharedvt_methods;
gboolean enabled;
} MonoStats;
*/
typedef struct {
/* JIT category */
- guint32 jit_methods;
- guint32 jit_bytes;
- guint32 jit_time;
- guint32 jit_failures;
+ gint32 jit_methods;
+ gint32 jit_bytes;
+ gint32 jit_time;
+ gint32 jit_failures;
/* Exceptions category */
- guint32 exceptions_thrown;
- guint32 exceptions_filters;
- guint32 exceptions_finallys;
- guint32 exceptions_depth;
- guint32 aspnet_requests_queued;
- guint32 aspnet_requests;
+ gint32 exceptions_thrown;
+ gint32 exceptions_filters;
+ gint32 exceptions_finallys;
+ gint32 exceptions_depth;
+ gint32 aspnet_requests_queued;
+ gint32 aspnet_requests;
/* Memory category */
- guint32 gc_collections0;
- guint32 gc_collections1;
- guint32 gc_collections2;
- guint32 gc_promotions0;
- guint32 gc_promotions1;
- guint32 gc_promotion_finalizers;
- guint32 gc_gen0size;
- guint32 gc_gen1size;
- guint32 gc_gen2size;
- guint32 gc_lossize;
- guint32 gc_fin_survivors;
- guint32 gc_num_handles;
- guint32 gc_allocated;
- guint32 gc_induced;
- guint32 gc_time;
- guint32 gc_total_bytes;
- guint32 gc_committed_bytes;
- guint32 gc_reserved_bytes;
- guint32 gc_num_pinned;
- guint32 gc_sync_blocks;
+ gint32 gc_collections0;
+ gint32 gc_collections1;
+ gint32 gc_collections2;
+ gint32 gc_promotions0;
+ gint32 gc_promotions1;
+ gint32 gc_promotion_finalizers;
+ gint64 gc_gen0size;
+ gint64 gc_gen1size;
+ gint64 gc_gen2size;
+ gint32 gc_lossize;
+ gint32 gc_fin_survivors;
+ gint32 gc_num_handles;
+ gint32 gc_allocated;
+ gint32 gc_induced;
+ gint32 gc_time;
+ gint64 gc_total_bytes;
+ gint64 gc_committed_bytes;
+ gint64 gc_reserved_bytes;
+ gint32 gc_num_pinned;
+ gint32 gc_sync_blocks;
/* Remoting category */
- guint32 remoting_calls;
- guint32 remoting_channels;
- guint32 remoting_proxies;
- guint32 remoting_classes;
- guint32 remoting_objects;
- guint32 remoting_contexts;
+ gint32 remoting_calls;
+ gint32 remoting_channels;
+ gint32 remoting_proxies;
+ gint32 remoting_classes;
+ gint32 remoting_objects;
+ gint32 remoting_contexts;
/* Loader category */
- guint32 loader_classes;
- guint32 loader_total_classes;
- guint32 loader_appdomains;
- guint32 loader_total_appdomains;
- guint32 loader_assemblies;
- guint32 loader_total_assemblies;
- guint32 loader_failures;
- guint32 loader_bytes;
- guint32 loader_appdomains_uloaded;
+ gint32 loader_classes;
+ gint32 loader_total_classes;
+ gint32 loader_appdomains;
+ gint32 loader_total_appdomains;
+ gint32 loader_assemblies;
+ gint32 loader_total_assemblies;
+ gint32 loader_failures;
+ gint32 loader_bytes;
+ gint32 loader_appdomains_uloaded;
/* Threads and Locks category */
- guint32 thread_contentions;
- guint32 thread_queue_len;
- guint32 thread_queue_max;
- guint32 thread_num_logical;
- guint32 thread_num_physical;
- guint32 thread_cur_recognized;
- guint32 thread_num_recognized;
+ gint32 thread_contentions;
+ gint32 thread_queue_len;
+ gint32 thread_queue_max;
+ gint32 thread_num_logical;
+ gint32 thread_num_physical;
+ gint32 thread_cur_recognized;
+ gint32 thread_num_recognized;
/* Interop category */
- guint32 interop_num_ccw;
- guint32 interop_num_stubs;
- guint32 interop_num_marshals;
+ gint32 interop_num_ccw;
+ gint32 interop_num_stubs;
+ gint32 interop_num_marshals;
/* Security category */
- guint32 security_num_checks;
- guint32 security_num_link_checks;
- guint32 security_time;
- guint32 security_depth;
- guint32 unused;
+ gint32 security_num_checks;
+ gint32 security_num_link_checks;
+ gint32 security_time;
+ gint32 security_depth;
+ gint32 unused;
/* Threadpool */
- guint64 threadpool_workitems;
- guint64 threadpool_ioworkitems;
- guint threadpool_threads;
- guint threadpool_iothreads;
+ gint64 threadpool_workitems;
+ gint64 threadpool_ioworkitems;
+ gint32 threadpool_threads;
+ gint32 threadpool_iothreads;
} MonoPerfCounters;
extern MonoPerfCounters *mono_perfcounters;
extern MonoStats mono_stats;
-typedef gpointer (*MonoRemotingTrampoline) (MonoDomain *domain, MonoMethod *method, MonoRemotingTarget target, MonoError *error);
-typedef gpointer (*MonoDelegateTrampoline) (MonoDomain *domain, MonoClass *klass);
-
typedef gboolean (*MonoGetCachedClassInfo) (MonoClass *klass, MonoCachedClassInfo *res);
typedef gboolean (*MonoGetClassFromName) (MonoImage *image, const char *name_space, const char *name, MonoClass **res);
MonoGenericContext *generic_context);
MonoMethod*
-mono_class_get_cctor (MonoClass *klass);
+mono_class_get_cctor (MonoClass *klass) MONO_LLVM_INTERNAL;
MonoMethod*
mono_class_get_finalizer (MonoClass *klass);
const char*
mono_class_get_property_default_value (MonoProperty *property, MonoTypeEnum *def_type);
-void
-mono_install_delegate_trampoline (MonoDelegateTrampoline func);
-
gpointer
mono_lookup_dynamic_token (MonoImage *image, guint32 token, MonoGenericContext *context, MonoError *error);
void
mono_install_get_class_from_name (MonoGetClassFromName func);
-MonoGenericContext*
+MONO_PROFILER_API MonoGenericContext*
mono_class_get_context (MonoClass *klass);
-MonoMethodSignature*
+MONO_PROFILER_API MonoMethodSignature*
mono_method_signature_checked (MonoMethod *m, MonoError *err);
MonoGenericContext*
mono_method_get_context_general (MonoMethod *method, gboolean uninflated);
-MonoGenericContext*
+MONO_PROFILER_API MonoGenericContext*
mono_method_get_context (MonoMethod *method);
/* Used by monodis, thus cannot be MONO_INTERNAL */
#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, MonoError *error);
-
-void
-mono_install_remoting_trampoline (MonoRemotingTrampoline func);
-
#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
+#define mono_object_is_transparent_proxy(object) (mono_class_is_transparent_proxy (mono_object_class (object)))
+
#define GENERATE_GET_CLASS_WITH_CACHE_DECL(shortname) \
MonoClass* mono_class_get_##shortname##_class (void);
#define GENERATE_TRY_GET_CLASS_WITH_CACHE_DECL(shortname) \
MonoClass* mono_class_try_get_##shortname##_class (void);
-#define GENERATE_GET_CLASS_WITH_CACHE(shortname,namespace,name) \
+#define GENERATE_GET_CLASS_WITH_CACHE(shortname,name_space,name) \
MonoClass* \
mono_class_get_##shortname##_class (void) \
{ \
static MonoClass *tmp_class; \
MonoClass *klass = tmp_class; \
if (!klass) { \
- klass = mono_class_load_from_name (mono_defaults.corlib, #namespace, #name); \
+ klass = mono_class_load_from_name (mono_defaults.corlib, name_space, name); \
mono_memory_barrier (); \
tmp_class = klass; \
} \
return klass; \
}
-#define GENERATE_TRY_GET_CLASS_WITH_CACHE(shortname,namespace,name) \
+#define GENERATE_TRY_GET_CLASS_WITH_CACHE(shortname,name_space,name) \
MonoClass* \
mono_class_try_get_##shortname##_class (void) \
{ \
MonoClass *klass = (MonoClass *)tmp_class; \
mono_memory_barrier (); \
if (!inited) { \
- klass = mono_class_try_load_from_name (mono_defaults.corlib, #namespace, #name); \
+ klass = mono_class_try_load_from_name (mono_defaults.corlib, name_space, name); \
tmp_class = klass; \
mono_memory_barrier (); \
inited = TRUE; \
#endif
+GENERATE_GET_CLASS_WITH_CACHE_DECL (appdomain_unloaded_exception)
+
extern MonoDefaults mono_defaults;
void
/* method debugging functions, for use inside gdb */
MONO_API void mono_method_print_code (MonoMethod *method);
-char *mono_signature_full_name (MonoMethodSignature *sig);
+MONO_PROFILER_API char *mono_signature_full_name (MonoMethodSignature *sig);
/*Enum validation related functions*/
MONO_API gboolean
MONO_API gboolean
mono_class_is_valid_enum (MonoClass *klass);
+MONO_PROFILER_API gboolean
+mono_type_is_primitive (MonoType *type);
+
MonoType *
mono_type_get_checked (MonoImage *image, guint32 type_token, MonoGenericContext *context, MonoError *error);
int
mono_method_get_vtable_index (MonoMethod *method);
+MonoMethod*
+mono_method_get_base_method (MonoMethod *method, gboolean definition, MonoError *error);
+
MonoMethod*
mono_method_search_in_array_class (MonoClass *klass, const char *name, MonoMethodSignature *sig);
gpointer
mono_class_alloc0 (MonoClass *klass, int size);
-void
-mono_class_alloc_ext (MonoClass *klass);
-
void
mono_class_setup_interfaces (MonoClass *klass, MonoError *error);
void
mono_class_set_generic_container (MonoClass *klass, MonoGenericContainer *container);
+MonoType*
+mono_class_gtd_get_canonical_inst (MonoClass *klass);
+
guint32
mono_class_get_first_method_idx (MonoClass *klass);
void
mono_class_set_field_count (MonoClass *klass, guint32 count);
+MonoMarshalType*
+mono_class_get_marshal_info (MonoClass *class);
+
+void
+mono_class_set_marshal_info (MonoClass *class, MonoMarshalType *marshal_info);
+
+guint32
+mono_class_get_ref_info_handle (MonoClass *class);
+
+guint32
+mono_class_set_ref_info_handle (MonoClass *class, guint32 value);
+
+MonoErrorBoxed*
+mono_class_get_exception_data (MonoClass *klass);
+
+void
+mono_class_set_exception_data (MonoClass *klass, MonoErrorBoxed *value);
+
+GList*
+mono_class_get_nested_classes_property (MonoClass *klass);
+
+void
+mono_class_set_nested_classes_property (MonoClass *klass, GList *value);
+
+MonoClassPropertyInfo*
+mono_class_get_property_info (MonoClass *klass);
+
+void
+mono_class_set_property_info (MonoClass *klass, MonoClassPropertyInfo *info);
+
+MonoClassEventInfo*
+mono_class_get_event_info (MonoClass *klass);
+
+void
+mono_class_set_event_info (MonoClass *klass, MonoClassEventInfo *info);
+
+MonoFieldDefaultValue*
+mono_class_get_field_def_values (MonoClass *klass);
+
+void
+mono_class_set_field_def_values (MonoClass *klass, MonoFieldDefaultValue *values);
+
+guint32
+mono_class_get_declsec_flags (MonoClass *class);
+
+void
+mono_class_set_declsec_flags (MonoClass *class, guint32 value);
+
+void
+mono_class_set_is_com_object (MonoClass *klass);
+
/*Now that everything has been defined, let's include the inline functions */
#include <mono/metadata/class-inlines.h>