X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FStable.c;h=0ed18bcec2c94992a7af8e7b6d7d4b186944b724;hb=006a18ea83799c0d4255071a2f8c08d3e9c7d84f;hp=5a1b92b3219ee27f63fb39ef2a16ecf8178202b7;hpb=9f2ceb4da7dfbc1cfd09ce54610ebe64288b9007;p=ghc-hetmet.git diff --git a/rts/Stable.c b/rts/Stable.c index 5a1b92b..0ed18bc 100644 --- a/rts/Stable.c +++ b/rts/Stable.c @@ -19,6 +19,7 @@ #include "RtsFlags.h" #include "OSThreads.h" #include "Trace.h" +#include "Stable.h" /* Comment from ADR's implementation in old RTS: @@ -169,10 +170,16 @@ exitStablePtrTable(void) stgFree(stable_ptr_table); stable_ptr_table = NULL; SPT_size = 0; +#ifdef THREADED_RTS + closeMutex(&stable_mutex); +#endif } /* * get at the real stuff...remove indirections. + * It untags pointers before dereferencing and + * retags the real stuff with its tag (if there + * is any) when returning. * * ToDo: move to a better home. */ @@ -180,16 +187,18 @@ static StgClosure* removeIndirections(StgClosure* p) { - StgClosure* q = p; + StgWord tag = GET_CLOSURE_TAG(p); + StgClosure* q = UNTAG_CLOSURE(p); while (get_itbl(q)->type == IND || get_itbl(q)->type == IND_STATIC || get_itbl(q)->type == IND_OLDGEN || get_itbl(q)->type == IND_PERM || get_itbl(q)->type == IND_OLDGEN_PERM ) { - q = ((StgInd *)q)->indirectee; + tag = GET_CLOSURE_TAG(q); + q = UNTAG_CLOSURE(((StgInd *)q)->indirectee); } - return q; + return TAG_CLOSURE(tag,q); } static StgWord @@ -412,15 +421,15 @@ gcStablePtrTable( void ) if (p->sn_obj == NULL) { // StableName object is dead freeStableName(p); - debugTrace(DEBUG_stable, "GC'd Stable name %ld", - p - stable_ptr_table); + debugTrace(DEBUG_stable, "GC'd Stable name %ld", + (long)(p - stable_ptr_table)); continue; } else { p->addr = (StgPtr)isAlive((StgClosure *)p->addr); debugTrace(DEBUG_stable, "stable name %ld still alive at %p, ref %ld\n", - p - stable_ptr_table, p->addr, p->ref); + (long)(p - stable_ptr_table), p->addr, p->ref); } } }