From b2eced5b4910ded034935d4e60083c15c2f367ed Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 4 Aug 1999 10:04:31 +0000 Subject: [PATCH] [project @ 1999-08-04 10:04:31 by simonmar] We weren't removing old entries from the hash table in two places. --- ghc/rts/Stable.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ghc/rts/Stable.c b/ghc/rts/Stable.c index d0dbc59..a429920 100644 --- a/ghc/rts/Stable.c +++ b/ghc/rts/Stable.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Stable.c,v 1.5 1999/07/16 09:53:44 panne Exp $ + * $Id: Stable.c,v 1.6 1999/08/04 10:04:31 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -187,6 +187,9 @@ static inline void freeStableName(snEntry *sn) { ASSERT(sn->sn_obj == NULL); + if (sn->addr != NULL) { + removeHashTable(addrToStableHash, (W_)sn->addr, NULL); + } sn->addr = (P_)stable_ptr_free; stable_ptr_free = sn; } @@ -347,9 +350,15 @@ gcStablePtrTable(rtsBool full) (StgClosure *)new = isAlive((StgClosure *)q); IF_DEBUG(stable, fprintf(stderr,"Stable name %d still alive at %p, weight %d\n", p - stable_ptr_table, new, p->weight)); - p->addr = new; - if (new != NULL) { - /* Re-hash this stable name */ + if (new == NULL) { + /* The target has been garbage collected. Remove its + * entry from the hash table. + */ + removeHashTable(addrToStableHash, (W_)q, NULL); + + } else { + /* Target still alive, Re-hash this stable name + */ if (full) { insertHashTable(addrToStableHash, (W_)new, (void *)(p - stable_ptr_table)); } else if (new != q) { @@ -357,6 +366,11 @@ gcStablePtrTable(rtsBool full) insertHashTable(addrToStableHash, (W_)new, (void *)(p - stable_ptr_table)); } } + + /* finally update the address of the target to point to its + * new location. + */ + p->addr = new; } } } -- 1.7.10.4