From c1e3719cc59f20d32c917e066ae7cd5edb98a96d Mon Sep 17 00:00:00 2001 From: Cheng Shao <terrorjack@type.dance> Date: Thu, 19 Oct 2023 00:38:43 +0000 Subject: [PATCH] rts: drop stale mentions of MIN_UPD_SIZE We used to have MIN_UPD_SIZE macro that describes the minimum reserved size for thunks, so that the thunk can be overwritten in place as indirections or blackholes. However, this macro has not been actually defined or used anywhere since a long time ago; StgThunkHeader already reserves a padding word for this purpose. Hence this patch which drops stale mentions of MIN_UPD_SIZE. --- docs/rts/rts.tex | 7 +++---- rts/PrimOps.cmm | 19 ++----------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/docs/rts/rts.tex b/docs/rts/rts.tex index 6a653183b468..73ed579de527 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 2d243345f3f4..bccb12a05389 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); -- GitLab