projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
further fix for floating point primitives
[ghc-hetmet.git]
/
ghc
/
rts
/
Stable.c
diff --git
a/ghc/rts/Stable.c
b/ghc/rts/Stable.c
index
93b2246
..
09efb6a
100644
(file)
--- a/
ghc/rts/Stable.c
+++ b/
ghc/rts/Stable.c
@@
-17,6
+17,7
@@
#include "Storage.h"
#include "RtsAPI.h"
#include "RtsFlags.h"
#include "Storage.h"
#include "RtsAPI.h"
#include "RtsFlags.h"
+#include "OSThreads.h"
/* Comment from ADR's implementation in old RTS:
/* Comment from ADR's implementation in old RTS:
@@
-79,6
+80,10
@@
static snEntry *stable_ptr_free = NULL;
static unsigned int SPT_size = 0;
static unsigned int SPT_size = 0;
+#ifdef THREADED_RTS
+static Mutex stable_mutex;
+#endif
+
/* 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.
/* 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.
@@
-140,6
+145,9
@@
initStablePtrTable(void)
//
// Also, getStablePtr is now called from __attribute__((constructor))
// functions, so initialising things here wouldn't work anyway.
//
// Also, getStablePtr is now called from __attribute__((constructor))
// functions, so initialising things here wouldn't work anyway.
+#ifdef THREADED_RTS
+ initMutex(&stable_mutex);
+#endif
}
/*
}
/*
@@
-163,8
+171,8
@@
removeIndirections(StgClosure* p)
return q;
}
return q;
}
-StgWord
-lookupStableName(StgPtr p)
+static StgWord
+lookupStableName_(StgPtr p)
{
StgWord sn;
void* sn_tmp;
{
StgWord sn;
void* sn_tmp;
@@
-200,6
+208,16
@@
lookupStableName(StgPtr p)
}
}
}
}
+StgWord
+lookupStableName(StgPtr p)
+{
+ StgWord res;
+ ACQUIRE_LOCK(&stable_mutex);
+ res = lookupStableName_(p);
+ RELEASE_LOCK(&stable_mutex);
+ return res;
+}
+
STATIC_INLINE void
freeStableName(snEntry *sn)
{
STATIC_INLINE void
freeStableName(snEntry *sn)
{
@@
-216,15
+234,21
@@
getStablePtr(StgPtr p)
{
StgWord sn;
{
StgWord sn;
- sn = lookupStableName(p);
+ ACQUIRE_LOCK(&stable_mutex);
+ sn = lookupStableName_(p);
stable_ptr_table[sn].ref++;
stable_ptr_table[sn].ref++;
+ RELEASE_LOCK(&stable_mutex);
return (StgStablePtr)(sn);
}
void
freeStablePtr(StgStablePtr sp)
{
return (StgStablePtr)(sn);
}
void
freeStablePtr(StgStablePtr sp)
{
- snEntry *sn = &stable_ptr_table[(StgWord)sp];
+ snEntry *sn;
+
+ ACQUIRE_LOCK(&stable_mutex);
+
+ sn = &stable_ptr_table[(StgWord)sp];
ASSERT((StgWord)sp < SPT_size && sn->addr != NULL && sn->ref > 0);
ASSERT((StgWord)sp < SPT_size && sn->addr != NULL && sn->ref > 0);
@@
-236,6
+260,8
@@
freeStablePtr(StgStablePtr sp)
if (sn->sn_obj == NULL && sn->ref == 0) {
freeStableName(sn);
}
if (sn->sn_obj == NULL && sn->ref == 0) {
freeStableName(sn);
}
+
+ RELEASE_LOCK(&stable_mutex);
}
void
}
void
@@
-376,13
+402,13
@@
gcStablePtrTable( void )
if (p->sn_obj == NULL) {
// StableName object is dead
freeStableName(p);
if (p->sn_obj == NULL) {
// StableName object is dead
freeStableName(p);
- IF_DEBUG(stable, debugBelch("GC'd Stable name %d\n",
+ IF_DEBUG(stable, debugBelch("GC'd Stable name %ld\n",
p - stable_ptr_table));
continue;
} else {
p->addr = (StgPtr)isAlive((StgClosure *)p->addr);
p - stable_ptr_table));
continue;
} else {
p->addr = (StgPtr)isAlive((StgClosure *)p->addr);
- IF_DEBUG(stable, debugBelch("Stable name %d still alive at %p, ref %ld\n", p - stable_ptr_table, p->addr, p->ref));
+ IF_DEBUG(stable, debugBelch("Stable name %ld still alive at %p, ref %ld\n", p - stable_ptr_table, p->addr, p->ref));
}
}
}
}
}
}