Commit | Line | Data |
---|---|---|
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 | ||
26 | typedef 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 | ||
40 | static inline bool isPointerInOldGen (GC_state s, pointer p); | |
41 | static inline bool isPointerInNursery (GC_state s, pointer p); | |
42 | #if ASSERT | |
43 | static inline bool isObjptrInOldGen (GC_state s, objptr op); | |
44 | #endif | |
45 | static inline bool isObjptrInNursery (GC_state s, objptr op); | |
46 | #if ASSERT | |
47 | static inline bool isObjptrInFromSpace (GC_state s, objptr op); | |
48 | #endif | |
49 | static inline bool hasHeapBytesFree (GC_state s, size_t oldGen, size_t nursery); | |
50 | static inline bool isHeapInit (GC_heap h); | |
51 | ||
52 | static void displayHeap (GC_state s, GC_heap heap, FILE *stream); | |
53 | ||
54 | static inline void initHeap (GC_state s, GC_heap h); | |
55 | static inline size_t sizeofHeapDesired (GC_state s, size_t live, size_t currentSize); | |
56 | ||
57 | static inline void releaseHeap (GC_state s, GC_heap h); | |
58 | static void shrinkHeap (GC_state s, GC_heap h, size_t keepSize); | |
59 | static bool createHeap (GC_state s, GC_heap h, size_t desiredSize, size_t minSize); | |
60 | static bool createHeapSecondary (GC_state s, size_t desiredSize); | |
61 | static bool remapHeap (GC_state s, GC_heap h, size_t desiredSize, size_t minSize); | |
62 | static void growHeap (GC_state s, size_t desiredSize, size_t minSize); | |
63 | static void resizeHeap (GC_state s, size_t minSize); | |
64 | static void resizeHeapSecondary (GC_state s); | |
65 | ||
66 | #endif /* (defined (MLTON_GC_INTERNAL_FUNCS)) */ |