Move some defines to sgen-conf.h so managed wrappers are actually used.
[mono.git] / mono / metadata / sgen-conf.h
1 /*
2  * Copyright 2001-2003 Ximian, Inc
3  * Copyright 2003-2010 Novell, Inc.
4  * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
5  * 
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  * 
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  * 
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 #ifndef __MONO_SGENCONF_H__
26 #define __MONO_SGENCONF_H__
27
28 /*Basic defines and static tunables */
29
30 #if SIZEOF_VOID_P == 4
31 typedef guint32 mword;
32 #else
33 typedef guint64 mword;
34 #endif
35
36
37 /*
38  * Turning on heavy statistics will turn off the managed allocator and
39  * the managed write barrier.
40  */
41 //#define HEAVY_STATISTICS
42
43 /*
44  * If this is set, the nursery is aligned to an address aligned to its size, ie.
45  * a 1MB nursery will be aligned to an address divisible by 1MB. This allows us to
46  * speed up ptr_in_nursery () checks which are very frequent. This requires the
47  * nursery size to be a compile time constant.
48  */
49 #define SGEN_ALIGN_NURSERY 1
50
51 /*
52  * The binary protocol enables logging a lot of the GC ativity in a way that is not very
53  * intrusive and produce a compact file that can be searched using a custom tool.
54  *
55  */
56 //#define SGEN_BINARY_PROTOCOL
57
58 /*
59  * Define this and use the "xdomain-checks" MONO_GC_DEBUG option to
60  * have cross-domain checks in the write barrier.
61  */
62 //#define XDOMAIN_CHECKS_IN_WBARRIER
63
64 #ifndef SGEN_BINARY_PROTOCOL
65 #ifndef HEAVY_STATISTICS
66 #define MANAGED_ALLOCATION
67 #ifndef XDOMAIN_CHECKS_IN_WBARRIER
68 #define MANAGED_WBARRIER
69 #endif
70 #endif
71 #endif
72
73 /*
74  * Maximum level of debug to enable on this build.
75  * Making this a static variable enables us to put logging in a lot of places.
76  * FIXME decouple logging from assertions
77  */
78 #define SGEN_MAX_DEBUG_LEVEL 2
79
80
81 #define GC_BITS_PER_WORD (sizeof (mword) * 8)
82
83 /*Size of the section used by the copying GC. */
84 #define SGEN_SIZEOF_GC_MEM_SECTION      ((sizeof (GCMemSection) + 7) & ~7)
85
86 /*
87  * to quickly find the head of an object pinned by a conservative
88  * address we keep track of the objects allocated for each
89  * SGEN_SCAN_START_SIZE memory chunk in the nursery or other memory
90  * sections. Larger values have less memory overhead and bigger
91  * runtime cost. 4-8 KB are reasonable values.
92  */
93 #define SGEN_SCAN_START_SIZE (4096*2)
94
95 /*
96  * Objects bigger then this go into the large object space.  This size
97  * has a few constraints.  It must fit into the major heap, which in
98  * the case of the copying collector means that it must fit into a
99  * pinned chunk.  It must also play well with the GC descriptors, some
100  * of which (DESC_TYPE_RUN_LENGTH, DESC_TYPE_SMALL_BITMAP) encode the
101  * object size.
102  */
103 #define SGEN_MAX_SMALL_OBJ_SIZE 8000
104
105 /*
106  * This is the maximum ammount of memory we're willing to waste in order to speed up allocation.
107  * Wastage comes in thre forms:
108  *
109  * -when building the nursery fragment list, small regions are discarded;
110  * -when allocating memory from a fragment if it ends up below the threshold, we remove it from the fragment list; and
111  * -when allocating a new tlab, we discard the remaining space of the old one
112  *
113  * Increasing this value speeds up allocation but will cause more frequent nursery collections as less space will be used.
114  * Descreasing this value will cause allocation to be slower since we'll have to cycle thru more fragments.
115  * 512 annedoctally keeps wastage under control and doesn't impact allocation performance too much. 
116 */
117 #define SGEN_MAX_NURSERY_WASTE 512
118
119
120 /* This is also the MAJOR_SECTION_SIZE for the copying major
121    collector */
122 #define SGEN_PINNED_CHUNK_SIZE  (128 * 1024)
123
124 /*
125  * Number of entries of a sequential store buffer.
126  * This number represents how frequently we'll have to alloc
127  * a new buffer, so it's a tradeoff of potential wasted space and
128  * increased performance.
129  * 
130  * The current value of 1024 was probably selected because it fits a x86 page.
131  * There's no history on the why's of this value besides this.
132  */
133 #define DEFAULT_REMSET_SIZE 1024
134
135 #endif