#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>
} 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
#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))
#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))
* 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);
* 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;
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); \
} }