Commit c819c0e4 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

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.
parent 0418c38d
......@@ -107,20 +107,6 @@ INLINE_HEADER const StgConInfoTable *get_con_itbl(const StgClosure *c)
return CON_INFO_PTR_TO_STRUCT((c)->;
/* 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->;
return INFO_PTR_TO_STRUCT(*p);
INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con)
return get_itbl(con)->srt;
......@@ -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->;
} 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;
while (get_volatile_itbl(p)->type == WHITEHOLE);
while (*(StgInfoTable* volatile*) &p-> == &stg_WHITEHOLE_info);
// busy_wait_nop(); // FIXME
goto try_again;
......@@ -1588,7 +1590,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin)
while (get_volatile_itbl(p)->type == WHITEHOLE);
while (*(StgInfoTable* volatile*) &p-> == &stg_WHITEHOLE_info);
goto try_again;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment