projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Clean the bootstrapping extensible-exceptions package
[ghc-hetmet.git]
/
rts
/
Stable.c
diff --git
a/rts/Stable.c
b/rts/Stable.c
index
5a1b92b
..
a2c47d7
100644
(file)
--- a/
rts/Stable.c
+++ b/
rts/Stable.c
@@
-19,6
+19,7
@@
#include "RtsFlags.h"
#include "OSThreads.h"
#include "Trace.h"
#include "RtsFlags.h"
#include "OSThreads.h"
#include "Trace.h"
+#include "Stable.h"
/* Comment from ADR's implementation in old RTS:
/* Comment from ADR's implementation in old RTS:
@@
-169,10
+170,16
@@
exitStablePtrTable(void)
stgFree(stable_ptr_table);
stable_ptr_table = NULL;
SPT_size = 0;
stgFree(stable_ptr_table);
stable_ptr_table = NULL;
SPT_size = 0;
+#ifdef THREADED_RTS
+ closeMutex(&stable_mutex);
+#endif
}
/*
* get at the real stuff...remove indirections.
}
/*
* get at the real stuff...remove indirections.
+ * It untags pointers before dereferencing and
+ * retags the real stuff with its tag (if there
+ * is any) when returning.
*
* ToDo: move to a better home.
*/
*
* ToDo: move to a better home.
*/
@@
-180,7
+187,8
@@
static
StgClosure*
removeIndirections(StgClosure* p)
{
StgClosure*
removeIndirections(StgClosure* p)
{
- StgClosure* q = p;
+ StgWord tag = GET_CLOSURE_TAG(p);
+ StgClosure* q = UNTAG_CLOSURE(p);
while (get_itbl(q)->type == IND ||
get_itbl(q)->type == IND_STATIC ||
while (get_itbl(q)->type == IND ||
get_itbl(q)->type == IND_STATIC ||
@@
-188,8
+196,11
@@
removeIndirections(StgClosure* p)
get_itbl(q)->type == IND_PERM ||
get_itbl(q)->type == IND_OLDGEN_PERM ) {
q = ((StgInd *)q)->indirectee;
get_itbl(q)->type == IND_PERM ||
get_itbl(q)->type == IND_OLDGEN_PERM ) {
q = ((StgInd *)q)->indirectee;
+ tag = GET_CLOSURE_TAG(q);
+ q = UNTAG_CLOSURE(q);
}
}
- return q;
+
+ return TAG_CLOSURE(tag,q);
}
static StgWord
}
static StgWord
@@
-207,6
+218,9
@@
lookupStableName_(StgPtr p)
*/
p = (StgPtr)removeIndirections((StgClosure*)p);
*/
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;
sn_tmp = lookupHashTable(addrToStableHash,(W_)p);
sn = (StgWord)sn_tmp;
@@
-312,7
+326,7
@@
enlargeStablePtrTable(void)
* -------------------------------------------------------------------------- */
void
* -------------------------------------------------------------------------- */
void
-markStablePtrTable(evac_fn evac)
+markStablePtrTable(evac_fn evac, void *user)
{
snEntry *p, *end_stable_ptr_table;
StgPtr q;
{
snEntry *p, *end_stable_ptr_table;
StgPtr q;
@@
-336,7
+350,7
@@
markStablePtrTable(evac_fn evac)
// if the ref is non-zero, treat addr as a root
if (p->ref != 0) {
// if the ref is non-zero, treat addr as a root
if (p->ref != 0) {
- evac((StgClosure **)&p->addr);
+ evac(user, (StgClosure **)&p->addr);
}
}
}
}
}
}
@@
-351,7
+365,7
@@
markStablePtrTable(evac_fn evac)
* -------------------------------------------------------------------------- */
void
* -------------------------------------------------------------------------- */
void
-threadStablePtrTable( evac_fn evac )
+threadStablePtrTable( evac_fn evac, void *user )
{
snEntry *p, *end_stable_ptr_table;
StgPtr q;
{
snEntry *p, *end_stable_ptr_table;
StgPtr q;
@@
-361,12
+375,12
@@
threadStablePtrTable( evac_fn evac )
for (p = stable_ptr_table+1; p < end_stable_ptr_table; p++) {
if (p->sn_obj != NULL) {
for (p = stable_ptr_table+1; p < end_stable_ptr_table; p++) {
if (p->sn_obj != NULL) {
- evac((StgClosure **)&p->sn_obj);
+ evac(user, (StgClosure **)&p->sn_obj);
}
q = p->addr;
if (q && (q < (P_)stable_ptr_table || q >= (P_)end_stable_ptr_table)) {
}
q = p->addr;
if (q && (q < (P_)stable_ptr_table || q >= (P_)end_stable_ptr_table)) {
- evac((StgClosure **)&p->addr);
+ evac(user, (StgClosure **)&p->addr);
}
}
}
}
}
}
@@
-412,15
+426,15
@@
gcStablePtrTable( void )
if (p->sn_obj == NULL) {
// StableName object is dead
freeStableName(p);
if (p->sn_obj == NULL) {
// StableName object is dead
freeStableName(p);
- debugTrace(DEBUG_stable, "GC'd Stable name %ld",
- p - stable_ptr_table);
+ debugTrace(DEBUG_stable, "GC'd Stable name %ld",
+ (long)(p - stable_ptr_table));
continue;
} else {
p->addr = (StgPtr)isAlive((StgClosure *)p->addr);
debugTrace(DEBUG_stable,
"stable name %ld still alive at %p, ref %ld\n",
continue;
} else {
p->addr = (StgPtr)isAlive((StgClosure *)p->addr);
debugTrace(DEBUG_stable,
"stable name %ld still alive at %p, ref %ld\n",
- p - stable_ptr_table, p->addr, p->ref);
+ (long)(p - stable_ptr_table), p->addr, p->ref);
}
}
}
}
}
}