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]) == BASE_CHAR_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]) == BASE_CHAR_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 BASE_CHAR_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 case COMPLEX_VECTOR_NIL_WIDETAG:
289 case COMPLEX_BIT_VECTOR_WIDETAG:
290 case COMPLEX_VECTOR_WIDETAG:
291 case COMPLEX_ARRAY_WIDETAG:
292 case VALUE_CELL_HEADER_WIDETAG:
293 case SYMBOL_HEADER_WIDETAG:
295 case CODE_HEADER_WIDETAG:
297 case SINGLE_FLOAT_WIDETAG:
298 case DOUBLE_FLOAT_WIDETAG:
299 #ifdef LONG_FLOAT_WIDETAG
300 case LONG_FLOAT_WIDETAG:
302 case SIMPLE_ARRAY_NIL_WIDETAG:
303 case SIMPLE_BASE_STRING_WIDETAG:
304 case SIMPLE_BIT_VECTOR_WIDETAG:
305 case SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG:
306 case SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG:
307 case SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG:
308 case SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG:
309 case SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG:
310 case SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG:
311 case SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG:
312 case SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG:
313 case SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG:
314 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
315 case SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG:
317 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
318 case SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG:
320 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
321 case SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG:
323 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
324 case SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG:
326 case SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG:
327 case SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG:
328 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
329 case SIMPLE_ARRAY_LONG_FLOAT_WIDETAG:
331 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
332 case SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG:
334 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
335 case SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG:
337 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
338 case SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG:
341 case WEAK_POINTER_WIDETAG:
345 if (pointer_filter_verbose) {
346 fprintf(stderr,"*Wo6: %x %x %x\n", (unsigned int) pointer,
347 (unsigned int) start_addr, *start_addr);
353 if (pointer_filter_verbose) {
354 fprintf(stderr,"*W?: %x %x %x\n", (unsigned int) pointer,
355 (unsigned int) start_addr, *start_addr);
364 #define MAX_STACK_POINTERS 256
365 lispobj *valid_stack_locations[MAX_STACK_POINTERS];
366 unsigned int num_valid_stack_locations;
368 #define MAX_STACK_RETURN_ADDRESSES 128
369 lispobj *valid_stack_ra_locations[MAX_STACK_RETURN_ADDRESSES];
370 lispobj *valid_stack_ra_code_objects[MAX_STACK_RETURN_ADDRESSES];
371 unsigned int num_valid_stack_ra_locations;
373 /* Identify valid stack slots. */
375 setup_i386_stack_scav(lispobj *lowaddr, lispobj *base)
377 lispobj *sp = lowaddr;
378 num_valid_stack_locations = 0;
379 num_valid_stack_ra_locations = 0;
380 for (sp = lowaddr; sp < base; sp++) {
382 /* Find the object start address */
383 lispobj *start_addr = search_dynamic_space((void *)thing);
385 /* We need to allow raw pointers into Code objects for
386 * return addresses. This will also pick up pointers to
387 * functions in code objects. */
388 if (widetag_of(*start_addr) == CODE_HEADER_WIDETAG) {
389 /* FIXME asserting here is a really dumb thing to do.
390 * If we've overflowed some arbitrary static limit, we
391 * should just refuse to purify, instead of killing
392 * the whole lisp session
394 gc_assert(num_valid_stack_ra_locations <
395 MAX_STACK_RETURN_ADDRESSES);
396 valid_stack_ra_locations[num_valid_stack_ra_locations] = sp;
397 valid_stack_ra_code_objects[num_valid_stack_ra_locations++] =
398 (lispobj *)((int)start_addr + OTHER_POINTER_LOWTAG);
400 if (valid_dynamic_space_pointer((void *)thing, start_addr)) {
401 gc_assert(num_valid_stack_locations < MAX_STACK_POINTERS);
402 valid_stack_locations[num_valid_stack_locations++] = sp;
407 if (pointer_filter_verbose) {
408 fprintf(stderr, "number of valid stack pointers = %d\n",
409 num_valid_stack_locations);
410 fprintf(stderr, "number of stack return addresses = %d\n",
411 num_valid_stack_ra_locations);
416 pscav_i386_stack(void)
420 for (i = 0; i < num_valid_stack_locations; i++)
421 pscav(valid_stack_locations[i], 1, 0);
423 for (i = 0; i < num_valid_stack_ra_locations; i++) {
424 lispobj code_obj = (lispobj)valid_stack_ra_code_objects[i];
425 pscav(&code_obj, 1, 0);
426 if (pointer_filter_verbose) {
427 fprintf(stderr,"*C moved RA %x to %x; for code object %x to %x\n",
428 *valid_stack_ra_locations[i],
429 (int)(*valid_stack_ra_locations[i])
430 - ((int)valid_stack_ra_code_objects[i] - (int)code_obj),
431 (unsigned int) valid_stack_ra_code_objects[i], code_obj);
433 *valid_stack_ra_locations[i] =
434 ((int)(*valid_stack_ra_locations[i])
435 - ((int)valid_stack_ra_code_objects[i] - (int)code_obj));
443 pscav_later(lispobj *where, int count)
447 if (count > LATERMAXCOUNT) {
448 while (count > LATERMAXCOUNT) {
449 pscav_later(where, LATERMAXCOUNT);
450 count -= LATERMAXCOUNT;
451 where += LATERMAXCOUNT;
455 if (later_blocks == NULL || later_count == LATERBLOCKSIZE ||
456 (later_count == LATERBLOCKSIZE-1 && count > 1)) {
457 new = (struct later *)malloc(sizeof(struct later));
458 new->next = later_blocks;
459 if (later_blocks && later_count < LATERBLOCKSIZE)
460 later_blocks->u[later_count].ptr = NULL;
466 later_blocks->u[later_count++].count = count;
467 later_blocks->u[later_count++].ptr = where;
472 ptrans_boxed(lispobj thing, lispobj header, boolean constant)
475 lispobj result, *new, *old;
477 nwords = 1 + HeaderValue(header);
480 old = (lispobj *)native_pointer(thing);
481 new = newspace_alloc(nwords,constant);
484 bcopy(old, new, nwords * sizeof(lispobj));
486 /* Deposit forwarding pointer. */
487 result = make_lispobj(new, lowtag_of(thing));
491 pscav(new, nwords, constant);
496 /* We need to look at the layout to see whether it is a pure structure
497 * class, and only then can we transport as constant. If it is pure,
498 * we can ALWAYS transport as a constant. */
500 ptrans_instance(lispobj thing, lispobj header, boolean /* ignored */ constant)
502 lispobj layout = ((struct instance *)native_pointer(thing))->slots[0];
503 lispobj pure = ((struct instance *)native_pointer(layout))->slots[15];
507 return (ptrans_boxed(thing, header, 1));
509 return (ptrans_boxed(thing, header, 0));
512 /* Substructure: special case for the COMPACT-INFO-ENVs,
513 * where the instance may have a point to the dynamic
514 * space placed into it (e.g. the cache-name slot), but
515 * the lists and arrays at the time of a purify can be
516 * moved to the RO space. */
518 lispobj result, *new, *old;
520 nwords = 1 + HeaderValue(header);
523 old = (lispobj *)native_pointer(thing);
524 new = newspace_alloc(nwords, 0); /* inconstant */
527 bcopy(old, new, nwords * sizeof(lispobj));
529 /* Deposit forwarding pointer. */
530 result = make_lispobj(new, lowtag_of(thing));
534 pscav(new, nwords, 1);
540 return NIL; /* dummy value: return something ... */
545 ptrans_fdefn(lispobj thing, lispobj header)
548 lispobj result, *new, *old, oldfn;
551 nwords = 1 + HeaderValue(header);
554 old = (lispobj *)native_pointer(thing);
555 new = newspace_alloc(nwords, 0); /* inconstant */
558 bcopy(old, new, nwords * sizeof(lispobj));
560 /* Deposit forwarding pointer. */
561 result = make_lispobj(new, lowtag_of(thing));
564 /* Scavenge the function. */
565 fdefn = (struct fdefn *)new;
567 pscav(&fdefn->fun, 1, 0);
568 if ((char *)oldfn + FUN_RAW_ADDR_OFFSET == fdefn->raw_addr)
569 fdefn->raw_addr = (char *)fdefn->fun + FUN_RAW_ADDR_OFFSET;
575 ptrans_unboxed(lispobj thing, lispobj header)
578 lispobj result, *new, *old;
580 nwords = 1 + HeaderValue(header);
583 old = (lispobj *)native_pointer(thing);
584 new = newspace_alloc(nwords,1); /* always constant */
587 bcopy(old, new, nwords * sizeof(lispobj));
589 /* Deposit forwarding pointer. */
590 result = make_lispobj(new , lowtag_of(thing));
597 ptrans_vector(lispobj thing, int bits, int extra,
598 boolean boxed, boolean constant)
600 struct vector *vector;
602 lispobj result, *new;
604 vector = (struct vector *)native_pointer(thing);
605 nwords = 2 + (CEILING((fixnum_value(vector->length)+extra)*bits,32)>>5);
607 new=newspace_alloc(nwords, (constant || !boxed));
608 bcopy(vector, new, nwords * sizeof(lispobj));
610 result = make_lispobj(new, lowtag_of(thing));
611 vector->header = result;
614 pscav(new, nwords, constant);
619 #ifdef LISP_FEATURE_X86
621 apply_code_fixups_during_purify(struct code *old_code, struct code *new_code)
623 int nheader_words, ncode_words, nwords;
624 void *constants_start_addr, *constants_end_addr;
625 void *code_start_addr, *code_end_addr;
626 lispobj fixups = NIL;
627 unsigned displacement = (unsigned)new_code - (unsigned)old_code;
628 struct vector *fixups_vector;
630 ncode_words = fixnum_value(new_code->code_size);
631 nheader_words = HeaderValue(*(lispobj *)new_code);
632 nwords = ncode_words + nheader_words;
634 constants_start_addr = (void *)new_code + 5*4;
635 constants_end_addr = (void *)new_code + nheader_words*4;
636 code_start_addr = (void *)new_code + nheader_words*4;
637 code_end_addr = (void *)new_code + nwords*4;
639 /* The first constant should be a pointer to the fixups for this
640 * code objects. Check. */
641 fixups = new_code->constants[0];
643 /* It will be 0 or the unbound-marker if there are no fixups, and
644 * will be an other-pointer to a vector if it is valid. */
646 (fixups==UNBOUND_MARKER_WIDETAG) ||
647 !is_lisp_pointer(fixups)) {
648 #ifdef LISP_FEATURE_GENCGC
649 /* Check for a possible errors. */
650 sniff_code_object(new_code,displacement);
655 fixups_vector = (struct vector *)native_pointer(fixups);
657 /* Could be pointing to a forwarding pointer. */
658 if (is_lisp_pointer(fixups) && (dynamic_pointer_p(fixups))
659 && forwarding_pointer_p(*(lispobj *)fixups_vector)) {
660 /* If so then follow it. */
662 (struct vector *)native_pointer(*(lispobj *)fixups_vector);
665 if (widetag_of(fixups_vector->header) ==
666 SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG) {
667 /* We got the fixups for the code block. Now work through the
668 * vector, and apply a fixup at each address. */
669 int length = fixnum_value(fixups_vector->length);
671 for (i=0; i<length; i++) {
672 unsigned offset = fixups_vector->data[i];
673 /* Now check the current value of offset. */
675 *(unsigned *)((unsigned)code_start_addr + offset);
677 /* If it's within the old_code object then it must be an
678 * absolute fixup (relative ones are not saved) */
679 if ((old_value>=(unsigned)old_code)
680 && (old_value<((unsigned)old_code + nwords*4)))
681 /* So add the dispacement. */
682 *(unsigned *)((unsigned)code_start_addr + offset) = old_value
685 /* It is outside the old code object so it must be a relative
686 * fixup (absolute fixups are not saved). So subtract the
688 *(unsigned *)((unsigned)code_start_addr + offset) = old_value
693 /* No longer need the fixups. */
694 new_code->constants[0] = 0;
696 #ifdef LISP_FEATURE_GENCGC
697 /* Check for possible errors. */
698 sniff_code_object(new_code,displacement);
704 ptrans_code(lispobj thing)
706 struct code *code, *new;
708 lispobj func, result;
710 code = (struct code *)native_pointer(thing);
711 nwords = HeaderValue(code->header) + fixnum_value(code->code_size);
713 new = (struct code *)newspace_alloc(nwords,1); /* constant */
715 bcopy(code, new, nwords * sizeof(lispobj));
717 #ifdef LISP_FEATURE_X86
718 apply_code_fixups_during_purify(code,new);
721 result = make_lispobj(new, OTHER_POINTER_LOWTAG);
723 /* Stick in a forwarding pointer for the code object. */
724 *(lispobj *)code = result;
726 /* Put in forwarding pointers for all the functions. */
727 for (func = code->entry_points;
729 func = ((struct simple_fun *)native_pointer(func))->next) {
731 gc_assert(lowtag_of(func) == FUN_POINTER_LOWTAG);
733 *(lispobj *)native_pointer(func) = result + (func - thing);
736 /* Arrange to scavenge the debug info later. */
737 pscav_later(&new->debug_info, 1);
739 /* FIXME: why would this be a fixnum? */
740 /* "why" is a hard word, but apparently for compiled functions the
741 trace_table_offset contains the length of the instructions, as
742 a fixnum. See CODE-INST-AREA-LENGTH in
743 src/compiler/target-disassem.lisp. -- CSR, 2004-01-08 */
744 if (!(fixnump(new->trace_table_offset)))
746 pscav(&new->trace_table_offset, 1, 0);
748 new->trace_table_offset = NIL; /* limit lifetime */
751 /* Scavenge the constants. */
752 pscav(new->constants, HeaderValue(new->header)-5, 1);
754 /* Scavenge all the functions. */
755 pscav(&new->entry_points, 1, 1);
756 for (func = new->entry_points;
758 func = ((struct simple_fun *)native_pointer(func))->next) {
759 gc_assert(lowtag_of(func) == FUN_POINTER_LOWTAG);
760 gc_assert(!dynamic_pointer_p(func));
762 #ifdef LISP_FEATURE_X86
763 /* Temporarily convert the self pointer to a real function pointer. */
764 ((struct simple_fun *)native_pointer(func))->self
765 -= FUN_RAW_ADDR_OFFSET;
767 pscav(&((struct simple_fun *)native_pointer(func))->self, 2, 1);
768 #ifdef LISP_FEATURE_X86
769 ((struct simple_fun *)native_pointer(func))->self
770 += FUN_RAW_ADDR_OFFSET;
772 pscav_later(&((struct simple_fun *)native_pointer(func))->name, 3);
779 ptrans_func(lispobj thing, lispobj header)
782 lispobj code, *new, *old, result;
783 struct simple_fun *function;
785 /* Thing can either be a function header, a closure function
786 * header, a closure, or a funcallable-instance. If it's a closure
787 * or a funcallable-instance, we do the same as ptrans_boxed.
788 * Otherwise we have to do something strange, 'cause it is buried
789 * inside a code object. */
791 if (widetag_of(header) == SIMPLE_FUN_HEADER_WIDETAG) {
793 /* We can only end up here if the code object has not been
794 * scavenged, because if it had been scavenged, forwarding pointers
795 * would have been left behind for all the entry points. */
797 function = (struct simple_fun *)native_pointer(thing);
800 ((native_pointer(thing) -
801 (HeaderValue(function->header))), OTHER_POINTER_LOWTAG);
803 /* This will cause the function's header to be replaced with a
804 * forwarding pointer. */
808 /* So we can just return that. */
809 return function->header;
812 /* It's some kind of closure-like thing. */
813 nwords = 1 + HeaderValue(header);
814 old = (lispobj *)native_pointer(thing);
816 /* Allocate the new one. FINs *must* not go in read_only
817 * space. Closures can; they never change */
820 (nwords,(widetag_of(header)!=FUNCALLABLE_INSTANCE_HEADER_WIDETAG));
823 bcopy(old, new, nwords * sizeof(lispobj));
825 /* Deposit forwarding pointer. */
826 result = make_lispobj(new, lowtag_of(thing));
830 pscav(new, nwords, 0);
837 ptrans_returnpc(lispobj thing, lispobj header)
841 /* Find the corresponding code object. */
842 code = thing - HeaderValue(header)*sizeof(lispobj);
844 /* Make sure it's been transported. */
845 new = *(lispobj *)native_pointer(code);
846 if (!forwarding_pointer_p(new))
847 new = ptrans_code(code);
849 /* Maintain the offset: */
850 return new + (thing - code);
853 #define WORDS_PER_CONS CEILING(sizeof(struct cons) / sizeof(lispobj), 2)
856 ptrans_list(lispobj thing, boolean constant)
858 struct cons *old, *new, *orig;
861 orig = (struct cons *) newspace_alloc(0,constant);
865 /* Allocate a new cons cell. */
866 old = (struct cons *)native_pointer(thing);
867 new = (struct cons *) newspace_alloc(WORDS_PER_CONS,constant);
869 /* Copy the cons cell and keep a pointer to the cdr. */
871 thing = new->cdr = old->cdr;
873 /* Set up the forwarding pointer. */
874 *(lispobj *)old = make_lispobj(new, LIST_POINTER_LOWTAG);
876 /* And count this cell. */
878 } while (lowtag_of(thing) == LIST_POINTER_LOWTAG &&
879 dynamic_pointer_p(thing) &&
880 !(forwarding_pointer_p(*(lispobj *)native_pointer(thing))));
882 /* Scavenge the list we just copied. */
883 pscav((lispobj *)orig, length * WORDS_PER_CONS, constant);
885 return make_lispobj(orig, LIST_POINTER_LOWTAG);
889 ptrans_otherptr(lispobj thing, lispobj header, boolean constant)
891 switch (widetag_of(header)) {
892 /* FIXME: this needs a reindent */
894 case SINGLE_FLOAT_WIDETAG:
895 case DOUBLE_FLOAT_WIDETAG:
896 #ifdef LONG_FLOAT_WIDETAG
897 case LONG_FLOAT_WIDETAG:
899 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
900 case COMPLEX_SINGLE_FLOAT_WIDETAG:
902 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
903 case COMPLEX_DOUBLE_FLOAT_WIDETAG:
905 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
906 case COMPLEX_LONG_FLOAT_WIDETAG:
909 return ptrans_unboxed(thing, header);
912 case COMPLEX_WIDETAG:
913 case SIMPLE_ARRAY_WIDETAG:
914 case COMPLEX_BASE_STRING_WIDETAG:
915 case COMPLEX_BIT_VECTOR_WIDETAG:
916 case COMPLEX_VECTOR_NIL_WIDETAG:
917 case COMPLEX_VECTOR_WIDETAG:
918 case COMPLEX_ARRAY_WIDETAG:
919 return ptrans_boxed(thing, header, constant);
921 case VALUE_CELL_HEADER_WIDETAG:
922 case WEAK_POINTER_WIDETAG:
923 return ptrans_boxed(thing, header, 0);
925 case SYMBOL_HEADER_WIDETAG:
926 return ptrans_boxed(thing, header, 0);
928 case SIMPLE_ARRAY_NIL_WIDETAG:
929 return ptrans_vector(thing, 0, 0, 0, constant);
931 case SIMPLE_BASE_STRING_WIDETAG:
932 return ptrans_vector(thing, 8, 1, 0, constant);
934 case SIMPLE_BIT_VECTOR_WIDETAG:
935 return ptrans_vector(thing, 1, 0, 0, constant);
937 case SIMPLE_VECTOR_WIDETAG:
938 return ptrans_vector(thing, 32, 0, 1, constant);
940 case SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG:
941 return ptrans_vector(thing, 2, 0, 0, constant);
943 case SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG:
944 return ptrans_vector(thing, 4, 0, 0, constant);
946 case SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG:
947 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
948 case SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG:
949 case SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG:
951 return ptrans_vector(thing, 8, 0, 0, constant);
953 case SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG:
954 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
955 case SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG:
956 case SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG:
958 return ptrans_vector(thing, 16, 0, 0, constant);
960 case SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG:
961 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
962 case SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG:
963 case SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG:
965 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
966 case SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG:
967 case SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG:
969 return ptrans_vector(thing, 32, 0, 0, constant);
971 case SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG:
972 return ptrans_vector(thing, 32, 0, 0, constant);
974 case SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG:
975 return ptrans_vector(thing, 64, 0, 0, constant);
977 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
978 case SIMPLE_ARRAY_LONG_FLOAT_WIDETAG:
979 #ifdef LISP_FEATURE_X86
980 return ptrans_vector(thing, 96, 0, 0, constant);
983 return ptrans_vector(thing, 128, 0, 0, constant);
987 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
988 case SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG:
989 return ptrans_vector(thing, 64, 0, 0, constant);
992 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
993 case SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG:
994 return ptrans_vector(thing, 128, 0, 0, constant);
997 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
998 case SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG:
999 #ifdef LISP_FEATURE_X86
1000 return ptrans_vector(thing, 192, 0, 0, constant);
1003 return ptrans_vector(thing, 256, 0, 0, constant);
1007 case CODE_HEADER_WIDETAG:
1008 return ptrans_code(thing);
1010 case RETURN_PC_HEADER_WIDETAG:
1011 return ptrans_returnpc(thing, header);
1014 return ptrans_fdefn(thing, header);
1017 /* Should only come across other pointers to the above stuff. */
1024 pscav_fdefn(struct fdefn *fdefn)
1028 fix_func = ((char *)(fdefn->fun+FUN_RAW_ADDR_OFFSET) == fdefn->raw_addr);
1029 pscav(&fdefn->name, 1, 1);
1030 pscav(&fdefn->fun, 1, 0);
1032 fdefn->raw_addr = (char *)(fdefn->fun + FUN_RAW_ADDR_OFFSET);
1033 return sizeof(struct fdefn) / sizeof(lispobj);
1036 #ifdef LISP_FEATURE_X86
1037 /* now putting code objects in static space */
1039 pscav_code(struct code*code)
1043 nwords = HeaderValue(code->header) + fixnum_value(code->code_size);
1045 /* Arrange to scavenge the debug info later. */
1046 pscav_later(&code->debug_info, 1);
1048 /* Scavenge the constants. */
1049 pscav(code->constants, HeaderValue(code->header)-5, 1);
1051 /* Scavenge all the functions. */
1052 pscav(&code->entry_points, 1, 1);
1053 for (func = code->entry_points;
1055 func = ((struct simple_fun *)native_pointer(func))->next) {
1056 gc_assert(lowtag_of(func) == FUN_POINTER_LOWTAG);
1057 gc_assert(!dynamic_pointer_p(func));
1059 #ifdef LISP_FEATURE_X86
1060 /* Temporarily convert the self pointer to a real function
1062 ((struct simple_fun *)native_pointer(func))->self
1063 -= FUN_RAW_ADDR_OFFSET;
1065 pscav(&((struct simple_fun *)native_pointer(func))->self, 2, 1);
1066 #ifdef LISP_FEATURE_X86
1067 ((struct simple_fun *)native_pointer(func))->self
1068 += FUN_RAW_ADDR_OFFSET;
1070 pscav_later(&((struct simple_fun *)native_pointer(func))->name, 3);
1073 return CEILING(nwords,2);
1078 pscav(lispobj *addr, int nwords, boolean constant)
1080 lispobj thing, *thingp, header;
1081 int count = 0; /* (0 = dummy init value to stop GCC warning) */
1082 struct vector *vector;
1084 while (nwords > 0) {
1086 if (is_lisp_pointer(thing)) {
1087 /* It's a pointer. Is it something we might have to move? */
1088 if (dynamic_pointer_p(thing)) {
1089 /* Maybe. Have we already moved it? */
1090 thingp = (lispobj *)native_pointer(thing);
1092 if (is_lisp_pointer(header) && forwarding_pointer_p(header))
1093 /* Yep, so just copy the forwarding pointer. */
1096 /* Nope, copy the object. */
1097 switch (lowtag_of(thing)) {
1098 case FUN_POINTER_LOWTAG:
1099 thing = ptrans_func(thing, header);
1102 case LIST_POINTER_LOWTAG:
1103 thing = ptrans_list(thing, constant);
1106 case INSTANCE_POINTER_LOWTAG:
1107 thing = ptrans_instance(thing, header, constant);
1110 case OTHER_POINTER_LOWTAG:
1111 thing = ptrans_otherptr(thing, header, constant);
1115 /* It was a pointer, but not one of them? */
1123 else if (thing & 3) { /* FIXME: 3? not 2? */
1124 /* It's an other immediate. Maybe the header for an unboxed */
1126 switch (widetag_of(thing)) {
1127 case BIGNUM_WIDETAG:
1128 case SINGLE_FLOAT_WIDETAG:
1129 case DOUBLE_FLOAT_WIDETAG:
1130 #ifdef LONG_FLOAT_WIDETAG
1131 case LONG_FLOAT_WIDETAG:
1134 /* It's an unboxed simple object. */
1135 count = HeaderValue(thing)+1;
1138 case SIMPLE_VECTOR_WIDETAG:
1139 if (HeaderValue(thing) == subtype_VectorValidHashing) {
1140 *addr = (subtype_VectorMustRehash << N_WIDETAG_BITS) |
1141 SIMPLE_VECTOR_WIDETAG;
1146 case SIMPLE_ARRAY_NIL_WIDETAG:
1150 case SIMPLE_BASE_STRING_WIDETAG:
1151 vector = (struct vector *)addr;
1152 count = CEILING(NWORDS(fixnum_value(vector->length)+1,8)+2,2);
1155 case SIMPLE_BIT_VECTOR_WIDETAG:
1156 vector = (struct vector *)addr;
1157 count = CEILING(NWORDS(fixnum_value(vector->length),1)+2,2);
1160 case SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG:
1161 vector = (struct vector *)addr;
1162 count = CEILING(NWORDS(fixnum_value(vector->length),2)+2,2);
1165 case SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG:
1166 vector = (struct vector *)addr;
1167 count = CEILING(NWORDS(fixnum_value(vector->length),4)+2,2);
1170 case SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG:
1171 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
1172 case SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG:
1173 case SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG:
1175 vector = (struct vector *)addr;
1176 count = CEILING(NWORDS(fixnum_value(vector->length),8)+2,2);
1179 case SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG:
1180 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
1181 case SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG:
1182 case SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG:
1184 vector = (struct vector *)addr;
1185 count = CEILING(NWORDS(fixnum_value(vector->length),16)+2,2);
1188 case SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG:
1189 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
1190 case SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG:
1191 case SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG:
1193 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
1194 case SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG:
1195 case SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG:
1197 vector = (struct vector *)addr;
1198 count = CEILING(NWORDS(fixnum_value(vector->length),32)+2,2);
1201 #if N_WORD_BITS == 64
1202 case SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG:
1203 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG
1204 case SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG:
1205 case SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG:
1207 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG
1208 case SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG:
1209 case SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG:
1211 vector = (struct vector *)addr;
1212 count = CEILING(NWORDS(fixnum_value(vector->length),64)+2,2);
1216 case SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG:
1217 vector = (struct vector *)addr;
1218 count = CEILING(fixnum_value(vector->length)+2,2);
1221 case SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG:
1222 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1223 case SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG:
1225 vector = (struct vector *)addr;
1226 count = fixnum_value(vector->length)*2+2;
1229 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1230 case SIMPLE_ARRAY_LONG_FLOAT_WIDETAG:
1231 vector = (struct vector *)addr;
1232 #ifdef LISP_FEATURE_X86
1233 count = fixnum_value(vector->length)*3+2;
1236 count = fixnum_value(vector->length)*4+2;
1241 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1242 case SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG:
1243 vector = (struct vector *)addr;
1244 count = fixnum_value(vector->length)*4+2;
1248 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1249 case SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG:
1250 vector = (struct vector *)addr;
1251 #ifdef LISP_FEATURE_X86
1252 count = fixnum_value(vector->length)*6+2;
1255 count = fixnum_value(vector->length)*8+2;
1260 case CODE_HEADER_WIDETAG:
1261 #ifndef LISP_FEATURE_X86
1262 gc_abort(); /* no code headers in static space */
1264 count = pscav_code((struct code*)addr);
1268 case SIMPLE_FUN_HEADER_WIDETAG:
1269 case RETURN_PC_HEADER_WIDETAG:
1270 /* We should never hit any of these, 'cause they occur
1271 * buried in the middle of code objects. */
1275 #ifdef LISP_FEATURE_X86
1276 case CLOSURE_HEADER_WIDETAG:
1277 case FUNCALLABLE_INSTANCE_HEADER_WIDETAG:
1278 /* The function self pointer needs special care on the
1279 * x86 because it is the real entry point. */
1281 lispobj fun = ((struct closure *)addr)->fun
1282 - FUN_RAW_ADDR_OFFSET;
1283 pscav(&fun, 1, constant);
1284 ((struct closure *)addr)->fun = fun + FUN_RAW_ADDR_OFFSET;
1290 case WEAK_POINTER_WIDETAG:
1291 /* Weak pointers get preserved during purify, 'cause I
1292 * don't feel like figuring out how to break them. */
1293 pscav(addr+1, 2, constant);
1298 /* We have to handle fdefn objects specially, so we
1299 * can fix up the raw function address. */
1300 count = pscav_fdefn((struct fdefn *)addr);
1309 /* It's a fixnum. */
1321 purify(lispobj static_roots, lispobj read_only_roots)
1325 struct later *laters, *next;
1326 struct thread *thread;
1328 if(all_threads->next) {
1329 /* FIXME: there should be _some_ sensible error reporting
1330 * convention. See following comment too */
1331 fprintf(stderr,"Can't purify when more than one thread exists\n");
1337 printf("[doing purification:");
1340 #ifdef LISP_FEATURE_GENCGC
1341 gc_alloc_update_all_page_tables();
1343 for_each_thread(thread)
1344 if (fixnum_value(SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX,thread)) != 0) {
1345 /* FIXME: 1. What does this mean? 2. It shouldn't be reporting
1346 * its error simply by a. printing a string b. to stdout instead
1348 printf(" Ack! Can't purify interrupt contexts. ");
1353 #if defined(LISP_FEATURE_X86)
1354 dynamic_space_free_pointer =
1355 (lispobj*)SymbolValue(ALLOCATION_POINTER,0);
1358 read_only_end = read_only_free =
1359 (lispobj *)SymbolValue(READ_ONLY_SPACE_FREE_POINTER,0);
1360 static_end = static_free =
1361 (lispobj *)SymbolValue(STATIC_SPACE_FREE_POINTER,0);
1368 #if (defined(LISP_FEATURE_GENCGC) && defined(LISP_FEATURE_X86))
1369 /* note this expects only one thread to be active. We'd have to
1370 * stop all the others in the same way as GC does if we wanted
1371 * PURIFY to work when >1 thread exists */
1372 setup_i386_stack_scav(((&static_roots)-2),
1373 ((void *)all_threads->control_stack_end));
1376 pscav(&static_roots, 1, 0);
1377 pscav(&read_only_roots, 1, 1);
1380 printf(" handlers");
1383 pscav((lispobj *) all_threads->interrupt_data->interrupt_handlers,
1384 sizeof(all_threads->interrupt_data->interrupt_handlers)
1392 #ifndef LISP_FEATURE_X86
1393 pscav((lispobj *)all_threads->control_stack_start,
1394 current_control_stack_pointer -
1395 all_threads->control_stack_start,
1398 #ifdef LISP_FEATURE_GENCGC
1404 printf(" bindings");
1407 #if !defined(LISP_FEATURE_X86)
1408 pscav( (lispobj *)all_threads->binding_stack_start,
1409 (lispobj *)current_binding_stack_pointer -
1410 all_threads->binding_stack_start,
1413 for_each_thread(thread) {
1414 pscav( (lispobj *)thread->binding_stack_start,
1415 (lispobj *)SymbolValue(BINDING_STACK_POINTER,thread) -
1416 (lispobj *)thread->binding_stack_start,
1418 pscav( (lispobj *) (thread+1),
1419 fixnum_value(SymbolValue(FREE_TLS_INDEX,0)) -
1420 (sizeof (struct thread))/(sizeof (lispobj)),
1427 /* The original CMU CL code had scavenge-read-only-space code
1428 * controlled by the Lisp-level variable
1429 * *SCAVENGE-READ-ONLY-SPACE*. It was disabled by default, and it
1430 * wasn't documented under what circumstances it was useful or
1431 * safe to turn it on, so it's been turned off in SBCL. If you
1432 * want/need this functionality, and can test and document it,
1433 * please submit a patch. */
1435 if (SymbolValue(SCAVENGE_READ_ONLY_SPACE) != UNBOUND_MARKER_WIDETAG
1436 && SymbolValue(SCAVENGE_READ_ONLY_SPACE) != NIL) {
1437 unsigned read_only_space_size =
1438 (lispobj *)SymbolValue(READ_ONLY_SPACE_FREE_POINTER) -
1439 (lispobj *)READ_ONLY_SPACE_START;
1441 "scavenging read only space: %d bytes\n",
1442 read_only_space_size * sizeof(lispobj));
1443 pscav( (lispobj *)READ_ONLY_SPACE_START, read_only_space_size, 0);
1451 clean = (lispobj *)STATIC_SPACE_START;
1453 while (clean != static_free)
1454 clean = pscav(clean, static_free - clean, 0);
1455 laters = later_blocks;
1456 count = later_count;
1457 later_blocks = NULL;
1459 while (laters != NULL) {
1460 for (i = 0; i < count; i++) {
1461 if (laters->u[i].count == 0) {
1463 } else if (laters->u[i].count <= LATERMAXCOUNT) {
1464 pscav(laters->u[i+1].ptr, laters->u[i].count, 1);
1467 pscav(laters->u[i].ptr, 1, 1);
1470 next = laters->next;
1473 count = LATERBLOCKSIZE;
1475 } while (clean != static_free || later_blocks != NULL);
1482 os_zero((os_vm_address_t) current_dynamic_space,
1483 (os_vm_size_t) DYNAMIC_SPACE_SIZE);
1485 /* Zero the stack. Note that the stack is also zeroed by SUB-GC
1486 * calling SCRUB-CONTROL-STACK - this zeros the stack on the x86. */
1487 #ifndef LISP_FEATURE_X86
1488 os_zero((os_vm_address_t) current_control_stack_pointer,
1490 ((all_threads->control_stack_end -
1491 current_control_stack_pointer) * sizeof(lispobj)));
1494 /* It helps to update the heap free pointers so that free_heap can
1495 * verify after it's done. */
1496 SetSymbolValue(READ_ONLY_SPACE_FREE_POINTER, (lispobj)read_only_free,0);
1497 SetSymbolValue(STATIC_SPACE_FREE_POINTER, (lispobj)static_free,0);
1499 #if !defined(ALLOCATION_POINTER)
1500 dynamic_space_free_pointer = current_dynamic_space;
1501 set_auto_gc_trigger(bytes_consed_between_gcs);
1503 #if defined LISP_FEATURE_GENCGC
1506 #error unsupported case /* in CMU CL, was "ibmrt using GC" */