Import Upstream version 20180207
[hcoop/debian/mlton.git] / runtime / gc / foreach.h
1 /* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 * Copyright (C) 1997-2000 NEC Research Institute.
4 *
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
7 */
8
9 #if (defined (MLTON_GC_INTERNAL_FUNCS))
10
11 typedef void (*GC_foreachObjptrFun) (GC_state s, objptr *opp);
12
13 static inline void callIfIsObjptr (GC_state s, GC_foreachObjptrFun f, objptr *opp);
14 /* foreachGlobalObjptr (s, f)
15 *
16 * Apply f to each global object pointer into the heap.
17 */
18 static inline void foreachGlobalObjptr (GC_state s, GC_foreachObjptrFun f);
19 /* foreachObjptrInObject (s, p, skipWeaks, f)
20 *
21 * Applies f to each object pointer in the object pointed to by p.
22 * Returns pointer to the end of object, i.e. just past object.
23 *
24 * If skipWeaks, then the object pointer in weak objects is skipped.
25 */
26 static inline pointer foreachObjptrInObject (GC_state s, pointer p,
27 GC_foreachObjptrFun f, bool skipWeaks);
28 /* foreachObjptrInRange (s, front, back, f, skipWeaks)
29 *
30 * Apply f to each pointer between front and *back, which should be a
31 * contiguous sequence of objects, where front points at the beginning
32 * of the first object and *back points just past the end of the last
33 * object. f may increase *back (for example, this is done by
34 * forward). foreachObjptrInRange returns a pointer to the end of
35 * the last object it visits.
36 *
37 * If skipWeaks, then the object pointer in weak objects is skipped.
38 */
39 static inline pointer foreachObjptrInRange (GC_state s, pointer front, pointer *back,
40 GC_foreachObjptrFun f, bool skipWeaks);
41
42
43 typedef void (*GC_foreachStackFrameFun) (GC_state s, GC_frameIndex i);
44
45 /* foreachStackFrame (s, f);
46 *
47 * Apply f to the frame index of each frame in the current stack.
48 */
49 static inline void foreachStackFrame (GC_state s, GC_foreachStackFrameFun f);
50
51 #endif /* (defined (MLTON_GC_INTERNAL_FUNCS)) */