1 \section[SMstacks.lc]{Stack allocation (sequential)}
3 Routine that allocates the A and B stack (sequential only).
8 # include "SMinternal.h"
10 #if 1 /* ndef CONCURRENT */ /* HWL */
17 EXTDATA_RO(StkO_static_info);
22 initStacks(smInfo *sm)
25 * Allocate them if they don't exist. One space does for both stacks, since they
26 * grow towards each other
28 if (stks_space == 0) {
30 stks_space = (P_) stgMallocWords(RTSflags.GcFlags.stksSize, "initStacks");
32 MainStkO = (P_) stgMallocWords(STKO_HS + RTSflags.GcFlags.stksSize, "initStacks");
33 stks_space = MainStkO + STKO_HS;
34 SET_STKO_HDR(MainStkO, StkO_static_info, CC_SUBSUMED);
35 STKO_SIZE(MainStkO) = RTSflags.GcFlags.stksSize + STKO_VHS;
36 STKO_SpB(MainStkO) = STKO_SuB(MainStkO) = STKO_BSTK_BOT(MainStkO) + BREL(1);
37 STKO_SpA(MainStkO) = STKO_SuA(MainStkO) = STKO_ASTK_BOT(MainStkO) + AREL(1);
38 STKO_LINK(MainStkO) = Prelude_Z91Z93_closure;
39 STKO_RETURN(MainStkO) = NULL;
41 ASSERT(sanityChk_StkO(MainStkO));
43 if (RTSflags.GcFlags.trace)
44 fprintf(stderr, "STACK init: botA, spa: 0x%lx, 0x%lx\n botB, spb: 0x%lx, 0x%lx\n",
45 (W_) STKO_ASTK_BOT(MainStkO), (W_) STKO_SpA(MainStkO), (W_) STKO_BSTK_BOT(MainStkO), (W_) STKO_SpB(MainStkO));
49 # if STACK_CHECK_BY_PAGE_FAULT
50 unmapMiddleStackPage((char *) stks_space, RTSflags.GcFlags.stksSize * sizeof(W_));
53 /* Initialise Stack Info and pointers */
54 #if 1 /* ndef CONCURRENT */ /* HWL */
55 stackInfo.botA = STK_A_FRAME_BASE(stks_space, RTSflags.GcFlags.stksSize);
56 stackInfo.botB = STK_B_FRAME_BASE(stks_space, RTSflags.GcFlags.stksSize);
58 MAIN_SuA = MAIN_SpA = stackInfo.botA + AREL(1);
59 MAIN_SuB = MAIN_SpB = stackInfo.botB + BREL(1);
61 if (RTSflags.GcFlags.trace)
62 fprintf(stderr, "STACK init: botA, spa: 0x%lx, 0x%lx\n botB, spb: 0x%lx, 0x%lx\n",
63 (W_) stackInfo.botA, (W_) MAIN_SpA, (W_) stackInfo.botB, (W_) MAIN_SpB);
64 #endif /* !CONCURRENT */
69 #endif /* not parallel */