Why not point to the next free location in Hp? (in Cmm)
In Cmm currently Hp points to the last occupied location. However most of the time we actually need the next free location, as can be seen with a quick grep/ack/ag:
$ ag -w "Hp"
...
rts/PrimOps.cmm
528: mv = Hp - SIZEOF_StgMutVar + WDS(1);
613: z = Hp - THUNK_2_SIZE + WDS(1);
672: z = Hp - THUNK_SIZE + WDS(1);
707: w = Hp - SIZEOF_StgWeak + WDS(1);
742: c = Hp - SIZEOF_StgCFinalizerList + WDS(1);
1368: tv = Hp - SIZEOF_StgTVar + WDS(1);
1469: mvar = Hp - SIZEOF_StgMVar + WDS(1);
1515: q = Hp - SIZEOF_StgMVarTSOQueue + WDS(1);
1681: q = Hp - SIZEOF_StgMVarTSOQueue + WDS(1);
1872: q = Hp - SIZEOF_StgMVarTSOQueue + WDS(1);
1990: bco = Hp - bytes + WDS(1);
2027: ap = Hp - SIZEOF_StgAP + WDS(1);
2059: dat_arr = Hp - dat_arr_sz + WDS(1);
2503: offset = Hp - bdescr_start(CurrentNursery);
2514: offset = Hp - bdescr_start(CurrentNursery);
rts/Apply.cmm
108: pap = Hp - SIZEOF_StgPAP + WDS(1);
134: pap = Hp - size + WDS(1);
...
I wonder if changing Hp so that it points to the next free location (or HpLim) would make more sense than the current implementation (which points to the last occupied location).