Improve GambitREPL iOS example.
[gambit-c.git] / lib / mem.h
blob0244071c7380f87d7a3a47f4f69caa51d0f1ec03
1 /* File: "mem.h", Time-stamp: <2007-06-08 08:24:00 feeley> */
3 /* Copyright (c) 1994-2007 by Marc Feeley, All Rights Reserved. */
5 #ifndef ___MEM_H
6 #define ___MEM_H
9 /*
10 * Memory allocation parameters:
12 * ___MAX_NB_PARMS is the maximum number of formal parameters of procedures.
14 * ___MAX_NB_ARGS is the maximum number of arguments (actual parameters)
15 * that are passed to procedures. It must be >= ___MAX_NB_PARMS.
17 * ___MAX_NB_FRAME_SLOTS is the maximum number of slots in continuation
18 * frames. It must be >= ___MAX_NB_ARGS.
20 * ___MSECTION_SIZE is the size in words of sections that contain
21 * movable objects (msections).
23 * ___MSECTION_FUDGE is the size in words of the msection fudge area.
24 * There is a fudge area at the end of the space reserved for
25 * allocating movable objects (heap fudge) and a fudge area at the end
26 * of the space reserved for allocating continuation frames (stack
27 * fudge). Instructions in the code generated by the compiler check
28 * whether the heap allocation pointer points into the heap fudge area
29 * after a bounded number of constant size allocations and whether the
30 * frame pointer points into the stack fudge area. When either of
31 * these cases occur, the assignment of space for the heap and stack
32 * is adjusted. If there is less than or equal to ___MSECTION_WASTE
33 * words of space left, a garbage collection is triggered.
34 * ___MSECTION_FUDGE must be >=
35 * ___MAX_NB_FRAME_SLOTS+1+___SUBTYPED_OVERHEAD (which is the size of
36 * the largest continuation frame).
38 * ___MSECTION_BIGGEST is the size in words beyond which an object will
39 * be allocated as a still object. It must be <= ___MSECTION_FUDGE.
41 * ___MIN_NB_MSECTIONS is the minimum number of msections contained
42 * in the heap.
44 * ___PSECTION_SIZE is the size in words of sections that contain permanent
45 * objects (psections).
47 * ___PSECTION_WASTE is the maximum number of words that are unused
48 * in a psection due to fragmentation. It must be <= ___PSECTION_SIZE.
50 * ___DEFAULT_LIVE_PERCENT is the default percentage of the heap that
51 * is live after a GC. At the end of a GC the heap is resized to reach
52 * this percentage.
56 #define ___MAX_NB_PARMS 1024
57 #define ___MAX_NB_ARGS 8192
58 #define ___MAX_NB_FRAME_SLOTS 8192
59 #define ___MSECTION_SIZE 131072
60 #define ___MSECTION_FUDGE (___MAX_NB_FRAME_SLOTS+1+___SUBTYPED_OVERHEAD)
61 #define ___MSECTION_WASTE (___MSECTION_FUDGE/16)
62 #define ___MSECTION_BIGGEST 255
63 #define ___MIN_NB_MSECTIONS 1
64 #define ___PSECTION_SIZE 4096
65 #define ___PSECTION_WASTE 32
66 #define ___DEFAULT_LIVE_PERCENT 50
69 extern ___SCMOBJ ___setup_mem ___PVOID;
70 extern void ___cleanup_mem ___PVOID;
73 #ifdef ___DEBUG_GARBAGE_COLLECT
75 #define ___garbage_collect(n) ___garbage_collect_debug (n,__LINE__,__FILE__)
77 extern ___BOOL ___garbage_collect_debug
78 ___P((long nonmovable_words_needed,
79 int line,
80 char *file),
81 ());
83 #else
85 extern ___BOOL ___garbage_collect
86 ___P((long nonmovable_words_needed),
87 ());
89 #endif
92 #ifdef ___DEBUG_STACK_LIMIT
93 #define ___stack_limit() ___stack_limit_debug (__LINE__,__FILE__)
94 extern ___BOOL ___stack_limit_debug ___P((int line, char *file),());
95 #else
96 extern ___BOOL ___stack_limit ___PVOID;
97 #endif
100 #ifdef ___DEBUG_HEAP_LIMIT
101 #define ___heap_limit() ___heap_limit_debug (__LINE__,__FILE__)
102 extern ___BOOL ___heap_limit_debug ___P((int line, char *file),());
103 #else
104 extern ___BOOL ___heap_limit ___PVOID;
105 #endif
108 extern ___SCMOBJ ___alloc_global_var ___P((___glo_struct **glo),());
110 extern ___F64 ___bytes_allocated ___PVOID;
113 #ifdef CALL_GC_FREQUENTLY
114 extern int ___gc_calls_to_punt;
115 #endif
118 #endif