-/* newCAF must be called before the itbl ptr is overwritten, since
- newCAF records the old itbl ptr in order to do CAF reverting
- (which Hugs needs to do in order that combined mode works right.)
-*/
-#define UPD_CAF(cafptr, bhptr) \
- { \
- LOCK_CLOSURE(cafptr); \
- STGCALL1(newCAF,(StgClosure *)cafptr); \
- ((StgInd *)cafptr)->indirectee = (StgClosure *)(bhptr); \
- SET_INFO((StgInd *)cafptr,(const StgInfoTable*)&stg_IND_STATIC_info);\
+/* We have two versions of this macro (sadly), one for use in C-- code,
+ * and the other for C.
+ *
+ * The and_then argument is a performance hack so that we can paste in
+ * the continuation code directly. It helps shave a couple of
+ * instructions off the common case in the update code, which is
+ * worthwhile (the update code is often part of the inner loop).
+ * (except that gcc now appears to common up this code again and
+ * invert the optimisation. Grrrr --SDM).
+ */
+#ifdef CMINUSMINUS
+#define generation(n) (W_[generations] + n*SIZEOF_generation)
+#define updateWithIndirection(info, ind_info, p1, p2, and_then) \
+ W_ bd; \
+ \
+/* ASSERT( p1 != p2 && !closure_IND(p1) ); \
+ */ LDV_RECORD_DEAD_FILL_SLOP_DYNAMIC(p1); \
+ bd = Bdescr(p1); \
+ if (bdescr_gen_no(bd) == 0) { \
+ StgInd_indirectee(p1) = p2; \
+ SET_INFO(p1, ind_info); \
+ LDV_RECORD_CREATE(p1); \
+ TICK_UPD_NEW_IND(); \
+ and_then; \
+ } else { \
+ if (info != stg_BLACKHOLE_BQ_info) { \
+ DEBUG_FILL_SLOP(p1); \
+ W_ __mut_once_list; \
+ __mut_once_list = generation(bdescr_gen_no(bd)) + \
+ OFFSET_generation_mut_once_list; \
+ StgMutClosure_mut_link(p1) = W_[__mut_once_list]; \
+ W_[__mut_once_list] = p1; \
+ } \
+ StgInd_indirectee(p1) = p2; \
+ SET_INFO(p1, stg_IND_OLDGEN_info); \
+ LDV_RECORD_CREATE(p1); \
+ TICK_UPD_OLD_IND(); \
+ and_then; \