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 scavtab[SINGLE_FLOAT_WIDETAG] = scav_unboxed;
1589 scavtab[DOUBLE_FLOAT_WIDETAG] = scav_unboxed;
1590 #ifdef LONG_FLOAT_WIDETAG
1591 scavtab[LONG_FLOAT_WIDETAG] = scav_unboxed;
1593 scavtab[COMPLEX_WIDETAG] = scav_boxed;
1594 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
1595 scavtab[COMPLEX_SINGLE_FLOAT_WIDETAG] = scav_unboxed;
1597 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
1598 scavtab[COMPLEX_DOUBLE_FLOAT_WIDETAG] = scav_unboxed;
1600 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
1601 scavtab[COMPLEX_LONG_FLOAT_WIDETAG] = scav_unboxed;
1603 scavtab[SIMPLE_ARRAY_WIDETAG] = scav_boxed;
1604 scavtab[SIMPLE_BASE_STRING_WIDETAG] = scav_base_string;
1605 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
1606 scavtab[SIMPLE_CHARACTER_STRING_WIDETAG] = scav_character_string;
1608 scavtab[SIMPLE_BIT_VECTOR_WIDETAG] = scav_vector_bit;
1609 scavtab[SIMPLE_ARRAY_NIL_WIDETAG] = scav_vector_nil;
1610 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG] =
1611 scav_vector_unsigned_byte_2;
1612 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG] =
1613 scav_vector_unsigned_byte_4;
1614 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG] =
1615 scav_vector_unsigned_byte_8;
1616 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG] =
1617 scav_vector_unsigned_byte_8;
1618 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG] =
1619 scav_vector_unsigned_byte_16;
1620 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG] =
1621 scav_vector_unsigned_byte_16;
1622 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG
1623 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG] =
1624 scav_vector_unsigned_byte_32;
1626 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG] =
1627 scav_vector_unsigned_byte_32;
1628 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG] =
1629 scav_vector_unsigned_byte_32;
1630 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG
1631 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG] =
1632 scav_vector_unsigned_byte_64;
1634 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG
1635 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG] =
1636 scav_vector_unsigned_byte_64;
1638 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG
1639 scavtab[SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG] =
1640 scav_vector_unsigned_byte_64;
1642 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
1643 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG] = scav_vector_unsigned_byte_8;
1645 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
1646 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG] =
1647 scav_vector_unsigned_byte_16;
1649 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
1650 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG] =
1651 scav_vector_unsigned_byte_32;
1653 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
1654 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG] =
1655 scav_vector_unsigned_byte_32;
1657 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG
1658 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG] =
1659 scav_vector_unsigned_byte_64;
1661 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG
1662 scavtab[SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG] =
1663 scav_vector_unsigned_byte_64;
1665 scavtab[SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG] = scav_vector_single_float;
1666 scavtab[SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG] = scav_vector_double_float;
1667 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1668 scavtab[SIMPLE_ARRAY_LONG_FLOAT_WIDETAG] = scav_vector_long_float;
1670 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1671 scavtab[SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG] =
1672 scav_vector_complex_single_float;
1674 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1675 scavtab[SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG] =
1676 scav_vector_complex_double_float;
1678 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1679 scavtab[SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG] =
1680 scav_vector_complex_long_float;
1682 scavtab[COMPLEX_BASE_STRING_WIDETAG] = scav_boxed;
1683 #ifdef COMPLEX_CHARACTER_STRING_WIDETAG
1684 scavtab[COMPLEX_CHARACTER_STRING_WIDETAG] = scav_boxed;
1686 scavtab[COMPLEX_VECTOR_NIL_WIDETAG] = scav_boxed;
1687 scavtab[COMPLEX_BIT_VECTOR_WIDETAG] = scav_boxed;
1688 scavtab[COMPLEX_VECTOR_WIDETAG] = scav_boxed;
1689 scavtab[COMPLEX_ARRAY_WIDETAG] = scav_boxed;
1690 scavtab[CODE_HEADER_WIDETAG] = scav_code_header;
1691 #ifndef LISP_FEATURE_GENCGC /* FIXME ..._X86 ? */
1692 scavtab[SIMPLE_FUN_HEADER_WIDETAG] = scav_fun_header;
1693 scavtab[RETURN_PC_HEADER_WIDETAG] = scav_return_pc_header;
1695 #if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
1696 scavtab[CLOSURE_HEADER_WIDETAG] = scav_closure_header;
1697 scavtab[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = scav_closure_header;
1699 scavtab[CLOSURE_HEADER_WIDETAG] = scav_boxed;
1700 scavtab[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = scav_boxed;
1702 scavtab[VALUE_CELL_HEADER_WIDETAG] = scav_boxed;
1703 scavtab[SYMBOL_HEADER_WIDETAG] = scav_boxed;
1704 scavtab[CHARACTER_WIDETAG] = scav_immediate;
1705 scavtab[SAP_WIDETAG] = scav_unboxed;
1706 scavtab[UNBOUND_MARKER_WIDETAG] = scav_immediate;
1707 scavtab[INSTANCE_HEADER_WIDETAG] = scav_boxed;
1708 #ifdef LISP_FEATURE_SPARC
1709 scavtab[FDEFN_WIDETAG] = scav_boxed;
1711 scavtab[FDEFN_WIDETAG] = scav_fdefn;
1714 /* transport other table, initialized same way as scavtab */
1715 for (i = 0; i < ((sizeof transother)/(sizeof transother[0])); i++)
1716 transother[i] = trans_lose;
1717 transother[BIGNUM_WIDETAG] = trans_unboxed;
1718 transother[RATIO_WIDETAG] = trans_boxed;
1719 transother[SINGLE_FLOAT_WIDETAG] = trans_unboxed;
1720 transother[DOUBLE_FLOAT_WIDETAG] = trans_unboxed;
1721 #ifdef LONG_FLOAT_WIDETAG
1722 transother[LONG_FLOAT_WIDETAG] = trans_unboxed;
1724 transother[COMPLEX_WIDETAG] = trans_boxed;
1725 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
1726 transother[COMPLEX_SINGLE_FLOAT_WIDETAG] = trans_unboxed;
1728 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
1729 transother[COMPLEX_DOUBLE_FLOAT_WIDETAG] = trans_unboxed;
1731 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
1732 transother[COMPLEX_LONG_FLOAT_WIDETAG] = trans_unboxed;
1734 transother[SIMPLE_ARRAY_WIDETAG] = trans_boxed; /* but not GENCGC */
1735 transother[SIMPLE_BASE_STRING_WIDETAG] = trans_base_string;
1736 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
1737 transother[SIMPLE_CHARACTER_STRING_WIDETAG] = trans_character_string;
1739 transother[SIMPLE_BIT_VECTOR_WIDETAG] = trans_vector_bit;
1740 transother[SIMPLE_VECTOR_WIDETAG] = trans_vector;
1741 transother[SIMPLE_ARRAY_NIL_WIDETAG] = trans_vector_nil;
1742 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG] =
1743 trans_vector_unsigned_byte_2;
1744 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG] =
1745 trans_vector_unsigned_byte_4;
1746 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG] =
1747 trans_vector_unsigned_byte_8;
1748 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG] =
1749 trans_vector_unsigned_byte_8;
1750 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG] =
1751 trans_vector_unsigned_byte_16;
1752 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG] =
1753 trans_vector_unsigned_byte_16;
1754 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG
1755 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG] =
1756 trans_vector_unsigned_byte_32;
1758 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG] =
1759 trans_vector_unsigned_byte_32;
1760 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG] =
1761 trans_vector_unsigned_byte_32;
1762 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG
1763 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG] =
1764 trans_vector_unsigned_byte_64;
1766 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG
1767 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG] =
1768 trans_vector_unsigned_byte_64;
1770 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG
1771 transother[SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG] =
1772 trans_vector_unsigned_byte_64;
1774 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
1775 transother[SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG] =
1776 trans_vector_unsigned_byte_8;
1778 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
1779 transother[SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG] =
1780 trans_vector_unsigned_byte_16;
1782 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
1783 transother[SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG] =
1784 trans_vector_unsigned_byte_32;
1786 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
1787 transother[SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG] =
1788 trans_vector_unsigned_byte_32;
1790 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG
1791 transother[SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG] =
1792 trans_vector_unsigned_byte_64;
1794 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG
1795 transother[SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG] =
1796 trans_vector_unsigned_byte_64;
1798 transother[SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG] =
1799 trans_vector_single_float;
1800 transother[SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG] =
1801 trans_vector_double_float;
1802 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1803 transother[SIMPLE_ARRAY_LONG_FLOAT_WIDETAG] =
1804 trans_vector_long_float;
1806 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1807 transother[SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG] =
1808 trans_vector_complex_single_float;
1810 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1811 transother[SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG] =
1812 trans_vector_complex_double_float;
1814 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1815 transother[SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG] =
1816 trans_vector_complex_long_float;
1818 transother[COMPLEX_BASE_STRING_WIDETAG] = trans_boxed;
1819 #ifdef COMPLEX_CHARACTER_STRING_WIDETAG
1820 transother[COMPLEX_CHARACTER_STRING_WIDETAG] = trans_boxed;
1822 transother[COMPLEX_BIT_VECTOR_WIDETAG] = trans_boxed;
1823 transother[COMPLEX_VECTOR_NIL_WIDETAG] = trans_boxed;
1824 transother[COMPLEX_VECTOR_WIDETAG] = trans_boxed;
1825 transother[COMPLEX_ARRAY_WIDETAG] = trans_boxed;
1826 transother[CODE_HEADER_WIDETAG] = trans_code_header;
1827 transother[SIMPLE_FUN_HEADER_WIDETAG] = trans_fun_header;
1828 transother[RETURN_PC_HEADER_WIDETAG] = trans_return_pc_header;
1829 transother[CLOSURE_HEADER_WIDETAG] = trans_boxed;
1830 transother[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = trans_boxed;
1831 transother[VALUE_CELL_HEADER_WIDETAG] = trans_boxed;
1832 transother[SYMBOL_HEADER_WIDETAG] = trans_boxed;
1833 transother[CHARACTER_WIDETAG] = trans_immediate;
1834 transother[SAP_WIDETAG] = trans_unboxed;
1835 transother[UNBOUND_MARKER_WIDETAG] = trans_immediate;
1836 transother[WEAK_POINTER_WIDETAG] = trans_weak_pointer;
1837 transother[INSTANCE_HEADER_WIDETAG] = trans_boxed;
1838 transother[FDEFN_WIDETAG] = trans_boxed;
1840 /* size table, initialized the same way as scavtab */
1841 for (i = 0; i < ((sizeof sizetab)/(sizeof sizetab[0])); i++)
1842 sizetab[i] = size_lose;
1843 for (i = 0; i < (1<<(N_WIDETAG_BITS-N_LOWTAG_BITS)); i++) {
1844 sizetab[EVEN_FIXNUM_LOWTAG|(i<<N_LOWTAG_BITS)] = size_immediate;
1845 sizetab[FUN_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = size_pointer;
1846 /* skipping OTHER_IMMEDIATE_0_LOWTAG */
1847 sizetab[LIST_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = size_pointer;
1848 sizetab[ODD_FIXNUM_LOWTAG|(i<<N_LOWTAG_BITS)] = size_immediate;
1849 sizetab[INSTANCE_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = size_pointer;
1850 /* skipping OTHER_IMMEDIATE_1_LOWTAG */
1851 sizetab[OTHER_POINTER_LOWTAG|(i<<N_LOWTAG_BITS)] = size_pointer;
1853 sizetab[BIGNUM_WIDETAG] = size_unboxed;
1854 sizetab[RATIO_WIDETAG] = size_boxed;
1855 sizetab[SINGLE_FLOAT_WIDETAG] = size_unboxed;
1856 sizetab[DOUBLE_FLOAT_WIDETAG] = size_unboxed;
1857 #ifdef LONG_FLOAT_WIDETAG
1858 sizetab[LONG_FLOAT_WIDETAG] = size_unboxed;
1860 sizetab[COMPLEX_WIDETAG] = size_boxed;
1861 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
1862 sizetab[COMPLEX_SINGLE_FLOAT_WIDETAG] = size_unboxed;
1864 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
1865 sizetab[COMPLEX_DOUBLE_FLOAT_WIDETAG] = size_unboxed;
1867 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
1868 sizetab[COMPLEX_LONG_FLOAT_WIDETAG] = size_unboxed;
1870 sizetab[SIMPLE_ARRAY_WIDETAG] = size_boxed;
1871 sizetab[SIMPLE_BASE_STRING_WIDETAG] = size_base_string;
1872 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
1873 sizetab[SIMPLE_CHARACTER_STRING_WIDETAG] = size_character_string;
1875 sizetab[SIMPLE_BIT_VECTOR_WIDETAG] = size_vector_bit;
1876 sizetab[SIMPLE_VECTOR_WIDETAG] = size_vector;
1877 sizetab[SIMPLE_ARRAY_NIL_WIDETAG] = size_vector_nil;
1878 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG] =
1879 size_vector_unsigned_byte_2;
1880 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG] =
1881 size_vector_unsigned_byte_4;
1882 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG] =
1883 size_vector_unsigned_byte_8;
1884 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG] =
1885 size_vector_unsigned_byte_8;
1886 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG] =
1887 size_vector_unsigned_byte_16;
1888 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG] =
1889 size_vector_unsigned_byte_16;
1890 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG
1891 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG] =
1892 size_vector_unsigned_byte_32;
1894 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG] =
1895 size_vector_unsigned_byte_32;
1896 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG] =
1897 size_vector_unsigned_byte_32;
1898 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG
1899 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG] =
1900 size_vector_unsigned_byte_64;
1902 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG
1903 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG] =
1904 size_vector_unsigned_byte_64;
1906 #ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG
1907 sizetab[SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG] =
1908 size_vector_unsigned_byte_64;
1910 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
1911 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG] = size_vector_unsigned_byte_8;
1913 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
1914 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG] =
1915 size_vector_unsigned_byte_16;
1917 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
1918 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG] =
1919 size_vector_unsigned_byte_32;
1921 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
1922 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG] =
1923 size_vector_unsigned_byte_32;
1925 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG
1926 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG] =
1927 size_vector_unsigned_byte_64;
1929 #ifdef SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG
1930 sizetab[SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG] =
1931 size_vector_unsigned_byte_64;
1933 sizetab[SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG] = size_vector_single_float;
1934 sizetab[SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG] = size_vector_double_float;
1935 #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
1936 sizetab[SIMPLE_ARRAY_LONG_FLOAT_WIDETAG] = size_vector_long_float;
1938 #ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
1939 sizetab[SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG] =
1940 size_vector_complex_single_float;
1942 #ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
1943 sizetab[SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG] =
1944 size_vector_complex_double_float;
1946 #ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
1947 sizetab[SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG] =
1948 size_vector_complex_long_float;
1950 sizetab[COMPLEX_BASE_STRING_WIDETAG] = size_boxed;
1951 #ifdef COMPLEX_CHARACTER_STRING_WIDETAG
1952 sizetab[COMPLEX_CHARACTER_STRING_WIDETAG] = size_boxed;
1954 sizetab[COMPLEX_VECTOR_NIL_WIDETAG] = size_boxed;
1955 sizetab[COMPLEX_BIT_VECTOR_WIDETAG] = size_boxed;
1956 sizetab[COMPLEX_VECTOR_WIDETAG] = size_boxed;
1957 sizetab[COMPLEX_ARRAY_WIDETAG] = size_boxed;
1958 sizetab[CODE_HEADER_WIDETAG] = size_code_header;
1960 /* We shouldn't see these, so just lose if it happens. */
1961 sizetab[SIMPLE_FUN_HEADER_WIDETAG] = size_function_header;
1962 sizetab[RETURN_PC_HEADER_WIDETAG] = size_return_pc_header;
1964 sizetab[CLOSURE_HEADER_WIDETAG] = size_boxed;
1965 sizetab[FUNCALLABLE_INSTANCE_HEADER_WIDETAG] = size_boxed;
1966 sizetab[VALUE_CELL_HEADER_WIDETAG] = size_boxed;
1967 sizetab[SYMBOL_HEADER_WIDETAG] = size_boxed;
1968 sizetab[CHARACTER_WIDETAG] = size_immediate;
1969 sizetab[SAP_WIDETAG] = size_unboxed;
1970 sizetab[UNBOUND_MARKER_WIDETAG] = size_immediate;
1971 sizetab[WEAK_POINTER_WIDETAG] = size_weak_pointer;
1972 sizetab[INSTANCE_HEADER_WIDETAG] = size_boxed;
1973 sizetab[FDEFN_WIDETAG] = size_boxed;
1977 /* Find the code object for the given pc, or return NULL on
1980 component_ptr_from_pc(lispobj *pc)
1982 lispobj *object = NULL;
1984 if ( (object = search_read_only_space(pc)) )
1986 else if ( (object = search_static_space(pc)) )
1989 object = search_dynamic_space(pc);
1991 if (object) /* if we found something */
1992 if (widetag_of(*object) == CODE_HEADER_WIDETAG)