*
* ---------------------------------------------------------------------------*/
-// Make static versions of inline functions in Stable.h:
-#define RTS_STABLE_C
-
#include "PosixSource.h"
#include "Rts.h"
+#include "RtsAPI.h"
+
#include "Hash.h"
#include "RtsUtils.h"
-#include "OSThreads.h"
-#include "Storage.h"
-#include "RtsAPI.h"
-#include "RtsFlags.h"
-#include "OSThreads.h"
#include "Trace.h"
#include "Stable.h"
static Mutex stable_mutex;
#endif
+static void enlargeStablePtrTable(void);
+
/* This hash table maps Haskell objects to stable names, so that every
* call to lookupStableName on a given object will return the same
* stable name.
while (get_itbl(q)->type == IND ||
get_itbl(q)->type == IND_STATIC ||
- get_itbl(q)->type == IND_OLDGEN ||
- get_itbl(q)->type == IND_PERM ||
- get_itbl(q)->type == IND_OLDGEN_PERM ) {
+ get_itbl(q)->type == IND_PERM) {
q = ((StgInd *)q)->indirectee;
tag = GET_CLOSURE_TAG(q);
q = UNTAG_CLOSURE(q);
*/
p = (StgPtr)removeIndirections((StgClosure*)p);
+ // register the untagged pointer. This just makes things simpler.
+ p = (StgPtr)UNTAG_CLOSURE((StgClosure*)p);
+
sn_tmp = lookupHashTable(addrToStableHash,(W_)p);
sn = (StgWord)sn_tmp;
RELEASE_LOCK(&stable_mutex);
}
-void
+static void
enlargeStablePtrTable(void)
{
nat old_SPT_size = SPT_size;
}
/* -----------------------------------------------------------------------------
+ * We must lock the StablePtr table during GC, to prevent simultaneous
+ * calls to freeStablePtr().
+ * -------------------------------------------------------------------------- */
+
+void
+stablePtrPreGC(void)
+{
+ ACQUIRE_LOCK(&stable_mutex);
+}
+
+void
+stablePtrPostGC(void)
+{
+ RELEASE_LOCK(&stable_mutex);
+}
+
+/* -----------------------------------------------------------------------------
* Treat stable pointers as roots for the garbage collector.
*
* A stable pointer is any stable name entry with a ref > 0. We'll