From: Simon Marlow Date: Mon, 8 Sep 2008 14:43:48 +0000 (+0000) Subject: Make LOOKS_LIKE_{INFO,CLOSURE}_PTR into inline functions, instead of macros X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=fef454a0f84acdf9e4efbce6425a04fbbb577dbe Make LOOKS_LIKE_{INFO,CLOSURE}_PTR into inline functions, instead of macros The macros were duplicating their arguments, which was normally harmless, but in the parallel GC was actually wrong and caused spurious assertion failures. --- diff --git a/includes/Storage.h b/includes/Storage.h index caa7c1d..2b8f107 100644 --- a/includes/Storage.h +++ b/includes/Storage.h @@ -359,15 +359,8 @@ void dirty_MUT_VAR(StgRegTable *reg, StgClosure *p); make sense... -------------------------------------------------------------------------- */ -#define LOOKS_LIKE_INFO_PTR(p) \ - (p && (IS_FORWARDING_PTR(p) || LOOKS_LIKE_INFO_PTR_NOT_NULL(p))) - -#define LOOKS_LIKE_INFO_PTR_NOT_NULL(p) \ - (((StgInfoTable *)(INFO_PTR_TO_STRUCT(p)))->type != INVALID_OBJECT && \ - ((StgInfoTable *)(INFO_PTR_TO_STRUCT(p)))->type < N_CLOSURE_TYPES) - -#define LOOKS_LIKE_CLOSURE_PTR(p) \ - (LOOKS_LIKE_INFO_PTR((UNTAG_CLOSURE((StgClosure *)(p)))->header.info)) +INLINE_HEADER rtsBool LOOKS_LIKE_INFO_PTR (StgWord p); +INLINE_HEADER rtsBool LOOKS_LIKE_CLOSURE_PTR (void *p); // XXX StgClosure* /* ----------------------------------------------------------------------------- Macros for calculating how big a closure will be (used during allocation) @@ -599,4 +592,20 @@ extern StgTSO * RTS_VAR(resurrected_threads); #define MK_FORWARDING_PTR(p) (((StgWord)p) | 1) #define UN_FORWARDING_PTR(p) (((StgWord)p) - 1) +INLINE_HEADER rtsBool LOOKS_LIKE_INFO_PTR_NOT_NULL (StgWord p) +{ + StgInfoTable *info = INFO_PTR_TO_STRUCT(p); + return info->type != INVALID_OBJECT && info->type < N_CLOSURE_TYPES; +} + +INLINE_HEADER rtsBool LOOKS_LIKE_INFO_PTR (StgWord p) +{ + return p && (IS_FORWARDING_PTR(p) || LOOKS_LIKE_INFO_PTR_NOT_NULL(p)); +} + +INLINE_HEADER rtsBool LOOKS_LIKE_CLOSURE_PTR (void *p) +{ + return LOOKS_LIKE_INFO_PTR((StgWord)(UNTAG_CLOSURE((StgClosure *)(p)))->header.info); +} + #endif /* STORAGE_H */ diff --git a/rts/Sanity.c b/rts/Sanity.c index 3df5aef..3eea3cd 100644 --- a/rts/Sanity.c +++ b/rts/Sanity.c @@ -247,7 +247,7 @@ checkClosure( StgClosure* p ) { const StgInfoTable *info; - ASSERT(LOOKS_LIKE_INFO_PTR(p->header.info)); + ASSERT(LOOKS_LIKE_CLOSURE_PTR(p)); p = UNTAG_CLOSURE(p); /* Is it a static closure (i.e. in the data segment)? */ @@ -587,7 +587,7 @@ checkHeap(bdescr *bd) /* skip over slop */ while (p < bd->free && - (*p < 0x1000 || !LOOKS_LIKE_INFO_PTR((void*)*p))) { p++; } + (*p < 0x1000 || !LOOKS_LIKE_INFO_PTR(*p))) { p++; } } } } @@ -628,7 +628,7 @@ checkHeapChunk(StgPtr start, StgPtr end) nat size; for (p=start; p= MIN_PAYLOAD_SIZE + sizeofW(StgHeader) ); @@ -834,7 +834,7 @@ checkStaticObjects ( StgClosure* static_objects ) StgClosure *indirectee = UNTAG_CLOSURE(((StgIndStatic *)p)->indirectee); ASSERT(LOOKS_LIKE_CLOSURE_PTR(indirectee)); - ASSERT(LOOKS_LIKE_INFO_PTR(indirectee->header.info)); + ASSERT(LOOKS_LIKE_INFO_PTR((StgWord)indirectee->header.info)); p = *IND_STATIC_LINK((StgClosure *)p); break; } diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c index a41894a..9e820ff 100644 --- a/rts/sm/Storage.c +++ b/rts/sm/Storage.c @@ -124,7 +124,7 @@ initStorage( void ) * doing something reasonable. */ /* We use the NOT_NULL variant or gcc warns that the test is always true */ - ASSERT(LOOKS_LIKE_INFO_PTR_NOT_NULL(&stg_BLACKHOLE_info)); + ASSERT(LOOKS_LIKE_INFO_PTR_NOT_NULL((StgWord)&stg_BLACKHOLE_info)); ASSERT(LOOKS_LIKE_CLOSURE_PTR(&stg_dummy_ret_closure)); ASSERT(!HEAP_ALLOCED(&stg_dummy_ret_closure));