1 /* -----------------------------------------------------------------------------
3 * (c) The University of Glasgow 2002-2004
5 * Helper bits for the generic apply code (AutoApply.hc)
7 * -------------------------------------------------------------------------- */
12 // Build a new PAP: function is in R1
13 // ret addr and m arguments taking up n words are on the stack.
14 // NB. x is a dummy argument attached to the 'for' label so that
15 // BUILD_PAP can be used multiple times in the same function.
16 #define BUILD_PAP(m,n,f,x) \
20 size = SIZEOF_StgPAP + WDS(n); \
21 HP_CHK_NP_ASSIGN_SP0(size,f); \
22 TICK_ALLOC_HEAP_NOCTR(BYTES_TO_WDS(size)); \
23 TICK_ALLOC_PAP(n+1 /* +1 for the FUN */, 0); \
24 pap = Hp + WDS(1) - size; \
25 SET_HDR(pap, stg_PAP_info, W_[CCCS]); \
26 StgPAP_arity(pap) = HALF_W_(arity - m); \
27 StgPAP_fun(pap) = R1; \
28 StgPAP_n_args(pap) = HALF_W_(n); \
32 StgPAP_payload(pap,i) = Sp(1+i); \
38 jump %ENTRY_CODE(Sp(0));
40 // Copy the old PAP, build a new one with the extra arg(s)
41 // ret addr and m arguments taking up n words are on the stack.
42 // NB. x is a dummy argument attached to the 'for' label so that
43 // BUILD_PAP can be used multiple times in the same function.
44 #define NEW_PAP(m,n,f,x) \
50 size = SIZEOF_StgPAP + WDS(TO_W_(StgPAP_n_args(pap))) + WDS(n); \
51 HP_CHK_NP_ASSIGN_SP0(size,f); \
52 TICK_ALLOC_HEAP_NOCTR(BYTES_TO_WDS(size)); \
53 TICK_ALLOC_PAP(n+1 /* +1 for the FUN */, 0); \
54 new_pap = Hp + WDS(1) - size; \
55 SET_HDR(new_pap, stg_PAP_info, W_[CCCS]); \
56 StgPAP_arity(new_pap) = HALF_W_(arity - m); \
58 n_args = TO_W_(StgPAP_n_args(pap)); \
59 StgPAP_n_args(new_pap) = HALF_W_(n_args + n); \
60 StgPAP_fun(new_pap) = StgPAP_fun(pap); \
64 StgPAP_payload(new_pap,i) = StgPAP_payload(pap,i); \
71 StgPAP_payload(new_pap,n_args+i) = Sp(1+i); \
77 jump %ENTRY_CODE(Sp(0));