X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FStable.h;h=fefdba966577b5a50d55f87379ae6d13340cb8f0;hb=1c82b947f92da21c57dcec6c65b570871e938f4c;hp=70c467429046b45e306eb2bc870d65f2d2a49cce;hpb=a59148d19c0252c616dbb67fc3998f8d5ffd1fd6;p=ghc-hetmet.git diff --git a/ghc/includes/Stable.h b/ghc/includes/Stable.h index 70c4674..fefdba9 100644 --- a/ghc/includes/Stable.h +++ b/ghc/includes/Stable.h @@ -1,12 +1,22 @@ /* ----------------------------------------------------------------------------- - * $Id: Stable.h,v 1.3 1999/02/26 12:46:45 simonm Exp $ + * $Id: Stable.h,v 1.15 2003/11/12 17:27:03 sof Exp $ * - * (c) The GHC Team, 1998-1999 + * (c) The GHC Team, 1998-2000 * - * Stable names and stable pointers + * Stable Pointers: A stable pointer is represented as an index into + * the stable pointer table in the low BITS_PER_WORD-8 bits with a + * weight in the upper 8 bits. + * + * SUP: StgStablePtr used to be a synonym for StgWord, but stable pointers + * are guaranteed to be void* on the C-side, so we have to do some occasional + * casting. Size is not a matter, because StgWord is always the same size as + * a void*. * * ---------------------------------------------------------------------------*/ +#ifndef STABLE_H +#define STABLE_H + /* ----------------------------------------------------------------------------- External C Interface -------------------------------------------------------------------------- */ @@ -14,51 +24,35 @@ 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 snEntry *stable_ptr_table; -extern snEntry *stable_ptr_free; +extern DLL_IMPORT_RTS snEntry *stable_ptr_table; -extern unsigned int SPT_size; - -extern inline StgPtr -deRefStablePtr(StgStablePtr sp) -{ - ASSERT(stable_ptr_table[sp & ~STABLEPTR_WEIGHT_MASK].weight > 0); - return stable_ptr_table[sp & ~STABLEPTR_WEIGHT_MASK].addr; -} - -extern inline void -freeStablePtr(StgStablePtr sp) -{ - StgWord sn = 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 += (sp & STABLEPTR_WEIGHT_MASK) >> STABLEPTR_WEIGHT_SHIFT; -} +extern void freeStablePtr(StgStablePtr sp); -extern inline StgStablePtr -splitStablePtr(StgStablePtr sp) +#if defined(__GNUC__) +# ifndef RTS_STABLE_C +extern inline +# endif +StgPtr deRefStablePtr(StgStablePtr sp) { - /* doesn't need access to the stable pointer table */ - StgWord weight = (sp & STABLEPTR_WEIGHT_MASK) / 2; - return (sp & ~STABLEPTR_WEIGHT_MASK) + weight; + ASSERT(stable_ptr_table[(StgWord)sp].ref > 0); + return stable_ptr_table[(StgWord)sp].addr; } +#else +/* No support for 'extern inline' */ +extern StgPtr deRefStablePtr(StgStablePtr sp); +#endif -/* No deRefStableName, because the existence of a stable name doesn't - * guarantee the existence of the object itself. - */ +#endif