Mercurial > projects > ldc
comparison lphobos/gc/gcx.d @ 131:5825d48b27d1 trunk
[svn r135] * Merged DMD 1.025 *
* Fixed a minor linking order mishap *
* Added an command line option -annotate *
* Fixed some problems with running optimizations *
* Added std.stdio and dependencies to lphobos (still not 100% working, but compiles and links) *
* Fixed problems with passing aggregate types to variadic functions *
* Added initial code towards full GC support, currently based on malloc and friends, not all the runtime calls the GC yet for memory *
* Fixed problems with resolving nested function context pointers for some heavily nested cases *
* Redid function argument passing + other minor code cleanups, still lots to do on this end... *
author | lindquist |
---|---|
date | Fri, 04 Jan 2008 01:38:42 +0100 |
parents | |
children | 373489eeaf90 |
comparison
equal
deleted
inserted
replaced
130:a7dfa0ed966c | 131:5825d48b27d1 |
---|---|
1 /* | |
2 * Copyright (C) 2004 by Digital Mars, www.digitalmars.com | |
3 * Written by Walter Bright | |
4 * | |
5 * This software is provided 'as-is', without any express or implied | |
6 * warranty. In no event will the authors be held liable for any damages | |
7 * arising from the use of this software. | |
8 * | |
9 * Permission is granted to anyone to use this software for any purpose, | |
10 * including commercial applications, and to alter it and redistribute it | |
11 * freely, subject to the following restrictions: | |
12 * | |
13 * o The origin of this software must not be misrepresented; you must not | |
14 * claim that you wrote the original software. If you use this software | |
15 * in a product, an acknowledgment in the product documentation would be | |
16 * appreciated but is not required. | |
17 * o Altered source versions must be plainly marked as such, and must not | |
18 * be misrepresented as being the original software. | |
19 * o This notice may not be removed or altered from any source | |
20 * distribution. | |
21 */ | |
22 | |
23 // D Garbage Collector stub to prevent linking in gc | |
24 | |
25 /* | |
26 * Modified for use as the preliminary GC for LLVMDC (LLVM D Compiler) | |
27 * by Tomas Lindquist Olsen, Dec 2007 | |
28 */ | |
29 | |
30 module gcx; | |
31 | |
32 debug=PRINTF; | |
33 | |
34 /***************************************************/ | |
35 | |
36 | |
37 version (Win32) | |
38 { | |
39 import win32; | |
40 } | |
41 | |
42 version (linux) | |
43 { | |
44 import gclinux; | |
45 } | |
46 | |
47 import gcstats; | |
48 import stdc = std.c.stdlib; | |
49 | |
50 | |
51 //alias GC* gc_t; | |
52 alias GC gc_t; | |
53 | |
54 //struct GCStats { } | |
55 | |
56 /* ============================ GC =============================== */ | |
57 | |
58 | |
59 //alias int size_t; | |
60 alias void (*GC_FINALIZER)(void *p, bool dummy); | |
61 | |
62 const uint GCVERSION = 1; // increment every time we change interface | |
63 // to GC. | |
64 | |
65 class GC | |
66 { | |
67 uint gcversion = GCVERSION; | |
68 | |
69 void *gcx; // implementation | |
70 | |
71 void initialize() | |
72 { | |
73 debug(PRINTF) printf("GC initialize()\n"); | |
74 } | |
75 | |
76 | |
77 void Dtor() | |
78 { | |
79 debug(PRINTF) printf("GC Dtor()\n"); | |
80 } | |
81 | |
82 invariant | |
83 { | |
84 debug(PRINTF) printf("GC invariant()\n"); | |
85 } | |
86 | |
87 void *malloc(size_t size) | |
88 { | |
89 debug(PRINTF) printf("GC malloc()\n"); | |
90 return malloc(size); | |
91 } | |
92 | |
93 void *mallocNoSync(size_t size) | |
94 { | |
95 debug(PRINTF) printf("GC mallocNoSync()\n"); | |
96 return malloc(size); | |
97 } | |
98 | |
99 | |
100 void *calloc(size_t size, size_t n) | |
101 { | |
102 debug(PRINTF) printf("GC calloc()\n"); | |
103 return calloc(n, size); | |
104 } | |
105 | |
106 | |
107 void *realloc(void *p, size_t size) | |
108 { | |
109 debug(PRINTF) printf("GC realloc()\n"); | |
110 return realloc(p, size); | |
111 } | |
112 | |
113 | |
114 void free(void *p) | |
115 { | |
116 debug(PRINTF) printf("GC free()\n"); | |
117 stdc.free(p); | |
118 } | |
119 | |
120 size_t capacity(void *p) | |
121 { | |
122 debug(PRINTF) printf("GC capacity()\n"); | |
123 return 0; | |
124 } | |
125 | |
126 void check(void *p) | |
127 { | |
128 debug(PRINTF) printf("GC check()\n"); | |
129 } | |
130 | |
131 | |
132 void setStackBottom(void *p) | |
133 { | |
134 debug(PRINTF) printf("GC setStackBottom()\n"); | |
135 } | |
136 | |
137 static void scanStaticData(gc_t g) | |
138 { | |
139 void *pbot; | |
140 void *ptop; | |
141 uint nbytes; | |
142 | |
143 debug(PRINTF) printf("GC scanStaticData()\n"); | |
144 //debug(PRINTF) printf("+GC.scanStaticData()\n"); | |
145 os_query_staticdataseg(&pbot, &nbytes); | |
146 ptop = pbot + nbytes; | |
147 g.addRange(pbot, ptop); | |
148 //debug(PRINTF) printf("-GC.scanStaticData()\n"); | |
149 } | |
150 | |
151 static void unscanStaticData(gc_t g) | |
152 { | |
153 void *pbot; | |
154 uint nbytes; | |
155 | |
156 debug(PRINTF) printf("GC unscanStaticData()\n"); | |
157 os_query_staticdataseg(&pbot, &nbytes); | |
158 g.removeRange(pbot); | |
159 } | |
160 | |
161 | |
162 void addRoot(void *p) // add p to list of roots | |
163 { | |
164 debug(PRINTF) printf("GC addRoot()\n"); | |
165 } | |
166 | |
167 void removeRoot(void *p) // remove p from list of roots | |
168 { | |
169 debug(PRINTF) printf("GC removeRoot()\n"); | |
170 } | |
171 | |
172 void addRange(void *pbot, void *ptop) // add range to scan for roots | |
173 { | |
174 debug(PRINTF) printf("GC addRange()\n"); | |
175 } | |
176 | |
177 void removeRange(void *pbot) // remove range | |
178 { | |
179 debug(PRINTF) printf("GC removeRange()\n"); | |
180 } | |
181 | |
182 void fullCollect() // do full garbage collection | |
183 { | |
184 debug(PRINTF) printf("GC fullCollect()\n"); | |
185 } | |
186 | |
187 void fullCollectNoStack() // do full garbage collection | |
188 { | |
189 debug(PRINTF) printf("GC fullCollectNoStack()\n"); | |
190 } | |
191 | |
192 void genCollect() // do generational garbage collection | |
193 { | |
194 debug(PRINTF) printf("GC genCollect()\n"); | |
195 } | |
196 | |
197 void minimize() // minimize physical memory usage | |
198 { | |
199 debug(PRINTF) printf("GC minimize()\n"); | |
200 } | |
201 | |
202 void setFinalizer(void *p, GC_FINALIZER pFn) | |
203 { | |
204 debug(PRINTF) printf("GC setFinalizer()\n"); | |
205 } | |
206 | |
207 void enable() | |
208 { | |
209 debug(PRINTF) printf("GC enable()\n"); | |
210 } | |
211 | |
212 void disable() | |
213 { | |
214 debug(PRINTF) printf("GC disable()\n"); | |
215 } | |
216 | |
217 void getStats(out GCStats stats) | |
218 { | |
219 debug(PRINTF) printf("GC getStats()\n"); | |
220 } | |
221 | |
222 void hasPointers(void* p) | |
223 { | |
224 debug(PRINTF) printf("GC hasPointers()\n"); | |
225 } | |
226 | |
227 void hasNoPointers(void* p) | |
228 { | |
229 debug(PRINTF) printf("GC hasNoPointers()\n"); | |
230 } | |
231 | |
232 void setV1_0() | |
233 { | |
234 debug(PRINTF) printf("GC setV1_0()\n"); | |
235 assert(0); | |
236 } | |
237 | |
238 size_t extend(void* p, size_t minsize, size_t maxsize) | |
239 { | |
240 debug(PRINTF) printf("GC extend()\n"); | |
241 assert(0); | |
242 } | |
243 } |