diff --git a/docs/rts/rts.tex b/docs/rts/rts.tex index 6a653183b468212fb43cf94cebbf5cb9b4cc4383..73ed579de5279da619e40c6fabce07d2624f2ef1 100644 --- a/docs/rts/rts.tex +++ b/docs/rts/rts.tex @@ -1970,10 +1970,9 @@ Here the right-hand sides of @range@ and @ys@ are both thunks; the former is static while the latter is dynamic. The layout of a thunk is the same as that for a function closure. -However, thunks must have a payload of at least @MIN_UPD_SIZE@ -words to allow it to be overwritten with a black hole and an -indirection. The compiler may have to add extra non-pointer fields to -satisfy this constraint. +However, a thunk header always contains an extra padding word at the +end. This allows the thunk to be overwritten with an indirection, +where the padding word will be repurposed as the indirectee pointer. \begin{center} \begin{tabular}{|l|l|l|l|l|}\hline diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index 2d243345f3f4ef4cc06c79c995d8fb015c86af76..bccb12a0538932ea8fcb24029ad83593dddce1b0 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -740,25 +740,15 @@ stg_atomicModifyMutVar2zh ( gcptr mv, gcptr f ) obviously we can share (f x). - z = [stg_ap_2 f x] (max (HS + 2) MIN_UPD_SIZE) - y = [stg_sel_0 z] (max (HS + 1) MIN_UPD_SIZE) + z = [stg_ap_2 f x] (SIZEOF_StgThunkHeader + WDS(2)) + y = [stg_sel_0 z] (SIZEOF_StgThunkHeader + WDS(1)) */ -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 1 -#define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE)) -#define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),WDS(MIN_UPD_SIZE-1)) -#else #define THUNK_1_SIZE (SIZEOF_StgThunkHeader + WDS(1)) #define TICK_ALLOC_THUNK_1() TICK_ALLOC_UP_THK(WDS(1),0) -#endif -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 2 -#define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE)) -#define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2)) -#else #define THUNK_2_SIZE (SIZEOF_StgThunkHeader + WDS(2)) #define TICK_ALLOC_THUNK_2() TICK_ALLOC_UP_THK(WDS(2),0) -#endif #define SIZE (THUNK_2_SIZE + THUNK_1_SIZE) @@ -815,13 +805,8 @@ stg_atomicModifyMutVarzuzh ( gcptr mv, gcptr f ) z = [stg_ap_2 f x] (max (HS + 2) MIN_UPD_SIZE) */ -#if defined(MIN_UPD_SIZE) && MIN_UPD_SIZE > 2 -#define THUNK_SIZE (SIZEOF_StgThunkHeader + WDS(MIN_UPD_SIZE)) -#define TICK_ALLOC_THUNK() TICK_ALLOC_UP_THK(WDS(2),WDS(MIN_UPD_SIZE-2)) -#else #define THUNK_SIZE (SIZEOF_StgThunkHeader + WDS(2)) #define TICK_ALLOC_THUNK() TICK_ALLOC_UP_THK(WDS(2),0) -#endif HP_CHK_GEN_TICKY(THUNK_SIZE);