1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
\section[SMstacks.lc]{Stack allocation (sequential)}
Routine that allocates the A and B stack (sequential only).
\begin{code}
#ifndef PAR
# define NULL_REG_MAP
# include "SMinternal.h"
stackData stackInfo;
P_ stks_space = 0;
#ifdef CONCURRENT
EXTDATA_RO(StkO_static_info);
P_ MainStkO;
#endif
I_
initStacks(sm)
smInfo *sm;
{
/*
* Allocate them if they don't exist. One space does for both stacks, since they
* grow towards each other
*/
if (stks_space == 0) {
#ifdef CONCURRENT
MainStkO = (P_) xmalloc((STKO_HS + SM_word_stk_size) * sizeof(W_));
stks_space = MainStkO + STKO_HS;
SET_STKO_HDR(MainStkO, StkO_static_info, CC_SUBSUMED);
STKO_SIZE(MainStkO) = SM_word_stk_size + STKO_VHS;
STKO_LINK(MainStkO) = Nil_closure;
STKO_RETURN(MainStkO) = NULL;
#else
stks_space = (P_) xmalloc(SM_word_stk_size * sizeof(W_));
#endif
}
# if STACK_CHECK_BY_PAGE_FAULT
unmapMiddleStackPage((char *) stks_space, SM_word_stk_size * sizeof(W_));
# endif
/* Initialise Stack Info and pointers */
stackInfo.botA = STK_A_FRAME_BASE(stks_space, SM_word_stk_size);
stackInfo.botB = STK_B_FRAME_BASE(stks_space, SM_word_stk_size);
MAIN_SuA = MAIN_SpA = stackInfo.botA + AREL(1);
MAIN_SuB = MAIN_SpB = stackInfo.botB + BREL(1);
if (SM_trace)
fprintf(stderr, "STACK init: botA, spa: 0x%lx, 0x%lx\n botB, spb: 0x%lx, 0x%lx\n",
(W_) stackInfo.botA, (W_) MAIN_SpA, (W_) stackInfo.botB, (W_) MAIN_SpB);
return 0;
}
#endif /* not parallel */
\end{code}
|