1 // -----------------------------------------------------------------------------
4 // (c) The University of Glasgow 2002
6 // Application-related bits.
8 // -----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
22 // Evaluate a closure and return it.
24 // stg_ap_0_info <--- Sp
26 // NOTE: this needs to be a polymorphic return point, because we can't
27 // be sure that the thing being evaluated is not a function.
29 // These names are just to keep VEC_POLY_INFO_TABLE() happy - all the
30 // entry points in the polymorphic info table point to the same code.
31 #define stg_ap_0_0_ret stg_ap_0_ret
32 #define stg_ap_0_1_ret stg_ap_0_ret
33 #define stg_ap_0_2_ret stg_ap_0_ret
34 #define stg_ap_0_3_ret stg_ap_0_ret
35 #define stg_ap_0_4_ret stg_ap_0_ret
36 #define stg_ap_0_5_ret stg_ap_0_ret
37 #define stg_ap_0_6_ret stg_ap_0_ret
38 #define stg_ap_0_7_ret stg_ap_0_ret
40 VEC_POLY_INFO_TABLE(stg_ap_0,
41 MK_SMALL_BITMAP(0/*framsize*/, 0/*bitmap*/),
42 0,0,0,RET_SMALL,,EF_);
46 // fn is in R1, no args on the stack
51 IF_DEBUG(apply,fprintf(stderr, "stg_ap_0_ret... "); printClosure(R1.cl));
52 IF_DEBUG(sanity,checkStackChunk(Sp+1,CurrentTSO->stack + CurrentTSO->stack_size));
59 /* -----------------------------------------------------------------------------
62 This entry code is *only* called by one of the stg_ap functions.
63 On entry: Sp points to the remaining arguments on the stack. If
64 the stack check fails, we can just push the PAP on the stack and
65 return to the scheduler.
67 On entry: R1 points to the PAP. The rest of the function's arguments
68 (*all* of 'em) are on the stack, starting at Sp[0].
70 The idea is to copy the chunk of stack from the PAP object onto the
71 stack / into registers, and enter the function.
72 -------------------------------------------------------------------------- */
74 INFO_TABLE(stg_PAP_info,stg_PAP_entry,/*special layout*/0,0,PAP,,EF_,"PAP","PAP");
83 pap = (StgPAP *) R1.p;
87 // Check for stack overflow and bump the stack pointer.
88 // We have a hand-rolled stack check fragment here, because none of
89 // the canned ones suit this situation.
90 if ((Sp - Words) < SpLim) {
91 DEBUG_ONLY(fprintf(stderr,"PAP STACK CHECK!\n"));
92 // there is a return address on the stack in the event of a
93 // stack check failure. The various stg_apply functions arrange
94 // this before calling stg_PAP_entry.
97 // Sp is already pointing one word below the arguments...
103 // Enter PAP cost centre -- lexical scoping only
104 ENTER_CCS_PAP_CL(pap);
107 p = (P_)(pap->payload);
110 for (i=0; i<Words; i++) {
118 JMP_(GET_ENTRY(R1.cl));
121 StgFunInfoTable *info;
122 info = get_fun_itbl(R1.cl);
123 if (info->fun_type == ARG_GEN || info->fun_type == ARG_GEN_BIG) {
124 JMP_(info->slow_apply);
126 JMP_(stg_ap_stack_entries[info->fun_type]);