1 // -----------------------------------------------------------------------------
4 // (c) The University of Glasgow 2002
6 // Helper bits for the generic apply code (AutoApply.hc)
7 // -----------------------------------------------------------------------------
12 // Build a new PAP: function is in R1,p
13 // ret addr and m arguments taking up n words are on the stack.
14 #define BUILD_PAP(m,n,f) \
18 TICK_SLOW_CALL_BUILT_PAP(); \
19 size = PAP_sizeW(n); \
20 HP_CHK_NP(size, Sp[0] = f;); \
21 TICK_ALLOC_PAP(n, 0); \
22 pap = (StgPAP *) (Hp + 1 - size); \
23 SET_HDR(pap, &stg_PAP_info, CCCS); \
24 pap->arity = arity - m; \
27 for (i = 0; i < n; i++) { \
28 pap->payload[i] = (StgClosure *)Sp[1+i]; \
32 JMP_(ENTRY_CODE(Sp[0])); \
35 // Copy the old PAP, build a new one with the extra arg(s)
36 // ret addr and m arguments taking up n words are on the stack.
37 #define NEW_PAP(m,n,f) \
39 StgPAP *pap, *new_pap; \
41 TICK_SLOW_CALL_NEW_PAP(); \
42 pap = (StgPAP *)R1.p; \
43 size = PAP_sizeW(pap->n_args + n); \
44 HP_CHK_NP(size, Sp[0] = f;); \
45 TICK_ALLOC_PAP(n, 0); \
46 new_pap = (StgPAP *) (Hp + 1 - size); \
47 SET_HDR(new_pap, &stg_PAP_info, CCCS); \
48 new_pap->arity = arity - m; \
49 new_pap->n_args = pap->n_args + n; \
50 new_pap->fun = pap->fun; \
51 for (i = 0; i < pap->n_args; i++) { \
52 new_pap->payload[i] = pap->payload[i]; \
54 for (i = 0; i < n; i++) { \
55 new_pap->payload[pap->n_args+i] = (StgClosure *)Sp[1+i]; \
59 JMP_(ENTRY_CODE(Sp[0])); \
62 // canned slow entry points, indexed by arg type (ARG_P, ARG_PP, etc.)
63 extern StgFun * stg_ap_stack_entries[];
65 // canned register save code for heap check failure in a function
66 extern StgFun * stg_stack_save_entries[];
68 // canned bitmap for each arg type
69 extern StgWord stg_arg_bitmaps[];