[sgen] Use all 3 lower vtable bits on 32 bits.
authorMark Probst <mark.probst@gmail.com>
Wed, 26 Nov 2014 01:23:14 +0000 (17:23 -0800)
committerMark Probst <mark.probst@gmail.com>
Wed, 26 Nov 2014 18:38:50 +0000 (10:38 -0800)
We can't actually use the trick of setting both the pinned and forwarded
bits to indicate cemented objects because the Tarjan bridge requires those
two bits never be set at the same time.

mono/metadata/sgen-gc.h
mono/metadata/sgen-tagged-pointer.h

index a0a89be8716a2bda5b70511514f5176798c6a7c0..0e328097c7f1ed7ddc278278d9013f66bff51d0c 100644 (file)
@@ -304,18 +304,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 +324,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 +332,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))
 
index 8089dd7d545d495831ecda1949eb486de1f201db..3d63e94bfcd89bb3678b5c5bbae166e594a5ad34 100644 (file)
 #ifndef __MONO_SGEN_TAGGED_POINTER_H__
 #define __MONO_SGEN_TAGGED_POINTER_H__
 
-#if SIZEOF_VOID_P == 8
 #define SGEN_TAGGED_POINTER_MASK       7
-#else
-#define SGEN_TAGGED_POINTER_MASK       3
-#endif
 
 #define SGEN_POINTER_IS_TAGGED_1(p)    ((mword)(p) & 1)
 #define SGEN_POINTER_TAG_1(p)          ((void*)((mword)(p) | 1))
 #define SGEN_POINTER_TAG_12(p)         ((mword)(p) & 3)
 #define SGEN_POINTER_SET_TAG_12(p,t)   ((void*)(((mword)(p) & ~3) | (t)))
 
-#if SIZEOF_VOID_P == 8
 #define SGEN_POINTER_IS_TAGGED_4(p)    ((mword)(p) & 4)
 #define SGEN_POINTER_TAG_4(p)          ((void*)((mword)(p) | 4))
 #define SGEN_POINTER_UNTAG_4(p)                ((void*)((mword)(p) & ~4))
 
 #define SGEN_POINTER_UNTAG_24(p)       ((void*)((mword)(p) & ~6))
-#endif
 
 #define SGEN_POINTER_IS_TAGGED_ANY(p)  ((mword)(p) & SGEN_TAGGED_POINTER_MASK)
 #define SGEN_POINTER_UNTAG_ALL(p)      ((void*)((mword)(p) & ~SGEN_TAGGED_POINTER_MASK))