From 32c9a0258c35c5a10216250d5ee0f8c92c519e33 Mon Sep 17 00:00:00 2001 From: simonmar Date: Tue, 9 Apr 2002 12:56:36 +0000 Subject: [PATCH] [project @ 2002-04-09 12:56:36 by simonmar] If we free a StablePtr which has no StableName attached, then just add its entry to the free list immediately, rather than waiting for the garbage collector to free it. --- ghc/rts/Stable.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ghc/rts/Stable.c b/ghc/rts/Stable.c index 0232e18..5cf9c28 100644 --- a/ghc/rts/Stable.c +++ b/ghc/rts/Stable.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Stable.c,v 1.19 2001/12/20 16:12:09 sewardj Exp $ + * $Id: Stable.c,v 1.20 2002/04/09 12:56:36 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -236,13 +236,18 @@ getStablePtr(StgPtr p) void freeStablePtr(StgStablePtr sp) { - StgWord sn = (StgWord)sp; + snEntry *sn = &stable_ptr_table[(StgWord)sp]; - ASSERT(sn < SPT_size - && stable_ptr_table[sn].addr != NULL - && stable_ptr_table[sn].ref > 0); - - stable_ptr_table[sn].ref --; + ASSERT((StgWord)sp < SPT_size && sn->addr != NULL && sn->ref > 0); + + sn->ref--; + + // If this entry has no StableName attached, then just free it + // immediately. This is important; it might be a while before the + // next major GC which actually collects the entry. + if (sn->sn_obj == NULL) { + freeStableName(sn); + } } void -- 1.7.10.4