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 "gc-internal.h"
46 #ifdef LISP_FEATURE_SPARC
47 #define LONG_FLOAT_SIZE 4
49 #ifdef LISP_FEATURE_X86
50 #define LONG_FLOAT_SIZE 3
55 forwarding_pointer_p(lispobj *pointer) {
56 lispobj first_word=*pointer;
57 #ifdef LISP_FEATURE_GENCGC
58 return (first_word == 0x01);
60 return (is_lisp_pointer(first_word)
61 && new_space_p(first_word));
65 static inline lispobj *
66 forwarding_pointer_value(lispobj *pointer) {
67 #ifdef LISP_FEATURE_GENCGC
68 return (lispobj *) ((pointer_sized_uint_t) pointer[1]);
70 return (lispobj *) ((pointer_sized_uint_t) pointer[0]);
74 set_forwarding_pointer(lispobj * pointer, lispobj newspace_copy) {
75 #ifdef LISP_FEATURE_GENCGC
77 pointer[1]=newspace_copy;
79 pointer[0]=newspace_copy;
84 long (*scavtab[256])(lispobj *where, lispobj object);
85 lispobj (*transother[256])(lispobj object);
86 long (*sizetab[256])(lispobj *where);
87 struct weak_pointer *weak_pointers;
89 unsigned long bytes_consed_between_gcs = 12*1024*1024;
96 /* to copy a boxed object */
98 copy_object(lispobj object, long nwords)
103 gc_assert(is_lisp_pointer(object));
104 gc_assert(from_space_p(object));
105 gc_assert((nwords & 0x01) == 0);
107 /* Get tag of object. */
108 tag = lowtag_of(object);
110 /* Allocate space. */
111 new = gc_general_alloc(nwords*N_WORD_BYTES,ALLOC_BOXED,ALLOC_QUICK);
113 /* Copy the object. */
114 memcpy(new,native_pointer(object),nwords*N_WORD_BYTES);
115 return make_lispobj(new,tag);
118 static long scav_lose(lispobj *where, lispobj object); /* forward decl */
120 /* FIXME: Most calls end up going to some trouble to compute an
121 * 'n_words' value for this function. The system might be a little
122 * simpler if this function used an 'end' parameter instead. */
124 scavenge(lispobj *start, long n_words)
126 lispobj *end = start + n_words;
128 long n_words_scavenged;
129 for (object_ptr = start;
132 object_ptr += n_words_scavenged) {
134 lispobj object = *object_ptr;
135 #ifdef LISP_FEATURE_GENCGC
136 gc_assert(!forwarding_pointer_p(object_ptr));
138 if (is_lisp_pointer(object)) {
139 if (from_space_p(object)) {
140 /* It currently points to old space. Check for a
141 * forwarding pointer. */
142 lispobj *ptr = native_pointer(object);
143 if (forwarding_pointer_p(ptr)) {
144 /* Yes, there's a forwarding pointer. */
145 *object_ptr = LOW_WORD(forwarding_pointer_value(ptr));
146 n_words_scavenged = 1;
148 /* Scavenge that pointer. */
150 (scavtab[widetag_of(object)])(object_ptr, object);
153 /* It points somewhere other than oldspace. Leave it
155 n_words_scavenged = 1;
158 #ifndef LISP_FEATURE_GENCGC
159 /* this workaround is probably not necessary for gencgc; at least, the
160 * behaviour it describes has never been reported */
161 else if (n_words==1) {
162 /* there are some situations where an
163 other-immediate may end up in a descriptor
164 register. I'm not sure whether this is
165 supposed to happen, but if it does then we
166 don't want to (a) barf or (b) scavenge over the
167 data-block, because there isn't one. So, if
168 we're checking a single word and it's anything
169 other than a pointer, just hush it up */
170 int type=widetag_of(object);
173 if ((scavtab[type]==scav_lose) ||
174 (((scavtab[type])(start,object))>1)) {
175 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",
180 else if (fixnump(object)) {
181 /* It's a fixnum: really easy.. */
182 n_words_scavenged = 1;
184 /* It's some sort of header object or another. */
186 (scavtab[widetag_of(object)])(object_ptr, object);
189 gc_assert(object_ptr == end);
192 static lispobj trans_fun_header(lispobj object); /* forward decls */
193 static lispobj trans_boxed(lispobj object);
196 scav_fun_pointer(lispobj *where, lispobj object)
198 lispobj *first_pointer;
201 gc_assert(is_lisp_pointer(object));
203 /* Object is a pointer into from_space - not a FP. */
204 first_pointer = (lispobj *) native_pointer(object);
206 /* must transport object -- object may point to either a function
207 * header, a closure function header, or to a closure header. */
209 switch (widetag_of(*first_pointer)) {
210 case SIMPLE_FUN_HEADER_WIDETAG:
211 copy = trans_fun_header(object);
214 copy = trans_boxed(object);
218 if (copy != object) {
219 /* Set forwarding pointer */
220 set_forwarding_pointer(first_pointer,copy);
223 gc_assert(is_lisp_pointer(copy));
224 gc_assert(!from_space_p(copy));
233 trans_code(struct code *code)
235 struct code *new_code;
236 lispobj first, l_code, l_new_code;
237 long nheader_words, ncode_words, nwords;
238 unsigned long displacement;
239 lispobj fheaderl, *prev_pointer;
241 /* if object has already been transported, just return pointer */
242 first = code->header;
243 if (forwarding_pointer_p((lispobj *)code)) {
245 printf("Was already transported\n");
247 return (struct code *) forwarding_pointer_value
248 ((lispobj *)((pointer_sized_uint_t) code));
251 gc_assert(widetag_of(first) == CODE_HEADER_WIDETAG);
253 /* prepare to transport the code vector */
254 l_code = (lispobj) LOW_WORD(code) | OTHER_POINTER_LOWTAG;
256 ncode_words = fixnum_value(code->code_size);
257 nheader_words = HeaderValue(code->header);
258 nwords = ncode_words + nheader_words;
259 nwords = CEILING(nwords, 2);
261 l_new_code = copy_object(l_code, nwords);
262 new_code = (struct code *) native_pointer(l_new_code);
264 #if defined(DEBUG_CODE_GC)
265 printf("Old code object at 0x%08x, new code object at 0x%08x.\n",
266 (unsigned long) code, (unsigned long) new_code);
267 printf("Code object is %d words long.\n", nwords);
270 #ifdef LISP_FEATURE_GENCGC
271 if (new_code == code)
275 displacement = l_new_code - l_code;
277 set_forwarding_pointer((lispobj *)code, l_new_code);
279 /* set forwarding pointers for all the function headers in the */
280 /* code object. also fix all self pointers */
282 fheaderl = code->entry_points;
283 prev_pointer = &new_code->entry_points;
285 while (fheaderl != NIL) {
286 struct simple_fun *fheaderp, *nfheaderp;
289 fheaderp = (struct simple_fun *) native_pointer(fheaderl);
290 gc_assert(widetag_of(fheaderp->header) == SIMPLE_FUN_HEADER_WIDETAG);
292 /* Calculate the new function pointer and the new */
293 /* function header. */
294 nfheaderl = fheaderl + displacement;
295 nfheaderp = (struct simple_fun *) native_pointer(nfheaderl);
298 printf("fheaderp->header (at %x) <- %x\n",
299 &(fheaderp->header) , nfheaderl);
301 set_forwarding_pointer((lispobj *)fheaderp, nfheaderl);
303 /* fix self pointer. */
305 #if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
306 FUN_RAW_ADDR_OFFSET +
310 *prev_pointer = nfheaderl;
312 fheaderl = fheaderp->next;
313 prev_pointer = &nfheaderp->next;
315 os_flush_icache((os_vm_address_t) (((long *)new_code) + nheader_words),
316 ncode_words * sizeof(long));
317 #ifdef LISP_FEATURE_GENCGC
318 gencgc_apply_code_fixups(code, new_code);
324 scav_code_header(lispobj *where, lispobj object)
327 long n_header_words, n_code_words, n_words;
328 lispobj entry_point; /* tagged pointer to entry point */
329 struct simple_fun *function_ptr; /* untagged pointer to entry point */
331 code = (struct code *) where;
332 n_code_words = fixnum_value(code->code_size);
333 n_header_words = HeaderValue(object);
334 n_words = n_code_words + n_header_words;
335 n_words = CEILING(n_words, 2);
337 /* Scavenge the boxed section of the code data block. */
338 scavenge(where + 1, n_header_words - 1);
340 /* Scavenge the boxed section of each function object in the
341 * code data block. */
342 for (entry_point = code->entry_points;
344 entry_point = function_ptr->next) {
346 gc_assert(is_lisp_pointer(entry_point));
348 function_ptr = (struct simple_fun *) native_pointer(entry_point);
349 gc_assert(widetag_of(function_ptr->header)==SIMPLE_FUN_HEADER_WIDETAG);
351 scavenge(&function_ptr->name, 1);
352 scavenge(&function_ptr->arglist, 1);
353 scavenge(&function_ptr->type, 1);
360 trans_code_header(lispobj object)
364 ncode = trans_code((struct code *) native_pointer(object));
365 return (lispobj) LOW_WORD(ncode) | OTHER_POINTER_LOWTAG;
370 size_code_header(lispobj *where)
373 long nheader_words, ncode_words, nwords;
375 code = (struct code *) where;
377 ncode_words = fixnum_value(code->code_size);
378 nheader_words = HeaderValue(code->header);
379 nwords = ncode_words + nheader_words;
380 nwords = CEILING(nwords, 2);
385 #ifndef LISP_FEATURE_X86 || LISP_FEATURE_X86_64
387 scav_return_pc_header(lispobj *where, lispobj object)
389 lose("attempted to scavenge a return PC header where=0x%08x object=0x%08x",
390 (unsigned long) where,
391 (unsigned long) object);
392 return 0; /* bogus return value to satisfy static type checking */
394 #endif /* LISP_FEATURE_X86 */
397 trans_return_pc_header(lispobj object)
399 struct simple_fun *return_pc;
400 unsigned long offset;
401 struct code *code, *ncode;
403 return_pc = (struct simple_fun *) native_pointer(object);
404 /* FIXME: was times 4, should it really be N_WORD_BYTES? */
405 offset = HeaderValue(return_pc->header) * N_WORD_BYTES;
407 /* Transport the whole code object */
408 code = (struct code *) ((unsigned long) return_pc - offset);
409 ncode = trans_code(code);
411 return ((lispobj) LOW_WORD(ncode) + offset) | OTHER_POINTER_LOWTAG;
414 /* On the 386, closures hold a pointer to the raw address instead of the
415 * function object, so we can use CALL [$FDEFN+const] to invoke
416 * the function without loading it into a register. Given that code
417 * objects don't move, we don't need to update anything, but we do
418 * have to figure out that the function is still live. */
420 #if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
422 scav_closure_header(lispobj *where, lispobj object)
424 struct closure *closure;
427 closure = (struct closure *)where;
428 fun = closure->fun - FUN_RAW_ADDR_OFFSET;
430 #ifdef LISP_FEATURE_GENCGC
431 /* The function may have moved so update the raw address. But
432 * don't write unnecessarily. */
433 if (closure->fun != fun + FUN_RAW_ADDR_OFFSET)
434 closure->fun = fun + FUN_RAW_ADDR_OFFSET;
440 #if !(defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64))
442 scav_fun_header(lispobj *where, lispobj object)
444 lose("attempted to scavenge a function header where=0x%08x object=0x%08x",
445 (unsigned long) where,
446 (unsigned long) object);
447 return 0; /* bogus return value to satisfy static type checking */
449 #endif /* LISP_FEATURE_X86 */
452 trans_fun_header(lispobj object)
454 struct simple_fun *fheader;
455 unsigned long offset;
456 struct code *code, *ncode;
458 fheader = (struct simple_fun *) native_pointer(object);
459 /* FIXME: was times 4, should it really be N_WORD_BYTES? */
460 offset = HeaderValue(fheader->header) * N_WORD_BYTES;
462 /* Transport the whole code object */
463 code = (struct code *) ((unsigned long) fheader - offset);
464 ncode = trans_code(code);
466 return ((lispobj) LOW_WORD(ncode) + offset) | FUN_POINTER_LOWTAG;
475 scav_instance_pointer(lispobj *where, lispobj object)
477 lispobj copy, *first_pointer;
479 /* Object is a pointer into from space - not a FP. */
480 copy = trans_boxed(object);
482 #ifdef LISP_FEATURE_GENCGC
483 gc_assert(copy != object);
486 first_pointer = (lispobj *) native_pointer(object);
487 set_forwarding_pointer(first_pointer,copy);
498 static lispobj trans_list(lispobj object);
501 scav_list_pointer(lispobj *where, lispobj object)
503 lispobj first, *first_pointer;
505 gc_assert(is_lisp_pointer(object));
507 /* Object is a pointer into from space - not FP. */
508 first_pointer = (lispobj *) native_pointer(object);
510 first = trans_list(object);
511 gc_assert(first != object);
513 /* Set forwarding pointer */
514 set_forwarding_pointer(first_pointer, first);
516 gc_assert(is_lisp_pointer(first));
517 gc_assert(!from_space_p(first));
525 trans_list(lispobj object)
527 lispobj new_list_pointer;
528 struct cons *cons, *new_cons;
531 cons = (struct cons *) native_pointer(object);
534 new_cons = (struct cons *)
535 gc_general_alloc(sizeof(struct cons),ALLOC_BOXED,ALLOC_QUICK);
536 new_cons->car = cons->car;
537 new_cons->cdr = cons->cdr; /* updated later */
538 new_list_pointer = make_lispobj(new_cons,lowtag_of(object));
540 /* Grab the cdr: set_forwarding_pointer will clobber it in GENCGC */
543 set_forwarding_pointer((lispobj *)cons, new_list_pointer);
545 /* Try to linearize the list in the cdr direction to help reduce
549 struct cons *cdr_cons, *new_cdr_cons;
551 if(lowtag_of(cdr) != LIST_POINTER_LOWTAG ||
552 !from_space_p(cdr) ||
553 forwarding_pointer_p((lispobj *)native_pointer(cdr)))
556 cdr_cons = (struct cons *) native_pointer(cdr);
559 new_cdr_cons = (struct cons*)
560 gc_general_alloc(sizeof(struct cons),ALLOC_BOXED,ALLOC_QUICK);
561 new_cdr_cons->car = cdr_cons->car;
562 new_cdr_cons->cdr = cdr_cons->cdr;
563 new_cdr = make_lispobj(new_cdr_cons, lowtag_of(cdr));
565 /* Grab the cdr before it is clobbered. */
567 set_forwarding_pointer((lispobj *)cdr_cons, new_cdr);
569 /* Update the cdr of the last cons copied into new space to
570 * keep the newspace scavenge from having to do it. */
571 new_cons->cdr = new_cdr;
573 new_cons = new_cdr_cons;
576 return new_list_pointer;
581 * scavenging and transporting other pointers
585 scav_other_pointer(lispobj *where, lispobj object)
587 lispobj first, *first_pointer;
589 gc_assert(is_lisp_pointer(object));
591 /* Object is a pointer into from space - not FP. */
592 first_pointer = (lispobj *) native_pointer(object);
593 first = (transother[widetag_of(*first_pointer)])(object);
595 if (first != object) {
596 set_forwarding_pointer(first_pointer, first);
597 #ifdef LISP_FEATURE_GENCGC
601 #ifndef LISP_FEATURE_GENCGC
604 gc_assert(is_lisp_pointer(first));
605 gc_assert(!from_space_p(first));
611 * immediate, boxed, and unboxed objects
615 size_pointer(lispobj *where)
621 scav_immediate(lispobj *where, lispobj object)
627 trans_immediate(lispobj object)
629 lose("trying to transport an immediate");
630 return NIL; /* bogus return value to satisfy static type checking */
634 size_immediate(lispobj *where)
641 scav_boxed(lispobj *where, lispobj object)
647 trans_boxed(lispobj object)
650 unsigned long length;
652 gc_assert(is_lisp_pointer(object));
654 header = *((lispobj *) native_pointer(object));
655 length = HeaderValue(header) + 1;
656 length = CEILING(length, 2);
658 return copy_object(object, length);
663 size_boxed(lispobj *where)
666 unsigned long length;
669 length = HeaderValue(header) + 1;
670 length = CEILING(length, 2);
675 /* Note: on the sparc we don't have to do anything special for fdefns, */
676 /* 'cause the raw-addr has a function lowtag. */
677 #ifndef LISP_FEATURE_SPARC
679 scav_fdefn(lispobj *where, lispobj object)
683 fdefn = (struct fdefn *)where;
685 /* FSHOW((stderr, "scav_fdefn, function = %p, raw_addr = %p\n",
686 fdefn->fun, fdefn->raw_addr)); */
688 if ((char *)(fdefn->fun + FUN_RAW_ADDR_OFFSET)
689 == (char *)((unsigned long)(fdefn->raw_addr))) {
690 scavenge(where + 1, sizeof(struct fdefn)/sizeof(lispobj) - 1);
692 /* Don't write unnecessarily. */
693 if (fdefn->raw_addr != (char *)(fdefn->fun + FUN_RAW_ADDR_OFFSET))
694 fdefn->raw_addr = (char *)(fdefn->fun + FUN_RAW_ADDR_OFFSET);
695 /* gc.c has more casts here, which may be relevant or alternatively
696 may be compiler warning defeaters. try
697 fdefn->raw_addr = ((char *) LOW_WORD(fdefn->fun)) + FUN_RAW_ADDR_OFFSET;
699 return sizeof(struct fdefn) / sizeof(lispobj);
707 scav_unboxed(lispobj *where, lispobj object)
709 unsigned long length;
711 length = HeaderValue(object) + 1;
712 length = CEILING(length, 2);
718 trans_unboxed(lispobj object)
721 unsigned long length;
724 gc_assert(is_lisp_pointer(object));
726 header = *((lispobj *) native_pointer(object));
727 length = HeaderValue(header) + 1;
728 length = CEILING(length, 2);
730 return copy_unboxed_object(object, length);
734 size_unboxed(lispobj *where)
737 unsigned long length;
740 length = HeaderValue(header) + 1;
741 length = CEILING(length, 2);
747 /* vector-like objects */
749 scav_base_string(lispobj *where, lispobj object)
751 struct vector *vector;
754 /* NOTE: Strings contain one more byte of data than the length */
755 /* slot indicates. */
757 vector = (struct vector *) where;
758 length = fixnum_value(vector->length) + 1;
759 nwords = CEILING(NWORDS(length, 8) + 2, 2);
764 trans_base_string(lispobj object)
766 struct vector *vector;
769 gc_assert(is_lisp_pointer(object));
771 /* NOTE: A string contains one more byte of data (a terminating
772 * '\0' to help when interfacing with C functions) than indicated
773 * by the length slot. */
775 vector = (struct vector *) native_pointer(object);
776 length = fixnum_value(vector->length) + 1;
777 nwords = CEILING(NWORDS(length, 8) + 2, 2);
779 return copy_large_unboxed_object(object, nwords);
783 size_base_string(lispobj *where)
785 struct vector *vector;
788 /* NOTE: A string contains one more byte of data (a terminating
789 * '\0' to help when interfacing with C functions) than indicated
790 * by the length slot. */
792 vector = (struct vector *) where;
793 length = fixnum_value(vector->length) + 1;
794 nwords = CEILING(NWORDS(length, 8) + 2, 2);
800 scav_character_string(lispobj *where, lispobj object)
802 struct vector *vector;
805 /* NOTE: Strings contain one more byte of data than the length */
806 /* slot indicates. */
808 vector = (struct vector *) where;
809 length = fixnum_value(vector->length) + 1;
810 nwords = CEILING(NWORDS(length, 32) + 2, 2);
815 trans_character_string(lispobj object)
817 struct vector *vector;
820 gc_assert(is_lisp_pointer(object));
822 /* NOTE: A string contains one more byte of data (a terminating
823 * '\0' to help when interfacing with C functions) than indicated
824 * by the length slot. */
826 vector = (struct vector *) native_pointer(object);
827 length = fixnum_value(vector->length) + 1;
828 nwords = CEILING(NWORDS(length, 32) + 2, 2);
830 return copy_large_unboxed_object(object, nwords);
834 size_character_string(lispobj *where)
836 struct vector *vector;
839 /* NOTE: A string contains one more byte of data (a terminating
840 * '\0' to help when interfacing with C functions) than indicated
841 * by the length slot. */
843 vector = (struct vector *) where;
844 length = fixnum_value(vector->length) + 1;
845 nwords = CEILING(NWORDS(length, 32) + 2, 2);
851 trans_vector(lispobj object)
853 struct vector *vector;
856 gc_assert(is_lisp_pointer(object));
858 vector = (struct vector *) native_pointer(object);
860 length = fixnum_value(vector->length);
861 nwords = CEILING(length + 2, 2);
863 return copy_large_object(object, nwords);
867 size_vector(lispobj *where)
869 struct vector *vector;
872 vector = (struct vector *) where;
873 length = fixnum_value(vector->length);
874 nwords = CEILING(length + 2, 2);
880 scav_vector_nil(lispobj *where, lispobj object)
886 trans_vector_nil(lispobj object)
888 gc_assert(is_lisp_pointer(object));
889 return copy_unboxed_object(object, 2);
893 size_vector_nil(lispobj *where)
895 /* Just the header word and the length word */
900 scav_vector_bit(lispobj *where, lispobj object)
902 struct vector *vector;
905 vector = (struct vector *) where;
906 length = fixnum_value(vector->length);
907 nwords = CEILING(NWORDS(length, 1) + 2, 2);
913 trans_vector_bit(lispobj object)
915 struct vector *vector;
918 gc_assert(is_lisp_pointer(object));
920 vector = (struct vector *) native_pointer(object);
921 length = fixnum_value(vector->length);
922 nwords = CEILING(NWORDS(length, 1) + 2, 2);
924 return copy_large_unboxed_object(object, nwords);
928 size_vector_bit(lispobj *where)
930 struct vector *vector;
933 vector = (struct vector *) where;
934 length = fixnum_value(vector->length);
935 nwords = CEILING(NWORDS(length, 1) + 2, 2);
941 scav_vector_unsigned_byte_2(lispobj *where, lispobj object)
943 struct vector *vector;
946 vector = (struct vector *) where;
947 length = fixnum_value(vector->length);
948 nwords = CEILING(NWORDS(length, 2) + 2, 2);
954 trans_vector_unsigned_byte_2(lispobj object)
956 struct vector *vector;
959 gc_assert(is_lisp_pointer(object));
961 vector = (struct vector *) native_pointer(object);
962 length = fixnum_value(vector->length);
963 nwords = CEILING(NWORDS(length, 2) + 2, 2);
965 return copy_large_unboxed_object(object, nwords);
969 size_vector_unsigned_byte_2(lispobj *where)
971 struct vector *vector;
974 vector = (struct vector *) where;
975 length = fixnum_value(vector->length);
976 nwords = CEILING(NWORDS(length, 2) + 2, 2);
982 scav_vector_unsigned_byte_4(lispobj *where, lispobj object)
984 struct vector *vector;
987 vector = (struct vector *) where;
988 length = fixnum_value(vector->length);
989 nwords = CEILING(NWORDS(length, 4) + 2, 2);
995 trans_vector_unsigned_byte_4(lispobj object)
997 struct vector *vector;
1000 gc_assert(is_lisp_pointer(object));
1002 vector = (struct vector *) native_pointer(object);
1003 length = fixnum_value(vector->length);
1004 nwords = CEILING(NWORDS(length, 4) + 2, 2);
1006 return copy_large_unboxed_object(object, nwords);
1009 size_vector_unsigned_byte_4(lispobj *where)
1011 struct vector *vector;
1012 long length, nwords;
1014 vector = (struct vector *) where;
1015 length = fixnum_value(vector->length);
1016 nwords = CEILING(NWORDS(length, 4) + 2, 2);
1023 scav_vector_unsigned_byte_8(lispobj *where, lispobj object)
1025 struct vector *vector;
1026 long length, nwords;
1028 vector = (struct vector *) where;
1029 length = fixnum_value(vector->length);
1030 nwords = CEILING(NWORDS(length, 8) + 2, 2);
1035 /*********************/
1040 trans_vector_unsigned_byte_8(lispobj object)
1042 struct vector *vector;
1043 long length, nwords;
1045 gc_assert(is_lisp_pointer(object));
1047 vector = (struct vector *) native_pointer(object);
1048 length = fixnum_value(vector->length);
1049 nwords = CEILING(NWORDS(length, 8) + 2, 2);
1051 return copy_large_unboxed_object(object, nwords);
1055 size_vector_unsigned_byte_8(lispobj *where)
1057 struct vector *vector;
1058 long length, nwords;
1060 vector = (struct vector *) where;
1061 length = fixnum_value(vector->length);
1062 nwords = CEILING(NWORDS(length, 8) + 2, 2);
1069 scav_vector_unsigned_byte_16(lispobj *where, lispobj object)
1071 struct vector *vector;
1072 long length, nwords;
1074 vector = (struct vector *) where;
1075 length = fixnum_value(vector->length);
1076 nwords = CEILING(NWORDS(length, 16) + 2, 2);
1082 trans_vector_unsigned_byte_16(lispobj object)
1084 struct vector *vector;
1085 long length, nwords;
1087 gc_assert(is_lisp_pointer(object));
1089 vector = (struct vector *) native_pointer(object);
1090 length = fixnum_value(vector->length);
1091 nwords = CEILING(NWORDS(length, 16) + 2, 2);
1093 return copy_large_unboxed_object(object, nwords);
1097 size_vector_unsigned_byte_16(lispobj *where)
1099 struct vector *vector;
1100 long length, nwords;
1102 vector = (struct vector *) where;
1103 length = fixnum_value(vector->length);
1104 nwords = CEILING(NWORDS(length, 16) + 2, 2);
1110 scav_vector_unsigned_byte_32(lispobj *where, lispobj object)
1112 struct vector *vector;
1113 long length, nwords;
1115 vector = (struct vector *) where;
1116 length = fixnum_value(vector->length);
1117 nwords = CEILING(NWORDS(length, 32) + 2, 2);
1123 trans_vector_unsigned_byte_32(lispobj object)
1125 struct vector *vector;
1126 long length, nwords;
1128 gc_assert(is_lisp_pointer(object));
1130 vector = (struct vector *) native_pointer(object);
1131 length = fixnum_value(vector->length);
1132 nwords = CEILING(NWORDS(length, 32) + 2, 2);
1134 return copy_large_unboxed_object(object, nwords);
1138 size_vector_unsigned_byte_32(lispobj *where)
1140 struct vector *vector;
1141 long length, nwords;
1143 vector = (struct vector *) where;
1144 length = fixnum_value(vector->length);
1145 nwords = CEILING(NWORDS(length, 32) + 2, 2);
1150 #if N_WORD_BITS == 64
1152 scav_vector_unsigned_byte_64(lispobj *where, lispobj object)
1154 struct vector *vector;
1155 long length, nwords;
1157 vector = (struct vector *) where;
1158 length = fixnum_value(vector->length);
1159 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1165 trans_vector_unsigned_byte_64(lispobj object)
1167 struct vector *vector;
1168 long length, nwords;
1170 gc_assert(is_lisp_pointer(object));
1172 vector = (struct vector *) native_pointer(object);
1173 length = fixnum_value(vector->length);
1174 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1176 return copy_large_unboxed_object(object, nwords);
1180 size_vector_unsigned_byte_64(lispobj *where)
1182 struct vector *vector;
1183 long length, nwords;
1185 vector = (struct vector *) where;
1186 length = fixnum_value(vector->length);
1187 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1194 scav_vector_single_float(lispobj *where, lispobj object)
1196 struct vector *vector;
1197 long length, nwords;
1199 vector = (struct vector *) where;
1200 length = fixnum_value(vector->length);
1201 nwords = CEILING(NWORDS(length, 32) + 2, 2);
1207 trans_vector_single_float(lispobj object)
1209 struct vector *vector;
1210 long length, nwords;
1212 gc_assert(is_lisp_pointer(object));
1214 vector = (struct vector *) native_pointer(object);
1215 length = fixnum_value(vector->length);
1216 nwords = CEILING(NWORDS(length, 32) + 2, 2);
1218 return copy_large_unboxed_object(object, nwords);
1222 size_vector_single_float(lispobj *where)
1224 struct vector *vector;
1225 long length, nwords;
1227 vector = (struct vector *) where;
1228 length = fixnum_value(vector->length);
1229 nwords = CEILING(NWORDS(length, 32) + 2, 2);
1235 scav_vector_double_float(lispobj *where, lispobj object)
1237 struct vector *vector;
1238 long length, nwords;
1240 vector = (struct vector *) where;
1241 length = fixnum_value(vector->length);
1242 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1248 trans_vector_double_float(lispobj object)
1250 struct vector *vector;
1251 long length, nwords;
1253 gc_assert(is_lisp_pointer(object));
1255 vector = (struct vector *) native_pointer(object);
1256 length = fixnum_value(vector->length);
1257 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1259 return copy_large_unboxed_object(object, nwords);
1263 size_vector_double_float(lispobj *where)
1265 struct vector *vector;
1266 long length, nwords;
1268 vector = (struct vector *) where;
1269 length = fixnum_value(vector->length);
1270 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1275 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1277 scav_vector_long_float(lispobj *where, lispobj object)
1279 struct vector *vector;
1280 long length, nwords;
1282 vector = (struct vector *) where;
1283 length = fixnum_value(vector->length);
1284 nwords = CEILING(length *
1291 trans_vector_long_float(lispobj object)
1293 struct vector *vector;
1294 long length, nwords;
1296 gc_assert(is_lisp_pointer(object));
1298 vector = (struct vector *) native_pointer(object);
1299 length = fixnum_value(vector->length);
1300 nwords = CEILING(length * LONG_FLOAT_SIZE + 2, 2);
1302 return copy_large_unboxed_object(object, nwords);
1306 size_vector_long_float(lispobj *where)
1308 struct vector *vector;
1309 long length, nwords;
1311 vector = (struct vector *) where;
1312 length = fixnum_value(vector->length);
1313 nwords = CEILING(length * LONG_FLOAT_SIZE + 2, 2);
1320 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1322 scav_vector_complex_single_float(lispobj *where, lispobj object)
1324 struct vector *vector;
1325 long length, nwords;
1327 vector = (struct vector *) where;
1328 length = fixnum_value(vector->length);
1329 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1335 trans_vector_complex_single_float(lispobj object)
1337 struct vector *vector;
1338 long length, nwords;
1340 gc_assert(is_lisp_pointer(object));
1342 vector = (struct vector *) native_pointer(object);
1343 length = fixnum_value(vector->length);
1344 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1346 return copy_large_unboxed_object(object, nwords);
1350 size_vector_complex_single_float(lispobj *where)
1352 struct vector *vector;
1353 long length, nwords;
1355 vector = (struct vector *) where;
1356 length = fixnum_value(vector->length);
1357 nwords = CEILING(NWORDS(length, 64) + 2, 2);
1363 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1365 scav_vector_complex_double_float(lispobj *where, lispobj object)
1367 struct vector *vector;
1368 long length, nwords;
1370 vector = (struct vector *) where;
1371 length = fixnum_value(vector->length);
1372 nwords = CEILING(NWORDS(length, 128) + 2, 2);
1378 trans_vector_complex_double_float(lispobj object)
1380 struct vector *vector;
1381 long length, nwords;
1383 gc_assert(is_lisp_pointer(object));
1385 vector = (struct vector *) native_pointer(object);
1386 length = fixnum_value(vector->length);
1387 nwords = CEILING(NWORDS(length, 128) + 2, 2);
1389 return copy_large_unboxed_object(object, nwords);
1393 size_vector_complex_double_float(lispobj *where)
1395 struct vector *vector;
1396 long length, nwords;
1398 vector = (struct vector *) where;
1399 length = fixnum_value(vector->length);
1400 nwords = CEILING(NWORDS(length, 128) + 2, 2);
1407 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1409 scav_vector_complex_long_float(lispobj *where, lispobj object)
1411 struct vector *vector;
1412 long length, nwords;
1414 vector = (struct vector *) where;
1415 length = fixnum_value(vector->length);
1416 nwords = CEILING(length * (2* LONG_FLOAT_SIZE) + 2, 2);
1422 trans_vector_complex_long_float(lispobj object)
1424 struct vector *vector;
1425 long length, nwords;
1427 gc_assert(is_lisp_pointer(object));
1429 vector = (struct vector *) native_pointer(object);
1430 length = fixnum_value(vector->length);
1431 nwords = CEILING(length * (2*LONG_FLOAT_SIZE) + 2, 2);
1433 return copy_large_unboxed_object(object, nwords);
1437 size_vector_complex_long_float(lispobj *where)
1439 struct vector *vector;
1440 long length, nwords;
1442 vector = (struct vector *) where;
1443 length = fixnum_value(vector->length);
1444 nwords = CEILING(length * (2*LONG_FLOAT_SIZE) + 2, 2);
1450 #define WEAK_POINTER_NWORDS \
1451 CEILING((sizeof(struct weak_pointer) / sizeof(lispobj)), 2)
1454 trans_weak_pointer(lispobj object)
1457 #ifndef LISP_FEATURE_GENCGC
1458 struct weak_pointer *wp;
1460 gc_assert(is_lisp_pointer(object));
1462 #if defined(DEBUG_WEAK)
1463 printf("Transporting weak pointer from 0x%08x\n", object);
1466 /* Need to remember where all the weak pointers are that have */
1467 /* been transported so they can be fixed up in a post-GC pass. */
1469 copy = copy_object(object, WEAK_POINTER_NWORDS);
1470 #ifndef LISP_FEATURE_GENCGC
1471 wp = (struct weak_pointer *) native_pointer(copy);
1473 gc_assert(widetag_of(wp->header)==WEAK_POINTER_WIDETAG);
1474 /* Push the weak pointer onto the list of weak pointers. */
1475 wp->next = LOW_WORD(weak_pointers);
1482 size_weak_pointer(lispobj *where)
1484 return WEAK_POINTER_NWORDS;
1488 void scan_weak_pointers(void)
1490 struct weak_pointer *wp;
1491 for (wp = weak_pointers; wp != NULL;
1492 wp=(struct weak_pointer *)native_pointer(wp->next)) {
1493 lispobj value = wp->value;
1494 lispobj *first_pointer;
1495 gc_assert(widetag_of(wp->header)==WEAK_POINTER_WIDETAG);
1496 if (!(is_lisp_pointer(value) && from_space_p(value)))
1499 /* Now, we need to check whether the object has been forwarded. If
1500 * it has been, the weak pointer is still good and needs to be
1501 * updated. Otherwise, the weak pointer needs to be nil'ed
1504 first_pointer = (lispobj *)native_pointer(value);
1506 if (forwarding_pointer_p(first_pointer)) {
1508 (lispobj)LOW_WORD(forwarding_pointer_value(first_pointer));
1524 scav_lose(lispobj *where, lispobj object)
1526 lose("no scavenge function for object 0x%08x (widetag 0x%x)",
1527 (unsigned long)object,
1528 widetag_of(*(lispobj*)native_pointer(object)));
1530 return 0; /* bogus return value to satisfy static type checking */
1534 trans_lose(lispobj object)
1536 lose("no transport function for object 0x%08x (widetag 0x%x)",
1537 (unsigned long)object,
1538 widetag_of(*(lispobj*)native_pointer(object)));
1539 return NIL; /* bogus return value to satisfy static type checking */
1543 size_lose(lispobj *where)
1545 lose("no size function for object at 0x%08x (widetag 0x%x)",
1546 (unsigned long)where,
1547 widetag_of(LOW_WORD(where)));
1548 return 1; /* bogus return value to satisfy static type checking */
1557 gc_init_tables(void)
1561 /* Set default value in all slots of scavenge table. FIXME
1562 * replace this gnarly sizeof with something based on
1564 for (i = 0; i < ((sizeof scavtab)/(sizeof scavtab[0])); i++) {
1565 scavtab[i] = scav_lose;
1568 /* For each type which can be selected by the lowtag alone, set
1569 * multiple entries in our widetag scavenge table (one for each
1570 * possible value of the high bits).
1573 for (i = 0; i < (1<<(N_WIDETAG_BITS-N_LOWTAG_BITS)); i++) {
1574 scavtab[EVEN_FIXNUM_LOWTAG|(i<<N_LOWTAG_BITS)] = scav_immediate;
1575 scavtab[FUN_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = scav_fun_pointer;
1576 /* skipping OTHER_IMMEDIATE_0_LOWTAG */
1577 scavtab[LIST_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = scav_list_pointer;
1578 scavtab[ODD_FIXNUM_LOWTAG|(i<<N_LOWTAG_BITS)] = scav_immediate;
1579 scavtab[INSTANCE_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = scav_instance_pointer;
1580 /* skipping OTHER_IMMEDIATE_1_LOWTAG */
1581 scavtab[OTHER_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = scav_other_pointer;
1584 /* Other-pointer types (those selected by all eight bits of the
1585 * tag) get one entry each in the scavenge table. */
1586 scavtab[BIGNUM_WIDETAG] = scav_unboxed;
1587 scavtab[RATIO_WIDETAG] = scav_boxed;
1588 #if N_WORD_BITS == 64
1589 scavtab[SINGLE_FLOAT_WIDETAG] = scav_immediate;
1591 scavtab[SINGLE_FLOAT_WIDETAG] = scav_unboxed;
1593 scavtab[DOUBLE_FLOAT_WIDETAG] = scav_unboxed;
1594 #ifdef LONG_FLOAT_WIDETAG
1595 scavtab[LONG_FLOAT_WIDETAG] = scav_unboxed;
1597 scavtab[COMPLEX_WIDETAG] = scav_boxed;
1598 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
1599 scavtab[COMPLEX_SINGLE_FLOAT_WIDETAG] = scav_unboxed;
1601 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
1602 scavtab[COMPLEX_DOUBLE_FLOAT_WIDETAG] = scav_unboxed;
1604 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
1605 scavtab[COMPLEX_LONG_FLOAT_WIDETAG] = scav_unboxed;
1607 scavtab[SIMPLE_ARRAY_WIDETAG] = scav_boxed;
1608 scavtab[SIMPLE_BASE_STRING_WIDETAG] = scav_base_string;
1609 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
1610 scavtab[SIMPLE_CHARACTER_STRING_WIDETAG] = scav_character_string;
1612 scavtab[SIMPLE_BIT_VECTOR_WIDETAG] = scav_vector_bit;
1613 scavtab[SIMPLE_ARRAY_NIL_WIDETAG] = scav_vector_nil;
1614 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG] =
1615 scav_vector_unsigned_byte_2;
1616 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG] =
1617 scav_vector_unsigned_byte_4;
1618 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG] =
1619 scav_vector_unsigned_byte_8;
1620 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG] =
1621 scav_vector_unsigned_byte_8;
1622 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG] =
1623 scav_vector_unsigned_byte_16;
1624 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG] =
1625 scav_vector_unsigned_byte_16;
1626 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG
1627 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG] =
1628 scav_vector_unsigned_byte_32;
1630 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG] =
1631 scav_vector_unsigned_byte_32;
1632 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG] =
1633 scav_vector_unsigned_byte_32;
1634 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG
1635 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG] =
1636 scav_vector_unsigned_byte_64;
1638 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG
1639 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG] =
1640 scav_vector_unsigned_byte_64;
1642 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG
1643 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG] =
1644 scav_vector_unsigned_byte_64;
1646 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
1647 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG] = scav_vector_unsigned_byte_8;
1649 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
1650 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG] =
1651 scav_vector_unsigned_byte_16;
1653 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
1654 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG] =
1655 scav_vector_unsigned_byte_32;
1657 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
1658 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG] =
1659 scav_vector_unsigned_byte_32;
1661 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG
1662 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG] =
1663 scav_vector_unsigned_byte_64;
1665 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG
1666 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG] =
1667 scav_vector_unsigned_byte_64;
1669 scavtab[SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG] = scav_vector_single_float;
1670 scavtab[SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG] = scav_vector_double_float;
1671 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1672 scavtab[SIMPLE_ARRAY_LONG_FLOAT_WIDETAG] = scav_vector_long_float;
1674 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1675 scavtab[SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG] =
1676 scav_vector_complex_single_float;
1678 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1679 scavtab[SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG] =
1680 scav_vector_complex_double_float;
1682 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1683 scavtab[SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG] =
1684 scav_vector_complex_long_float;
1686 scavtab[COMPLEX_BASE_STRING_WIDETAG] = scav_boxed;
1687 #ifdef COMPLEX_CHARACTER_STRING_WIDETAG
1688 scavtab[COMPLEX_CHARACTER_STRING_WIDETAG] = scav_boxed;
1690 scavtab[COMPLEX_VECTOR_NIL_WIDETAG] = scav_boxed;
1691 scavtab[COMPLEX_BIT_VECTOR_WIDETAG] = scav_boxed;
1692 scavtab[COMPLEX_VECTOR_WIDETAG] = scav_boxed;
1693 scavtab[COMPLEX_ARRAY_WIDETAG] = scav_boxed;
1694 scavtab[CODE_HEADER_WIDETAG] = scav_code_header;
1695 #ifndef LISP_FEATURE_GENCGC /* FIXME ..._X86 ? */
1696 scavtab[SIMPLE_FUN_HEADER_WIDETAG] = scav_fun_header;
1697 scavtab[RETURN_PC_HEADER_WIDETAG] = scav_return_pc_header;
1699 #if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
1700 scavtab[CLOSURE_HEADER_WIDETAG] = scav_closure_header;
1701 scavtab[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = scav_closure_header;
1703 scavtab[CLOSURE_HEADER_WIDETAG] = scav_boxed;
1704 scavtab[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = scav_boxed;
1706 scavtab[VALUE_CELL_HEADER_WIDETAG] = scav_boxed;
1707 scavtab[SYMBOL_HEADER_WIDETAG] = scav_boxed;
1708 scavtab[CHARACTER_WIDETAG] = scav_immediate;
1709 scavtab[SAP_WIDETAG] = scav_unboxed;
1710 scavtab[UNBOUND_MARKER_WIDETAG] = scav_immediate;
1711 scavtab[INSTANCE_HEADER_WIDETAG] = scav_boxed;
1712 #ifdef LISP_FEATURE_SPARC
1713 scavtab[FDEFN_WIDETAG] = scav_boxed;
1715 scavtab[FDEFN_WIDETAG] = scav_fdefn;
1718 /* transport other table, initialized same way as scavtab */
1719 for (i = 0; i < ((sizeof transother)/(sizeof transother[0])); i++)
1720 transother[i] = trans_lose;
1721 transother[BIGNUM_WIDETAG] = trans_unboxed;
1722 transother[RATIO_WIDETAG] = trans_boxed;
1724 #if N_WORD_BITS == 64
1725 transother[SINGLE_FLOAT_WIDETAG] = trans_immediate;
1727 transother[SINGLE_FLOAT_WIDETAG] = trans_unboxed;
1729 transother[DOUBLE_FLOAT_WIDETAG] = trans_unboxed;
1730 #ifdef LONG_FLOAT_WIDETAG
1731 transother[LONG_FLOAT_WIDETAG] = trans_unboxed;
1733 transother[COMPLEX_WIDETAG] = trans_boxed;
1734 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
1735 transother[COMPLEX_SINGLE_FLOAT_WIDETAG] = trans_unboxed;
1737 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
1738 transother[COMPLEX_DOUBLE_FLOAT_WIDETAG] = trans_unboxed;
1740 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
1741 transother[COMPLEX_LONG_FLOAT_WIDETAG] = trans_unboxed;
1743 transother[SIMPLE_ARRAY_WIDETAG] = trans_boxed; /* but not GENCGC */
1744 transother[SIMPLE_BASE_STRING_WIDETAG] = trans_base_string;
1745 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
1746 transother[SIMPLE_CHARACTER_STRING_WIDETAG] = trans_character_string;
1748 transother[SIMPLE_BIT_VECTOR_WIDETAG] = trans_vector_bit;
1749 transother[SIMPLE_VECTOR_WIDETAG] = trans_vector;
1750 transother[SIMPLE_ARRAY_NIL_WIDETAG] = trans_vector_nil;
1751 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG] =
1752 trans_vector_unsigned_byte_2;
1753 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG] =
1754 trans_vector_unsigned_byte_4;
1755 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG] =
1756 trans_vector_unsigned_byte_8;
1757 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG] =
1758 trans_vector_unsigned_byte_8;
1759 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG] =
1760 trans_vector_unsigned_byte_16;
1761 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG] =
1762 trans_vector_unsigned_byte_16;
1763 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG
1764 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG] =
1765 trans_vector_unsigned_byte_32;
1767 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG] =
1768 trans_vector_unsigned_byte_32;
1769 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG] =
1770 trans_vector_unsigned_byte_32;
1771 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG
1772 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG] =
1773 trans_vector_unsigned_byte_64;
1775 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG
1776 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG] =
1777 trans_vector_unsigned_byte_64;
1779 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG
1780 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG] =
1781 trans_vector_unsigned_byte_64;
1783 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
1784 transother[SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG] =
1785 trans_vector_unsigned_byte_8;
1787 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
1788 transother[SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG] =
1789 trans_vector_unsigned_byte_16;
1791 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
1792 transother[SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG] =
1793 trans_vector_unsigned_byte_32;
1795 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
1796 transother[SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG] =
1797 trans_vector_unsigned_byte_32;
1799 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG
1800 transother[SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG] =
1801 trans_vector_unsigned_byte_64;
1803 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG
1804 transother[SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG] =
1805 trans_vector_unsigned_byte_64;
1807 transother[SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG] =
1808 trans_vector_single_float;
1809 transother[SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG] =
1810 trans_vector_double_float;
1811 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1812 transother[SIMPLE_ARRAY_LONG_FLOAT_WIDETAG] =
1813 trans_vector_long_float;
1815 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1816 transother[SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG] =
1817 trans_vector_complex_single_float;
1819 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1820 transother[SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG] =
1821 trans_vector_complex_double_float;
1823 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1824 transother[SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG] =
1825 trans_vector_complex_long_float;
1827 transother[COMPLEX_BASE_STRING_WIDETAG] = trans_boxed;
1828 #ifdef COMPLEX_CHARACTER_STRING_WIDETAG
1829 transother[COMPLEX_CHARACTER_STRING_WIDETAG] = trans_boxed;
1831 transother[COMPLEX_BIT_VECTOR_WIDETAG] = trans_boxed;
1832 transother[COMPLEX_VECTOR_NIL_WIDETAG] = trans_boxed;
1833 transother[COMPLEX_VECTOR_WIDETAG] = trans_boxed;
1834 transother[COMPLEX_ARRAY_WIDETAG] = trans_boxed;
1835 transother[CODE_HEADER_WIDETAG] = trans_code_header;
1836 transother[SIMPLE_FUN_HEADER_WIDETAG] = trans_fun_header;
1837 transother[RETURN_PC_HEADER_WIDETAG] = trans_return_pc_header;
1838 transother[CLOSURE_HEADER_WIDETAG] = trans_boxed;
1839 transother[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = trans_boxed;
1840 transother[VALUE_CELL_HEADER_WIDETAG] = trans_boxed;
1841 transother[SYMBOL_HEADER_WIDETAG] = trans_boxed;
1842 transother[CHARACTER_WIDETAG] = trans_immediate;
1843 transother[SAP_WIDETAG] = trans_unboxed;
1844 transother[UNBOUND_MARKER_WIDETAG] = trans_immediate;
1845 transother[WEAK_POINTER_WIDETAG] = trans_weak_pointer;
1846 transother[INSTANCE_HEADER_WIDETAG] = trans_boxed;
1847 transother[FDEFN_WIDETAG] = trans_boxed;
1849 /* size table, initialized the same way as scavtab */
1850 for (i = 0; i < ((sizeof sizetab)/(sizeof sizetab[0])); i++)
1851 sizetab[i] = size_lose;
1852 for (i = 0; i < (1<<(N_WIDETAG_BITS-N_LOWTAG_BITS)); i++) {
1853 sizetab[EVEN_FIXNUM_LOWTAG|(i<<N_LOWTAG_BITS)] = size_immediate;
1854 sizetab[FUN_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = size_pointer;
1855 /* skipping OTHER_IMMEDIATE_0_LOWTAG */
1856 sizetab[LIST_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = size_pointer;
1857 sizetab[ODD_FIXNUM_LOWTAG|(i<<N_LOWTAG_BITS)] = size_immediate;
1858 sizetab[INSTANCE_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = size_pointer;
1859 /* skipping OTHER_IMMEDIATE_1_LOWTAG */
1860 sizetab[OTHER_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = size_pointer;
1862 sizetab[BIGNUM_WIDETAG] = size_unboxed;
1863 sizetab[RATIO_WIDETAG] = size_boxed;
1864 #if N_WORD_BITS == 64
1865 sizetab[SINGLE_FLOAT_WIDETAG] = size_immediate;
1867 sizetab[SINGLE_FLOAT_WIDETAG] = size_unboxed;
1869 sizetab[DOUBLE_FLOAT_WIDETAG] = size_unboxed;
1870 #ifdef LONG_FLOAT_WIDETAG
1871 sizetab[LONG_FLOAT_WIDETAG] = size_unboxed;
1873 sizetab[COMPLEX_WIDETAG] = size_boxed;
1874 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
1875 sizetab[COMPLEX_SINGLE_FLOAT_WIDETAG] = size_unboxed;
1877 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
1878 sizetab[COMPLEX_DOUBLE_FLOAT_WIDETAG] = size_unboxed;
1880 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
1881 sizetab[COMPLEX_LONG_FLOAT_WIDETAG] = size_unboxed;
1883 sizetab[SIMPLE_ARRAY_WIDETAG] = size_boxed;
1884 sizetab[SIMPLE_BASE_STRING_WIDETAG] = size_base_string;
1885 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
1886 sizetab[SIMPLE_CHARACTER_STRING_WIDETAG] = size_character_string;
1888 sizetab[SIMPLE_BIT_VECTOR_WIDETAG] = size_vector_bit;
1889 sizetab[SIMPLE_VECTOR_WIDETAG] = size_vector;
1890 sizetab[SIMPLE_ARRAY_NIL_WIDETAG] = size_vector_nil;
1891 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG] =
1892 size_vector_unsigned_byte_2;
1893 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG] =
1894 size_vector_unsigned_byte_4;
1895 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG] =
1896 size_vector_unsigned_byte_8;
1897 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG] =
1898 size_vector_unsigned_byte_8;
1899 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG] =
1900 size_vector_unsigned_byte_16;
1901 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG] =
1902 size_vector_unsigned_byte_16;
1903 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG
1904 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG] =
1905 size_vector_unsigned_byte_32;
1907 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG] =
1908 size_vector_unsigned_byte_32;
1909 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG] =
1910 size_vector_unsigned_byte_32;
1911 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG
1912 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG] =
1913 size_vector_unsigned_byte_64;
1915 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG
1916 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG] =
1917 size_vector_unsigned_byte_64;
1919 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG
1920 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG] =
1921 size_vector_unsigned_byte_64;
1923 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
1924 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG] = size_vector_unsigned_byte_8;
1926 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
1927 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG] =
1928 size_vector_unsigned_byte_16;
1930 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
1931 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG] =
1932 size_vector_unsigned_byte_32;
1934 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
1935 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG] =
1936 size_vector_unsigned_byte_32;
1938 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG
1939 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG] =
1940 size_vector_unsigned_byte_64;
1942 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG
1943 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG] =
1944 size_vector_unsigned_byte_64;
1946 sizetab[SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG] = size_vector_single_float;
1947 sizetab[SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG] = size_vector_double_float;
1948 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1949 sizetab[SIMPLE_ARRAY_LONG_FLOAT_WIDETAG] = size_vector_long_float;
1951 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1952 sizetab[SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG] =
1953 size_vector_complex_single_float;
1955 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1956 sizetab[SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG] =
1957 size_vector_complex_double_float;
1959 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1960 sizetab[SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG] =
1961 size_vector_complex_long_float;
1963 sizetab[COMPLEX_BASE_STRING_WIDETAG] = size_boxed;
1964 #ifdef COMPLEX_CHARACTER_STRING_WIDETAG
1965 sizetab[COMPLEX_CHARACTER_STRING_WIDETAG] = size_boxed;
1967 sizetab[COMPLEX_VECTOR_NIL_WIDETAG] = size_boxed;
1968 sizetab[COMPLEX_BIT_VECTOR_WIDETAG] = size_boxed;
1969 sizetab[COMPLEX_VECTOR_WIDETAG] = size_boxed;
1970 sizetab[COMPLEX_ARRAY_WIDETAG] = size_boxed;
1971 sizetab[CODE_HEADER_WIDETAG] = size_code_header;
1973 /* We shouldn't see these, so just lose if it happens. */
1974 sizetab[SIMPLE_FUN_HEADER_WIDETAG] = size_function_header;
1975 sizetab[RETURN_PC_HEADER_WIDETAG] = size_return_pc_header;
1977 sizetab[CLOSURE_HEADER_WIDETAG] = size_boxed;
1978 sizetab[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = size_boxed;
1979 sizetab[VALUE_CELL_HEADER_WIDETAG] = size_boxed;
1980 sizetab[SYMBOL_HEADER_WIDETAG] = size_boxed;
1981 sizetab[CHARACTER_WIDETAG] = size_immediate;
1982 sizetab[SAP_WIDETAG] = size_unboxed;
1983 sizetab[UNBOUND_MARKER_WIDETAG] = size_immediate;
1984 sizetab[WEAK_POINTER_WIDETAG] = size_weak_pointer;
1985 sizetab[INSTANCE_HEADER_WIDETAG] = size_boxed;
1986 sizetab[FDEFN_WIDETAG] = size_boxed;
1990 /* Find the code object for the given pc, or return NULL on
1993 component_ptr_from_pc(lispobj *pc)
1995 lispobj *object = NULL;
1997 if ( (object = search_read_only_space(pc)) )
1999 else if ( (object = search_static_space(pc)) )
2002 object = search_dynamic_space(pc);
2004 if (object) /* if we found something */
2005 if (widetag_of(*object) == CODE_HEADER_WIDETAG)