1 \section[STGRegs]{Macros for saving/restoring STG registers}
9 %************************************************************************
11 \subsection[saving-restoring-STG-regs]{Saving/restoring STG registers}
13 %************************************************************************
15 These routines will fail on the SPARC if they are allowed to drop out-of-line
16 (the wrong register window will be active).
20 #if defined(__STG_GCC_REGS__) && defined(MAIN_REG_MAP)
22 EXTDATA(STK_STUB_closure);
23 EXTFUN(STK_STUB_entry);
24 EXTDATA_RO(vtbl_StdUpdFrame);
26 /* Keep -Wmissing-prototypes from complaining */
27 void SaveAllStgRegs(STG_NO_ARGS);
29 void SaveAllStgContext(void * /*return address*/);
31 void SaveAllStgContext(STG_NO_ARGS);
33 void SaveStgStackRegs(STG_NO_ARGS);
34 void RestoreAllStgRegs(STG_NO_ARGS);
35 void RestoreStackStgRegs(STG_NO_ARGS);
38 void SaveAllStgRegs(STG_NO_ARGS)
42 /* I do not think so: CurrentRegTable will not have changed
43 between entry to and exit from "Haskell land" (WDP 95/12)
45 /* CurrentRegTable = BaseReg; */
48 /* Hack!!! slam the current C stack pointer into the reg. table
49 in the event that we need to copy a chunk of the C stack
50 before entering Haskell via a stable pointer (contact
51 <sof> for (gruesome) details!)
55 ToDo: support this across platforms.
57 #if 0 && defined(CONCURRENT) && defined(i386_TARGET_ARCH)
58 if (CurrentTSO != CurrentTSOinC) {
59 __asm__ volatile (" mov %%esp,%0" : "m=" (CurrentRegTable->rCstkptr));
135 #if defined(REG_SpA) || defined(CONCURRENT)
139 #if defined(REG_SuA) || defined(CONCURRENT)
143 #if defined(REG_SpB) || defined(CONCURRENT)
147 #if defined(REG_SuB) || defined(CONCURRENT)
151 SAVE_Hp = Hp; /* always! */
152 SAVE_HpLim = HpLim; /* ditto! */
158 SaveAllStgContext(void * ret_addr)
160 SaveAllStgContext(STG_NO_ARGS)
165 # if defined(PROFILING) || defined(PAR)
166 TSO_CCC(CurrentTSO) = CCC;
167 CCC = (CostCentre)STATIC_CC_REF(CC_MAIN);
169 # if i386_TARGET_ARCH
170 SET_RETADDR(TSO_PC2(CurrentTSO), ret_addr)
172 SET_RETADDR(TSO_PC2(CurrentTSO))
178 void SaveStgStackRegs(STG_NO_ARGS)
180 #if defined(REG_SpA) || defined(CONCURRENT)
184 #if defined(REG_SuA) || defined(CONCURRENT)
188 #if defined(REG_SpB) || defined(CONCURRENT)
192 #if defined(REG_SuB) || defined(CONCURRENT)
197 extern STG_INLINE void
198 RestoreAllStgRegs (STG_NO_ARGS)
201 /* Re-initialise the register table pointer */
203 BaseReg = CurrentRegTable;
205 BaseReg = &MainRegTable;
281 #if defined(REG_StkO) && defined(CONCURRENT)
285 #if defined(REG_SpA) || defined(CONCURRENT)
289 #if defined(REG_SuA) || defined(CONCURRENT)
293 #if defined(REG_SpB) || defined(CONCURRENT)
297 #if defined(REG_SuB) || defined(CONCURRENT)
301 Hp = SAVE_Hp; /* always! */
302 HpLim = SAVE_HpLim; /* ditto! */
304 #ifdef REG_StdUpdRetVec
305 StdUpdRetVecReg = vtbl_StdUpdFrame;
309 StkStubReg = STK_STUB_closure;
313 # if defined(PROFILING) || defined(PAR)
314 CCC = TSO_CCC(CurrentTSO);
319 extern STG_INLINE void
320 RestoreStackStgRegs (STG_NO_ARGS)
322 #if defined(REG_SpA) || defined(CONCURRENT)
326 #if defined(REG_SuA) || defined(CONCURRENT)
330 #if defined(REG_SpB) || defined(CONCURRENT)
334 #if defined(REG_SuB) || defined(CONCURRENT)
339 #else /* For the unwashed and unregisterized */
343 #define SaveAllStgRegs() \
346 SAVE_HpLim = HpLim; \
353 #define RestoreAllStgRegs() \
356 HpLim = SAVE_HpLim; \
363 #define RestoreStackStgRegs() \
373 #define SaveAllStgRegs() do {SAVE_Hp = Hp; SAVE_HpLim = HpLim;} while(0)
375 #define RestoreAllStgRegs() do {Hp = SAVE_Hp; HpLim = SAVE_HpLim;} while(0)
376 #define RestoreStackStgRegs() /* nothing */
378 #endif /* CONCURRENT */
380 #define SaveAllStgContext() SaveAllStgRegs()
382 #endif /* __STG_GCC_REGS__ && MAIN_REG_MAP */
384 #endif /* STGREGS_H */