From e19ffca9c4f5192a8757bfb3f35e6a3907f29e76 Mon Sep 17 00:00:00 2001 From: sof Date: Tue, 29 Feb 2000 19:59:38 +0000 Subject: [PATCH] [project @ 2000-02-29 19:59:38 by sof] Added removeIndirections() and make use of it in lookupStableName() -- increases the possibilities of StableName sharing. --- ghc/rts/Stable.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/ghc/rts/Stable.c b/ghc/rts/Stable.c index 2d280a4..d0d64dd 100644 --- a/ghc/rts/Stable.c +++ b/ghc/rts/Stable.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Stable.c,v 1.9 1999/10/26 17:15:39 sewardj Exp $ + * $Id: Stable.c,v 1.10 2000/02/29 19:59:38 sof Exp $ * * (c) The GHC Team, 1998-1999 * @@ -152,6 +152,27 @@ initStablePtrTable(void) SPT_size = 0; } +/* + * get at the real stuff...remove indirections. + * + * ToDo: move to a better home. + */ +static +StgClosure* +removeIndirections(StgClosure* p) +{ + StgClosure* q = p; + + while (q->header.info->type == IND || + q->header.info->type == IND_STATIC || + q->header.info->type == IND_OLDGEN || + q->header.info->type == IND_PERM || + q->header.info->type == IND_OLDGEN_PERM ) { + q = ((StgInd *)q)->indirectee; + } + return q; +} + StgWord lookupStableName(StgPtr p) { @@ -160,7 +181,13 @@ lookupStableName(StgPtr p) if (stable_ptr_free == NULL) { enlargeStablePtrTable(); } - + + /* removing indirections increases the likelihood + * of finding a match in the stable name + * hash table. + */ + p = (StgPtr)removeIndirections((StgClosure*)p); + (void *)sn = lookupHashTable(addrToStableHash,(W_)p); if (sn != 0) { -- 1.7.10.4