Merge pull request #444 from knocte/xbuild_improvements
[mono.git] / mono / metadata / class-internals.h
index e8087f4f29d5413ef1d980fc9997c73f520ad7cb..bc4469196a3fef66884bcf07940f342e80448662 100644 (file)
@@ -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"
@@ -308,6 +318,7 @@ 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 */
 
        guint8     exception_type;      /* MONO_EXCEPTION_* */
 
@@ -401,6 +412,7 @@ 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
 
 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;
@@ -415,7 +427,6 @@ struct MonoVTable {
         * the vtable.
         */
        void *gc_descr;         
-       void *size_descr;
        MonoDomain *domain;  /* each object/vtable belongs to exactly one domain */
         gpointer    type; /* System.Type type for klass */
        guint8     *interface_bitmap;
@@ -425,6 +436,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 */
@@ -523,6 +536,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.
@@ -628,7 +643,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;
@@ -810,7 +853,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);
 
@@ -845,9 +888,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;