X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=ghc%2Fincludes%2FStable.h;h=386087e351c5d1b7eba9aeb6ccb95977001d19b8;hb=b8598510c6f7138eeadfc749ec237d9b15df9696;hp=66486bd6380b32779dd9345ece1b57fb39dee9ca;hpb=2de8104d13dde6a4ace1acc8c264b71908514b67;p=ghc-hetmet.git diff --git a/ghc/includes/Stable.h b/ghc/includes/Stable.h index 66486bd..386087e 100644 --- a/ghc/includes/Stable.h +++ b/ghc/includes/Stable.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Stable.h,v 1.7 2000/11/07 17:05:47 simonmar Exp $ + * $Id: Stable.h,v 1.13 2002/08/16 13:29:05 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -12,10 +12,10 @@ * casting. Size is not a matter, because StgWord is always the same size as * a void*. * - * ----------------------------------------------------------------------------*/ + * ---------------------------------------------------------------------------*/ -#define STABLEPTR_WEIGHT_MASK ((StgWord)0xff << ((sizeof(StgWord)-1) * BITS_PER_BYTE)) -#define STABLEPTR_WEIGHT_SHIFT (BITS_IN(StgWord) - 8) +#ifndef STABLE_H +#define STABLE_H /* ----------------------------------------------------------------------------- External C Interface @@ -24,52 +24,32 @@ extern StgPtr deRefStablePtr(StgStablePtr stable_ptr); extern void freeStablePtr(StgStablePtr sp); extern StgStablePtr splitStablePtr(StgStablePtr sp); +extern StgStablePtr getStablePtr(StgPtr p); /* ----------------------------------------------------------------------------- PRIVATE from here. -------------------------------------------------------------------------- */ -extern StgStablePtr getStablePtr(StgPtr p); - typedef struct { StgPtr addr; /* Haskell object, free list, or NULL */ - StgWord weight; /* used for reference counting */ + StgPtr old; /* old Haskell object, used during GC */ + StgWord ref; /* used for reference counting */ StgClosure *sn_obj; /* the StableName object (or NULL) */ } snEntry; extern DLL_IMPORT_RTS snEntry *stable_ptr_table; -extern DLL_IMPORT_RTS snEntry *stable_ptr_free; -extern DLL_IMPORT_RTS unsigned int SPT_size; +extern void freeStablePtr(StgStablePtr sp); extern inline StgPtr deRefStablePtr(StgStablePtr sp) { - ASSERT(stable_ptr_table[stgCast(StgWord,sp) & ~STABLEPTR_WEIGHT_MASK].weight > 0); - return stable_ptr_table[stgCast(StgWord,sp) & ~STABLEPTR_WEIGHT_MASK].addr; -} - -extern inline void -freeStablePtr(StgStablePtr sp) -{ - StgWord sn = stgCast(StgWord,sp) & ~STABLEPTR_WEIGHT_MASK; - - ASSERT(sn < SPT_size - && stable_ptr_table[sn].addr != NULL - && stable_ptr_table[sn].weight > 0); - - stable_ptr_table[sn].weight += - 1 << ((((StgWord)sp & STABLEPTR_WEIGHT_MASK) >> STABLEPTR_WEIGHT_SHIFT) - 1); -} - -extern inline StgStablePtr -splitStablePtr(StgStablePtr sp) -{ - /* doesn't need access to the stable pointer table */ - StgWord weight = (stgCast(StgWord,sp) & STABLEPTR_WEIGHT_MASK) / 2; - return stgCast(StgStablePtr,(stgCast(StgWord,sp) & ~STABLEPTR_WEIGHT_MASK) + weight); + ASSERT(stable_ptr_table[(StgWord)sp].ref > 0); + return stable_ptr_table[(StgWord)sp].addr; } /* No deRefStableName, because the existence of a stable name doesn't * guarantee the existence of the object itself. */ + +#endif