1 /* Copyright (C) 2012,2014 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.
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
10 #if (defined (MLTON_GC_INTERNAL_TYPES))
13 /* These fields are at the front because they are the most commonly
14 * referenced, and having them at smaller offsets may decrease code
15 * size and improve cache performance.
17 pointer frontier
; /* heap.start <= frontier < limit */
18 pointer limit
; /* limit = heap.start + heap.size */
19 pointer stackTop
; /* Top of stack in current thread. */
20 pointer stackLimit
; /* stackBottom + stackSize - maxFrameSize */
22 /* Alphabetized fields follow. */
23 size_t alignment
; /* */
26 char **atMLtons
; /* Initial @MLton args, processed before command line. */
29 objptr callFromCHandlerThread
; /* Handler for exported C calls (in heap). */
30 struct GC_callStackState callStackState
;
31 bool canMinor
; /* TRUE iff there is space for a minor gc. */
32 struct GC_controls controls
;
33 struct GC_cumulativeStatistics cumulativeStatistics
;
34 objptr currentThread
; /* Currently executing thread (in heap). */
35 struct GC_forwardState forwardState
;
36 GC_frameLayout frameLayouts
; /* Array of frame layouts. */
37 uint32_t frameLayoutsLength
; /* Cardinality of frameLayouts array. */
38 struct GC_generationalMaps generationalMaps
;
40 uint32_t globalsLength
;
41 bool hashConsDuringGC
;
43 struct GC_lastMajorStatistics lastMajorStatistics
;
44 pointer limitPlusSlop
; /* limit + GC_HEAP_LIMIT_SLOP */
45 int (*loadGlobals
)(FILE *f
); /* loads the globals from the file. */
46 uint32_t magic
; /* The magic number for this executable. */
47 uint32_t maxFrameSize
;
48 bool mutatorMarksCards
;
49 GC_objectHashTable objectHashTable
;
50 GC_objectType objectTypes
; /* Array of object types. */
51 uint32_t objectTypesLength
; /* Cardinality of objectTypes array. */
52 struct GC_profiling profiling
;
53 GC_frameIndex (*returnAddressToFrameIndex
) (GC_returnAddress ra
);
54 objptr savedThread
; /* Result of GC_copyCurrentThread.
55 * Thread interrupted by arrival of signal.
57 int (*saveGlobals
)(FILE *f
); /* saves the globals to the file. */
58 bool saveWorldStatus
; /* */
59 struct GC_heap secondaryHeap
; /* Used for major copying collection. */
60 objptr signalHandlerThread
; /* Handler for signals (in heap). */
61 struct GC_signalsInfo signalsInfo
;
62 struct GC_sourceMaps sourceMaps
;
63 pointer stackBottom
; /* Bottom of stack in current thread. */
64 struct GC_sysvals sysvals
;
65 struct GC_translateState translateState
;
66 struct GC_vectorInit
*vectorInits
;
67 uint32_t vectorInitsLength
;
68 GC_weak weaks
; /* Linked list of (live) weak pointers */
71 #endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */
73 #if (defined (MLTON_GC_INTERNAL_FUNCS))
75 static void displayGCState (GC_state s
, FILE *stream
);
77 static inline size_t sizeofGCStateCurrentStackUsed (GC_state s
);
78 static inline void setGCStateCurrentThreadAndStack (GC_state s
);
79 static void setGCStateCurrentHeap (GC_state s
,
80 size_t oldGenBytesRequested
,
81 size_t nurseryBytesRequested
);
83 #endif /* (defined (MLTON_GC_INTERNAL_FUNCS)) */
85 #if (defined (MLTON_GC_INTERNAL_BASIS))
87 PRIVATE
bool GC_getAmOriginal (GC_state s
);
88 PRIVATE
void GC_setAmOriginal (GC_state s
, bool b
);
89 PRIVATE
void GC_setControlsMessages (GC_state s
, bool b
);
90 PRIVATE
void GC_setControlsSummary (GC_state s
, bool b
);
91 PRIVATE
void GC_setControlsRusageMeasureGC (GC_state s
, bool b
);
92 PRIVATE
uintmax_t GC_getCumulativeStatisticsBytesAllocated (GC_state s
);
93 PRIVATE
uintmax_t GC_getCumulativeStatisticsNumCopyingGCs (GC_state s
);
94 PRIVATE
uintmax_t GC_getCumulativeStatisticsNumMarkCompactGCs (GC_state s
);
95 PRIVATE
uintmax_t GC_getCumulativeStatisticsNumMinorGCs (GC_state s
);
96 PRIVATE
size_t GC_getCumulativeStatisticsMaxBytesLive (GC_state s
);
97 PRIVATE
void GC_setHashConsDuringGC (GC_state s
, bool b
);
98 PRIVATE
size_t GC_getLastMajorStatisticsBytesLive (GC_state s
);
100 PRIVATE pointer
GC_getCallFromCHandlerThread (GC_state s
);
101 PRIVATE
void GC_setCallFromCHandlerThread (GC_state s
, pointer p
);
102 PRIVATE pointer
GC_getCurrentThread (GC_state s
);
103 PRIVATE pointer
GC_getSavedThread (GC_state s
);
104 PRIVATE
void GC_setSavedThread (GC_state s
, pointer p
);
105 PRIVATE
void GC_setSignalHandlerThread (GC_state s
, pointer p
);
107 #endif /* (defined (MLTON_GC_INTERNAL_BASIS)) */
109 PRIVATE
struct rusage
* GC_getRusageGCAddr (GC_state s
);
111 PRIVATE sigset_t
* GC_getSignalsHandledAddr (GC_state s
);
112 PRIVATE sigset_t
* GC_getSignalsPendingAddr (GC_state s
);
113 PRIVATE
void GC_setGCSignalHandled (GC_state s
, bool b
);
114 PRIVATE
bool GC_getGCSignalPending (GC_state s
);
115 PRIVATE
void GC_setGCSignalPending (GC_state s
, bool b
);