Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / runtime / gc / heap.h
CommitLineData
7f918cf1
CE
1/* Copyright (C) 2012 Matthew Fluet.
2 * Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 * Copyright (C) 1997-2000 NEC Research Institute.
5 *
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
8 */
9
10#if (defined (MLTON_GC_INTERNAL_TYPES))
11
12/*
13 * All ML objects (including ML execution stacks) are allocated in a
14 * contiguous heap. The heap has the following general layout:
15 *
16 * -------------------------------------------------------------------------
17 * | old generation | | nursery | cardMap | crossMap |
18 * -------------------------------------------------------------------------
19 * |------oldGenSize------|
20 * |-----------------------size-----------------------|
21 * ^ ^
22 * start nursery
23 * |------------------------------withMapsSize-----------------------------|
24*/
25
26typedef struct GC_heap {
27 pointer nursery; /* start of nursery */
28 size_t oldGenSize; /* size of old generation */
29 size_t size; /* size of heap */
30 pointer start; /* start of heap (and old generation) */
31 size_t withMapsSize; /* size of heap with card/cross maps */
32} *GC_heap;
33
34#define GC_HEAP_LIMIT_SLOP 512
35
36#endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */
37
38#if (defined (MLTON_GC_INTERNAL_FUNCS))
39
40static inline bool isPointerInOldGen (GC_state s, pointer p);
41static inline bool isPointerInNursery (GC_state s, pointer p);
42#if ASSERT
43static inline bool isObjptrInOldGen (GC_state s, objptr op);
44#endif
45static inline bool isObjptrInNursery (GC_state s, objptr op);
46#if ASSERT
47static inline bool isObjptrInFromSpace (GC_state s, objptr op);
48#endif
49static inline bool hasHeapBytesFree (GC_state s, size_t oldGen, size_t nursery);
50static inline bool isHeapInit (GC_heap h);
51
52static void displayHeap (GC_state s, GC_heap heap, FILE *stream);
53
54static inline void initHeap (GC_state s, GC_heap h);
55static inline size_t sizeofHeapDesired (GC_state s, size_t live, size_t currentSize);
56
57static inline void releaseHeap (GC_state s, GC_heap h);
58static void shrinkHeap (GC_state s, GC_heap h, size_t keepSize);
59static bool createHeap (GC_state s, GC_heap h, size_t desiredSize, size_t minSize);
60static bool createHeapSecondary (GC_state s, size_t desiredSize);
61static bool remapHeap (GC_state s, GC_heap h, size_t desiredSize, size_t minSize);
62static void growHeap (GC_state s, size_t desiredSize, size_t minSize);
63static void resizeHeap (GC_state s, size_t minSize);
64static void resizeHeapSecondary (GC_state s);
65
66#endif /* (defined (MLTON_GC_INTERNAL_FUNCS)) */