1 //////////////////////////////////////////////////////////////////////////////
4 // ADLib, Prop and their related set of tools and documentation are in the
5 // public domain. The author(s) of this software reserve no copyrights on
6 // the source code and any code generated using the tools. You are encouraged
7 // to use ADLib and Prop to develop software, in both academic and commercial
8 // settings, and are welcomed to incorporate any part of ADLib and Prop into
11 // Although you are under no obligation to do so, we strongly recommend that
12 // you give away all software developed using our tools.
14 // We also ask that credit be given to us when ADLib and/or Prop are used in
15 // your programs, and that this notice be preserved intact in all the source
18 // This software is still under development and we welcome(read crave for)
19 // any suggestions and help from the users.
21 // Allen Leung (aleung@netcom.com, leun7056@cs.nyu.edu)
23 //////////////////////////////////////////////////////////////////////////////
25 #ifndef gc_configuration_h
26 #define gc_configuration_h
28 //////////////////////////////////////////////////////////////////////////////
29 // This file is used to customize the garbage collectors. Please
30 // read this through carefully and customize it to suit your platform's
32 //////////////////////////////////////////////////////////////////////////////
34 //////////////////////////////////////////////////////////////////////////////
35 // Maximum number of garbage collectors instance.
36 // Notice that more than one type of heaps are allowed.
37 //////////////////////////////////////////////////////////////////////////////
38 #define GC_MAX_NUMBER_OF_COLLECTORS 256
40 //////////////////////////////////////////////////////////////////////////////
41 // Size of a *logical* page in bytes. Memory managed by the managers
42 // are partitioned into logical pages. Increasing the page size will
43 // decrease the sizes bookkeeping data structures, but may increase retention.
44 // Page size *MUST* be a power of two but it doesn't have to match the
45 // underlying page size of the VM.
47 // I think 256 bytes is probably too small while something like 4K
48 // is probably too large.
49 //////////////////////////////////////////////////////////////////////////////
50 #define GC_PAGE_SIZE 512
52 //////////////////////////////////////////////////////////////////////////////
53 // Should we use blacklisting to decrease the likehood of
54 // false root identification?
56 // The default is yes.
57 // We'll allow up to ten percentage of all memory to be blacklisted,
58 // or 64K of memory at one time, or 512K total, whichever is lower.
60 //////////////////////////////////////////////////////////////////////////////
61 #define GC_USE_BLACKLISTING
62 #define GC_MIN_BLACKLISTED_PAGES 4
63 #define GC_MAX_BLACKLISTED_PERCENTAGE 10
64 #define GC_MAX_BLACKLISTED_PAGES (65536/GC_PAGE_SIZE)
65 #define GC_MAX_TOTAL_BLACKLISTED_PAGES (512*1024/GC_PAGE_SIZE)
67 //////////////////////////////////////////////////////////////////////////////
68 // Should cross heap pointers be allowed?
69 // The default is yes. If you want to allocate connecting structures
70 // in multiple collectable heaps then this is a must. If you'll only use
71 // one collector at a time then you can safely comment this option
72 // out. The code will be a bit faster.
73 //////////////////////////////////////////////////////////////////////////////
74 #define GC_HAS_CROSS_HEAP_POINTERS
76 //////////////////////////////////////////////////////////////////////////////
77 // Should we try to keep track of garbage collection time?
78 // The default is yes. This is generally a good idea since you may want
79 // to profile the programs during fine-tuning. I only have POSIX
80 // compliant code(I think) for the timers stuff so you may have to roll
81 // your own. Or comment this out if your compiler barfs on the timer
83 //////////////////////////////////////////////////////////////////////////////
86 //////////////////////////////////////////////////////////////////////////////
87 // Debugging flag. Off for production use.
88 //////////////////////////////////////////////////////////////////////////////
91 //////////////////////////////////////////////////////////////////////////////
92 // Architecture dependent information follows:
94 // GC_ALIGNMENT -- a suitable data alignment in bytes. This is
95 // 8 on most platforms. All data allocated
96 // are guaranteed to satisfy this constraint.
97 // Notice that while decrease this alignment may
98 // decrease the sizes of objects allocated, it
99 // will also increase the sizes of the internal
100 // bitmaps and the times for roots identification,
101 // as more addresses will become candidates.
102 // GC_DATA_START -- a macro to find the start of static data
103 // GC_DATA_END -- a macro to find the end of the static data
105 // GC_GET_HEAP_BOTTOM -- a macro to locate the bottom of the heap
106 // GC_GET_HEAP_TOP -- a macro to locate the top of the heap
108 // Some assumptions that I've made:
110 // 8 bits in a bytes.
112 // 4 byte alignment for pointers.
113 // linear address space.
114 // the static area is contiguous and not expandable during execution.
115 // the heap area is contiguous.
116 // the stack area is contiguous(no spaghetti stack please).
117 // _setjmp() will properly flush the registers onto the stack.
118 //////////////////////////////////////////////////////////////////////////////
120 //////////////////////////////////////////////////////////////////////////////
121 // Configuration for Linux on x86 architectures.
122 // Configuration for Sparc on SUN/OS
123 //////////////////////////////////////////////////////////////////////////////
124 #if defined(linux) || defined(sparc)
125 # define GC_ALIGNMENT 8 // use 8-byte alignment for our heap
128 # define GC_DATA_START (void*)(((unsigned long)(&etext) + 0xfff) & ~0xfff)
129 # define GC_DATA_END (void*)(&end)
132 extern "C" void * sbrk(int);
133 # define GC_GET_HEAP_BOTTOM sbrk(0)
134 # define GC_GET_HEAP_TOP sbrk(0)
135 # define GC_CONFIGURED
138 //////////////////////////////////////////////////////////////////////////////
139 // Default configuration: assume vanilla Unixes.
140 // Caution: I don't know if it'll work!!!!
142 // Please add your own and email any new configurations to
144 // leun7056@cs.nyu.edu
146 // It'll be much appreciated.
147 //////////////////////////////////////////////////////////////////////////////
148 #ifndef GC_CONFIGURED
149 struct GC_ALIGNMENT_TYPE { int a; void * b; double c; };
150 #define GC_ALIGNMENT sizeof(GC_ALIGNMENT_TYPE)
153 # define GC_DATA_START (void*)(((unsigned long)(&etext) + 0xfff) & ~0xfff)
154 # define GC_DATA_END (void*)(&end)
157 extern "C" void * sbrk(int);
158 # define GC_GET_HEAP_BOTTOM sbrk(0)
159 # define GC_GET_HEAP_TOP sbrk(0)