Debian Codegraph @

external/bdwgc/doc/README.amiga

raw
1 Kjetil S. Matheussen's notes (28-11-2000)
2
3 Compiles under SAS/C again. Should also still compile under other
4 Amiga compilers without big changes. I haven't checked if it still
5 works under gcc, because I don't have gcc for Amiga. But I have
6 updated 'Makefile', and hope it compiles fine.
7
8
9 WHATS NEW:
10
11 1.
12 Made a pretty big effort in preventing GCs allocating-functions from returning
13 chip-mem.
14
15 The lower part of the new file AmigaOS.c does this in various ways, mainly by
16 wrapping GC_malloc, GC_malloc_atomic, GC_malloc_uncollectable,
17 GC_malloc_atomic_uncollectable, GC_malloc_ignore_off_page
18 and GC_malloc_atomic_ignore_off_page. GC_realloc is also wrapped, but
19 doesn't do the same effort in preventing to return chip-mem.
20 Other allocating-functions (f.ex. GC_*_typed_) can probably be
21 used without any problems, but beware that the warn hook will not be called.
22 In case of problems, don't define GC_AMIGA_FASTALLOC.
23
24 Programs using more time actually using the memory allocated
25 (instead of just allocate and free rapidly) have
26 the most to earn on this, but even gctest now normally runs twice
27 as fast and uses less memory, on my poor 8MB machine.
28
29 The changes have only effect when there is no more
30 fast-mem left. But with the way GC works, it
31 could happen quite often. Beware that an atexit handler had to be added,
32 so using the abort() function will make a big memory-loss.
33 If you absolutely must call abort() instead of exit(), try calling
34 the GC_amiga_free_all_mem function before abort().
35
36 New Amiga-specific compilation flags:
37
38 GC_AMIGA_FASTALLOC - By NOT defining this option, GC will work like before,
39 it will not try to force fast-mem out of the OS, and
40 it will use normal calloc for allocation, and the rest
41 of the following flags will have no effect.
42
43 GC_AMIGA_ONLYFAST - Makes GC never to return chip-mem. GC_AMIGA_RETRY have
44 no effect if this flag is set.
45
46 GC_AMIGA_GC - If gc returns NULL, do a GC_gcollect, and try again. This
47 usually is a success with the standard GC configuration.
48 It is also the most important flag to set to prevent
49 GC from returning chip-mem. Beware that it slows down a lot
50 when a program is rapidly allocating/deallocating when
51 there's either very little fast-memory left or very little
52 chip-memory left. Its not a very common situation, but gctest
53 sometimes (very rare) use many minutes because of this.
54
55 GC_AMIGA_RETRY - If gc succeed allocating memory, but it is chip-mem,
56 try again and see if it is fast-mem. Most of the time,
57 it will actually return fast-mem for the second try.
58 I have set max number of retries to 9 or size/5000. You
59 can change this if you like. (see GC_amiga_rec_alloc())
60
61 GC_AMIGA_PRINTSTATS - Gather some statistics during the execution of a
62 program, and prints out the info when the atexit-handler
63 is called.
64
65 My recommendation is to set all this flags, except GC_AMIGA_PRINTSTATS and
66 GC_AMIGA_ONLYFAST.
67
68 If your program demands high response-time, you should
69 not define GC_AMIGA_GC, and possible also define GC_AMIGA_ONLYFAST.
70 GC_AMIGA_RETRY does not seem to slow down much.
71
72 Also, when compiling up programs, and GC_AMIGA_FASTALLOC was not defined when
73 compiling gc, you can define GC_AMIGA_MAKINGLIB to avoid having these allocation-
74 functions wrapped. (see gc.h)
75
76 Note that GC_realloc must not be called before any of
77 the other above mentioned allocating-functions have been called. (shouldn't be
78 any programs doing so either, I hope).
79
80 Another note. The allocation-function is wrapped when defining
81 GC_AMIGA_FASTALLOC by letting the function go thru the new
82 GC_amiga_allocwrapper_do function-pointer (see gc.h). Means that
83 sending function-pointers, such as GC_malloc, GC_malloc_atomic, etc.,
84 for later to be called like f.ex this, (*GC_malloc_function_pointer)(size),
85 will not wrap the function. This is normally not a big problem, unless
86 all allocation function is called like this, which will cause the
87 atexit un-allocating function never to be called. Then you either
88 have to manually add the atexit handler, or call the allocation-
89 functions function-pointer functions like this;
90 (*GC_amiga_allocwrapper_do)(size,GC_malloc_function_pointer).
91 There are probably better ways this problem could be handled, unfortunately,
92 I didn't find any without rewriting or replacing a lot of the GC-code, which
93 I really didn't want to. (Making new GC_malloc_* functions, and just
94 define f.ex GC_malloc as GC_amiga_malloc should work too).
95
96
97 New Amiga-specific function:
98
99 void GC_amiga_set_toany(void (*func)(void));
100
101 'func' is a function that will be called right before gc has to change
102 allocation-method from MEMF_FAST to MEMF_ANY. Ie. when it is likely
103 it will return chip-mem.
104
105
106 2. A few small compiler-specific additions to make it compile with SAS/C again.
107
108 3. Updated and rewritten the smakefile, so that it works again and that
109 the "unnecessary" 'SCOPTIONS' files could be removed. Also included
110 the cord-smakefile stuff in the main smakefile, so that the cord smakefile
111 could be removed too. By writing smake -f Smakefile.smk, both gc.lib and
112 cord.lib will be made.
113
114
115
116 STILL MISSING:
117
118 Programs can not be started from workbench, at least not for SAS/C. (Martin
119 Tauchmanns note about that it now works with workbench is definitely wrong
120 when concerning SAS/C). An iconx-script solves this problem.
121
122
123 BEWARE!
124
125 -To run gctest, set the stack to around 200000 bytes first.
126 -SAS/C-specific: cord will crash if you compile gc.lib with
127 either parm=reg or parm=both. (missing legal prototypes for
128 function-pointers someplace is the reason I guess.).
129
130
131 tested with software: Radium, http://www.stud.ifi.uio.no/~ksvalast/radium/
132 tested with hardware: MC68060
133
134
135 Martin Tauchmann's notes (1-Apr-99)
136
137 Works now, also with the GNU-C compiler V2.7.2.1. <ftp://ftp.unina.it/pub/amiga/geekgadgets/amiga/m68k/snapshots/971125/amiga-bin/>
138 Modify the `Makefile`
139 CC=cc $(ABI_FLAG)
140 to
141 CC=gcc $(ABI_FLAG)
142
143 TECHNICAL NOTES
144
145 - `GC_get_stack_base()`, `GC_register_data_segments()` works now with every
146 C compiler; also Workbench.
147
148 - Removed AMIGA_SKIP_SEG, but the Code-Segment must not be scanned by GC.
149
150
151 PROBLEMS
152 - When the Linker, does`t merge all Code-Segments to an single one. LD of GCC
153 do it always.
154
155 - With ixemul.library V47.3, when an GC program launched from another program
156 (example: `Make` or `if_mach M68K AMIGA gctest`), `GC_register_data_segments()`
157 found the Segment-List of the caller program.
158 Can be fixed, if the run-time initialization code (for C programs, usually *crt0*)
159 support `__data` and `__bss`.
160
161 - PowerPC Amiga currently not supported.
162
163 - Dynamic libraries (dyn_load.c) not supported.
164
165
166 TESTED WITH SOFTWARE
167
168 `Optimized Oberon 2 C` (oo2c) <http://cognac.informatik.uni-kl.de/download/index.html>
169
170
171 TESTED WITH HARDWARE
172
173 MC68030
174
175
176 Michel Schinz's notes
177
178 WHO DID WHAT
179
180 The original Amiga port was made by Jesper Peterson. I (Michel Schinz)
181 modified it slightly to reflect the changes made in the new official
182 distributions, and to take advantage of the new SAS/C 6.x features. I also
183 created a makefile to compile the "cord" package (see the cord
184 subdirectory).
185
186 TECHNICAL NOTES
187
188 In addition to Jesper's notes, I have the following to say:
189
190 - Starting with version 4.3, gctest checks to see if the code segment is
191 added to the root set or not, and complains if it is. Previous versions
192 of this Amiga port added the code segment to the root set, so I tried to
193 fix that. The only problem is that, as far as I know, it is impossible to
194 know which segments are code segments and which are data segments (there
195 are indeed solutions to this problem, like scanning the program on disk
196 or patch the LoadSeg functions, but they are rather complicated). The
197 solution I have chosen (see os_dep.c) is to test whether the program
198 counter is in the segment we are about to add to the root set, and if it
199 is, to skip the segment. The problems are that this solution is rather
200 awkward and that it works only for one code segment. This means that if
201 your program has more than one code segment, all of them but one will be
202 added to the root set. This isn't a big problem in fact, since the
203 collector will continue to work correctly, but it may be slower.
204
205 Anyway, the code which decides whether to skip a segment or not can be
206 removed simply by not defining AMIGA_SKIP_SEG. But notice that if you do
207 so, gctest will complain (it will say that "GC_is_visible produced wrong
208 failure indication"). However, it may be useful if you happen to have
209 pointers stored in a code segment (you really shouldn't).
210
211 If anyone has a good solution to the problem of finding, when a program
212 is loaded in memory, whether a segment is a code or a data segment,
213 please let me know.
214
215
216 Jesper Peterson's notes
217
218 ADDITIONAL NOTES FOR AMIGA PORT
219
220 These notes assume some familiarity with Amiga internals.
221
222 WHY I PORTED TO THE AMIGA
223
224 The sole reason why I made this port was as a first step in getting
225 the Sather(*) language on the Amiga. A port of this language will
226 be done as soon as the Sather 1.0 sources are made available to me.
227 Given this motivation, the garbage collection (GC) port is rather
228 minimal.
229
230 (*) For information on Sather read the comp.lang.sather newsgroup.
231
232 LIMITATIONS
233
234 This port assumes that the startup code linked with target programs
235 is that supplied with SAS/C versions 6.0 or later. This allows
236 assumptions to be made about where to find the stack base pointer
237 and data segments when programs are run from WorkBench, as opposed
238 to running from the CLI. The compiler dependent code is all in the
239 GC_get_stack_base() and GC_register_data_segments() functions, but
240 may spread as I add Amiga specific features.
241
242 Given that SAS/C was assumed, the port is set up to be built with
243 "smake" using the "SMakefile". Compiler options in "SCoptions" can
244 be set with "scopts" program. Both "smake" and "scopts" are part of
245 the SAS/C commercial development system.
246
247 In keeping with the porting philosophy outlined above, this port
248 will not behave well with Amiga specific code. Especially not inter-
249 process comms via messages, and setting up public structures like
250 Intuition objects or anything else in the system lists. For the
251 time being the use of this library is limited to single threaded
252 ANSI/POSIX compliant or near-compliant code. (ie. Stick to stdio
253 for now). Given this limitation there is currently no mechanism for
254 allocating "CHIP" or "PUBLIC" memory under the garbage collector.
255 I'll add this after giving it considerable thought. The major
256 problem is the entire physical address space may have to me scanned,
257 since there is no telling who we may have passed memory to.
258
259 If you allocate your own stack in client code, you will have to
260 assign the pointer plus stack size to GC_stackbottom.
261
262 The initial stack size of the target program can be compiled in by
263 setting the __stack symbol (see SAS documentation). It can be over-
264 ridden from the CLI by running the AmigaDOS "stack" program, or from
265 the WorkBench by setting the stack size in the tool types window.
266
267 SAS/C COMPILER OPTIONS (SCoptions)
268
269 You may wish to check the "CPU" code option is appropriate for your
270 intended target system.
271
272 Under no circumstances set the "StackExtend" code option in either
273 compiling the library or *ANY* client code.
274
275 All benign compiler warnings have been suppressed. These mainly
276 involve lack of prototypes in the code, and dead assignments
277 detected by the optimizer.
278
279 THE GOOD NEWS
280
281 The library as it stands is compatible with the GigaMem commercial
282 virtual memory software, and probably similar PD software.
283
284 The performance of "gctest" on an Amiga 2630 (68030 @ 25Mhz)
285 compares favorably with an HP9000 with similar architecture (a 325
286 with a 68030 I think).
287
288 -----------------------------------------------------------------------