From a8214af467142b45729355daf97528515f19ea77 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 6 Jun 2022 16:58:53 +0200 Subject: [PATCH] Whippet reserves a bit in object kind for forwarding Tags without the bit are forwarding addresses. --- whippet.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/whippet.h b/whippet.h index 3314397d5..ab358faee 100644 --- a/whippet.h +++ b/whippet.h @@ -251,14 +251,20 @@ static inline size_t size_to_granules(size_t size) { return (size + GRANULE_SIZE - 1) >> GRANULE_SIZE_LOG_2; } -// Alloc kind is in bits 0-7, for live objects. -static const uintptr_t gcobj_alloc_kind_mask = 0xff; -static const uintptr_t gcobj_alloc_kind_shift = 0; +// Alloc kind is in bits 1-7, for live objects. +static const uintptr_t gcobj_alloc_kind_mask = 0x7f; +static const uintptr_t gcobj_alloc_kind_shift = 1; +static const uintptr_t gcobj_forwarded_mask = 0x1; +static const uintptr_t gcobj_not_forwarded_bit = 0x1; static inline uint8_t tag_live_alloc_kind(uintptr_t tag) { return (tag >> gcobj_alloc_kind_shift) & gcobj_alloc_kind_mask; } static inline uintptr_t tag_live(uint8_t alloc_kind) { - return ((uintptr_t)alloc_kind << gcobj_alloc_kind_shift); + return ((uintptr_t)alloc_kind << gcobj_alloc_kind_shift) + | gcobj_not_forwarded_bit; +} +static inline uintptr_t tag_forwarded(struct gcobj *new_addr) { + return (uintptr_t)new_addr; } struct gcobj {