summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-11-17 09:27:06 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-11-19 11:57:36 -0500
commitc819c0e413069cb4e16236fb3e6576658060a17d (patch)
treeeb193aa80a9f7e704769070e2685cbc918492993
parent0418c38d55c7a47967187dce2db5ea2ab1021b1e (diff)
downloadhaskell-c819c0e413069cb4e16236fb3e6576658060a17d.tar.gz
nonmoving: Use correct info table pointer accessor
Previously we used INFO_PTR_TO_STRUCT instead of THUNK_INFO_PTR_TO_STRUCT when looking at a thunk. These two happen to be equivalent on 64-bit architectures due to alignment considerations however they are different on 32-bit platforms. This lead to #17487. To fix this we also employ a small optimization: there is only one thunk of type WHITEHOLE (namely stg_WHITEHOLE_info). Consequently, we can just use a plain pointer comparison instead of testing against info->type.
-rw-r--r--includes/rts/storage/ClosureMacros.h14
-rw-r--r--rts/sm/NonMovingMark.c12
2 files changed, 7 insertions, 19 deletions
diff --git a/includes/rts/storage/ClosureMacros.h b/includes/rts/storage/ClosureMacros.h
index b5ae2dafc6..1b3628f2b9 100644
--- a/includes/rts/storage/ClosureMacros.h
+++ b/includes/rts/storage/ClosureMacros.h
@@ -107,20 +107,6 @@ INLINE_HEADER const StgConInfoTable *get_con_itbl(const StgClosure *c)
return CON_INFO_PTR_TO_STRUCT((c)->header.info);
}
-/* Used when we expect another thread to be mutating the info table pointer of
- * a closure (e.g. when busy-waiting on a WHITEHOLE).
- */
-INLINE_HEADER const StgInfoTable *get_volatile_itbl(StgClosure *c) {
- // The volatile here is import to ensure that the compiler does not
- // optimise away multiple loads, e.g. in a busy-wait loop. Note that
- // we can't use VOLATILE_LOAD here as the casts result in strict aliasing
- // rule violations and this header may be compiled outside of the RTS
- // (where we use -fno-strict-aliasing).
- StgInfoTable * *volatile p = (StgInfoTable * *volatile) &c->header.info;
- return INFO_PTR_TO_STRUCT(*p);
-}
-
-
INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con)
{
return get_itbl(con)->srt;
diff --git a/rts/sm/NonMovingMark.c b/rts/sm/NonMovingMark.c
index b7ab772bdd..e236056092 100644
--- a/rts/sm/NonMovingMark.c
+++ b/rts/sm/NonMovingMark.c
@@ -567,9 +567,11 @@ inline void updateRemembSetPushThunk(Capability *cap, StgThunk *thunk)
{
const StgInfoTable *info;
do {
- info = get_volatile_itbl((StgClosure *) thunk);
- } while (info->type == WHITEHOLE);
- updateRemembSetPushThunkEager(cap, (StgThunkInfoTable *) info, thunk);
+ info = *(StgInfoTable* volatile*) &thunk->header.info;
+ } while (info == &stg_WHITEHOLE_info);
+
+ const StgThunkInfoTable *thunk_info = THUNK_INFO_PTR_TO_STRUCT(info);
+ updateRemembSetPushThunkEager(cap, thunk_info, thunk);
}
/* Push the free variables of a thunk to the update remembered set.
@@ -1229,7 +1231,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin)
goto done;
case WHITEHOLE:
- while (get_volatile_itbl(p)->type == WHITEHOLE);
+ while (*(StgInfoTable* volatile*) &p->header.info == &stg_WHITEHOLE_info);
// busy_wait_nop(); // FIXME
goto try_again;
@@ -1588,7 +1590,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin)
}
case WHITEHOLE:
- while (get_volatile_itbl(p)->type == WHITEHOLE);
+ while (*(StgInfoTable* volatile*) &p->header.info == &stg_WHITEHOLE_info);
goto try_again;
case COMPACT_NFDATA: