2 * Garbage Collection common functions for scavenging, moving and sizing
3 * objects. These are for use with both GC (stop & copy GC) and GENCGC
7 * This software is part of the SBCL system. See the README file for
10 * This software is derived from the CMU CL system, which was
11 * written at Carnegie Mellon University and released into the
12 * public domain. The software is in the public domain and is
13 * provided with absolutely no warranty. See the COPYING and CREDITS
14 * files for more information.
18 * For a review of garbage collection techniques (e.g. generational
19 * GC) and terminology (e.g. "scavenging") see Paul R. Wilson,
20 * "Uniprocessor Garbage Collection Techniques". As of 20000618, this
21 * had been accepted for _ACM Computing Surveys_ and was available
22 * as a PostScript preprint through
23 * <http://www.cs.utexas.edu/users/oops/papers.html>
25 * <ftp://ftp.cs.utexas.edu/pub/garbage/bigsurv.ps>.
36 #include "interrupt.h"
42 #include "genesis/primitive-objects.h"
43 #include "genesis/static-symbols.h"
44 #include "genesis/layout.h"
45 #include "gc-internal.h"
47 #ifdef LISP_FEATURE_SPARC
48 #define LONG_FLOAT_SIZE 4
50 #ifdef LISP_FEATURE_X86
51 #define LONG_FLOAT_SIZE 3
56 forwarding_pointer_p(lispobj *pointer) {
57 lispobj first_word=*pointer;
58 #ifdef LISP_FEATURE_GENCGC
59 return (first_word == 0x01);
61 return (is_lisp_pointer(first_word)
62 && new_space_p(first_word));
66 static inline lispobj *
67 forwarding_pointer_value(lispobj *pointer) {
68 #ifdef LISP_FEATURE_GENCGC
69 return (lispobj *) ((pointer_sized_uint_t) pointer[1]);
71 return (lispobj *) ((pointer_sized_uint_t) pointer[0]);
75 set_forwarding_pointer(lispobj * pointer, lispobj newspace_copy) {
76 #ifdef LISP_FEATURE_GENCGC
78 pointer[1]=newspace_copy;
80 pointer[0]=newspace_copy;
85 long (*scavtab[256])(lispobj *where, lispobj object);
86 lispobj (*transother[256])(lispobj object);
87 long (*sizetab[256])(lispobj *where);
88 struct weak_pointer *weak_pointers;
90 unsigned long bytes_consed_between_gcs = 12*1024*1024;
97 /* to copy a boxed object */
99 copy_object(lispobj object, long nwords)
104 gc_assert(is_lisp_pointer(object));
105 gc_assert(from_space_p(object));
106 gc_assert((nwords & 0x01) == 0);
108 /* Get tag of object. */
109 tag = lowtag_of(object);
111 /* Allocate space. */
112 new = gc_general_alloc(nwords*N_WORD_BYTES,ALLOC_BOXED,ALLOC_QUICK);
114 /* Copy the object. */
115 memcpy(new,native_pointer(object),nwords*N_WORD_BYTES);
116 return make_lispobj(new,tag);
119 static long scav_lose(lispobj *where, lispobj object); /* forward decl */
121 /* FIXME: Most calls end up going to some trouble to compute an
122 * 'n_words' value for this function. The system might be a little
123 * simpler if this function used an 'end' parameter instead. */
125 scavenge(lispobj *start, long n_words)
127 lispobj *end = start + n_words;
129 long n_words_scavenged;
130 for (object_ptr = start;
133 object_ptr += n_words_scavenged) {
135 lispobj object = *object_ptr;
136 #ifdef LISP_FEATURE_GENCGC
137 gc_assert(!forwarding_pointer_p(object_ptr));
139 if (is_lisp_pointer(object)) {
140 if (from_space_p(object)) {
141 /* It currently points to old space. Check for a
142 * forwarding pointer. */
143 lispobj *ptr = native_pointer(object);
144 if (forwarding_pointer_p(ptr)) {
145 /* Yes, there's a forwarding pointer. */
146 *object_ptr = LOW_WORD(forwarding_pointer_value(ptr));
147 n_words_scavenged = 1;
149 /* Scavenge that pointer. */
151 (scavtab[widetag_of(object)])(object_ptr, object);
154 /* It points somewhere other than oldspace. Leave it
156 n_words_scavenged = 1;
159 #ifndef LISP_FEATURE_GENCGC
160 /* this workaround is probably not necessary for gencgc; at least, the
161 * behaviour it describes has never been reported */
162 else if (n_words==1) {
163 /* there are some situations where an
164 other-immediate may end up in a descriptor
165 register. I'm not sure whether this is
166 supposed to happen, but if it does then we
167 don't want to (a) barf or (b) scavenge over the
168 data-block, because there isn't one. So, if
169 we're checking a single word and it's anything
170 other than a pointer, just hush it up */
171 int type=widetag_of(object);
174 if ((scavtab[type]==scav_lose) ||
175 (((scavtab[type])(start,object))>1)) {
176 fprintf(stderr,"warning: attempted to scavenge non-descriptor value %x at %p. If you can\nreproduce this warning, send a bug report (see manual page for details)\n",
181 else if (fixnump(object)) {
182 /* It's a fixnum: really easy.. */
183 n_words_scavenged = 1;
185 /* It's some sort of header object or another. */
187 (scavtab[widetag_of(object)])(object_ptr, object);
190 gc_assert(object_ptr == end);
193 static lispobj trans_fun_header(lispobj object); /* forward decls */
194 static lispobj trans_boxed(lispobj object);
197 scav_fun_pointer(lispobj *where, lispobj object)
199 lispobj *first_pointer;
202 gc_assert(is_lisp_pointer(object));
204 /* Object is a pointer into from_space - not a FP. */
205 first_pointer = (lispobj *) native_pointer(object);
207 /* must transport object -- object may point to either a function
208 * header, a closure function header, or to a closure header. */
210 switch (widetag_of(*first_pointer)) {
211 case SIMPLE_FUN_HEADER_WIDETAG:
212 copy = trans_fun_header(object);
215 copy = trans_boxed(object);
219 if (copy != object) {
220 /* Set forwarding pointer */
221 set_forwarding_pointer(first_pointer,copy);
224 gc_assert(is_lisp_pointer(copy));
225 gc_assert(!from_space_p(copy));
234 trans_code(struct code *code)
236 struct code *new_code;
237 lispobj first, l_code, l_new_code;
238 long nheader_words, ncode_words, nwords;
239 unsigned long displacement;
240 lispobj fheaderl, *prev_pointer;
242 /* if object has already been transported, just return pointer */
243 first = code->header;
244 if (forwarding_pointer_p((lispobj *)code)) {
246 printf("Was already transported\n");
248 return (struct code *) forwarding_pointer_value
249 ((lispobj *)((pointer_sized_uint_t) code));
252 gc_assert(widetag_of(first) == CODE_HEADER_WIDETAG);
254 /* prepare to transport the code vector */
255 l_code = (lispobj) LOW_WORD(code) | OTHER_POINTER_LOWTAG;
257 ncode_words = fixnum_value(code->code_size);
258 nheader_words = HeaderValue(code->header);
259 nwords = ncode_words + nheader_words;
260 nwords = CEILING(nwords, 2);
262 l_new_code = copy_object(l_code, nwords);
263 new_code = (struct code *) native_pointer(l_new_code);
265 #if defined(DEBUG_CODE_GC)
266 printf("Old code object at 0x%08x, new code object at 0x%08x.\n",
267 (unsigned long) code, (unsigned long) new_code);
268 printf("Code object is %d words long.\n", nwords);
271 #ifdef LISP_FEATURE_GENCGC
272 if (new_code == code)
276 displacement = l_new_code - l_code;
278 set_forwarding_pointer((lispobj *)code, l_new_code);
280 /* set forwarding pointers for all the function headers in the */
281 /* code object. also fix all self pointers */
283 fheaderl = code->entry_points;
284 prev_pointer = &new_code->entry_points;
286 while (fheaderl != NIL) {
287 struct simple_fun *fheaderp, *nfheaderp;
290 fheaderp = (struct simple_fun *) native_pointer(fheaderl);
291 gc_assert(widetag_of(fheaderp->header) == SIMPLE_FUN_HEADER_WIDETAG);
293 /* Calculate the new function pointer and the new */
294 /* function header. */
295 nfheaderl = fheaderl + displacement;
296 nfheaderp = (struct simple_fun *) native_pointer(nfheaderl);
299 printf("fheaderp->header (at %x) <- %x\n",
300 &(fheaderp->header) , nfheaderl);
302 set_forwarding_pointer((lispobj *)fheaderp, nfheaderl);
304 /* fix self pointer. */
306 #if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
307 FUN_RAW_ADDR_OFFSET +
311 *prev_pointer = nfheaderl;
313 fheaderl = fheaderp->next;
314 prev_pointer = &nfheaderp->next;
316 os_flush_icache((os_vm_address_t) (((long *)new_code) + nheader_words),
317 ncode_words * sizeof(long));
318 #ifdef LISP_FEATURE_GENCGC
319 gencgc_apply_code_fixups(code, new_code);
325 scav_code_header(lispobj *where, lispobj object)
328 long n_header_words, n_code_words, n_words;
329 lispobj entry_point; /* tagged pointer to entry point */
330 struct simple_fun *function_ptr; /* untagged pointer to entry point */
332 code = (struct code *) where;
333 n_code_words = fixnum_value(code->code_size);
334 n_header_words = HeaderValue(object);
335 n_words = n_code_words + n_header_words;
336 n_words = CEILING(n_words, 2);
338 /* Scavenge the boxed section of the code data block. */
339 scavenge(where + 1, n_header_words - 1);
341 /* Scavenge the boxed section of each function object in the
342 * code data block. */
343 for (entry_point = code->entry_points;
345 entry_point = function_ptr->next) {
347 gc_assert(is_lisp_pointer(entry_point));
349 function_ptr = (struct simple_fun *) native_pointer(entry_point);
350 gc_assert(widetag_of(function_ptr->header)==SIMPLE_FUN_HEADER_WIDETAG);
352 scavenge(&function_ptr->name, 1);
353 scavenge(&function_ptr->arglist, 1);
354 scavenge(&function_ptr->type, 1);
361 trans_code_header(lispobj object)
365 ncode = trans_code((struct code *) native_pointer(object));
366 return (lispobj) LOW_WORD(ncode) | OTHER_POINTER_LOWTAG;
371 size_code_header(lispobj *where)
374 long nheader_words, ncode_words, nwords;
376 code = (struct code *) where;
378 ncode_words = fixnum_value(code->code_size);
379 nheader_words = HeaderValue(code->header);
380 nwords = ncode_words + nheader_words;
381 nwords = CEILING(nwords, 2);
386 #if !defined(LISP_FEATURE_X86) && ! defined(LISP_FEATURE_X86_64)
388 scav_return_pc_header(lispobj *where, lispobj object)
390 lose("attempted to scavenge a return PC header where=0x%08x object=0x%08x",
391 (unsigned long) where,
392 (unsigned long) object);
393 return 0; /* bogus return value to satisfy static type checking */
395 #endif /* LISP_FEATURE_X86 */
398 trans_return_pc_header(lispobj object)
400 struct simple_fun *return_pc;
401 unsigned long offset;
402 struct code *code, *ncode;
404 return_pc = (struct simple_fun *) native_pointer(object);
405 /* FIXME: was times 4, should it really be N_WORD_BYTES? */
406 offset = HeaderValue(return_pc->header) * N_WORD_BYTES;
408 /* Transport the whole code object */
409 code = (struct code *) ((unsigned long) return_pc - offset);
410 ncode = trans_code(code);
412 return ((lispobj) LOW_WORD(ncode) + offset) | OTHER_POINTER_LOWTAG;
415 /* On the 386, closures hold a pointer to the raw address instead of the
416 * function object, so we can use CALL [$FDEFN+const] to invoke
417 * the function without loading it into a register. Given that code
418 * objects don't move, we don't need to update anything, but we do
419 * have to figure out that the function is still live. */
421 #if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
423 scav_closure_header(lispobj *where, lispobj object)
425 struct closure *closure;
428 closure = (struct closure *)where;
429 fun = closure->fun - FUN_RAW_ADDR_OFFSET;
431 #ifdef LISP_FEATURE_GENCGC
432 /* The function may have moved so update the raw address. But
433 * don't write unnecessarily. */
434 if (closure->fun != fun + FUN_RAW_ADDR_OFFSET)
435 closure->fun = fun + FUN_RAW_ADDR_OFFSET;
441 #if !(defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64))
443 scav_fun_header(lispobj *where, lispobj object)
445 lose("attempted to scavenge a function header where=0x%08x object=0x%08x",
446 (unsigned long) where,
447 (unsigned long) object);
448 return 0; /* bogus return value to satisfy static type checking */
450 #endif /* LISP_FEATURE_X86 */
453 trans_fun_header(lispobj object)
455 struct simple_fun *fheader;
456 unsigned long offset;
457 struct code *code, *ncode;
459 fheader = (struct simple_fun *) native_pointer(object);
460 /* FIXME: was times 4, should it really be N_WORD_BYTES? */
461 offset = HeaderValue(fheader->header) * N_WORD_BYTES;
463 /* Transport the whole code object */
464 code = (struct code *) ((unsigned long) fheader - offset);
465 ncode = trans_code(code);
467 return ((lispobj) LOW_WORD(ncode) + offset) | FUN_POINTER_LOWTAG;
476 scav_instance_pointer(lispobj *where, lispobj object)
478 lispobj copy, *first_pointer;
480 /* Object is a pointer into from space - not a FP. */
481 copy = trans_boxed(object);
483 #ifdef LISP_FEATURE_GENCGC
484 gc_assert(copy != object);
487 first_pointer = (lispobj *) native_pointer(object);
488 set_forwarding_pointer(first_pointer,copy);
499 static lispobj trans_list(lispobj object);
502 scav_list_pointer(lispobj *where, lispobj object)
504 lispobj first, *first_pointer;
506 gc_assert(is_lisp_pointer(object));
508 /* Object is a pointer into from space - not FP. */
509 first_pointer = (lispobj *) native_pointer(object);
511 first = trans_list(object);
512 gc_assert(first != object);
514 /* Set forwarding pointer */
515 set_forwarding_pointer(first_pointer, first);
517 gc_assert(is_lisp_pointer(first));
518 gc_assert(!from_space_p(first));
526 trans_list(lispobj object)
528 lispobj new_list_pointer;
529 struct cons *cons, *new_cons;
532 cons = (struct cons *) native_pointer(object);
535 new_cons = (struct cons *)
536 gc_general_alloc(sizeof(struct cons),ALLOC_BOXED,ALLOC_QUICK);
537 new_cons->car = cons->car;
538 new_cons->cdr = cons->cdr; /* updated later */
539 new_list_pointer = make_lispobj(new_cons,lowtag_of(object));
541 /* Grab the cdr: set_forwarding_pointer will clobber it in GENCGC */
544 set_forwarding_pointer((lispobj *)cons, new_list_pointer);
546 /* Try to linearize the list in the cdr direction to help reduce
550 struct cons *cdr_cons, *new_cdr_cons;
552 if(lowtag_of(cdr) != LIST_POINTER_LOWTAG ||
553 !from_space_p(cdr) ||
554 forwarding_pointer_p((lispobj *)native_pointer(cdr)))
557 cdr_cons = (struct cons *) native_pointer(cdr);
560 new_cdr_cons = (struct cons*)
561 gc_general_alloc(sizeof(struct cons),ALLOC_BOXED,ALLOC_QUICK);
562 new_cdr_cons->car = cdr_cons->car;
563 new_cdr_cons->cdr = cdr_cons->cdr;
564 new_cdr = make_lispobj(new_cdr_cons, lowtag_of(cdr));
566 /* Grab the cdr before it is clobbered. */
568 set_forwarding_pointer((lispobj *)cdr_cons, new_cdr);
570 /* Update the cdr of the last cons copied into new space to
571 * keep the newspace scavenge from having to do it. */
572 new_cons->cdr = new_cdr;
574 new_cons = new_cdr_cons;
577 return new_list_pointer;
582 * scavenging and transporting other pointers
586 scav_other_pointer(lispobj *where, lispobj object)
588 lispobj first, *first_pointer;
590 gc_assert(is_lisp_pointer(object));
592 /* Object is a pointer into from space - not FP. */
593 first_pointer = (lispobj *) native_pointer(object);
594 first = (transother[widetag_of(*first_pointer)])(object);
596 if (first != object) {
597 set_forwarding_pointer(first_pointer, first);
598 #ifdef LISP_FEATURE_GENCGC
602 #ifndef LISP_FEATURE_GENCGC
605 gc_assert(is_lisp_pointer(first));
606 gc_assert(!from_space_p(first));
612 * immediate, boxed, and unboxed objects
616 size_pointer(lispobj *where)
622 scav_immediate(lispobj *where, lispobj object)
628 trans_immediate(lispobj object)
630 lose("trying to transport an immediate");
631 return NIL; /* bogus return value to satisfy static type checking */
635 size_immediate(lispobj *where)
642 scav_boxed(lispobj *where, lispobj object)
648 scav_instance(lispobj *where, lispobj object)
651 long ntotal = HeaderValue(object);
652 lispobj layout = ((struct instance *)native_pointer(where))->slots[0];
656 if (forwarding_pointer_p(native_pointer(layout)))
657 layout = (lispobj) forwarding_pointer_value(native_pointer(layout));
659 nuntagged = ((struct layout *)native_pointer(layout))->n_untagged_slots;
660 scavenge(where + 1, ntotal - fixnum_value(nuntagged));
666 trans_boxed(lispobj object)
669 unsigned long length;
671 gc_assert(is_lisp_pointer(object));
673 header = *((lispobj *) native_pointer(object));
674 length = HeaderValue(header) + 1;
675 length = CEILING(length, 2);
677 return copy_object(object, length);
682 size_boxed(lispobj *where)
685 unsigned long length;
688 length = HeaderValue(header) + 1;
689 length = CEILING(length, 2);
694 /* Note: on the sparc we don't have to do anything special for fdefns, */
695 /* 'cause the raw-addr has a function lowtag. */
696 #ifndef LISP_FEATURE_SPARC
698 scav_fdefn(lispobj *where, lispobj object)
702 fdefn = (struct fdefn *)where;
704 /* FSHOW((stderr, "scav_fdefn, function = %p, raw_addr = %p\n",
705 fdefn->fun, fdefn->raw_addr)); */
707 if ((char *)(fdefn->fun + FUN_RAW_ADDR_OFFSET)
708 == (char *)((unsigned long)(fdefn->raw_addr))) {
709 scavenge(where + 1, sizeof(struct fdefn)/sizeof(lispobj) - 1);
711 /* Don't write unnecessarily. */
712 if (fdefn->raw_addr != (char *)(fdefn->fun + FUN_RAW_ADDR_OFFSET))
713 fdefn->raw_addr = (char *)(fdefn->fun + FUN_RAW_ADDR_OFFSET);
714 /* gc.c has more casts here, which may be relevant or alternatively
715 may be compiler warning defeaters. try
716 fdefn->raw_addr = ((char *) LOW_WORD(fdefn->fun)) + FUN_RAW_ADDR_OFFSET;
718 return sizeof(struct fdefn) / sizeof(lispobj);
726 scav_unboxed(lispobj *where, lispobj object)
728 unsigned long length;
730 length = HeaderValue(object) + 1;
731 length = CEILING(length, 2);
737 trans_unboxed(lispobj object)
740 unsigned long length;
743 gc_assert(is_lisp_pointer(object));
745 header = *((lispobj *) native_pointer(object));
746 length = HeaderValue(header) + 1;
747 length = CEILING(length, 2);
749 return copy_unboxed_object(object, length);
753 size_unboxed(lispobj *where)
756 unsigned long length;
759 length = HeaderValue(header) + 1;
760 length = CEILING(length, 2);
766 /* vector-like objects */
768 scav_base_string(lispobj *where, lispobj object)
770 struct vector *vector;
773 /* NOTE: Strings contain one more byte of data than the length */
774 /* slot indicates. */
776 vector = (struct vector *) where;
777 length = fixnum_value(vector->length) + 1;
778 nwords = CEILING(NWORDS(length, 8) + 2, 2);
783 trans_base_string(lispobj object)
785 struct vector *vector;
788 gc_assert(is_lisp_pointer(object));
790 /* NOTE: A string contains one more byte of data (a terminating
791 * '\0' to help when interfacing with C functions) than indicated
792 * by the length slot. */
794 vector = (struct vector *) native_pointer(object);
795 length = fixnum_value(vector->length) + 1;
796 nwords = CEILING(NWORDS(length, 8) + 2, 2);
798 return copy_large_unboxed_object(object, nwords);
802 size_base_string(lispobj *where)
804 struct vector *vector;
807 /* NOTE: A string contains one more byte of data (a terminating
808 * '\0' to help when interfacing with C functions) than indicated
809 * by the length slot. */
811 vector = (struct vector *) where;
812 length = fixnum_value(vector->length) + 1;
813 nwords = CEILING(NWORDS(length, 8) + 2, 2);
819 scav_character_string(lispobj *where, lispobj object)
821 struct vector *vector;
824 /* NOTE: Strings contain one more byte of data than the length */
825 /* slot indicates. */
827 vector = (struct vector *) where;
828 length = fixnum_value(vector->length) + 1;
829 nwords = CEILING(NWORDS(length, 32) + 2, 2);
834 trans_character_string(lispobj object)
836 struct vector *vector;
839 gc_assert(is_lisp_pointer(object));
841 /* NOTE: A string contains one more byte of data (a terminating
842 * '\0' to help when interfacing with C functions) than indicated
843 * by the length slot. */
845 vector = (struct vector *) native_pointer(object);
846 length = fixnum_value(vector->length) + 1;
847 nwords = CEILING(NWORDS(length, 32) + 2, 2);
849 return copy_large_unboxed_object(object, nwords);
853 size_character_string(lispobj *where)
855 struct vector *vector;
858 /* NOTE: A string contains one more byte of data (a terminating
859 * '\0' to help when interfacing with C functions) than indicated
860 * by the length slot. */
862 vector = (struct vector *) where;
863 length = fixnum_value(vector->length) + 1;
864 nwords = CEILING(NWORDS(length, 32) + 2, 2);
870 trans_vector(lispobj object)
872 struct vector *vector;
875 gc_assert(is_lisp_pointer(object));
877 vector = (struct vector *) native_pointer(object);
879 length = fixnum_value(vector->length);
880 nwords = CEILING(length + 2, 2);
882 return copy_large_object(object, nwords);
886 size_vector(lispobj *where)
888 struct vector *vector;
891 vector = (struct vector *) where;
892 length = fixnum_value(vector->length);
893 nwords = CEILING(length + 2, 2);
899 scav_vector_nil(lispobj *where, lispobj object)
905 trans_vector_nil(lispobj object)
907 gc_assert(is_lisp_pointer(object));
908 return copy_unboxed_object(object, 2);
912 size_vector_nil(lispobj *where)
914 /* Just the header word and the length word */
919 scav_vector_bit(lispobj *where, lispobj object)
921 struct vector *vector;
924 vector = (struct vector *) where;
925 length = fixnum_value(vector->length);
926 nwords = CEILING(NWORDS(length, 1) + 2, 2);
932 trans_vector_bit(lispobj object)
934 struct vector *vector;
937 gc_assert(is_lisp_pointer(object));
939 vector = (struct vector *) native_pointer(object);
940 length = fixnum_value(vector->length);
941 nwords = CEILING(NWORDS(length, 1) + 2, 2);
943 return copy_large_unboxed_object(object, nwords);
947 size_vector_bit(lispobj *where)
949 struct vector *vector;
952 vector = (struct vector *) where;
953 length = fixnum_value(vector->length);
954 nwords = CEILING(NWORDS(length, 1) + 2, 2);
960 scav_vector_unsigned_byte_2(lispobj *where, lispobj object)
962 struct vector *vector;
965 vector = (struct vector *) where;
966 length = fixnum_value(vector->length);
967 nwords = CEILING(NWORDS(length, 2) + 2, 2);
973 trans_vector_unsigned_byte_2(lispobj object)
975 struct vector *vector;
978 gc_assert(is_lisp_pointer(object));
980 vector = (struct vector *) native_pointer(object);
981 length = fixnum_value(vector->length);
982 nwords = CEILING(NWORDS(length, 2) + 2, 2);
984 return copy_large_unboxed_object(object, nwords);
988 size_vector_unsigned_byte_2(lispobj *where)
990 struct vector *vector;
993 vector = (struct vector *) where;
994 length = fixnum_value(vector->length);
995 nwords = CEILING(NWORDS(length, 2) + 2, 2);
1001 scav_vector_unsigned_byte_4(lispobj *where, lispobj object)
1003 struct vector *vector;
1004 long length, nwords;
1006 vector = (struct vector *) where;
1007 length = fixnum_value(vector->length);
1008 nwords = CEILING(NWORDS(length, 4) + 2, 2);
1014 trans_vector_unsigned_byte_4(lispobj object)
1016 struct vector *vector;
1017 long length, nwords;
1019 gc_assert(is_lisp_pointer(object));
1021 vector = (struct vector *) native_pointer(object);
1022 length = fixnum_value(vector->length);
1023 nwords = CEILING(NWORDS(length, 4) + 2, 2);
1025 return copy_large_unboxed_object(object, nwords);
1028 size_vector_unsigned_byte_4(lispobj *where)
1030 struct vector *vector;
1031 long length, nwords;
1033 vector = (struct vector *) where;
1034 length = fixnum_value(vector->length);
1035 nwords = CEILING(NWORDS(length, 4) + 2, 2);
1042 scav_vector_unsigned_byte_8(lispobj *where, lispobj object)
1044 struct vector *vector;
1045 long length, nwords;
1047 vector = (struct vector *) where;
1048 length = fixnum_value(vector->length);
1049 nwords = CEILING(NWORDS(length, 8) + 2, 2);
1054 /*********************/
1059 trans_vector_unsigned_byte_8(lispobj object)
1061 struct vector *vector;
1062 long length, nwords;
1064 gc_assert(is_lisp_pointer(object));
1066 vector = (struct vector *) native_pointer(object);
1067 length = fixnum_value(vector->length);
1068 nwords = CEILING(NWORDS(length, 8) + 2, 2);
1070 return copy_large_unboxed_object(object, nwords);
1074 size_vector_unsigned_byte_8(lispobj *where)
1076 struct vector *vector;
1077 long length, nwords;
1079 vector = (struct vector *) where;
1080 length = fixnum_value(vector->length);
1081 nwords = CEILING(NWORDS(length, 8) + 2, 2);
1088 scav_vector_unsigned_byte_16(lispobj *where, lispobj object)
1090 struct vector *vector;
1091 long length, nwords;
1093 vector = (struct vector *) where;
1094 length = fixnum_value(vector->length);
1095 nwords = CEILING(NWORDS(length, 16) + 2, 2);
1101 trans_vector_unsigned_byte_16(lispobj object)
1103 struct vector *vector;
1104 long length, nwords;
1106 gc_assert(is_lisp_pointer(object));
1108 vector = (struct vector *) native_pointer(object);
1109 length = fixnum_value(vector->length);
1110 nwords = CEILING(NWORDS(length, 16) + 2, 2);
1112 return copy_large_unboxed_object(object, nwords);
1116 size_vector_unsigned_byte_16(lispobj *where)
1118 struct vector *vector;
1119 long length, nwords;
1121 vector = (struct vector *) where;
1122 length = fixnum_value(vector->length);
1123 nwords = CEILING(NWORDS(length, 16) + 2, 2);
1129 scav_vector_unsigned_byte_32(lispobj *where, lispobj object)
1131 struct vector *vector;
1132 long length, nwords;
1134 vector = (struct vector *) where;
1135 length = fixnum_value(vector->length);
1136 nwords = CEILING(NWORDS(length, 32) + 2, 2);
1142 trans_vector_unsigned_byte_32(lispobj object)
1144 struct vector *vector;
1145 long length, nwords;
1147 gc_assert(is_lisp_pointer(object));
1149 vector = (struct vector *) native_pointer(object);
1150 length = fixnum_value(vector->length);
1151 nwords = CEILING(NWORDS(length, 32) + 2, 2);
1153 return copy_large_unboxed_object(object, nwords);
1157 size_vector_unsigned_byte_32(lispobj *where)
1159 struct vector *vector;
1160 long length, nwords;
1162 vector = (struct vector *) where;
1163 length = fixnum_value(vector->length);
1164 nwords = CEILING(NWORDS(length, 32) + 2, 2);
1169 #if N_WORD_BITS == 64
1171 scav_vector_unsigned_byte_64(lispobj *where, lispobj object)
1173 struct vector *vector;
1174 long length, nwords;
1176 vector = (struct vector *) where;
1177 length = fixnum_value(vector->length);
1178 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1184 trans_vector_unsigned_byte_64(lispobj object)
1186 struct vector *vector;
1187 long length, nwords;
1189 gc_assert(is_lisp_pointer(object));
1191 vector = (struct vector *) native_pointer(object);
1192 length = fixnum_value(vector->length);
1193 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1195 return copy_large_unboxed_object(object, nwords);
1199 size_vector_unsigned_byte_64(lispobj *where)
1201 struct vector *vector;
1202 long length, nwords;
1204 vector = (struct vector *) where;
1205 length = fixnum_value(vector->length);
1206 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1213 scav_vector_single_float(lispobj *where, lispobj object)
1215 struct vector *vector;
1216 long length, nwords;
1218 vector = (struct vector *) where;
1219 length = fixnum_value(vector->length);
1220 nwords = CEILING(NWORDS(length, 32) + 2, 2);
1226 trans_vector_single_float(lispobj object)
1228 struct vector *vector;
1229 long length, nwords;
1231 gc_assert(is_lisp_pointer(object));
1233 vector = (struct vector *) native_pointer(object);
1234 length = fixnum_value(vector->length);
1235 nwords = CEILING(NWORDS(length, 32) + 2, 2);
1237 return copy_large_unboxed_object(object, nwords);
1241 size_vector_single_float(lispobj *where)
1243 struct vector *vector;
1244 long length, nwords;
1246 vector = (struct vector *) where;
1247 length = fixnum_value(vector->length);
1248 nwords = CEILING(NWORDS(length, 32) + 2, 2);
1254 scav_vector_double_float(lispobj *where, lispobj object)
1256 struct vector *vector;
1257 long length, nwords;
1259 vector = (struct vector *) where;
1260 length = fixnum_value(vector->length);
1261 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1267 trans_vector_double_float(lispobj object)
1269 struct vector *vector;
1270 long length, nwords;
1272 gc_assert(is_lisp_pointer(object));
1274 vector = (struct vector *) native_pointer(object);
1275 length = fixnum_value(vector->length);
1276 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1278 return copy_large_unboxed_object(object, nwords);
1282 size_vector_double_float(lispobj *where)
1284 struct vector *vector;
1285 long length, nwords;
1287 vector = (struct vector *) where;
1288 length = fixnum_value(vector->length);
1289 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1294 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1296 scav_vector_long_float(lispobj *where, lispobj object)
1298 struct vector *vector;
1299 long length, nwords;
1301 vector = (struct vector *) where;
1302 length = fixnum_value(vector->length);
1303 nwords = CEILING(length *
1310 trans_vector_long_float(lispobj object)
1312 struct vector *vector;
1313 long length, nwords;
1315 gc_assert(is_lisp_pointer(object));
1317 vector = (struct vector *) native_pointer(object);
1318 length = fixnum_value(vector->length);
1319 nwords = CEILING(length * LONG_FLOAT_SIZE + 2, 2);
1321 return copy_large_unboxed_object(object, nwords);
1325 size_vector_long_float(lispobj *where)
1327 struct vector *vector;
1328 long length, nwords;
1330 vector = (struct vector *) where;
1331 length = fixnum_value(vector->length);
1332 nwords = CEILING(length * LONG_FLOAT_SIZE + 2, 2);
1339 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1341 scav_vector_complex_single_float(lispobj *where, lispobj object)
1343 struct vector *vector;
1344 long length, nwords;
1346 vector = (struct vector *) where;
1347 length = fixnum_value(vector->length);
1348 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1354 trans_vector_complex_single_float(lispobj object)
1356 struct vector *vector;
1357 long length, nwords;
1359 gc_assert(is_lisp_pointer(object));
1361 vector = (struct vector *) native_pointer(object);
1362 length = fixnum_value(vector->length);
1363 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1365 return copy_large_unboxed_object(object, nwords);
1369 size_vector_complex_single_float(lispobj *where)
1371 struct vector *vector;
1372 long length, nwords;
1374 vector = (struct vector *) where;
1375 length = fixnum_value(vector->length);
1376 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1382 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1384 scav_vector_complex_double_float(lispobj *where, lispobj object)
1386 struct vector *vector;
1387 long length, nwords;
1389 vector = (struct vector *) where;
1390 length = fixnum_value(vector->length);
1391 nwords = CEILING(NWORDS(length, 128) + 2, 2);
1397 trans_vector_complex_double_float(lispobj object)
1399 struct vector *vector;
1400 long length, nwords;
1402 gc_assert(is_lisp_pointer(object));
1404 vector = (struct vector *) native_pointer(object);
1405 length = fixnum_value(vector->length);
1406 nwords = CEILING(NWORDS(length, 128) + 2, 2);
1408 return copy_large_unboxed_object(object, nwords);
1412 size_vector_complex_double_float(lispobj *where)
1414 struct vector *vector;
1415 long length, nwords;
1417 vector = (struct vector *) where;
1418 length = fixnum_value(vector->length);
1419 nwords = CEILING(NWORDS(length, 128) + 2, 2);
1426 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1428 scav_vector_complex_long_float(lispobj *where, lispobj object)
1430 struct vector *vector;
1431 long length, nwords;
1433 vector = (struct vector *) where;
1434 length = fixnum_value(vector->length);
1435 nwords = CEILING(length * (2* LONG_FLOAT_SIZE) + 2, 2);
1441 trans_vector_complex_long_float(lispobj object)
1443 struct vector *vector;
1444 long length, nwords;
1446 gc_assert(is_lisp_pointer(object));
1448 vector = (struct vector *) native_pointer(object);
1449 length = fixnum_value(vector->length);
1450 nwords = CEILING(length * (2*LONG_FLOAT_SIZE) + 2, 2);
1452 return copy_large_unboxed_object(object, nwords);
1456 size_vector_complex_long_float(lispobj *where)
1458 struct vector *vector;
1459 long length, nwords;
1461 vector = (struct vector *) where;
1462 length = fixnum_value(vector->length);
1463 nwords = CEILING(length * (2*LONG_FLOAT_SIZE) + 2, 2);
1469 #define WEAK_POINTER_NWORDS \
1470 CEILING((sizeof(struct weak_pointer) / sizeof(lispobj)), 2)
1473 trans_weak_pointer(lispobj object)
1476 #ifndef LISP_FEATURE_GENCGC
1477 struct weak_pointer *wp;
1479 gc_assert(is_lisp_pointer(object));
1481 #if defined(DEBUG_WEAK)
1482 printf("Transporting weak pointer from 0x%08x\n", object);
1485 /* Need to remember where all the weak pointers are that have */
1486 /* been transported so they can be fixed up in a post-GC pass. */
1488 copy = copy_object(object, WEAK_POINTER_NWORDS);
1489 #ifndef LISP_FEATURE_GENCGC
1490 wp = (struct weak_pointer *) native_pointer(copy);
1492 gc_assert(widetag_of(wp->header)==WEAK_POINTER_WIDETAG);
1493 /* Push the weak pointer onto the list of weak pointers. */
1494 wp->next = LOW_WORD(weak_pointers);
1501 size_weak_pointer(lispobj *where)
1503 return WEAK_POINTER_NWORDS;
1507 void scan_weak_pointers(void)
1509 struct weak_pointer *wp;
1510 for (wp = weak_pointers; wp != NULL;
1511 wp=(struct weak_pointer *)native_pointer(wp->next)) {
1512 lispobj value = wp->value;
1513 lispobj *first_pointer;
1514 gc_assert(widetag_of(wp->header)==WEAK_POINTER_WIDETAG);
1515 if (!(is_lisp_pointer(value) && from_space_p(value)))
1518 /* Now, we need to check whether the object has been forwarded. If
1519 * it has been, the weak pointer is still good and needs to be
1520 * updated. Otherwise, the weak pointer needs to be nil'ed
1523 first_pointer = (lispobj *)native_pointer(value);
1525 if (forwarding_pointer_p(first_pointer)) {
1527 (lispobj)LOW_WORD(forwarding_pointer_value(first_pointer));
1543 scav_lose(lispobj *where, lispobj object)
1545 lose("no scavenge function for object 0x%08x (widetag 0x%x)",
1546 (unsigned long)object,
1547 widetag_of(*(lispobj*)native_pointer(object)));
1549 return 0; /* bogus return value to satisfy static type checking */
1553 trans_lose(lispobj object)
1555 lose("no transport function for object 0x%08x (widetag 0x%x)",
1556 (unsigned long)object,
1557 widetag_of(*(lispobj*)native_pointer(object)));
1558 return NIL; /* bogus return value to satisfy static type checking */
1562 size_lose(lispobj *where)
1564 lose("no size function for object at 0x%08x (widetag 0x%x)",
1565 (unsigned long)where,
1566 widetag_of(LOW_WORD(where)));
1567 return 1; /* bogus return value to satisfy static type checking */
1576 gc_init_tables(void)
1580 /* Set default value in all slots of scavenge table. FIXME
1581 * replace this gnarly sizeof with something based on
1583 for (i = 0; i < ((sizeof scavtab)/(sizeof scavtab[0])); i++) {
1584 scavtab[i] = scav_lose;
1587 /* For each type which can be selected by the lowtag alone, set
1588 * multiple entries in our widetag scavenge table (one for each
1589 * possible value of the high bits).
1592 for (i = 0; i < (1<<(N_WIDETAG_BITS-N_LOWTAG_BITS)); i++) {
1593 scavtab[EVEN_FIXNUM_LOWTAG|(i<<N_LOWTAG_BITS)] = scav_immediate;
1594 scavtab[FUN_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = scav_fun_pointer;
1595 /* skipping OTHER_IMMEDIATE_0_LOWTAG */
1596 scavtab[LIST_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = scav_list_pointer;
1597 scavtab[ODD_FIXNUM_LOWTAG|(i<<N_LOWTAG_BITS)] = scav_immediate;
1598 scavtab[INSTANCE_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = scav_instance_pointer;
1599 /* skipping OTHER_IMMEDIATE_1_LOWTAG */
1600 scavtab[OTHER_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = scav_other_pointer;
1603 /* Other-pointer types (those selected by all eight bits of the
1604 * tag) get one entry each in the scavenge table. */
1605 scavtab[BIGNUM_WIDETAG] = scav_unboxed;
1606 scavtab[RATIO_WIDETAG] = scav_boxed;
1607 #if N_WORD_BITS == 64
1608 scavtab[SINGLE_FLOAT_WIDETAG] = scav_immediate;
1610 scavtab[SINGLE_FLOAT_WIDETAG] = scav_unboxed;
1612 scavtab[DOUBLE_FLOAT_WIDETAG] = scav_unboxed;
1613 #ifdef LONG_FLOAT_WIDETAG
1614 scavtab[LONG_FLOAT_WIDETAG] = scav_unboxed;
1616 scavtab[COMPLEX_WIDETAG] = scav_boxed;
1617 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
1618 scavtab[COMPLEX_SINGLE_FLOAT_WIDETAG] = scav_unboxed;
1620 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
1621 scavtab[COMPLEX_DOUBLE_FLOAT_WIDETAG] = scav_unboxed;
1623 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
1624 scavtab[COMPLEX_LONG_FLOAT_WIDETAG] = scav_unboxed;
1626 scavtab[SIMPLE_ARRAY_WIDETAG] = scav_boxed;
1627 scavtab[SIMPLE_BASE_STRING_WIDETAG] = scav_base_string;
1628 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
1629 scavtab[SIMPLE_CHARACTER_STRING_WIDETAG] = scav_character_string;
1631 scavtab[SIMPLE_BIT_VECTOR_WIDETAG] = scav_vector_bit;
1632 scavtab[SIMPLE_ARRAY_NIL_WIDETAG] = scav_vector_nil;
1633 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG] =
1634 scav_vector_unsigned_byte_2;
1635 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG] =
1636 scav_vector_unsigned_byte_4;
1637 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG] =
1638 scav_vector_unsigned_byte_8;
1639 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG] =
1640 scav_vector_unsigned_byte_8;
1641 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG] =
1642 scav_vector_unsigned_byte_16;
1643 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG] =
1644 scav_vector_unsigned_byte_16;
1645 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG
1646 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG] =
1647 scav_vector_unsigned_byte_32;
1649 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG] =
1650 scav_vector_unsigned_byte_32;
1651 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG] =
1652 scav_vector_unsigned_byte_32;
1653 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG
1654 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG] =
1655 scav_vector_unsigned_byte_64;
1657 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG
1658 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG] =
1659 scav_vector_unsigned_byte_64;
1661 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG
1662 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG] =
1663 scav_vector_unsigned_byte_64;
1665 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
1666 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG] = scav_vector_unsigned_byte_8;
1668 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
1669 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG] =
1670 scav_vector_unsigned_byte_16;
1672 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
1673 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG] =
1674 scav_vector_unsigned_byte_32;
1676 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
1677 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG] =
1678 scav_vector_unsigned_byte_32;
1680 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG
1681 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG] =
1682 scav_vector_unsigned_byte_64;
1684 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG
1685 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG] =
1686 scav_vector_unsigned_byte_64;
1688 scavtab[SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG] = scav_vector_single_float;
1689 scavtab[SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG] = scav_vector_double_float;
1690 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1691 scavtab[SIMPLE_ARRAY_LONG_FLOAT_WIDETAG] = scav_vector_long_float;
1693 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1694 scavtab[SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG] =
1695 scav_vector_complex_single_float;
1697 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1698 scavtab[SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG] =
1699 scav_vector_complex_double_float;
1701 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1702 scavtab[SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG] =
1703 scav_vector_complex_long_float;
1705 scavtab[COMPLEX_BASE_STRING_WIDETAG] = scav_boxed;
1706 #ifdef COMPLEX_CHARACTER_STRING_WIDETAG
1707 scavtab[COMPLEX_CHARACTER_STRING_WIDETAG] = scav_boxed;
1709 scavtab[COMPLEX_VECTOR_NIL_WIDETAG] = scav_boxed;
1710 scavtab[COMPLEX_BIT_VECTOR_WIDETAG] = scav_boxed;
1711 scavtab[COMPLEX_VECTOR_WIDETAG] = scav_boxed;
1712 scavtab[COMPLEX_ARRAY_WIDETAG] = scav_boxed;
1713 scavtab[CODE_HEADER_WIDETAG] = scav_code_header;
1714 #ifndef LISP_FEATURE_GENCGC /* FIXME ..._X86 ? */
1715 scavtab[SIMPLE_FUN_HEADER_WIDETAG] = scav_fun_header;
1716 scavtab[RETURN_PC_HEADER_WIDETAG] = scav_return_pc_header;
1718 #if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
1719 scavtab[CLOSURE_HEADER_WIDETAG] = scav_closure_header;
1720 scavtab[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = scav_closure_header;
1722 scavtab[CLOSURE_HEADER_WIDETAG] = scav_boxed;
1723 scavtab[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = scav_boxed;
1725 scavtab[VALUE_CELL_HEADER_WIDETAG] = scav_boxed;
1726 scavtab[SYMBOL_HEADER_WIDETAG] = scav_boxed;
1727 scavtab[CHARACTER_WIDETAG] = scav_immediate;
1728 scavtab[SAP_WIDETAG] = scav_unboxed;
1729 scavtab[UNBOUND_MARKER_WIDETAG] = scav_immediate;
1730 scavtab[INSTANCE_HEADER_WIDETAG] = scav_instance;
1731 #ifdef LISP_FEATURE_SPARC
1732 scavtab[FDEFN_WIDETAG] = scav_boxed;
1734 scavtab[FDEFN_WIDETAG] = scav_fdefn;
1737 /* transport other table, initialized same way as scavtab */
1738 for (i = 0; i < ((sizeof transother)/(sizeof transother[0])); i++)
1739 transother[i] = trans_lose;
1740 transother[BIGNUM_WIDETAG] = trans_unboxed;
1741 transother[RATIO_WIDETAG] = trans_boxed;
1743 #if N_WORD_BITS == 64
1744 transother[SINGLE_FLOAT_WIDETAG] = trans_immediate;
1746 transother[SINGLE_FLOAT_WIDETAG] = trans_unboxed;
1748 transother[DOUBLE_FLOAT_WIDETAG] = trans_unboxed;
1749 #ifdef LONG_FLOAT_WIDETAG
1750 transother[LONG_FLOAT_WIDETAG] = trans_unboxed;
1752 transother[COMPLEX_WIDETAG] = trans_boxed;
1753 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
1754 transother[COMPLEX_SINGLE_FLOAT_WIDETAG] = trans_unboxed;
1756 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
1757 transother[COMPLEX_DOUBLE_FLOAT_WIDETAG] = trans_unboxed;
1759 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
1760 transother[COMPLEX_LONG_FLOAT_WIDETAG] = trans_unboxed;
1762 transother[SIMPLE_ARRAY_WIDETAG] = trans_boxed; /* but not GENCGC */
1763 transother[SIMPLE_BASE_STRING_WIDETAG] = trans_base_string;
1764 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
1765 transother[SIMPLE_CHARACTER_STRING_WIDETAG] = trans_character_string;
1767 transother[SIMPLE_BIT_VECTOR_WIDETAG] = trans_vector_bit;
1768 transother[SIMPLE_VECTOR_WIDETAG] = trans_vector;
1769 transother[SIMPLE_ARRAY_NIL_WIDETAG] = trans_vector_nil;
1770 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG] =
1771 trans_vector_unsigned_byte_2;
1772 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG] =
1773 trans_vector_unsigned_byte_4;
1774 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG] =
1775 trans_vector_unsigned_byte_8;
1776 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG] =
1777 trans_vector_unsigned_byte_8;
1778 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG] =
1779 trans_vector_unsigned_byte_16;
1780 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG] =
1781 trans_vector_unsigned_byte_16;
1782 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG
1783 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG] =
1784 trans_vector_unsigned_byte_32;
1786 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG] =
1787 trans_vector_unsigned_byte_32;
1788 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG] =
1789 trans_vector_unsigned_byte_32;
1790 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG
1791 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG] =
1792 trans_vector_unsigned_byte_64;
1794 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG
1795 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG] =
1796 trans_vector_unsigned_byte_64;
1798 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG
1799 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG] =
1800 trans_vector_unsigned_byte_64;
1802 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
1803 transother[SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG] =
1804 trans_vector_unsigned_byte_8;
1806 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
1807 transother[SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG] =
1808 trans_vector_unsigned_byte_16;
1810 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
1811 transother[SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG] =
1812 trans_vector_unsigned_byte_32;
1814 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
1815 transother[SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG] =
1816 trans_vector_unsigned_byte_32;
1818 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG
1819 transother[SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG] =
1820 trans_vector_unsigned_byte_64;
1822 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG
1823 transother[SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG] =
1824 trans_vector_unsigned_byte_64;
1826 transother[SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG] =
1827 trans_vector_single_float;
1828 transother[SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG] =
1829 trans_vector_double_float;
1830 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1831 transother[SIMPLE_ARRAY_LONG_FLOAT_WIDETAG] =
1832 trans_vector_long_float;
1834 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1835 transother[SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG] =
1836 trans_vector_complex_single_float;
1838 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1839 transother[SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG] =
1840 trans_vector_complex_double_float;
1842 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1843 transother[SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG] =
1844 trans_vector_complex_long_float;
1846 transother[COMPLEX_BASE_STRING_WIDETAG] = trans_boxed;
1847 #ifdef COMPLEX_CHARACTER_STRING_WIDETAG
1848 transother[COMPLEX_CHARACTER_STRING_WIDETAG] = trans_boxed;
1850 transother[COMPLEX_BIT_VECTOR_WIDETAG] = trans_boxed;
1851 transother[COMPLEX_VECTOR_NIL_WIDETAG] = trans_boxed;
1852 transother[COMPLEX_VECTOR_WIDETAG] = trans_boxed;
1853 transother[COMPLEX_ARRAY_WIDETAG] = trans_boxed;
1854 transother[CODE_HEADER_WIDETAG] = trans_code_header;
1855 transother[SIMPLE_FUN_HEADER_WIDETAG] = trans_fun_header;
1856 transother[RETURN_PC_HEADER_WIDETAG] = trans_return_pc_header;
1857 transother[CLOSURE_HEADER_WIDETAG] = trans_boxed;
1858 transother[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = trans_boxed;
1859 transother[VALUE_CELL_HEADER_WIDETAG] = trans_boxed;
1860 transother[SYMBOL_HEADER_WIDETAG] = trans_boxed;
1861 transother[CHARACTER_WIDETAG] = trans_immediate;
1862 transother[SAP_WIDETAG] = trans_unboxed;
1863 transother[UNBOUND_MARKER_WIDETAG] = trans_immediate;
1864 transother[WEAK_POINTER_WIDETAG] = trans_weak_pointer;
1865 transother[INSTANCE_HEADER_WIDETAG] = trans_boxed;
1866 transother[FDEFN_WIDETAG] = trans_boxed;
1868 /* size table, initialized the same way as scavtab */
1869 for (i = 0; i < ((sizeof sizetab)/(sizeof sizetab[0])); i++)
1870 sizetab[i] = size_lose;
1871 for (i = 0; i < (1<<(N_WIDETAG_BITS-N_LOWTAG_BITS)); i++) {
1872 sizetab[EVEN_FIXNUM_LOWTAG|(i<<N_LOWTAG_BITS)] = size_immediate;
1873 sizetab[FUN_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = size_pointer;
1874 /* skipping OTHER_IMMEDIATE_0_LOWTAG */
1875 sizetab[LIST_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = size_pointer;
1876 sizetab[ODD_FIXNUM_LOWTAG|(i<<N_LOWTAG_BITS)] = size_immediate;
1877 sizetab[INSTANCE_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = size_pointer;
1878 /* skipping OTHER_IMMEDIATE_1_LOWTAG */
1879 sizetab[OTHER_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = size_pointer;
1881 sizetab[BIGNUM_WIDETAG] = size_unboxed;
1882 sizetab[RATIO_WIDETAG] = size_boxed;
1883 #if N_WORD_BITS == 64
1884 sizetab[SINGLE_FLOAT_WIDETAG] = size_immediate;
1886 sizetab[SINGLE_FLOAT_WIDETAG] = size_unboxed;
1888 sizetab[DOUBLE_FLOAT_WIDETAG] = size_unboxed;
1889 #ifdef LONG_FLOAT_WIDETAG
1890 sizetab[LONG_FLOAT_WIDETAG] = size_unboxed;
1892 sizetab[COMPLEX_WIDETAG] = size_boxed;
1893 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
1894 sizetab[COMPLEX_SINGLE_FLOAT_WIDETAG] = size_unboxed;
1896 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
1897 sizetab[COMPLEX_DOUBLE_FLOAT_WIDETAG] = size_unboxed;
1899 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
1900 sizetab[COMPLEX_LONG_FLOAT_WIDETAG] = size_unboxed;
1902 sizetab[SIMPLE_ARRAY_WIDETAG] = size_boxed;
1903 sizetab[SIMPLE_BASE_STRING_WIDETAG] = size_base_string;
1904 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
1905 sizetab[SIMPLE_CHARACTER_STRING_WIDETAG] = size_character_string;
1907 sizetab[SIMPLE_BIT_VECTOR_WIDETAG] = size_vector_bit;
1908 sizetab[SIMPLE_VECTOR_WIDETAG] = size_vector;
1909 sizetab[SIMPLE_ARRAY_NIL_WIDETAG] = size_vector_nil;
1910 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG] =
1911 size_vector_unsigned_byte_2;
1912 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG] =
1913 size_vector_unsigned_byte_4;
1914 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG] =
1915 size_vector_unsigned_byte_8;
1916 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG] =
1917 size_vector_unsigned_byte_8;
1918 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG] =
1919 size_vector_unsigned_byte_16;
1920 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG] =
1921 size_vector_unsigned_byte_16;
1922 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG
1923 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG] =
1924 size_vector_unsigned_byte_32;
1926 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG] =
1927 size_vector_unsigned_byte_32;
1928 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG] =
1929 size_vector_unsigned_byte_32;
1930 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG
1931 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG] =
1932 size_vector_unsigned_byte_64;
1934 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG
1935 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG] =
1936 size_vector_unsigned_byte_64;
1938 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG
1939 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG] =
1940 size_vector_unsigned_byte_64;
1942 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
1943 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG] = size_vector_unsigned_byte_8;
1945 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
1946 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG] =
1947 size_vector_unsigned_byte_16;
1949 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
1950 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG] =
1951 size_vector_unsigned_byte_32;
1953 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
1954 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG] =
1955 size_vector_unsigned_byte_32;
1957 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG
1958 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG] =
1959 size_vector_unsigned_byte_64;
1961 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG
1962 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG] =
1963 size_vector_unsigned_byte_64;
1965 sizetab[SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG] = size_vector_single_float;
1966 sizetab[SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG] = size_vector_double_float;
1967 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1968 sizetab[SIMPLE_ARRAY_LONG_FLOAT_WIDETAG] = size_vector_long_float;
1970 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1971 sizetab[SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG] =
1972 size_vector_complex_single_float;
1974 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1975 sizetab[SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG] =
1976 size_vector_complex_double_float;
1978 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1979 sizetab[SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG] =
1980 size_vector_complex_long_float;
1982 sizetab[COMPLEX_BASE_STRING_WIDETAG] = size_boxed;
1983 #ifdef COMPLEX_CHARACTER_STRING_WIDETAG
1984 sizetab[COMPLEX_CHARACTER_STRING_WIDETAG] = size_boxed;
1986 sizetab[COMPLEX_VECTOR_NIL_WIDETAG] = size_boxed;
1987 sizetab[COMPLEX_BIT_VECTOR_WIDETAG] = size_boxed;
1988 sizetab[COMPLEX_VECTOR_WIDETAG] = size_boxed;
1989 sizetab[COMPLEX_ARRAY_WIDETAG] = size_boxed;
1990 sizetab[CODE_HEADER_WIDETAG] = size_code_header;
1992 /* We shouldn't see these, so just lose if it happens. */
1993 sizetab[SIMPLE_FUN_HEADER_WIDETAG] = size_function_header;
1994 sizetab[RETURN_PC_HEADER_WIDETAG] = size_return_pc_header;
1996 sizetab[CLOSURE_HEADER_WIDETAG] = size_boxed;
1997 sizetab[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = size_boxed;
1998 sizetab[VALUE_CELL_HEADER_WIDETAG] = size_boxed;
1999 sizetab[SYMBOL_HEADER_WIDETAG] = size_boxed;
2000 sizetab[CHARACTER_WIDETAG] = size_immediate;
2001 sizetab[SAP_WIDETAG] = size_unboxed;
2002 sizetab[UNBOUND_MARKER_WIDETAG] = size_immediate;
2003 sizetab[WEAK_POINTER_WIDETAG] = size_weak_pointer;
2004 sizetab[INSTANCE_HEADER_WIDETAG] = size_boxed;
2005 sizetab[FDEFN_WIDETAG] = size_boxed;
2009 /* Find the code object for the given pc, or return NULL on
2012 component_ptr_from_pc(lispobj *pc)
2014 lispobj *object = NULL;
2016 if ( (object = search_read_only_space(pc)) )
2018 else if ( (object = search_static_space(pc)) )
2021 object = search_dynamic_space(pc);
2023 if (object) /* if we found something */
2024 if (widetag_of(*object) == CODE_HEADER_WIDETAG)
2030 /* Scan an area looking for an object which encloses the given pointer.
2031 * Return the object start on success or NULL on failure. */
2033 gc_search_space(lispobj *start, size_t words, lispobj *pointer)
2037 lispobj thing = *start;
2039 /* If thing is an immediate then this is a cons. */
2040 if (is_lisp_pointer(thing)
2042 || (widetag_of(thing) == CHARACTER_WIDETAG)
2043 #if N_WORD_BITS == 64
2044 || (widetag_of(thing) == SINGLE_FLOAT_WIDETAG)
2046 || (widetag_of(thing) == UNBOUND_MARKER_WIDETAG))
2049 count = (sizetab[widetag_of(thing)])(start);
2051 /* Check whether the pointer is within this object. */
2052 if ((pointer >= start) && (pointer < (start+count))) {
2054 /*FSHOW((stderr,"/found %x in %x %x\n", pointer, start, thing));*/
2058 /* Round up the count. */
2059 count = CEILING(count,2);