X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=includes%2FCmm.h;h=4cfb432811f6da84f719f06b150772e1454da34c;hb=ffa600f6702f215dd132b8b1b8a1f07d3a9e3ea6;hp=cecf92640bf807cfa8b19b5273c440ee3ed664d0;hpb=6015a94f9108a502150565577b66c23650796639;p=ghc-hetmet.git diff --git a/includes/Cmm.h b/includes/Cmm.h index cecf926..4cfb432 100644 --- a/includes/Cmm.h +++ b/includes/Cmm.h @@ -102,18 +102,8 @@ #endif /* - * The RTS must UNTAG a pointer before dereferencing it. - * The use of UNTAG follows the following rules of thumb: - * - * - Any pointer might be tagged. - * - Except the pointers that are passed in R1 to RTS functions. - * - R1 is also untagged when entering constructor code. - * - * TODO: - * - * - Remove redundancies of tagging and untagging in code generation. - * - Optimize getTag or dataToTag# ? - * + * The RTS must sometimes UNTAG a pointer before dereferencing it. + * See the wiki page Commentary/Rts/HaskellExecution/PointerTagging */ #define TAG_MASK ((1 << TAG_BITS) - 1) #define UNTAG(p) (p & ~TAG_MASK) @@ -407,9 +397,12 @@ #define BITMAP_BITS(bitmap) ((bitmap) >> BITMAP_BITS_SHIFT) /* Debugging macros */ -#define LOOKS_LIKE_INFO_PTR(p) \ - ((p) != NULL && \ - (TO_W_(%INFO_TYPE(%STD_INFO(p))) != INVALID_OBJECT) && \ +#define LOOKS_LIKE_INFO_PTR(p) \ + ((p) != NULL && \ + LOOKS_LIKE_INFO_PTR_NOT_NULL(p)) + +#define LOOKS_LIKE_INFO_PTR_NOT_NULL(p) \ + ( (TO_W_(%INFO_TYPE(%STD_INFO(p))) != INVALID_OBJECT) && \ (TO_W_(%INFO_TYPE(%STD_INFO(p))) < N_CLOSURE_TYPES)) #define LOOKS_LIKE_CLOSURE_PTR(p) (LOOKS_LIKE_INFO_PTR(GET_INFO(UNTAG(p)))) @@ -571,9 +564,13 @@ W_[free] = p; \ bdescr_free(__bd) = free + WDS(1); -#define recordMutable(p, regs) \ - W_ __p; \ - __p = p; \ - recordMutableCap(__p, TO_W_(bdescr_gen_no(Bdescr(__p))), regs) +#define recordMutable(p, regs) \ + W_ __p; \ + W_ __bd; \ + W_ __gen; \ + __p = p; \ + __bd = Bdescr(__p); \ + __gen = TO_W_(bdescr_gen_no(__bd)); \ + if (__gen > 0) { recordMutableCap(__p, __gen, regs); } #endif /* CMM_H */