[runtime] Introduce MonoError into mono_metadata_parse_method_signature_full.
[mono.git] / mono / metadata / sgen-gc.h
index b40123ae822515df23d62c8e397bc41858323440..25015bd1ae664996e4f2bdd0aaac0279fd1d9928 100644 (file)
@@ -34,7 +34,6 @@ typedef struct _SgenThreadInfo SgenThreadInfo;
 #ifdef HAVE_PTHREAD_H
 #include <pthread.h>
 #endif
-#include <signal.h>
 #include <mono/utils/mono-compiler.h>
 #include <mono/utils/mono-threads.h>
 #include <mono/utils/dtrace.h>
@@ -304,18 +303,15 @@ typedef struct {
 } GCVTable;
 
 /*
- * We use the lowest bits in the vtable pointer of objects to tag whether they're forwarded,
- * pinned, and/or cemented.  On 64 bit architectures, where vtables are 8-byte aligned, we
- * use one bit for each of those.  On 32 bit architectures, we just use the lowest two bits,
- * which works because objects cannot both be forwarded and pinned/cemented, and cemented
- * objects are always pinned, too.  These are the valid states:
+ * We use the lowest three bits in the vtable pointer of objects to tag whether they're
+ * forwarded, pinned, and/or cemented.  These are the valid states:
  *
- * | State            | 64 bits | 32 bits |
- * |------------------+---------+---------|
- * | default          |     000 |      00 |
- * | forwarded        |     001 |      01 |
- * | pinned           |     010 |      10 |
- * | pinned, cemented |     110 |      11 |
+ * | State            | bits |
+ * |------------------+------+
+ * | default          |  000 |
+ * | forwarded        |  001 |
+ * | pinned           |  010 |
+ * | pinned, cemented |  110 |
  *
  * We store them in the vtable slot because the bits are used in the sync block for other
  * purposes: if we merge them and alloc the sync blocks aligned to 8 bytes, we can change
@@ -327,7 +323,6 @@ typedef struct {
 
 #define SGEN_VTABLE_BITS_MASK  SGEN_TAGGED_POINTER_MASK
 
-#if SIZEOF_VOID_P == 8
 #define SGEN_POINTER_IS_TAGGED_FORWARDED(p)    SGEN_POINTER_IS_TAGGED_1((p))
 #define SGEN_POINTER_TAG_FORWARDED(p)          SGEN_POINTER_TAG_1((p))
 
@@ -336,16 +331,6 @@ typedef struct {
 
 #define SGEN_POINTER_IS_TAGGED_CEMENTED(p)     SGEN_POINTER_IS_TAGGED_4((p))
 #define SGEN_POINTER_TAG_CEMENTED(p)           SGEN_POINTER_TAG_4((p))
-#else
-#define SGEN_POINTER_IS_TAGGED_FORWARDED(p)    (SGEN_POINTER_TAG_12 ((p)) == 1)
-#define SGEN_POINTER_TAG_FORWARDED(p)          SGEN_POINTER_SET_TAG_12((p), 1)
-
-#define SGEN_POINTER_IS_TAGGED_PINNED(p)       SGEN_POINTER_IS_TAGGED_2 ((p))
-#define SGEN_POINTER_TAG_PINNED(p)             SGEN_POINTER_TAG_2 ((p))
-
-#define SGEN_POINTER_IS_TAGGED_CEMENTED(p)     (SGEN_POINTER_TAG_12 ((p)) == 3)
-#define SGEN_POINTER_TAG_CEMENTED(p)           SGEN_POINTER_SET_TAG_12 ((p), 3)
-#endif
 
 #define SGEN_POINTER_UNTAG_VTABLE(p)           SGEN_POINTER_UNTAG_ALL((p))
 
@@ -779,7 +764,7 @@ slow_object_get_size (MonoVTable *vtable, MonoObject* o)
         * mono_array_length_fast not using the object's vtable.
         */
        if (klass == mono_defaults.string_class) {
-               return offsetof (MonoString, chars) + 2 * mono_string_length_fast ((MonoString*) o) + 2;
+               return G_STRUCT_OFFSET (MonoString, chars) + 2 * mono_string_length_fast ((MonoString*) o) + 2;
        } else if (klass->rank) {
                MonoArray *array = (MonoArray*)o;
                size_t size = sizeof (MonoArray) + klass->sizes.element_size * mono_array_length_fast (array);
@@ -821,18 +806,18 @@ sgen_obj_get_descriptor_safe (char *obj)
  * vtable field, is not intact.  This is necessary for the parallel
  * collector.
  */
-static inline mword
+static MONO_NEVER_INLINE mword
 sgen_par_object_get_size (MonoVTable *vtable, MonoObject* o)
 {
        mword descr = (mword)vtable->gc_descr;
-       mword type = descr & 0x7;
+       mword type = descr & DESC_TYPE_MASK;
 
        if (type == DESC_TYPE_RUN_LENGTH || type == DESC_TYPE_SMALL_PTRFREE) {
                mword size = descr & 0xfff8;
                SGEN_ASSERT (9, size >= sizeof (MonoObject), "Run length object size to small");
                return size;
        } else if (descr == SGEN_DESC_STRING) {
-               return offsetof (MonoString, chars) + 2 * mono_string_length_fast ((MonoString*) o) + 2;
+               return G_STRUCT_OFFSET (MonoString, chars) + 2 * mono_string_length_fast ((MonoString*) o) + 2;
        } else if (type == DESC_TYPE_VECTOR) {
                int element_size = ((descr) >> VECTOR_ELSIZE_SHIFT) & MAX_ELEMENT_SIZE;
                MonoArray *array = (MonoArray*)o;
@@ -1235,7 +1220,7 @@ gboolean nursery_canaries_enabled (void) MONO_INTERNAL;
                                char* canary_ptr = (char*) (addr) + sgen_safe_object_get_size_unaligned ((MonoObject *) (addr));        \
                                if (!CANARY_VALID(canary_ptr)) {        \
                                        char canary_copy[CANARY_SIZE +1];       \
-                                       strncpy (canary_copy, canary_ptr, 8);   \
+                                       strncpy (canary_copy, canary_ptr, CANARY_SIZE); \
                                        canary_copy[CANARY_SIZE] = 0;   \
                                        g_error ("CORRUPT CANARY:\naddr->%p\ntype->%s\nexcepted->'%s'\nfound->'%s'\n", (char*) addr, ((MonoObject*)addr)->vtable->klass->name, CANARY_STRING, canary_copy);     \
                                } }