Add a bit-map encoding of Object-reference field offsets to ClassObject.
Class.c populates a new field with a bit for each of the first 32 instance
fields, to show if it is a reference or not, and an escape value if there is a
reference field beyond 32.
The GC uses the encoded bitmap -- if available -- to extract Object refererences
from DataObjects.
diff --git a/vm/oo/Object.h b/vm/oo/Object.h
index 8c2f251..82194c3 100644
--- a/vm/oo/Object.h
+++ b/vm/oo/Object.h
@@ -148,12 +148,23 @@
#define CLASS_OFFSET_ALIGNMENT 4
#define CLASS_HIGH_BIT ((unsigned int)1 << (CLASS_BITS_PER_WORD - 1))
/*
- * Return a single bit, or zero if the encoding can't encode the offset.
+ * Given an offset, return the bit number which would encode that offset.
+ * Local use only.
+ */
+#define _CLASS_BIT_NUMBER_FROM_OFFSET(byteOffset) \
+ (((unsigned int)(byteOffset) - CLASS_SMALLEST_OFFSET) / \
+ CLASS_OFFSET_ALIGNMENT)
+/*
+ * Is the given offset too large to be encoded?
+ */
+#define CLASS_CAN_ENCODE_OFFSET(byteOffset) \
+ (_CLASS_BIT_NUMBER_FROM_OFFSET(byteOffset) < CLASS_BITS_PER_WORD)
+/*
+ * Return a single bit, encoding the offset.
+ * Undefined if the offset is too large, as defined above.
*/
#define CLASS_BIT_FROM_OFFSET(byteOffset) \
- (CLASS_HIGH_BIT >> \
- (((unsigned int)(byteOffset) - CLASS_SMALLEST_OFFSET) / \
- CLASS_OFFSET_ALIGNMENT))
+ (CLASS_HIGH_BIT >> _CLASS_BIT_NUMBER_FROM_OFFSET(byteOffset))
/*
* Return an offset, given a bit number as returned from CLZ.
*/