2 * C-level stuff to implement Lisp-level PURIFY
6 * This software is part of the SBCL system. See the README file for
9 * This software is derived from the CMU CL system, which was
10 * written at Carnegie Mellon University and released into the
11 * public domain. The software is in the public domain and is
12 * provided with absolutely no warranty. See the COPYING and CREDITS
13 * files for more information.
17 #include <sys/types.h>
27 #include "interrupt.h"
32 #include "gc-internal.h"
34 #include "genesis/primitive-objects.h"
35 #include "genesis/static-symbols.h"
39 #if defined(LISP_FEATURE_GENCGC)
40 /* this is another artifact of the poor integration between gencgc and
41 * the rest of the runtime: on cheney gc there is a global
42 * dynamic_space_free_pointer which is valid whenever foreign function
43 * call is active, but in gencgc there's no such variable and we have
46 static lispobj *dynamic_space_free_pointer;
48 extern unsigned long bytes_consed_between_gcs;
51 lose("GC invariant lost, file \"%s\", line %d", __FILE__, __LINE__)
54 #define gc_assert(ex) do { \
55 if (!(ex)) gc_abort(); \
62 /* These hold the original end of the read_only and static spaces so
63 * we can tell what are forwarding pointers. */
65 static lispobj *read_only_end, *static_end;
67 static lispobj *read_only_free, *static_free;
69 static lispobj *pscav(lispobj *addr, int nwords, boolean constant);
71 #define LATERBLOCKSIZE 1020
72 #define LATERMAXCOUNT 10
81 } *later_blocks = NULL;
82 static int later_count = 0;
84 /* FIXME: Shouldn't this be defined in sbcl.h? See also notes in
88 #define FUN_RAW_ADDR_OFFSET 0
90 #define FUN_RAW_ADDR_OFFSET (6*sizeof(lispobj) - FUN_POINTER_LOWTAG)
94 forwarding_pointer_p(lispobj obj)
96 lispobj *ptr = native_pointer(obj);
98 return ((static_end <= ptr && ptr <= static_free) ||
99 (read_only_end <= ptr && ptr <= read_only_free));
103 dynamic_pointer_p(lispobj ptr)
105 #ifndef LISP_FEATURE_GENCGC
106 return (ptr >= (lispobj)current_dynamic_space
108 ptr < (lispobj)dynamic_space_free_pointer);
110 /* Be more conservative, and remember, this is a maybe. */
111 return (ptr >= (lispobj)DYNAMIC_SPACE_START
113 ptr < (lispobj)dynamic_space_free_pointer);
117 static inline lispobj *
118 newspace_alloc(int nwords, int constantp)
121 nwords=CEILING(nwords,2);
124 read_only_free+=nwords;
134 #ifdef LISP_FEATURE_X86
136 #ifdef LISP_FEATURE_GENCGC
138 * enhanced x86/GENCGC stack scavenging by Douglas Crosher
140 * Scavenging the stack on the i386 is problematic due to conservative
141 * roots and raw return addresses. Here it is handled in two passes:
142 * the first pass runs before any objects are moved and tries to
143 * identify valid pointers and return address on the stack, the second
144 * pass scavenges these.
147 static unsigned pointer_filter_verbose = 0;
149 /* FIXME: This is substantially the same code as
150 * possibly_valid_dynamic_space_pointer in gencgc.c. The only
151 * relevant difference seems to be that the gencgc code also checks
152 * for raw pointers into Code objects, whereas in purify these are
153 * checked separately in setup_i386_stack_scav - they go onto
154 * valid_stack_ra_locations instead of just valid_stack_locations */
157 valid_dynamic_space_pointer(lispobj *pointer, lispobj *start_addr)
159 /* If it's not a return address then it needs to be a valid Lisp
161 if (!is_lisp_pointer((lispobj)pointer))
164 /* Check that the object pointed to is consistent with the pointer
166 switch (lowtag_of((lispobj)pointer)) {
167 case FUN_POINTER_LOWTAG:
168 /* Start_addr should be the enclosing code object, or a closure
170 switch (widetag_of(*start_addr)) {
171 case CODE_HEADER_WIDETAG:
172 /* This case is probably caught above. */
174 case CLOSURE_HEADER_WIDETAG:
175 case FUNCALLABLE_INSTANCE_HEADER_WIDETAG:
176 if ((int)pointer != ((int)start_addr+FUN_POINTER_LOWTAG)) {
177 if (pointer_filter_verbose) {
178 fprintf(stderr,"*Wf2: %x %x %x\n", (unsigned int) pointer,
179 (unsigned int) start_addr, *start_addr);
185 if (pointer_filter_verbose) {
186 fprintf(stderr,"*Wf3: %x %x %x\n", (unsigned int) pointer,
187 (unsigned int) start_addr, *start_addr);
192 case LIST_POINTER_LOWTAG:
193 if ((int)pointer != ((int)start_addr+LIST_POINTER_LOWTAG)) {
194 if (pointer_filter_verbose)
195 fprintf(stderr,"*Wl1: %x %x %x\n", (unsigned int) pointer,
196 (unsigned int) start_addr, *start_addr);
199 /* Is it plausible cons? */
200 if ((is_lisp_pointer(start_addr[0])
201 || ((start_addr[0] & 3) == 0) /* fixnum */
202 || (widetag_of(start_addr[0]) == CHARACTER_WIDETAG)
203 || (widetag_of(start_addr[0]) == UNBOUND_MARKER_WIDETAG))
204 && (is_lisp_pointer(start_addr[1])
205 || ((start_addr[1] & 3) == 0) /* fixnum */
206 || (widetag_of(start_addr[1]) == CHARACTER_WIDETAG)
207 || (widetag_of(start_addr[1]) == UNBOUND_MARKER_WIDETAG))) {
210 if (pointer_filter_verbose) {
211 fprintf(stderr,"*Wl2: %x %x %x\n", (unsigned int) pointer,
212 (unsigned int) start_addr, *start_addr);
216 case INSTANCE_POINTER_LOWTAG:
217 if ((int)pointer != ((int)start_addr+INSTANCE_POINTER_LOWTAG)) {
218 if (pointer_filter_verbose) {
219 fprintf(stderr,"*Wi1: %x %x %x\n", (unsigned int) pointer,
220 (unsigned int) start_addr, *start_addr);
224 if (widetag_of(start_addr[0]) != INSTANCE_HEADER_WIDETAG) {
225 if (pointer_filter_verbose) {
226 fprintf(stderr,"*Wi2: %x %x %x\n", (unsigned int) pointer,
227 (unsigned int) start_addr, *start_addr);
232 case OTHER_POINTER_LOWTAG:
233 if ((int)pointer != ((int)start_addr+OTHER_POINTER_LOWTAG)) {
234 if (pointer_filter_verbose) {
235 fprintf(stderr,"*Wo1: %x %x %x\n", (unsigned int) pointer,
236 (unsigned int) start_addr, *start_addr);
240 /* Is it plausible? Not a cons. XXX should check the headers. */
241 if (is_lisp_pointer(start_addr[0]) || ((start_addr[0] & 3) == 0)) {
242 if (pointer_filter_verbose) {
243 fprintf(stderr,"*Wo2: %x %x %x\n", (unsigned int) pointer,
244 (unsigned int) start_addr, *start_addr);
248 switch (widetag_of(start_addr[0])) {
249 case UNBOUND_MARKER_WIDETAG:
250 case CHARACTER_WIDETAG:
251 if (pointer_filter_verbose) {
252 fprintf(stderr,"*Wo3: %x %x %x\n", (unsigned int) pointer,
253 (unsigned int) start_addr, *start_addr);
257 /* only pointed to by function pointers? */
258 case CLOSURE_HEADER_WIDETAG:
259 case FUNCALLABLE_INSTANCE_HEADER_WIDETAG:
260 if (pointer_filter_verbose) {
261 fprintf(stderr,"*Wo4: %x %x %x\n", (unsigned int) pointer,
262 (unsigned int) start_addr, *start_addr);
266 case INSTANCE_HEADER_WIDETAG:
267 if (pointer_filter_verbose) {
268 fprintf(stderr,"*Wo5: %x %x %x\n", (unsigned int) pointer,
269 (unsigned int) start_addr, *start_addr);
273 /* the valid other immediate pointer objects */
274 case SIMPLE_VECTOR_WIDETAG:
276 case COMPLEX_WIDETAG:
277 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
278 case COMPLEX_SINGLE_FLOAT_WIDETAG:
280 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
281 case COMPLEX_DOUBLE_FLOAT_WIDETAG:
283 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
284 case COMPLEX_LONG_FLOAT_WIDETAG:
286 case SIMPLE_ARRAY_WIDETAG:
287 case COMPLEX_BASE_STRING_WIDETAG:
288 #ifdef COMPLEX_CHARACTER_STRING_WIDETAG
289 case COMPLEX_CHARACTER_STRING_WIDETAG:
291 case COMPLEX_VECTOR_NIL_WIDETAG:
292 case COMPLEX_BIT_VECTOR_WIDETAG:
293 case COMPLEX_VECTOR_WIDETAG:
294 case COMPLEX_ARRAY_WIDETAG:
295 case VALUE_CELL_HEADER_WIDETAG:
296 case SYMBOL_HEADER_WIDETAG:
298 case CODE_HEADER_WIDETAG:
300 case SINGLE_FLOAT_WIDETAG:
301 case DOUBLE_FLOAT_WIDETAG:
302 #ifdef LONG_FLOAT_WIDETAG
303 case LONG_FLOAT_WIDETAG:
305 case SIMPLE_ARRAY_NIL_WIDETAG:
306 case SIMPLE_BASE_STRING_WIDETAG:
307 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
308 case SIMPLE_CHARACTER_STRING_WIDETAG:
310 case SIMPLE_BIT_VECTOR_WIDETAG:
311 case SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG:
312 case SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG:
313 case SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG:
314 case SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG:
315 case SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG:
316 case SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG:
317 case SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG:
318 case SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG:
319 case SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG:
320 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
321 case SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG:
323 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
324 case SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG:
326 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
327 case SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG:
329 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
330 case SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG:
332 case SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG:
333 case SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG:
334 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
335 case SIMPLE_ARRAY_LONG_FLOAT_WIDETAG:
337 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
338 case SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG:
340 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
341 case SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG:
343 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
344 case SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG:
347 case WEAK_POINTER_WIDETAG:
351 if (pointer_filter_verbose) {
352 fprintf(stderr,"*Wo6: %x %x %x\n", (unsigned int) pointer,
353 (unsigned int) start_addr, *start_addr);
359 if (pointer_filter_verbose) {
360 fprintf(stderr,"*W?: %x %x %x\n", (unsigned int) pointer,
361 (unsigned int) start_addr, *start_addr);
370 #define MAX_STACK_POINTERS 256
371 lispobj *valid_stack_locations[MAX_STACK_POINTERS];
372 unsigned int num_valid_stack_locations;
374 #define MAX_STACK_RETURN_ADDRESSES 128
375 lispobj *valid_stack_ra_locations[MAX_STACK_RETURN_ADDRESSES];
376 lispobj *valid_stack_ra_code_objects[MAX_STACK_RETURN_ADDRESSES];
377 unsigned int num_valid_stack_ra_locations;
379 /* Identify valid stack slots. */
381 setup_i386_stack_scav(lispobj *lowaddr, lispobj *base)
383 lispobj *sp = lowaddr;
384 num_valid_stack_locations = 0;
385 num_valid_stack_ra_locations = 0;
386 for (sp = lowaddr; sp < base; sp++) {
388 /* Find the object start address */
389 lispobj *start_addr = search_dynamic_space((void *)thing);
391 /* We need to allow raw pointers into Code objects for
392 * return addresses. This will also pick up pointers to
393 * functions in code objects. */
394 if (widetag_of(*start_addr) == CODE_HEADER_WIDETAG) {
395 /* FIXME asserting here is a really dumb thing to do.
396 * If we've overflowed some arbitrary static limit, we
397 * should just refuse to purify, instead of killing
398 * the whole lisp session
400 gc_assert(num_valid_stack_ra_locations <
401 MAX_STACK_RETURN_ADDRESSES);
402 valid_stack_ra_locations[num_valid_stack_ra_locations] = sp;
403 valid_stack_ra_code_objects[num_valid_stack_ra_locations++] =
404 (lispobj *)((int)start_addr + OTHER_POINTER_LOWTAG);
406 if (valid_dynamic_space_pointer((void *)thing, start_addr)) {
407 gc_assert(num_valid_stack_locations < MAX_STACK_POINTERS);
408 valid_stack_locations[num_valid_stack_locations++] = sp;
413 if (pointer_filter_verbose) {
414 fprintf(stderr, "number of valid stack pointers = %d\n",
415 num_valid_stack_locations);
416 fprintf(stderr, "number of stack return addresses = %d\n",
417 num_valid_stack_ra_locations);
422 pscav_i386_stack(void)
426 for (i = 0; i < num_valid_stack_locations; i++)
427 pscav(valid_stack_locations[i], 1, 0);
429 for (i = 0; i < num_valid_stack_ra_locations; i++) {
430 lispobj code_obj = (lispobj)valid_stack_ra_code_objects[i];
431 pscav(&code_obj, 1, 0);
432 if (pointer_filter_verbose) {
433 fprintf(stderr,"*C moved RA %x to %x; for code object %x to %x\n",
434 *valid_stack_ra_locations[i],
435 (int)(*valid_stack_ra_locations[i])
436 - ((int)valid_stack_ra_code_objects[i] - (int)code_obj),
437 (unsigned int) valid_stack_ra_code_objects[i], code_obj);
439 *valid_stack_ra_locations[i] =
440 ((int)(*valid_stack_ra_locations[i])
441 - ((int)valid_stack_ra_code_objects[i] - (int)code_obj));
449 pscav_later(lispobj *where, int count)
453 if (count > LATERMAXCOUNT) {
454 while (count > LATERMAXCOUNT) {
455 pscav_later(where, LATERMAXCOUNT);
456 count -= LATERMAXCOUNT;
457 where += LATERMAXCOUNT;
461 if (later_blocks == NULL || later_count == LATERBLOCKSIZE ||
462 (later_count == LATERBLOCKSIZE-1 && count > 1)) {
463 new = (struct later *)malloc(sizeof(struct later));
464 new->next = later_blocks;
465 if (later_blocks && later_count < LATERBLOCKSIZE)
466 later_blocks->u[later_count].ptr = NULL;
472 later_blocks->u[later_count++].count = count;
473 later_blocks->u[later_count++].ptr = where;
478 ptrans_boxed(lispobj thing, lispobj header, boolean constant)
481 lispobj result, *new, *old;
483 nwords = 1 + HeaderValue(header);
486 old = (lispobj *)native_pointer(thing);
487 new = newspace_alloc(nwords,constant);
490 bcopy(old, new, nwords * sizeof(lispobj));
492 /* Deposit forwarding pointer. */
493 result = make_lispobj(new, lowtag_of(thing));
497 pscav(new, nwords, constant);
502 /* We need to look at the layout to see whether it is a pure structure
503 * class, and only then can we transport as constant. If it is pure,
504 * we can ALWAYS transport as a constant. */
506 ptrans_instance(lispobj thing, lispobj header, boolean /* ignored */ constant)
508 lispobj layout = ((struct instance *)native_pointer(thing))->slots[0];
509 lispobj pure = ((struct instance *)native_pointer(layout))->slots[15];
513 return (ptrans_boxed(thing, header, 1));
515 return (ptrans_boxed(thing, header, 0));
518 /* Substructure: special case for the COMPACT-INFO-ENVs,
519 * where the instance may have a point to the dynamic
520 * space placed into it (e.g. the cache-name slot), but
521 * the lists and arrays at the time of a purify can be
522 * moved to the RO space. */
524 lispobj result, *new, *old;
526 nwords = 1 + HeaderValue(header);
529 old = (lispobj *)native_pointer(thing);
530 new = newspace_alloc(nwords, 0); /* inconstant */
533 bcopy(old, new, nwords * sizeof(lispobj));
535 /* Deposit forwarding pointer. */
536 result = make_lispobj(new, lowtag_of(thing));
540 pscav(new, nwords, 1);
546 return NIL; /* dummy value: return something ... */
551 ptrans_fdefn(lispobj thing, lispobj header)
554 lispobj result, *new, *old, oldfn;
557 nwords = 1 + HeaderValue(header);
560 old = (lispobj *)native_pointer(thing);
561 new = newspace_alloc(nwords, 0); /* inconstant */
564 bcopy(old, new, nwords * sizeof(lispobj));
566 /* Deposit forwarding pointer. */
567 result = make_lispobj(new, lowtag_of(thing));
570 /* Scavenge the function. */
571 fdefn = (struct fdefn *)new;
573 pscav(&fdefn->fun, 1, 0);
574 if ((char *)oldfn + FUN_RAW_ADDR_OFFSET == fdefn->raw_addr)
575 fdefn->raw_addr = (char *)fdefn->fun + FUN_RAW_ADDR_OFFSET;
581 ptrans_unboxed(lispobj thing, lispobj header)
584 lispobj result, *new, *old;
586 nwords = 1 + HeaderValue(header);
589 old = (lispobj *)native_pointer(thing);
590 new = newspace_alloc(nwords,1); /* always constant */
593 bcopy(old, new, nwords * sizeof(lispobj));
595 /* Deposit forwarding pointer. */
596 result = make_lispobj(new , lowtag_of(thing));
603 ptrans_vector(lispobj thing, int bits, int extra,
604 boolean boxed, boolean constant)
606 struct vector *vector;
608 lispobj result, *new;
610 vector = (struct vector *)native_pointer(thing);
611 nwords = 2 + (CEILING((fixnum_value(vector->length)+extra)*bits,32)>>5);
613 new=newspace_alloc(nwords, (constant || !boxed));
614 bcopy(vector, new, nwords * sizeof(lispobj));
616 result = make_lispobj(new, lowtag_of(thing));
617 vector->header = result;
620 pscav(new, nwords, constant);
625 #ifdef LISP_FEATURE_X86
627 apply_code_fixups_during_purify(struct code *old_code, struct code *new_code)
629 int nheader_words, ncode_words, nwords;
630 void *constants_start_addr, *constants_end_addr;
631 void *code_start_addr, *code_end_addr;
632 lispobj fixups = NIL;
633 unsigned displacement = (unsigned)new_code - (unsigned)old_code;
634 struct vector *fixups_vector;
636 ncode_words = fixnum_value(new_code->code_size);
637 nheader_words = HeaderValue(*(lispobj *)new_code);
638 nwords = ncode_words + nheader_words;
640 constants_start_addr = (void *)new_code + 5*4;
641 constants_end_addr = (void *)new_code + nheader_words*4;
642 code_start_addr = (void *)new_code + nheader_words*4;
643 code_end_addr = (void *)new_code + nwords*4;
645 /* The first constant should be a pointer to the fixups for this
646 * code objects. Check. */
647 fixups = new_code->constants[0];
649 /* It will be 0 or the unbound-marker if there are no fixups, and
650 * will be an other-pointer to a vector if it is valid. */
652 (fixups==UNBOUND_MARKER_WIDETAG) ||
653 !is_lisp_pointer(fixups)) {
654 #ifdef LISP_FEATURE_GENCGC
655 /* Check for a possible errors. */
656 sniff_code_object(new_code,displacement);
661 fixups_vector = (struct vector *)native_pointer(fixups);
663 /* Could be pointing to a forwarding pointer. */
664 if (is_lisp_pointer(fixups) && (dynamic_pointer_p(fixups))
665 && forwarding_pointer_p(*(lispobj *)fixups_vector)) {
666 /* If so then follow it. */
668 (struct vector *)native_pointer(*(lispobj *)fixups_vector);
671 if (widetag_of(fixups_vector->header) ==
672 SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG) {
673 /* We got the fixups for the code block. Now work through the
674 * vector, and apply a fixup at each address. */
675 int length = fixnum_value(fixups_vector->length);
677 for (i=0; i<length; i++) {
678 unsigned offset = fixups_vector->data[i];
679 /* Now check the current value of offset. */
681 *(unsigned *)((unsigned)code_start_addr + offset);
683 /* If it's within the old_code object then it must be an
684 * absolute fixup (relative ones are not saved) */
685 if ((old_value>=(unsigned)old_code)
686 && (old_value<((unsigned)old_code + nwords*4)))
687 /* So add the dispacement. */
688 *(unsigned *)((unsigned)code_start_addr + offset) = old_value
691 /* It is outside the old code object so it must be a relative
692 * fixup (absolute fixups are not saved). So subtract the
694 *(unsigned *)((unsigned)code_start_addr + offset) = old_value
699 /* No longer need the fixups. */
700 new_code->constants[0] = 0;
702 #ifdef LISP_FEATURE_GENCGC
703 /* Check for possible errors. */
704 sniff_code_object(new_code,displacement);
710 ptrans_code(lispobj thing)
712 struct code *code, *new;
714 lispobj func, result;
716 code = (struct code *)native_pointer(thing);
717 nwords = HeaderValue(code->header) + fixnum_value(code->code_size);
719 new = (struct code *)newspace_alloc(nwords,1); /* constant */
721 bcopy(code, new, nwords * sizeof(lispobj));
723 #ifdef LISP_FEATURE_X86
724 apply_code_fixups_during_purify(code,new);
727 result = make_lispobj(new, OTHER_POINTER_LOWTAG);
729 /* Stick in a forwarding pointer for the code object. */
730 *(lispobj *)code = result;
732 /* Put in forwarding pointers for all the functions. */
733 for (func = code->entry_points;
735 func = ((struct simple_fun *)native_pointer(func))->next) {
737 gc_assert(lowtag_of(func) == FUN_POINTER_LOWTAG);
739 *(lispobj *)native_pointer(func) = result + (func - thing);
742 /* Arrange to scavenge the debug info later. */
743 pscav_later(&new->debug_info, 1);
745 /* FIXME: why would this be a fixnum? */
746 /* "why" is a hard word, but apparently for compiled functions the
747 trace_table_offset contains the length of the instructions, as
748 a fixnum. See CODE-INST-AREA-LENGTH in
749 src/compiler/target-disassem.lisp. -- CSR, 2004-01-08 */
750 if (!(fixnump(new->trace_table_offset)))
752 pscav(&new->trace_table_offset, 1, 0);
754 new->trace_table_offset = NIL; /* limit lifetime */
757 /* Scavenge the constants. */
758 pscav(new->constants, HeaderValue(new->header)-5, 1);
760 /* Scavenge all the functions. */
761 pscav(&new->entry_points, 1, 1);
762 for (func = new->entry_points;
764 func = ((struct simple_fun *)native_pointer(func))->next) {
765 gc_assert(lowtag_of(func) == FUN_POINTER_LOWTAG);
766 gc_assert(!dynamic_pointer_p(func));
768 #ifdef LISP_FEATURE_X86
769 /* Temporarily convert the self pointer to a real function pointer. */
770 ((struct simple_fun *)native_pointer(func))->self
771 -= FUN_RAW_ADDR_OFFSET;
773 pscav(&((struct simple_fun *)native_pointer(func))->self, 2, 1);
774 #ifdef LISP_FEATURE_X86
775 ((struct simple_fun *)native_pointer(func))->self
776 += FUN_RAW_ADDR_OFFSET;
778 pscav_later(&((struct simple_fun *)native_pointer(func))->name, 3);
785 ptrans_func(lispobj thing, lispobj header)
788 lispobj code, *new, *old, result;
789 struct simple_fun *function;
791 /* Thing can either be a function header, a closure function
792 * header, a closure, or a funcallable-instance. If it's a closure
793 * or a funcallable-instance, we do the same as ptrans_boxed.
794 * Otherwise we have to do something strange, 'cause it is buried
795 * inside a code object. */
797 if (widetag_of(header) == SIMPLE_FUN_HEADER_WIDETAG) {
799 /* We can only end up here if the code object has not been
800 * scavenged, because if it had been scavenged, forwarding pointers
801 * would have been left behind for all the entry points. */
803 function = (struct simple_fun *)native_pointer(thing);
806 ((native_pointer(thing) -
807 (HeaderValue(function->header))), OTHER_POINTER_LOWTAG);
809 /* This will cause the function's header to be replaced with a
810 * forwarding pointer. */
814 /* So we can just return that. */
815 return function->header;
818 /* It's some kind of closure-like thing. */
819 nwords = 1 + HeaderValue(header);
820 old = (lispobj *)native_pointer(thing);
822 /* Allocate the new one. FINs *must* not go in read_only
823 * space. Closures can; they never change */
826 (nwords,(widetag_of(header)!=FUNCALLABLE_INSTANCE_HEADER_WIDETAG));
829 bcopy(old, new, nwords * sizeof(lispobj));
831 /* Deposit forwarding pointer. */
832 result = make_lispobj(new, lowtag_of(thing));
836 pscav(new, nwords, 0);
843 ptrans_returnpc(lispobj thing, lispobj header)
847 /* Find the corresponding code object. */
848 code = thing - HeaderValue(header)*sizeof(lispobj);
850 /* Make sure it's been transported. */
851 new = *(lispobj *)native_pointer(code);
852 if (!forwarding_pointer_p(new))
853 new = ptrans_code(code);
855 /* Maintain the offset: */
856 return new + (thing - code);
859 #define WORDS_PER_CONS CEILING(sizeof(struct cons) / sizeof(lispobj), 2)
862 ptrans_list(lispobj thing, boolean constant)
864 struct cons *old, *new, *orig;
867 orig = (struct cons *) newspace_alloc(0,constant);
871 /* Allocate a new cons cell. */
872 old = (struct cons *)native_pointer(thing);
873 new = (struct cons *) newspace_alloc(WORDS_PER_CONS,constant);
875 /* Copy the cons cell and keep a pointer to the cdr. */
877 thing = new->cdr = old->cdr;
879 /* Set up the forwarding pointer. */
880 *(lispobj *)old = make_lispobj(new, LIST_POINTER_LOWTAG);
882 /* And count this cell. */
884 } while (lowtag_of(thing) == LIST_POINTER_LOWTAG &&
885 dynamic_pointer_p(thing) &&
886 !(forwarding_pointer_p(*(lispobj *)native_pointer(thing))));
888 /* Scavenge the list we just copied. */
889 pscav((lispobj *)orig, length * WORDS_PER_CONS, constant);
891 return make_lispobj(orig, LIST_POINTER_LOWTAG);
895 ptrans_otherptr(lispobj thing, lispobj header, boolean constant)
897 switch (widetag_of(header)) {
898 /* FIXME: this needs a reindent */
900 case SINGLE_FLOAT_WIDETAG:
901 case DOUBLE_FLOAT_WIDETAG:
902 #ifdef LONG_FLOAT_WIDETAG
903 case LONG_FLOAT_WIDETAG:
905 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
906 case COMPLEX_SINGLE_FLOAT_WIDETAG:
908 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
909 case COMPLEX_DOUBLE_FLOAT_WIDETAG:
911 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
912 case COMPLEX_LONG_FLOAT_WIDETAG:
915 return ptrans_unboxed(thing, header);
918 case COMPLEX_WIDETAG:
919 case SIMPLE_ARRAY_WIDETAG:
920 case COMPLEX_BASE_STRING_WIDETAG:
921 #ifdef COMPLEX_CHARACTER_STRING_WIDETAG
922 case COMPLEX_CHARACTER_STRING_WIDETAG:
924 case COMPLEX_BIT_VECTOR_WIDETAG:
925 case COMPLEX_VECTOR_NIL_WIDETAG:
926 case COMPLEX_VECTOR_WIDETAG:
927 case COMPLEX_ARRAY_WIDETAG:
928 return ptrans_boxed(thing, header, constant);
930 case VALUE_CELL_HEADER_WIDETAG:
931 case WEAK_POINTER_WIDETAG:
932 return ptrans_boxed(thing, header, 0);
934 case SYMBOL_HEADER_WIDETAG:
935 return ptrans_boxed(thing, header, 0);
937 case SIMPLE_ARRAY_NIL_WIDETAG:
938 return ptrans_vector(thing, 0, 0, 0, constant);
940 case SIMPLE_BASE_STRING_WIDETAG:
941 return ptrans_vector(thing, 8, 1, 0, constant);
943 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
944 case SIMPLE_CHARACTER_STRING_WIDETAG:
945 return ptrans_vector(thing, 32, 1, 0, constant);
948 case SIMPLE_BIT_VECTOR_WIDETAG:
949 return ptrans_vector(thing, 1, 0, 0, constant);
951 case SIMPLE_VECTOR_WIDETAG:
952 return ptrans_vector(thing, 32, 0, 1, constant);
954 case SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG:
955 return ptrans_vector(thing, 2, 0, 0, constant);
957 case SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG:
958 return ptrans_vector(thing, 4, 0, 0, constant);
960 case SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG:
961 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
962 case SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG:
963 case SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG:
965 return ptrans_vector(thing, 8, 0, 0, constant);
967 case SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG:
968 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
969 case SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG:
970 case SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG:
972 return ptrans_vector(thing, 16, 0, 0, constant);
974 case SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG:
975 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
976 case SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG:
977 case SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG:
979 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
980 case SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG:
981 case SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG:
983 return ptrans_vector(thing, 32, 0, 0, constant);
985 case SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG:
986 return ptrans_vector(thing, 32, 0, 0, constant);
988 case SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG:
989 return ptrans_vector(thing, 64, 0, 0, constant);
991 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
992 case SIMPLE_ARRAY_LONG_FLOAT_WIDETAG:
993 #ifdef LISP_FEATURE_X86
994 return ptrans_vector(thing, 96, 0, 0, constant);
997 return ptrans_vector(thing, 128, 0, 0, constant);
1001 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1002 case SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG:
1003 return ptrans_vector(thing, 64, 0, 0, constant);
1006 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1007 case SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG:
1008 return ptrans_vector(thing, 128, 0, 0, constant);
1011 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1012 case SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG:
1013 #ifdef LISP_FEATURE_X86
1014 return ptrans_vector(thing, 192, 0, 0, constant);
1017 return ptrans_vector(thing, 256, 0, 0, constant);
1021 case CODE_HEADER_WIDETAG:
1022 return ptrans_code(thing);
1024 case RETURN_PC_HEADER_WIDETAG:
1025 return ptrans_returnpc(thing, header);
1028 return ptrans_fdefn(thing, header);
1031 /* Should only come across other pointers to the above stuff. */
1038 pscav_fdefn(struct fdefn *fdefn)
1042 fix_func = ((char *)(fdefn->fun+FUN_RAW_ADDR_OFFSET) == fdefn->raw_addr);
1043 pscav(&fdefn->name, 1, 1);
1044 pscav(&fdefn->fun, 1, 0);
1046 fdefn->raw_addr = (char *)(fdefn->fun + FUN_RAW_ADDR_OFFSET);
1047 return sizeof(struct fdefn) / sizeof(lispobj);
1050 #ifdef LISP_FEATURE_X86
1051 /* now putting code objects in static space */
1053 pscav_code(struct code*code)
1057 nwords = HeaderValue(code->header) + fixnum_value(code->code_size);
1059 /* Arrange to scavenge the debug info later. */
1060 pscav_later(&code->debug_info, 1);
1062 /* Scavenge the constants. */
1063 pscav(code->constants, HeaderValue(code->header)-5, 1);
1065 /* Scavenge all the functions. */
1066 pscav(&code->entry_points, 1, 1);
1067 for (func = code->entry_points;
1069 func = ((struct simple_fun *)native_pointer(func))->next) {
1070 gc_assert(lowtag_of(func) == FUN_POINTER_LOWTAG);
1071 gc_assert(!dynamic_pointer_p(func));
1073 #ifdef LISP_FEATURE_X86
1074 /* Temporarily convert the self pointer to a real function
1076 ((struct simple_fun *)native_pointer(func))->self
1077 -= FUN_RAW_ADDR_OFFSET;
1079 pscav(&((struct simple_fun *)native_pointer(func))->self, 2, 1);
1080 #ifdef LISP_FEATURE_X86
1081 ((struct simple_fun *)native_pointer(func))->self
1082 += FUN_RAW_ADDR_OFFSET;
1084 pscav_later(&((struct simple_fun *)native_pointer(func))->name, 3);
1087 return CEILING(nwords,2);
1092 pscav(lispobj *addr, int nwords, boolean constant)
1094 lispobj thing, *thingp, header;
1095 int count = 0; /* (0 = dummy init value to stop GCC warning) */
1096 struct vector *vector;
1098 while (nwords > 0) {
1100 if (is_lisp_pointer(thing)) {
1101 /* It's a pointer. Is it something we might have to move? */
1102 if (dynamic_pointer_p(thing)) {
1103 /* Maybe. Have we already moved it? */
1104 thingp = (lispobj *)native_pointer(thing);
1106 if (is_lisp_pointer(header) && forwarding_pointer_p(header))
1107 /* Yep, so just copy the forwarding pointer. */
1110 /* Nope, copy the object. */
1111 switch (lowtag_of(thing)) {
1112 case FUN_POINTER_LOWTAG:
1113 thing = ptrans_func(thing, header);
1116 case LIST_POINTER_LOWTAG:
1117 thing = ptrans_list(thing, constant);
1120 case INSTANCE_POINTER_LOWTAG:
1121 thing = ptrans_instance(thing, header, constant);
1124 case OTHER_POINTER_LOWTAG:
1125 thing = ptrans_otherptr(thing, header, constant);
1129 /* It was a pointer, but not one of them? */
1137 else if (thing & 3) { /* FIXME: 3? not 2? */
1138 /* It's an other immediate. Maybe the header for an unboxed */
1140 switch (widetag_of(thing)) {
1141 case BIGNUM_WIDETAG:
1142 case SINGLE_FLOAT_WIDETAG:
1143 case DOUBLE_FLOAT_WIDETAG:
1144 #ifdef LONG_FLOAT_WIDETAG
1145 case LONG_FLOAT_WIDETAG:
1148 /* It's an unboxed simple object. */
1149 count = HeaderValue(thing)+1;
1152 case SIMPLE_VECTOR_WIDETAG:
1153 if (HeaderValue(thing) == subtype_VectorValidHashing) {
1154 *addr = (subtype_VectorMustRehash << N_WIDETAG_BITS) |
1155 SIMPLE_VECTOR_WIDETAG;
1160 case SIMPLE_ARRAY_NIL_WIDETAG:
1164 case SIMPLE_BASE_STRING_WIDETAG:
1165 vector = (struct vector *)addr;
1166 count = CEILING(NWORDS(fixnum_value(vector->length)+1,8)+2,2);
1169 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
1170 case SIMPLE_CHARACTER_STRING_WIDETAG:
1171 vector = (struct vector *)addr;
1172 count = CEILING(NWORDS(fixnum_value(vector->length)+1,32)+2,2);
1176 case SIMPLE_BIT_VECTOR_WIDETAG:
1177 vector = (struct vector *)addr;
1178 count = CEILING(NWORDS(fixnum_value(vector->length),1)+2,2);
1181 case SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG:
1182 vector = (struct vector *)addr;
1183 count = CEILING(NWORDS(fixnum_value(vector->length),2)+2,2);
1186 case SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG:
1187 vector = (struct vector *)addr;
1188 count = CEILING(NWORDS(fixnum_value(vector->length),4)+2,2);
1191 case SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG:
1192 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
1193 case SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG:
1194 case SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG:
1196 vector = (struct vector *)addr;
1197 count = CEILING(NWORDS(fixnum_value(vector->length),8)+2,2);
1200 case SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG:
1201 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
1202 case SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG:
1203 case SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG:
1205 vector = (struct vector *)addr;
1206 count = CEILING(NWORDS(fixnum_value(vector->length),16)+2,2);
1209 case SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG:
1210 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
1211 case SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG:
1212 case SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG:
1214 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
1215 case SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG:
1216 case SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG:
1218 vector = (struct vector *)addr;
1219 count = CEILING(NWORDS(fixnum_value(vector->length),32)+2,2);
1222 #if N_WORD_BITS == 64
1223 case SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG:
1224 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG
1225 case SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG:
1226 case SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG:
1228 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG
1229 case SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG:
1230 case SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG:
1232 vector = (struct vector *)addr;
1233 count = CEILING(NWORDS(fixnum_value(vector->length),64)+2,2);
1237 case SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG:
1238 vector = (struct vector *)addr;
1239 count = CEILING(fixnum_value(vector->length)+2,2);
1242 case SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG:
1243 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1244 case SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG:
1246 vector = (struct vector *)addr;
1247 count = fixnum_value(vector->length)*2+2;
1250 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1251 case SIMPLE_ARRAY_LONG_FLOAT_WIDETAG:
1252 vector = (struct vector *)addr;
1253 #ifdef LISP_FEATURE_X86
1254 count = fixnum_value(vector->length)*3+2;
1257 count = fixnum_value(vector->length)*4+2;
1262 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1263 case SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG:
1264 vector = (struct vector *)addr;
1265 count = fixnum_value(vector->length)*4+2;
1269 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1270 case SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG:
1271 vector = (struct vector *)addr;
1272 #ifdef LISP_FEATURE_X86
1273 count = fixnum_value(vector->length)*6+2;
1276 count = fixnum_value(vector->length)*8+2;
1281 case CODE_HEADER_WIDETAG:
1282 #ifndef LISP_FEATURE_X86
1283 gc_abort(); /* no code headers in static space */
1285 count = pscav_code((struct code*)addr);
1289 case SIMPLE_FUN_HEADER_WIDETAG:
1290 case RETURN_PC_HEADER_WIDETAG:
1291 /* We should never hit any of these, 'cause they occur
1292 * buried in the middle of code objects. */
1296 #ifdef LISP_FEATURE_X86
1297 case CLOSURE_HEADER_WIDETAG:
1298 case FUNCALLABLE_INSTANCE_HEADER_WIDETAG:
1299 /* The function self pointer needs special care on the
1300 * x86 because it is the real entry point. */
1302 lispobj fun = ((struct closure *)addr)->fun
1303 - FUN_RAW_ADDR_OFFSET;
1304 pscav(&fun, 1, constant);
1305 ((struct closure *)addr)->fun = fun + FUN_RAW_ADDR_OFFSET;
1311 case WEAK_POINTER_WIDETAG:
1312 /* Weak pointers get preserved during purify, 'cause I
1313 * don't feel like figuring out how to break them. */
1314 pscav(addr+1, 2, constant);
1319 /* We have to handle fdefn objects specially, so we
1320 * can fix up the raw function address. */
1321 count = pscav_fdefn((struct fdefn *)addr);
1330 /* It's a fixnum. */
1342 purify(lispobj static_roots, lispobj read_only_roots)
1346 struct later *laters, *next;
1347 struct thread *thread;
1349 if(all_threads->next) {
1350 /* FIXME: there should be _some_ sensible error reporting
1351 * convention. See following comment too */
1352 fprintf(stderr,"Can't purify when more than one thread exists\n");
1358 printf("[doing purification:");
1361 #ifdef LISP_FEATURE_GENCGC
1362 gc_alloc_update_all_page_tables();
1364 for_each_thread(thread)
1365 if (fixnum_value(SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX,thread)) != 0) {
1366 /* FIXME: 1. What does this mean? 2. It shouldn't be reporting
1367 * its error simply by a. printing a string b. to stdout instead
1369 printf(" Ack! Can't purify interrupt contexts. ");
1374 #if defined(LISP_FEATURE_X86)
1375 dynamic_space_free_pointer =
1376 (lispobj*)SymbolValue(ALLOCATION_POINTER,0);
1379 read_only_end = read_only_free =
1380 (lispobj *)SymbolValue(READ_ONLY_SPACE_FREE_POINTER,0);
1381 static_end = static_free =
1382 (lispobj *)SymbolValue(STATIC_SPACE_FREE_POINTER,0);
1389 #if (defined(LISP_FEATURE_GENCGC) && defined(LISP_FEATURE_X86))
1390 /* note this expects only one thread to be active. We'd have to
1391 * stop all the others in the same way as GC does if we wanted
1392 * PURIFY to work when >1 thread exists */
1393 setup_i386_stack_scav(((&static_roots)-2),
1394 ((void *)all_threads->control_stack_end));
1397 pscav(&static_roots, 1, 0);
1398 pscav(&read_only_roots, 1, 1);
1401 printf(" handlers");
1404 pscav((lispobj *) all_threads->interrupt_data->interrupt_handlers,
1405 sizeof(all_threads->interrupt_data->interrupt_handlers)
1413 #ifndef LISP_FEATURE_X86
1414 pscav((lispobj *)all_threads->control_stack_start,
1415 current_control_stack_pointer -
1416 all_threads->control_stack_start,
1419 #ifdef LISP_FEATURE_GENCGC
1425 printf(" bindings");
1428 #if !defined(LISP_FEATURE_X86)
1429 pscav( (lispobj *)all_threads->binding_stack_start,
1430 (lispobj *)current_binding_stack_pointer -
1431 all_threads->binding_stack_start,
1434 for_each_thread(thread) {
1435 pscav( (lispobj *)thread->binding_stack_start,
1436 (lispobj *)SymbolValue(BINDING_STACK_POINTER,thread) -
1437 (lispobj *)thread->binding_stack_start,
1439 pscav( (lispobj *) (thread+1),
1440 fixnum_value(SymbolValue(FREE_TLS_INDEX,0)) -
1441 (sizeof (struct thread))/(sizeof (lispobj)),
1448 /* The original CMU CL code had scavenge-read-only-space code
1449 * controlled by the Lisp-level variable
1450 * *SCAVENGE-READ-ONLY-SPACE*. It was disabled by default, and it
1451 * wasn't documented under what circumstances it was useful or
1452 * safe to turn it on, so it's been turned off in SBCL. If you
1453 * want/need this functionality, and can test and document it,
1454 * please submit a patch. */
1456 if (SymbolValue(SCAVENGE_READ_ONLY_SPACE) != UNBOUND_MARKER_WIDETAG
1457 && SymbolValue(SCAVENGE_READ_ONLY_SPACE) != NIL) {
1458 unsigned read_only_space_size =
1459 (lispobj *)SymbolValue(READ_ONLY_SPACE_FREE_POINTER) -
1460 (lispobj *)READ_ONLY_SPACE_START;
1462 "scavenging read only space: %d bytes\n",
1463 read_only_space_size * sizeof(lispobj));
1464 pscav( (lispobj *)READ_ONLY_SPACE_START, read_only_space_size, 0);
1472 clean = (lispobj *)STATIC_SPACE_START;
1474 while (clean != static_free)
1475 clean = pscav(clean, static_free - clean, 0);
1476 laters = later_blocks;
1477 count = later_count;
1478 later_blocks = NULL;
1480 while (laters != NULL) {
1481 for (i = 0; i < count; i++) {
1482 if (laters->u[i].count == 0) {
1484 } else if (laters->u[i].count <= LATERMAXCOUNT) {
1485 pscav(laters->u[i+1].ptr, laters->u[i].count, 1);
1488 pscav(laters->u[i].ptr, 1, 1);
1491 next = laters->next;
1494 count = LATERBLOCKSIZE;
1496 } while (clean != static_free || later_blocks != NULL);
1503 os_zero((os_vm_address_t) current_dynamic_space,
1504 (os_vm_size_t) DYNAMIC_SPACE_SIZE);
1506 /* Zero the stack. Note that the stack is also zeroed by SUB-GC
1507 * calling SCRUB-CONTROL-STACK - this zeros the stack on the x86. */
1508 #ifndef LISP_FEATURE_X86
1509 os_zero((os_vm_address_t) current_control_stack_pointer,
1511 ((all_threads->control_stack_end -
1512 current_control_stack_pointer) * sizeof(lispobj)));
1515 /* It helps to update the heap free pointers so that free_heap can
1516 * verify after it's done. */
1517 SetSymbolValue(READ_ONLY_SPACE_FREE_POINTER, (lispobj)read_only_free,0);
1518 SetSymbolValue(STATIC_SPACE_FREE_POINTER, (lispobj)static_free,0);
1520 #if !defined(ALLOCATION_POINTER)
1521 dynamic_space_free_pointer = current_dynamic_space;
1522 set_auto_gc_trigger(bytes_consed_between_gcs);
1524 #if defined LISP_FEATURE_GENCGC
1527 #error unsupported case /* in CMU CL, was "ibmrt using GC" */