X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fpurify.c;h=f64e290bbb626068dc4c6d0d98cf52115d8ae1f5;hb=4fa6bd72374a1f1a715cfcac618f54ab4cb6b689;hp=18a310c013df55c1f92e2331fb8d7de475cdec10;hpb=cea4896b2482b7b2b429c1631d774b4cfbc0efba;p=sbcl.git diff --git a/src/runtime/purify.c b/src/runtime/purify.c index 18a310c..f64e290 100644 --- a/src/runtime/purify.c +++ b/src/runtime/purify.c @@ -16,24 +16,32 @@ #include #include #include +#include +#include +#include "sbcl.h" #include "runtime.h" #include "os.h" -#include "sbcl.h" #include "globals.h" #include "validate.h" #include "interrupt.h" #include "purify.h" #include "interr.h" -#ifdef GENCGC -#include "gencgc.h" -#endif +#include "gc.h" +#include "gc-internal.h" +#include "thread.h" +#include "genesis/primitive-objects.h" +#include "genesis/static-symbols.h" -#undef PRINTNOISE +#define PRINTNOISE -#if defined(ibmrt) || defined(__i386__) +#if defined(LISP_FEATURE_X86) +/* again, what's so special about the x86 that this is differently + * visible there than on other platforms? -dan 20010125 + */ static lispobj *dynamic_space_free_pointer; #endif +extern unsigned long bytes_consed_between_gcs; #define gc_abort() \ lose("GC invariant lost, file \"%s\", line %d", __FILE__, __LINE__) @@ -59,7 +67,8 @@ static lispobj *pscav(lispobj *addr, int nwords, boolean constant); #define LATERBLOCKSIZE 1020 #define LATERMAXCOUNT 10 -static struct later { +static struct +later { struct later *next; union { lispobj *ptr; @@ -71,18 +80,19 @@ static int later_count = 0; #define CEILING(x,y) (((x) + ((y) - 1)) & (~((y) - 1))) #define NWORDS(x,y) (CEILING((x),(y)) / (y)) +/* FIXME: Shouldn't this be defined in sbcl.h? See also notes in + * cheneygc.c */ + #ifdef sparc -#define RAW_ADDR_OFFSET 0 +#define FUN_RAW_ADDR_OFFSET 0 #else -#define RAW_ADDR_OFFSET (6*sizeof(lispobj) - type_FunctionPointer) +#define FUN_RAW_ADDR_OFFSET (6*sizeof(lispobj) - FUN_POINTER_LOWTAG) #endif static boolean forwarding_pointer_p(lispobj obj) { - lispobj *ptr; - - ptr = (lispobj *)obj; + lispobj *ptr = native_pointer(obj); return ((static_end <= ptr && ptr <= static_free) || (read_only_end <= ptr && ptr <= read_only_free)); @@ -91,12 +101,10 @@ forwarding_pointer_p(lispobj obj) static boolean dynamic_pointer_p(lispobj ptr) { -#ifndef __i386__ - /* KLUDGE: This has an implicit dependence on the ordering of - * address spaces, and is therefore basically wrong. I'd fix it, - * but I don't have a non-386 port to test it on. Porters are - * encouraged to fix it. -- WHN 2000-10-17 */ - return (ptr >= (lispobj)DYNAMIC_SPACE_START); +#ifndef LISP_FEATURE_GENCGC + return (ptr >= (lispobj)current_dynamic_space + && + ptr < (lispobj)dynamic_space_free_pointer); #else /* Be more conservative, and remember, this is a maybe. */ return (ptr >= (lispobj)DYNAMIC_SPACE_START @@ -105,113 +113,28 @@ dynamic_pointer_p(lispobj ptr) #endif } - -#ifdef __i386__ - -#ifdef WANT_CGC -/* original x86/CGC stack scavenging code by Paul Werkowski */ - -static int -maybe_can_move_p(lispobj thing) -{ - lispobj *thingp,header; - if (dynamic_pointer_p(thing)) { /* in dynamic space */ - thingp = (lispobj*)PTR(thing); - header = *thingp; - if(Pointerp(header) && forwarding_pointer_p(header)) - return -1; /* must change it */ - if(LowtagOf(thing) == type_ListPointer) - return type_ListPointer; /* can we check this somehow */ - else if (thing & 3) { /* not fixnum */ - int kind = TypeOf(header); - /* printf(" %x %x",header,kind); */ - switch (kind) { /* something with a header */ - case type_Bignum: - case type_SingleFloat: - case type_DoubleFloat: -#ifdef type_LongFloat - case type_LongFloat: -#endif - case type_Sap: - case type_SimpleVector: - case type_SimpleString: - case type_SimpleBitVector: - case type_SimpleArrayUnsignedByte2: - case type_SimpleArrayUnsignedByte4: - case type_SimpleArrayUnsignedByte8: - case type_SimpleArrayUnsignedByte16: - case type_SimpleArrayUnsignedByte32: -#ifdef type_SimpleArraySignedByte8 - case type_SimpleArraySignedByte8: -#endif -#ifdef type_SimpleArraySignedByte16 - case type_SimpleArraySignedByte16: -#endif -#ifdef type_SimpleArraySignedByte30 - case type_SimpleArraySignedByte30: -#endif -#ifdef type_SimpleArraySignedByte32 - case type_SimpleArraySignedByte32: -#endif - case type_SimpleArraySingleFloat: - case type_SimpleArrayDoubleFloat: -#ifdef type_SimpleArrayLongFloat - case type_SimpleArrayLongFloat: -#endif -#ifdef type_SimpleArrayComplexSingleFloat - case type_SimpleArrayComplexSingleFloat: -#endif -#ifdef type_SimpleArrayComplexDoubleFloat - case type_SimpleArrayComplexDoubleFloat: -#endif -#ifdef type_SimpleArrayComplexLongFloat - case type_SimpleArrayComplexLongFloat: -#endif - case type_CodeHeader: - case type_FunctionHeader: - case type_ClosureFunctionHeader: - case type_ReturnPcHeader: - case type_ClosureHeader: - case type_FuncallableInstanceHeader: - case type_InstanceHeader: - case type_ValueCellHeader: - case type_ByteCodeFunction: - case type_ByteCodeClosure: - case type_WeakPointer: - case type_Fdefn: - return kind; - break; - default: - return 0; - }}} - return 0; -} - -static int pverbose=0; -#define PVERBOSE pverbose -static void -carefully_pscav_stack(lispobj*lowaddr, lispobj*base) +static inline lispobj * +newspace_alloc(int nwords, int constantp) { - lispobj*sp = lowaddr; - while (sp < base) - { int k; - lispobj thing = *sp; - if((unsigned)thing & 0x3) /* may be pointer */ - { - /* need to check for valid float/double? */ - k = maybe_can_move_p(thing); - if(PVERBOSE)printf("%8x %8x %d\n",sp, thing, k); - if(k) - pscav(sp, 1, 0); - } - sp++; + lispobj *ret; + nwords=CEILING(nwords,2); + if(constantp) { + ret=read_only_free; + read_only_free+=nwords; + } else { + ret=static_free; + static_free+=nwords; } + return ret; } -#endif -#ifdef GENCGC + + +#ifdef LISP_FEATURE_X86 + +#ifdef LISP_FEATURE_GENCGC /* - * Enhanced x86/GENCGC stack scavenging by Douglas Crosher. + * enhanced x86/GENCGC stack scavenging by Douglas Crosher * * Scavenging the stack on the i386 is problematic due to conservative * roots and raw return addresses. Here it is handled in two passes: @@ -222,197 +145,219 @@ carefully_pscav_stack(lispobj*lowaddr, lispobj*base) static unsigned pointer_filter_verbose = 0; +/* FIXME: This is substantially the same code as + * possibly_valid_dynamic_space_pointer in gencgc.c. The only + * relevant difference seems to be that the gencgc code also checks + * for raw pointers into Code objects, whereas in purify these are + * checked separately in setup_i386_stack_scav - they go onto + * valid_stack_ra_locations instead of just valid_stack_locations */ + static int valid_dynamic_space_pointer(lispobj *pointer, lispobj *start_addr) { - /* If it's not a return address then it needs to be a valid Lisp - * pointer. */ - if (!Pointerp((lispobj)pointer)) - return 0; + /* If it's not a return address then it needs to be a valid Lisp + * pointer. */ + if (!is_lisp_pointer((lispobj)pointer)) + return 0; - /* Check that the object pointed to is consistent with the pointer - * low tag. */ - switch (LowtagOf((lispobj)pointer)) { - case type_FunctionPointer: - /* Start_addr should be the enclosing code object, or a closure - * header. */ - switch (TypeOf(*start_addr)) { - case type_CodeHeader: - /* This case is probably caught above. */ - break; - case type_ClosureHeader: - case type_FuncallableInstanceHeader: - case type_ByteCodeFunction: - case type_ByteCodeClosure: - if ((int)pointer != ((int)start_addr+type_FunctionPointer)) { + /* Check that the object pointed to is consistent with the pointer + * low tag. */ + switch (lowtag_of((lispobj)pointer)) { + case FUN_POINTER_LOWTAG: + /* Start_addr should be the enclosing code object, or a closure + * header. */ + switch (widetag_of(*start_addr)) { + case CODE_HEADER_WIDETAG: + /* This case is probably caught above. */ + break; + case CLOSURE_HEADER_WIDETAG: + case FUNCALLABLE_INSTANCE_HEADER_WIDETAG: + if ((int)pointer != ((int)start_addr+FUN_POINTER_LOWTAG)) { + if (pointer_filter_verbose) { + fprintf(stderr,"*Wf2: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); + } + return 0; + } + break; + default: + if (pointer_filter_verbose) { + fprintf(stderr,"*Wf3: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); + } + return 0; + } + break; + case LIST_POINTER_LOWTAG: + if ((int)pointer != ((int)start_addr+LIST_POINTER_LOWTAG)) { + if (pointer_filter_verbose) + fprintf(stderr,"*Wl1: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); + return 0; + } + /* Is it plausible cons? */ + if ((is_lisp_pointer(start_addr[0]) + || ((start_addr[0] & 3) == 0) /* fixnum */ + || (widetag_of(start_addr[0]) == BASE_CHAR_WIDETAG) + || (widetag_of(start_addr[0]) == UNBOUND_MARKER_WIDETAG)) + && (is_lisp_pointer(start_addr[1]) + || ((start_addr[1] & 3) == 0) /* fixnum */ + || (widetag_of(start_addr[1]) == BASE_CHAR_WIDETAG) + || (widetag_of(start_addr[1]) == UNBOUND_MARKER_WIDETAG))) { + break; + } else { + if (pointer_filter_verbose) { + fprintf(stderr,"*Wl2: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); + } + return 0; + } + case INSTANCE_POINTER_LOWTAG: + if ((int)pointer != ((int)start_addr+INSTANCE_POINTER_LOWTAG)) { + if (pointer_filter_verbose) { + fprintf(stderr,"*Wi1: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); + } + return 0; + } + if (widetag_of(start_addr[0]) != INSTANCE_HEADER_WIDETAG) { + if (pointer_filter_verbose) { + fprintf(stderr,"*Wi2: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); + } + return 0; + } + break; + case OTHER_POINTER_LOWTAG: + if ((int)pointer != ((int)start_addr+OTHER_POINTER_LOWTAG)) { + if (pointer_filter_verbose) { + fprintf(stderr,"*Wo1: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); + } + return 0; + } + /* Is it plausible? Not a cons. XXX should check the headers. */ + if (is_lisp_pointer(start_addr[0]) || ((start_addr[0] & 3) == 0)) { + if (pointer_filter_verbose) { + fprintf(stderr,"*Wo2: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); + } + return 0; + } + switch (widetag_of(start_addr[0])) { + case UNBOUND_MARKER_WIDETAG: + case BASE_CHAR_WIDETAG: + if (pointer_filter_verbose) { + fprintf(stderr,"*Wo3: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); + } + return 0; + + /* only pointed to by function pointers? */ + case CLOSURE_HEADER_WIDETAG: + case FUNCALLABLE_INSTANCE_HEADER_WIDETAG: + if (pointer_filter_verbose) { + fprintf(stderr,"*Wo4: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); + } + return 0; + + case INSTANCE_HEADER_WIDETAG: + if (pointer_filter_verbose) { + fprintf(stderr,"*Wo5: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); + } + return 0; + + /* the valid other immediate pointer objects */ + case SIMPLE_VECTOR_WIDETAG: + case RATIO_WIDETAG: + case COMPLEX_WIDETAG: +#ifdef COMPLEX_SINGLE_FLOAT_WIDETAG + case COMPLEX_SINGLE_FLOAT_WIDETAG: +#endif +#ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG + case COMPLEX_DOUBLE_FLOAT_WIDETAG: +#endif +#ifdef COMPLEX_LONG_FLOAT_WIDETAG + case COMPLEX_LONG_FLOAT_WIDETAG: +#endif + case SIMPLE_ARRAY_WIDETAG: + case COMPLEX_BASE_STRING_WIDETAG: + case COMPLEX_VECTOR_NIL_WIDETAG: + case COMPLEX_BIT_VECTOR_WIDETAG: + case COMPLEX_VECTOR_WIDETAG: + case COMPLEX_ARRAY_WIDETAG: + case VALUE_CELL_HEADER_WIDETAG: + case SYMBOL_HEADER_WIDETAG: + case FDEFN_WIDETAG: + case CODE_HEADER_WIDETAG: + case BIGNUM_WIDETAG: + case SINGLE_FLOAT_WIDETAG: + case DOUBLE_FLOAT_WIDETAG: +#ifdef LONG_FLOAT_WIDETAG + case LONG_FLOAT_WIDETAG: +#endif + case SIMPLE_ARRAY_NIL_WIDETAG: + case SIMPLE_BASE_STRING_WIDETAG: + case SIMPLE_BIT_VECTOR_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG: +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG: +#endif +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG: +#endif +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG: +#endif +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG: +#endif + case SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG: + case SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG: +#ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG + case SIMPLE_ARRAY_LONG_FLOAT_WIDETAG: +#endif +#ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG + case SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG: +#endif +#ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG + case SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG: +#endif +#ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG + case SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG: +#endif + case SAP_WIDETAG: + case WEAK_POINTER_WIDETAG: + break; + + default: + if (pointer_filter_verbose) { + fprintf(stderr,"*Wo6: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); + } + return 0; + } + break; + default: if (pointer_filter_verbose) { - fprintf(stderr,"*Wf2: %x %x %x\n", pointer, start_addr, *start_addr); + fprintf(stderr,"*W?: %x %x %x\n", (unsigned int) pointer, + (unsigned int) start_addr, *start_addr); } return 0; - } - break; - default: - if (pointer_filter_verbose) { - fprintf(stderr,"*Wf3: %x %x %x\n", pointer, start_addr, *start_addr); - } - return 0; - } - break; - case type_ListPointer: - if ((int)pointer != ((int)start_addr+type_ListPointer)) { - if (pointer_filter_verbose) - fprintf(stderr,"*Wl1: %x %x %x\n", pointer, start_addr, *start_addr); - return 0; } - /* Is it plausible cons? */ - if((Pointerp(start_addr[0]) - || ((start_addr[0] & 3) == 0) /* fixnum */ - || (TypeOf(start_addr[0]) == type_BaseChar) - || (TypeOf(start_addr[0]) == type_UnboundMarker)) - && (Pointerp(start_addr[1]) - || ((start_addr[1] & 3) == 0) /* fixnum */ - || (TypeOf(start_addr[1]) == type_BaseChar) - || (TypeOf(start_addr[1]) == type_UnboundMarker))) { - break; - } else { - if (pointer_filter_verbose) { - fprintf(stderr,"*Wl2: %x %x %x\n", pointer, start_addr, *start_addr); - } - return 0; - } - case type_InstancePointer: - if ((int)pointer != ((int)start_addr+type_InstancePointer)) { - if (pointer_filter_verbose) { - fprintf(stderr,"*Wi1: %x %x %x\n", pointer, start_addr, *start_addr); - } - return 0; - } - if (TypeOf(start_addr[0]) != type_InstanceHeader) { - if (pointer_filter_verbose) { - fprintf(stderr,"*Wi2: %x %x %x\n", pointer, start_addr, *start_addr); - } - return 0; - } - break; - case type_OtherPointer: - if ((int)pointer != ((int)start_addr+type_OtherPointer)) { - if (pointer_filter_verbose) { - fprintf(stderr,"*Wo1: %x %x %x\n", pointer, start_addr, *start_addr); - } - return 0; - } - /* Is it plausible? Not a cons. X should check the headers. */ - if(Pointerp(start_addr[0]) || ((start_addr[0] & 3) == 0)) { - if (pointer_filter_verbose) { - fprintf(stderr,"*Wo2: %x %x %x\n", pointer, start_addr, *start_addr); - } - return 0; - } - switch (TypeOf(start_addr[0])) { - case type_UnboundMarker: - case type_BaseChar: - if (pointer_filter_verbose) { - fprintf(stderr,"*Wo3: %x %x %x\n", pointer, start_addr, *start_addr); - } - return 0; - - /* only pointed to by function pointers? */ - case type_ClosureHeader: - case type_FuncallableInstanceHeader: - case type_ByteCodeFunction: - case type_ByteCodeClosure: - if (pointer_filter_verbose) { - fprintf(stderr,"*Wo4: %x %x %x\n", pointer, start_addr, *start_addr); - } - return 0; - - case type_InstanceHeader: - if (pointer_filter_verbose) { - fprintf(stderr,"*Wo5: %x %x %x\n", pointer, start_addr, *start_addr); - } - return 0; - - /* the valid other immediate pointer objects */ - case type_SimpleVector: - case type_Ratio: - case type_Complex: -#ifdef type_ComplexSingleFloat - case type_ComplexSingleFloat: -#endif -#ifdef type_ComplexDoubleFloat - case type_ComplexDoubleFloat: -#endif -#ifdef type_ComplexLongFloat - case type_ComplexLongFloat: -#endif - case type_SimpleArray: - case type_ComplexString: - case type_ComplexBitVector: - case type_ComplexVector: - case type_ComplexArray: - case type_ValueCellHeader: - case type_SymbolHeader: - case type_Fdefn: - case type_CodeHeader: - case type_Bignum: - case type_SingleFloat: - case type_DoubleFloat: -#ifdef type_LongFloat - case type_LongFloat: -#endif - case type_SimpleString: - case type_SimpleBitVector: - case type_SimpleArrayUnsignedByte2: - case type_SimpleArrayUnsignedByte4: - case type_SimpleArrayUnsignedByte8: - case type_SimpleArrayUnsignedByte16: - case type_SimpleArrayUnsignedByte32: -#ifdef type_SimpleArraySignedByte8 - case type_SimpleArraySignedByte8: -#endif -#ifdef type_SimpleArraySignedByte16 - case type_SimpleArraySignedByte16: -#endif -#ifdef type_SimpleArraySignedByte30 - case type_SimpleArraySignedByte30: -#endif -#ifdef type_SimpleArraySignedByte32 - case type_SimpleArraySignedByte32: -#endif - case type_SimpleArraySingleFloat: - case type_SimpleArrayDoubleFloat: -#ifdef type_SimpleArrayLongFloat - case type_SimpleArrayLongFloat: -#endif -#ifdef type_SimpleArrayComplexSingleFloat - case type_SimpleArrayComplexSingleFloat: -#endif -#ifdef type_SimpleArrayComplexDoubleFloat - case type_SimpleArrayComplexDoubleFloat: -#endif -#ifdef type_SimpleArrayComplexLongFloat - case type_SimpleArrayComplexLongFloat: -#endif - case type_Sap: - case type_WeakPointer: - break; - - default: - if (pointer_filter_verbose) { - fprintf(stderr,"*Wo6: %x %x %x\n", pointer, start_addr, *start_addr); - } - return 0; - } - break; - default: - if (pointer_filter_verbose) { - fprintf(stderr,"*W?: %x %x %x\n", pointer, start_addr, *start_addr); - } - return 0; - } - /* looks good */ - return 1; + /* looks good */ + return 1; } #define MAX_STACK_POINTERS 256 @@ -428,60 +373,66 @@ unsigned int num_valid_stack_ra_locations; static void setup_i386_stack_scav(lispobj *lowaddr, lispobj *base) { - lispobj *sp = lowaddr; - num_valid_stack_locations = 0; - num_valid_stack_ra_locations = 0; - for (sp = lowaddr; sp < base; sp++) { - lispobj thing = *sp; - /* Find the object start address */ - lispobj *start_addr = search_dynamic_space((void *)thing); - if (start_addr) { - /* We need to allow raw pointers into Code objects for return - * addresses. This will also pick up pointers to functions in code - * objects. */ - if (TypeOf(*start_addr) == type_CodeHeader) { - gc_assert(num_valid_stack_ra_locations < MAX_STACK_RETURN_ADDRESSES); - valid_stack_ra_locations[num_valid_stack_ra_locations] = sp; - valid_stack_ra_code_objects[num_valid_stack_ra_locations++] = - (lispobj *)((int)start_addr + type_OtherPointer); - } else { - if (valid_dynamic_space_pointer((void *)thing, start_addr)) { - gc_assert(num_valid_stack_locations < MAX_STACK_POINTERS); - valid_stack_locations[num_valid_stack_locations++] = sp; + lispobj *sp = lowaddr; + num_valid_stack_locations = 0; + num_valid_stack_ra_locations = 0; + for (sp = lowaddr; sp < base; sp++) { + lispobj thing = *sp; + /* Find the object start address */ + lispobj *start_addr = search_dynamic_space((void *)thing); + if (start_addr) { + /* We need to allow raw pointers into Code objects for + * return addresses. This will also pick up pointers to + * functions in code objects. */ + if (widetag_of(*start_addr) == CODE_HEADER_WIDETAG) { + /* FIXME asserting here is a really dumb thing to do. + * If we've overflowed some arbitrary static limit, we + * should just refuse to purify, instead of killing + * the whole lisp session + */ + gc_assert(num_valid_stack_ra_locations < + MAX_STACK_RETURN_ADDRESSES); + valid_stack_ra_locations[num_valid_stack_ra_locations] = sp; + valid_stack_ra_code_objects[num_valid_stack_ra_locations++] = + (lispobj *)((int)start_addr + OTHER_POINTER_LOWTAG); + } else { + if (valid_dynamic_space_pointer((void *)thing, start_addr)) { + gc_assert(num_valid_stack_locations < MAX_STACK_POINTERS); + valid_stack_locations[num_valid_stack_locations++] = sp; + } + } } - } } - } - if (pointer_filter_verbose) { - fprintf(stderr, "number of valid stack pointers = %d\n", - num_valid_stack_locations); - fprintf(stderr, "number of stack return addresses = %d\n", - num_valid_stack_ra_locations); - } + if (pointer_filter_verbose) { + fprintf(stderr, "number of valid stack pointers = %d\n", + num_valid_stack_locations); + fprintf(stderr, "number of stack return addresses = %d\n", + num_valid_stack_ra_locations); + } } static void pscav_i386_stack(void) { - int i; + int i; - for (i = 0; i < num_valid_stack_locations; i++) - pscav(valid_stack_locations[i], 1, 0); + for (i = 0; i < num_valid_stack_locations; i++) + pscav(valid_stack_locations[i], 1, 0); - for (i = 0; i < num_valid_stack_ra_locations; i++) { - lispobj code_obj = (lispobj)valid_stack_ra_code_objects[i]; - pscav(&code_obj, 1, 0); - if (pointer_filter_verbose) { - fprintf(stderr,"*C moved RA %x to %x; for code object %x to %x\n", - *valid_stack_ra_locations[i], - (int)(*valid_stack_ra_locations[i]) - - ((int)valid_stack_ra_code_objects[i] - (int)code_obj), - valid_stack_ra_code_objects[i], code_obj); + for (i = 0; i < num_valid_stack_ra_locations; i++) { + lispobj code_obj = (lispobj)valid_stack_ra_code_objects[i]; + pscav(&code_obj, 1, 0); + if (pointer_filter_verbose) { + fprintf(stderr,"*C moved RA %x to %x; for code object %x to %x\n", + *valid_stack_ra_locations[i], + (int)(*valid_stack_ra_locations[i]) + - ((int)valid_stack_ra_code_objects[i] - (int)code_obj), + (unsigned int) valid_stack_ra_code_objects[i], code_obj); + } + *valid_stack_ra_locations[i] = + ((int)(*valid_stack_ra_locations[i]) + - ((int)valid_stack_ra_code_objects[i] - (int)code_obj)); } - *valid_stack_ra_locations[i] = - ((int)(*valid_stack_ra_locations[i]) - - ((int)valid_stack_ra_code_objects[i] - (int)code_obj)); - } } #endif #endif @@ -516,7 +467,8 @@ pscav_later(lispobj *where, int count) } } -static lispobj ptrans_boxed(lispobj thing, lispobj header, boolean constant) +static lispobj +ptrans_boxed(lispobj thing, lispobj header, boolean constant) { int nwords; lispobj result, *new, *old; @@ -524,21 +476,14 @@ static lispobj ptrans_boxed(lispobj thing, lispobj header, boolean constant) nwords = 1 + HeaderValue(header); /* Allocate it */ - old = (lispobj *)PTR(thing); - if (constant) { - new = read_only_free; - read_only_free += CEILING(nwords, 2); - } - else { - new = static_free; - static_free += CEILING(nwords, 2); - } + old = (lispobj *)native_pointer(thing); + new = newspace_alloc(nwords,constant); /* Copy it. */ bcopy(old, new, nwords * sizeof(lispobj)); /* Deposit forwarding pointer. */ - result = (lispobj)new | LowtagOf(thing); + result = make_lispobj(new, lowtag_of(thing)); *old = result; /* Scavenge it. */ @@ -548,12 +493,13 @@ static lispobj ptrans_boxed(lispobj thing, lispobj header, boolean constant) } /* We need to look at the layout to see whether it is a pure structure - * class, and only then can we transport as constant. If it is pure, we can - * ALWAYS transport as a constant. */ -static lispobj ptrans_instance(lispobj thing, lispobj header, boolean constant) + * class, and only then can we transport as constant. If it is pure, + * we can ALWAYS transport as a constant. */ +static lispobj +ptrans_instance(lispobj thing, lispobj header, boolean /* ignored */ constant) { - lispobj layout = ((struct instance *)PTR(thing))->slots[0]; - lispobj pure = ((struct instance *)PTR(layout))->slots[15]; + lispobj layout = ((struct instance *)native_pointer(thing))->slots[0]; + lispobj pure = ((struct instance *)native_pointer(layout))->slots[15]; switch (pure) { case T: @@ -562,25 +508,25 @@ static lispobj ptrans_instance(lispobj thing, lispobj header, boolean constant) return (ptrans_boxed(thing, header, 0)); case 0: { - /* Substructure: special case for the compact-info-envs, where - * the instance may have a point to the dynamic space placed - * into it (e.g. the cache-name slot), but the lists and arrays - * at the time of a purify can be moved to the RO space. */ + /* Substructure: special case for the COMPACT-INFO-ENVs, + * where the instance may have a point to the dynamic + * space placed into it (e.g. the cache-name slot), but + * the lists and arrays at the time of a purify can be + * moved to the RO space. */ int nwords; lispobj result, *new, *old; nwords = 1 + HeaderValue(header); /* Allocate it */ - old = (lispobj *)PTR(thing); - new = static_free; - static_free += CEILING(nwords, 2); + old = (lispobj *)native_pointer(thing); + new = newspace_alloc(nwords, 0); /* inconstant */ /* Copy it. */ bcopy(old, new, nwords * sizeof(lispobj)); /* Deposit forwarding pointer. */ - result = (lispobj)new | LowtagOf(thing); + result = make_lispobj(new, lowtag_of(thing)); *old = result; /* Scavenge it. */ @@ -590,10 +536,12 @@ static lispobj ptrans_instance(lispobj thing, lispobj header, boolean constant) } default: gc_abort(); + return NIL; /* dummy value: return something ... */ } } -static lispobj ptrans_fdefn(lispobj thing, lispobj header) +static lispobj +ptrans_fdefn(lispobj thing, lispobj header) { int nwords; lispobj result, *new, *old, oldfn; @@ -602,71 +550,63 @@ static lispobj ptrans_fdefn(lispobj thing, lispobj header) nwords = 1 + HeaderValue(header); /* Allocate it */ - old = (lispobj *)PTR(thing); - new = static_free; - static_free += CEILING(nwords, 2); + old = (lispobj *)native_pointer(thing); + new = newspace_alloc(nwords, 0); /* inconstant */ /* Copy it. */ bcopy(old, new, nwords * sizeof(lispobj)); /* Deposit forwarding pointer. */ - result = (lispobj)new | LowtagOf(thing); + result = make_lispobj(new, lowtag_of(thing)); *old = result; /* Scavenge the function. */ fdefn = (struct fdefn *)new; - oldfn = fdefn->function; - pscav(&fdefn->function, 1, 0); - if ((char *)oldfn + RAW_ADDR_OFFSET == fdefn->raw_addr) - fdefn->raw_addr = (char *)fdefn->function + RAW_ADDR_OFFSET; + oldfn = fdefn->fun; + pscav(&fdefn->fun, 1, 0); + if ((char *)oldfn + FUN_RAW_ADDR_OFFSET == fdefn->raw_addr) + fdefn->raw_addr = (char *)fdefn->fun + FUN_RAW_ADDR_OFFSET; return result; } -static lispobj ptrans_unboxed(lispobj thing, lispobj header) +static lispobj +ptrans_unboxed(lispobj thing, lispobj header) { int nwords; lispobj result, *new, *old; - + nwords = 1 + HeaderValue(header); - + /* Allocate it */ - old = (lispobj *)PTR(thing); - new = read_only_free; - read_only_free += CEILING(nwords, 2); - - /* Copy it. */ + old = (lispobj *)native_pointer(thing); + new = newspace_alloc(nwords,1); /* always constant */ + + /* copy it. */ bcopy(old, new, nwords * sizeof(lispobj)); - + /* Deposit forwarding pointer. */ - result = (lispobj)new | LowtagOf(thing); + result = make_lispobj(new , lowtag_of(thing)); *old = result; return result; } -static lispobj ptrans_vector(lispobj thing, int bits, int extra, - boolean boxed, boolean constant) +static lispobj +ptrans_vector(lispobj thing, int bits, int extra, + boolean boxed, boolean constant) { struct vector *vector; int nwords; lispobj result, *new; - vector = (struct vector *)PTR(thing); + vector = (struct vector *)native_pointer(thing); nwords = 2 + (CEILING((fixnum_value(vector->length)+extra)*bits,32)>>5); - if (boxed && !constant) { - new = static_free; - static_free += CEILING(nwords, 2); - } - else { - new = read_only_free; - read_only_free += CEILING(nwords, 2); - } - + new=newspace_alloc(nwords, (constant || !boxed)); bcopy(vector, new, nwords * sizeof(lispobj)); - result = (lispobj)new | LowtagOf(thing); + result = make_lispobj(new, lowtag_of(thing)); vector->header = result; if (boxed) @@ -675,111 +615,109 @@ static lispobj ptrans_vector(lispobj thing, int bits, int extra, return result; } -#ifdef __i386__ +#ifdef LISP_FEATURE_X86 static void apply_code_fixups_during_purify(struct code *old_code, struct code *new_code) { - int nheader_words, ncode_words, nwords; - void *constants_start_addr, *constants_end_addr; - void *code_start_addr, *code_end_addr; - lispobj p; - lispobj fixups = NIL; - unsigned displacement = (unsigned)new_code - (unsigned)old_code; - struct vector *fixups_vector; - - /* Byte compiled code has no fixups. The trace table offset will be - * a fixnum if it's x86 compiled code - check. */ - if (new_code->trace_table_offset & 0x3) - return; - - /* Else it's x86 machine code. */ - ncode_words = fixnum_value(new_code->code_size); - nheader_words = HeaderValue(*(lispobj *)new_code); - nwords = ncode_words + nheader_words; - - constants_start_addr = (void *)new_code + 5*4; - constants_end_addr = (void *)new_code + nheader_words*4; - code_start_addr = (void *)new_code + nheader_words*4; - code_end_addr = (void *)new_code + nwords*4; - - /* The first constant should be a pointer to the fixups for this - * code objects. Check. */ - fixups = new_code->constants[0]; - - /* It will be 0 or the unbound-marker if there are no fixups, and - * will be an other-pointer to a vector if it is valid. */ - if ((fixups==0) || (fixups==type_UnboundMarker) || !Pointerp(fixups)) { -#ifdef GENCGC - /* Check for a possible errors. */ - sniff_code_object(new_code,displacement); -#endif - return; - } + int nheader_words, ncode_words, nwords; + void *constants_start_addr, *constants_end_addr; + void *code_start_addr, *code_end_addr; + lispobj fixups = NIL; + unsigned displacement = (unsigned)new_code - (unsigned)old_code; + struct vector *fixups_vector; + + ncode_words = fixnum_value(new_code->code_size); + nheader_words = HeaderValue(*(lispobj *)new_code); + nwords = ncode_words + nheader_words; + + constants_start_addr = (void *)new_code + 5*4; + constants_end_addr = (void *)new_code + nheader_words*4; + code_start_addr = (void *)new_code + nheader_words*4; + code_end_addr = (void *)new_code + nwords*4; + + /* The first constant should be a pointer to the fixups for this + * code objects. Check. */ + fixups = new_code->constants[0]; + + /* It will be 0 or the unbound-marker if there are no fixups, and + * will be an other-pointer to a vector if it is valid. */ + if ((fixups==0) || + (fixups==UNBOUND_MARKER_WIDETAG) || + !is_lisp_pointer(fixups)) { +#ifdef LISP_FEATURE_GENCGC + /* Check for a possible errors. */ + sniff_code_object(new_code,displacement); +#endif + return; + } - fixups_vector = (struct vector *)PTR(fixups); + fixups_vector = (struct vector *)native_pointer(fixups); - /* Could be pointing to a forwarding pointer. */ - if (Pointerp(fixups) && (dynamic_pointer_p(fixups)) - && forwarding_pointer_p(*(lispobj *)fixups_vector)) { - /* If so then follow it. */ - fixups_vector = (struct vector *)PTR(*(lispobj *)fixups_vector); - } + /* Could be pointing to a forwarding pointer. */ + if (is_lisp_pointer(fixups) && (dynamic_pointer_p(fixups)) + && forwarding_pointer_p(*(lispobj *)fixups_vector)) { + /* If so then follow it. */ + fixups_vector = + (struct vector *)native_pointer(*(lispobj *)fixups_vector); + } - if (TypeOf(fixups_vector->header) == type_SimpleArrayUnsignedByte32) { - /* We got the fixups for the code block. Now work through the vector, - * and apply a fixup at each address. */ - int length = fixnum_value(fixups_vector->length); - int i; - for (i=0; idata[i]; - /* Now check the current value of offset. */ - unsigned old_value = *(unsigned *)((unsigned)code_start_addr + offset); - - /* If it's within the old_code object then it must be an - * absolute fixup (relative ones are not saved) */ - if ((old_value>=(unsigned)old_code) - && (old_value<((unsigned)old_code + nwords*4))) - /* So add the dispacement. */ - *(unsigned *)((unsigned)code_start_addr + offset) = old_value - + displacement; - else - /* It is outside the old code object so it must be a relative - * fixup (absolute fixups are not saved). So subtract the - * displacement. */ - *(unsigned *)((unsigned)code_start_addr + offset) = old_value - - displacement; + if (widetag_of(fixups_vector->header) == + SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG) { + /* We got the fixups for the code block. Now work through the + * vector, and apply a fixup at each address. */ + int length = fixnum_value(fixups_vector->length); + int i; + for (i=0; idata[i]; + /* Now check the current value of offset. */ + unsigned old_value = + *(unsigned *)((unsigned)code_start_addr + offset); + + /* If it's within the old_code object then it must be an + * absolute fixup (relative ones are not saved) */ + if ((old_value>=(unsigned)old_code) + && (old_value<((unsigned)old_code + nwords*4))) + /* So add the dispacement. */ + *(unsigned *)((unsigned)code_start_addr + offset) = old_value + + displacement; + else + /* It is outside the old code object so it must be a relative + * fixup (absolute fixups are not saved). So subtract the + * displacement. */ + *(unsigned *)((unsigned)code_start_addr + offset) = old_value + - displacement; + } } - } - /* No longer need the fixups. */ - new_code->constants[0] = 0; + /* No longer need the fixups. */ + new_code->constants[0] = 0; -#ifdef GENCGC - /* Check for possible errors. */ - sniff_code_object(new_code,displacement); +#ifdef LISP_FEATURE_GENCGC + /* Check for possible errors. */ + sniff_code_object(new_code,displacement); #endif } #endif -static lispobj ptrans_code(lispobj thing) +static lispobj +ptrans_code(lispobj thing) { struct code *code, *new; int nwords; lispobj func, result; - code = (struct code *)PTR(thing); + code = (struct code *)native_pointer(thing); nwords = HeaderValue(code->header) + fixnum_value(code->code_size); - new = (struct code *)read_only_free; - read_only_free += CEILING(nwords, 2); + new = (struct code *)newspace_alloc(nwords,1); /* constant */ bcopy(code, new, nwords * sizeof(lispobj)); -#ifdef __i386__ +#ifdef LISP_FEATURE_X86 apply_code_fixups_during_purify(code,new); #endif - result = (lispobj)new | type_OtherPointer; + result = make_lispobj(new, OTHER_POINTER_LOWTAG); /* Stick in a forwarding pointer for the code object. */ *(lispobj *)code = result; @@ -787,21 +725,26 @@ static lispobj ptrans_code(lispobj thing) /* Put in forwarding pointers for all the functions. */ for (func = code->entry_points; func != NIL; - func = ((struct function *)PTR(func))->next) { + func = ((struct simple_fun *)native_pointer(func))->next) { - gc_assert(LowtagOf(func) == type_FunctionPointer); + gc_assert(lowtag_of(func) == FUN_POINTER_LOWTAG); - *(lispobj *)PTR(func) = result + (func - thing); + *(lispobj *)native_pointer(func) = result + (func - thing); } /* Arrange to scavenge the debug info later. */ pscav_later(&new->debug_info, 1); - if(new->trace_table_offset & 0x3) + /* FIXME: why would this be a fixnum? */ + /* "why" is a hard word, but apparently for compiled functions the + trace_table_offset contains the length of the instructions, as + a fixnum. See CODE-INST-AREA-LENGTH in + src/compiler/target-disassem.lisp. -- CSR, 2004-01-08 */ + if (!(fixnump(new->trace_table_offset))) #if 0 - pscav(&new->trace_table_offset, 1, 0); + pscav(&new->trace_table_offset, 1, 0); #else - new->trace_table_offset = NIL; /* limit lifetime */ + new->trace_table_offset = NIL; /* limit lifetime */ #endif /* Scavenge the constants. */ @@ -811,30 +754,32 @@ static lispobj ptrans_code(lispobj thing) pscav(&new->entry_points, 1, 1); for (func = new->entry_points; func != NIL; - func = ((struct function *)PTR(func))->next) { - gc_assert(LowtagOf(func) == type_FunctionPointer); + func = ((struct simple_fun *)native_pointer(func))->next) { + gc_assert(lowtag_of(func) == FUN_POINTER_LOWTAG); gc_assert(!dynamic_pointer_p(func)); -#ifdef __i386__ - /* Temporarly convert the self pointer to a real function - pointer. */ - ((struct function *)PTR(func))->self -= RAW_ADDR_OFFSET; +#ifdef LISP_FEATURE_X86 + /* Temporarily convert the self pointer to a real function pointer. */ + ((struct simple_fun *)native_pointer(func))->self + -= FUN_RAW_ADDR_OFFSET; #endif - pscav(&((struct function *)PTR(func))->self, 2, 1); -#ifdef __i386__ - ((struct function *)PTR(func))->self += RAW_ADDR_OFFSET; + pscav(&((struct simple_fun *)native_pointer(func))->self, 2, 1); +#ifdef LISP_FEATURE_X86 + ((struct simple_fun *)native_pointer(func))->self + += FUN_RAW_ADDR_OFFSET; #endif - pscav_later(&((struct function *)PTR(func))->name, 3); + pscav_later(&((struct simple_fun *)native_pointer(func))->name, 3); } return result; } -static lispobj ptrans_func(lispobj thing, lispobj header) +static lispobj +ptrans_func(lispobj thing, lispobj header) { int nwords; lispobj code, *new, *old, result; - struct function *function; + struct simple_fun *function; /* Thing can either be a function header, a closure function * header, a closure, or a funcallable-instance. If it's a closure @@ -842,19 +787,21 @@ static lispobj ptrans_func(lispobj thing, lispobj header) * Otherwise we have to do something strange, 'cause it is buried * inside a code object. */ - if (TypeOf(header) == type_FunctionHeader || - TypeOf(header) == type_ClosureFunctionHeader) { + if (widetag_of(header) == SIMPLE_FUN_HEADER_WIDETAG) { /* We can only end up here if the code object has not been * scavenged, because if it had been scavenged, forwarding pointers * would have been left behind for all the entry points. */ - function = (struct function *)PTR(thing); - code = (PTR(thing)-(HeaderValue(function->header)*sizeof(lispobj))) | - type_OtherPointer; - + function = (struct simple_fun *)native_pointer(thing); + code = + make_lispobj + ((native_pointer(thing) - + (HeaderValue(function->header))), OTHER_POINTER_LOWTAG); + /* This will cause the function's header to be replaced with a * forwarding pointer. */ + ptrans_code(code); /* So we can just return that. */ @@ -863,26 +810,19 @@ static lispobj ptrans_func(lispobj thing, lispobj header) else { /* It's some kind of closure-like thing. */ nwords = 1 + HeaderValue(header); - old = (lispobj *)PTR(thing); + old = (lispobj *)native_pointer(thing); - /* Allocate the new one. */ - if (TypeOf(header) == type_FuncallableInstanceHeader) { - /* FINs *must* not go in read_only space. */ - new = static_free; - static_free += CEILING(nwords, 2); - } - else { - /* Closures can always go in read-only space, 'cause they - * never change. */ + /* Allocate the new one. FINs *must* not go in read_only + * space. Closures can; they never change */ - new = read_only_free; - read_only_free += CEILING(nwords, 2); - } + new = newspace_alloc + (nwords,(widetag_of(header)!=FUNCALLABLE_INSTANCE_HEADER_WIDETAG)); + /* Copy it. */ bcopy(old, new, nwords * sizeof(lispobj)); /* Deposit forwarding pointer. */ - result = (lispobj)new | LowtagOf(thing); + result = make_lispobj(new, lowtag_of(thing)); *old = result; /* Scavenge it. */ @@ -892,7 +832,8 @@ static lispobj ptrans_func(lispobj thing, lispobj header) } } -static lispobj ptrans_returnpc(lispobj thing, lispobj header) +static lispobj +ptrans_returnpc(lispobj thing, lispobj header) { lispobj code, new; @@ -900,7 +841,7 @@ static lispobj ptrans_returnpc(lispobj thing, lispobj header) code = thing - HeaderValue(header)*sizeof(lispobj); /* Make sure it's been transported. */ - new = *(lispobj *)PTR(code); + new = *(lispobj *)native_pointer(code); if (!forwarding_pointer_p(new)) new = ptrans_code(code); @@ -910,129 +851,131 @@ static lispobj ptrans_returnpc(lispobj thing, lispobj header) #define WORDS_PER_CONS CEILING(sizeof(struct cons) / sizeof(lispobj), 2) -static lispobj ptrans_list(lispobj thing, boolean constant) +static lispobj +ptrans_list(lispobj thing, boolean constant) { struct cons *old, *new, *orig; int length; - if (constant) - orig = (struct cons *)read_only_free; - else - orig = (struct cons *)static_free; + orig = newspace_alloc(0,constant); length = 0; do { /* Allocate a new cons cell. */ - old = (struct cons *)PTR(thing); - if (constant) { - new = (struct cons *)read_only_free; - read_only_free += WORDS_PER_CONS; - } - else { - new = (struct cons *)static_free; - static_free += WORDS_PER_CONS; - } + old = (struct cons *)native_pointer(thing); + new = (struct cons *) newspace_alloc(WORDS_PER_CONS,constant); /* Copy the cons cell and keep a pointer to the cdr. */ new->car = old->car; thing = new->cdr = old->cdr; /* Set up the forwarding pointer. */ - *(lispobj *)old = ((lispobj)new) | type_ListPointer; + *(lispobj *)old = make_lispobj(new, LIST_POINTER_LOWTAG); /* And count this cell. */ length++; - } while (LowtagOf(thing) == type_ListPointer && + } while (lowtag_of(thing) == LIST_POINTER_LOWTAG && dynamic_pointer_p(thing) && - !(forwarding_pointer_p(*(lispobj *)PTR(thing)))); + !(forwarding_pointer_p(*(lispobj *)native_pointer(thing)))); /* Scavenge the list we just copied. */ pscav((lispobj *)orig, length * WORDS_PER_CONS, constant); - return ((lispobj)orig) | type_ListPointer; + return make_lispobj(orig, LIST_POINTER_LOWTAG); } -static lispobj ptrans_otherptr(lispobj thing, lispobj header, boolean constant) +static lispobj +ptrans_otherptr(lispobj thing, lispobj header, boolean constant) { - switch (TypeOf(header)) { - case type_Bignum: - case type_SingleFloat: - case type_DoubleFloat: -#ifdef type_LongFloat - case type_LongFloat: -#endif -#ifdef type_ComplexSingleFloat - case type_ComplexSingleFloat: -#endif -#ifdef type_ComplexDoubleFloat - case type_ComplexDoubleFloat: -#endif -#ifdef type_ComplexLongFloat - case type_ComplexLongFloat: -#endif - case type_Sap: - return ptrans_unboxed(thing, header); - - case type_Ratio: - case type_Complex: - case type_SimpleArray: - case type_ComplexString: - case type_ComplexVector: - case type_ComplexArray: + switch (widetag_of(header)) { + /* FIXME: this needs a reindent */ + case BIGNUM_WIDETAG: + case SINGLE_FLOAT_WIDETAG: + case DOUBLE_FLOAT_WIDETAG: +#ifdef LONG_FLOAT_WIDETAG + case LONG_FLOAT_WIDETAG: +#endif +#ifdef COMPLEX_SINGLE_FLOAT_WIDETAG + case COMPLEX_SINGLE_FLOAT_WIDETAG: +#endif +#ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG + case COMPLEX_DOUBLE_FLOAT_WIDETAG: +#endif +#ifdef COMPLEX_LONG_FLOAT_WIDETAG + case COMPLEX_LONG_FLOAT_WIDETAG: +#endif + case SAP_WIDETAG: + return ptrans_unboxed(thing, header); + + case RATIO_WIDETAG: + case COMPLEX_WIDETAG: + case SIMPLE_ARRAY_WIDETAG: + case COMPLEX_BASE_STRING_WIDETAG: + case COMPLEX_BIT_VECTOR_WIDETAG: + case COMPLEX_VECTOR_NIL_WIDETAG: + case COMPLEX_VECTOR_WIDETAG: + case COMPLEX_ARRAY_WIDETAG: return ptrans_boxed(thing, header, constant); - case type_ValueCellHeader: - case type_WeakPointer: + case VALUE_CELL_HEADER_WIDETAG: + case WEAK_POINTER_WIDETAG: return ptrans_boxed(thing, header, 0); - case type_SymbolHeader: + case SYMBOL_HEADER_WIDETAG: return ptrans_boxed(thing, header, 0); - case type_SimpleString: + case SIMPLE_ARRAY_NIL_WIDETAG: + return ptrans_vector(thing, 0, 0, 0, constant); + + case SIMPLE_BASE_STRING_WIDETAG: return ptrans_vector(thing, 8, 1, 0, constant); - case type_SimpleBitVector: + case SIMPLE_BIT_VECTOR_WIDETAG: return ptrans_vector(thing, 1, 0, 0, constant); - case type_SimpleVector: + case SIMPLE_VECTOR_WIDETAG: return ptrans_vector(thing, 32, 0, 1, constant); - case type_SimpleArrayUnsignedByte2: + case SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG: return ptrans_vector(thing, 2, 0, 0, constant); - case type_SimpleArrayUnsignedByte4: + case SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG: return ptrans_vector(thing, 4, 0, 0, constant); - case type_SimpleArrayUnsignedByte8: -#ifdef type_SimpleArraySignedByte8 - case type_SimpleArraySignedByte8: + case SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG: +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG: #endif return ptrans_vector(thing, 8, 0, 0, constant); - case type_SimpleArrayUnsignedByte16: -#ifdef type_SimpleArraySignedByte16 - case type_SimpleArraySignedByte16: + case SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG: +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG: #endif return ptrans_vector(thing, 16, 0, 0, constant); - case type_SimpleArrayUnsignedByte32: -#ifdef type_SimpleArraySignedByte30 - case type_SimpleArraySignedByte30: + case SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG: +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG: #endif -#ifdef type_SimpleArraySignedByte32 - case type_SimpleArraySignedByte32: +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG: #endif return ptrans_vector(thing, 32, 0, 0, constant); - case type_SimpleArraySingleFloat: + case SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG: return ptrans_vector(thing, 32, 0, 0, constant); - case type_SimpleArrayDoubleFloat: + case SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG: return ptrans_vector(thing, 64, 0, 0, constant); -#ifdef type_SimpleArrayLongFloat - case type_SimpleArrayLongFloat: -#ifdef __i386__ +#ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG + case SIMPLE_ARRAY_LONG_FLOAT_WIDETAG: +#ifdef LISP_FEATURE_X86 return ptrans_vector(thing, 96, 0, 0, constant); #endif #ifdef sparc @@ -1040,19 +983,19 @@ static lispobj ptrans_otherptr(lispobj thing, lispobj header, boolean constant) #endif #endif -#ifdef type_SimpleArrayComplexSingleFloat - case type_SimpleArrayComplexSingleFloat: +#ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG + case SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG: return ptrans_vector(thing, 64, 0, 0, constant); #endif -#ifdef type_SimpleArrayComplexDoubleFloat - case type_SimpleArrayComplexDoubleFloat: +#ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG + case SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG: return ptrans_vector(thing, 128, 0, 0, constant); #endif -#ifdef type_SimpleArrayComplexLongFloat - case type_SimpleArrayComplexLongFloat: -#ifdef __i386__ +#ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG + case SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG: +#ifdef LISP_FEATURE_X86 return ptrans_vector(thing, 192, 0, 0, constant); #endif #ifdef sparc @@ -1060,13 +1003,13 @@ static lispobj ptrans_otherptr(lispobj thing, lispobj header, boolean constant) #endif #endif - case type_CodeHeader: + case CODE_HEADER_WIDETAG: return ptrans_code(thing); - case type_ReturnPcHeader: + case RETURN_PC_HEADER_WIDETAG: return ptrans_returnpc(thing, header); - case type_Fdefn: + case FDEFN_WIDETAG: return ptrans_fdefn(thing, header); default: @@ -1076,19 +1019,20 @@ static lispobj ptrans_otherptr(lispobj thing, lispobj header, boolean constant) } } -static int pscav_fdefn(struct fdefn *fdefn) +static int +pscav_fdefn(struct fdefn *fdefn) { boolean fix_func; - fix_func = ((char *)(fdefn->function+RAW_ADDR_OFFSET) == fdefn->raw_addr); + fix_func = ((char *)(fdefn->fun+FUN_RAW_ADDR_OFFSET) == fdefn->raw_addr); pscav(&fdefn->name, 1, 1); - pscav(&fdefn->function, 1, 0); + pscav(&fdefn->fun, 1, 0); if (fix_func) - fdefn->raw_addr = (char *)(fdefn->function + RAW_ADDR_OFFSET); + fdefn->raw_addr = (char *)(fdefn->fun + FUN_RAW_ADDR_OFFSET); return sizeof(struct fdefn) / sizeof(lispobj); } -#ifdef __i386__ +#ifdef LISP_FEATURE_X86 /* now putting code objects in static space */ static int pscav_code(struct code*code) @@ -1097,19 +1041,6 @@ pscav_code(struct code*code) lispobj func; nwords = HeaderValue(code->header) + fixnum_value(code->code_size); - /* pw--The trace_table_offset slot can contain a list pointer. This - * occurs when the code object is a top level form that initializes - * a byte-compiled function. The fact that PURIFY was ignoring this - * slot may be a bug unrelated to the x86 port, except that TLF's - * normally become unreachable after the loader calls them and - * won't be seen by PURIFY at all!! */ - if(code->trace_table_offset & 0x3) -#if 0 - pscav(&code->trace_table_offset, 1, 0); -#else - code->trace_table_offset = NIL; /* limit lifetime */ -#endif - /* Arrange to scavenge the debug info later. */ pscav_later(&code->debug_info, 1); @@ -1120,59 +1051,62 @@ pscav_code(struct code*code) pscav(&code->entry_points, 1, 1); for (func = code->entry_points; func != NIL; - func = ((struct function *)PTR(func))->next) { - gc_assert(LowtagOf(func) == type_FunctionPointer); + func = ((struct simple_fun *)native_pointer(func))->next) { + gc_assert(lowtag_of(func) == FUN_POINTER_LOWTAG); gc_assert(!dynamic_pointer_p(func)); -#ifdef __i386__ - /* Temporarly convert the self pointer to a real function +#ifdef LISP_FEATURE_X86 + /* Temporarily convert the self pointer to a real function * pointer. */ - ((struct function *)PTR(func))->self -= RAW_ADDR_OFFSET; + ((struct simple_fun *)native_pointer(func))->self + -= FUN_RAW_ADDR_OFFSET; #endif - pscav(&((struct function *)PTR(func))->self, 2, 1); -#ifdef __i386__ - ((struct function *)PTR(func))->self += RAW_ADDR_OFFSET; + pscav(&((struct simple_fun *)native_pointer(func))->self, 2, 1); +#ifdef LISP_FEATURE_X86 + ((struct simple_fun *)native_pointer(func))->self + += FUN_RAW_ADDR_OFFSET; #endif - pscav_later(&((struct function *)PTR(func))->name, 3); + pscav_later(&((struct simple_fun *)native_pointer(func))->name, 3); } return CEILING(nwords,2); } #endif -static lispobj *pscav(lispobj *addr, int nwords, boolean constant) +static lispobj * +pscav(lispobj *addr, int nwords, boolean constant) { lispobj thing, *thingp, header; - int count; + int count = 0; /* (0 = dummy init value to stop GCC warning) */ struct vector *vector; while (nwords > 0) { thing = *addr; - if (Pointerp(thing)) { + if (is_lisp_pointer(thing)) { /* It's a pointer. Is it something we might have to move? */ if (dynamic_pointer_p(thing)) { /* Maybe. Have we already moved it? */ - thingp = (lispobj *)PTR(thing); + thingp = (lispobj *)native_pointer(thing); header = *thingp; - if (Pointerp(header) && forwarding_pointer_p(header)) + if (is_lisp_pointer(header) && forwarding_pointer_p(header)) /* Yep, so just copy the forwarding pointer. */ thing = header; else { /* Nope, copy the object. */ - switch (LowtagOf(thing)) { - case type_FunctionPointer: + switch (lowtag_of(thing)) { + case FUN_POINTER_LOWTAG: thing = ptrans_func(thing, header); break; - case type_ListPointer: + case LIST_POINTER_LOWTAG: thing = ptrans_list(thing, constant); break; - case type_InstancePointer: + case INSTANCE_POINTER_LOWTAG: thing = ptrans_instance(thing, header, constant); break; - case type_OtherPointer: + case OTHER_POINTER_LOWTAG: thing = ptrans_otherptr(thing, header, constant); break; @@ -1185,92 +1119,101 @@ static lispobj *pscav(lispobj *addr, int nwords, boolean constant) } count = 1; } - else if (thing & 3) { + else if (thing & 3) { /* FIXME: 3? not 2? */ /* It's an other immediate. Maybe the header for an unboxed */ /* object. */ - switch (TypeOf(thing)) { - case type_Bignum: - case type_SingleFloat: - case type_DoubleFloat: -#ifdef type_LongFloat - case type_LongFloat: -#endif - case type_Sap: + switch (widetag_of(thing)) { + case BIGNUM_WIDETAG: + case SINGLE_FLOAT_WIDETAG: + case DOUBLE_FLOAT_WIDETAG: +#ifdef LONG_FLOAT_WIDETAG + case LONG_FLOAT_WIDETAG: +#endif + case SAP_WIDETAG: /* It's an unboxed simple object. */ count = HeaderValue(thing)+1; break; - case type_SimpleVector: - if (HeaderValue(thing) == subtype_VectorValidHashing) - *addr = (subtype_VectorMustRehash<length)+1,4)+2,2); break; - case type_SimpleBitVector: + case SIMPLE_BIT_VECTOR_WIDETAG: vector = (struct vector *)addr; count = CEILING(NWORDS(fixnum_value(vector->length),32)+2,2); break; - case type_SimpleArrayUnsignedByte2: + case SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG: vector = (struct vector *)addr; count = CEILING(NWORDS(fixnum_value(vector->length),16)+2,2); break; - case type_SimpleArrayUnsignedByte4: + case SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG: vector = (struct vector *)addr; count = CEILING(NWORDS(fixnum_value(vector->length),8)+2,2); break; - case type_SimpleArrayUnsignedByte8: -#ifdef type_SimpleArraySignedByte8 - case type_SimpleArraySignedByte8: + case SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG: +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG: #endif vector = (struct vector *)addr; count = CEILING(NWORDS(fixnum_value(vector->length),4)+2,2); break; - case type_SimpleArrayUnsignedByte16: -#ifdef type_SimpleArraySignedByte16 - case type_SimpleArraySignedByte16: + case SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG: +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG: #endif vector = (struct vector *)addr; count = CEILING(NWORDS(fixnum_value(vector->length),2)+2,2); break; - case type_SimpleArrayUnsignedByte32: -#ifdef type_SimpleArraySignedByte30 - case type_SimpleArraySignedByte30: + case SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG: +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG: #endif -#ifdef type_SimpleArraySignedByte32 - case type_SimpleArraySignedByte32: +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG: #endif vector = (struct vector *)addr; count = CEILING(fixnum_value(vector->length)+2,2); break; - case type_SimpleArraySingleFloat: + case SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG: vector = (struct vector *)addr; count = CEILING(fixnum_value(vector->length)+2,2); break; - case type_SimpleArrayDoubleFloat: -#ifdef type_SimpleArrayComplexSingleFloat - case type_SimpleArrayComplexSingleFloat: + case SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG: +#ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG + case SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG: #endif vector = (struct vector *)addr; count = fixnum_value(vector->length)*2+2; break; -#ifdef type_SimpleArrayLongFloat - case type_SimpleArrayLongFloat: +#ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG + case SIMPLE_ARRAY_LONG_FLOAT_WIDETAG: vector = (struct vector *)addr; -#ifdef __i386__ +#ifdef LISP_FEATURE_X86 count = fixnum_value(vector->length)*3+2; #endif #ifdef sparc @@ -1279,17 +1222,17 @@ static lispobj *pscav(lispobj *addr, int nwords, boolean constant) break; #endif -#ifdef type_SimpleArrayComplexDoubleFloat - case type_SimpleArrayComplexDoubleFloat: +#ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG + case SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG: vector = (struct vector *)addr; count = fixnum_value(vector->length)*4+2; break; #endif -#ifdef type_SimpleArrayComplexLongFloat - case type_SimpleArrayComplexLongFloat: +#ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG + case SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG: vector = (struct vector *)addr; -#ifdef __i386__ +#ifdef LISP_FEATURE_X86 count = fixnum_value(vector->length)*6+2; #endif #ifdef sparc @@ -1298,47 +1241,44 @@ static lispobj *pscav(lispobj *addr, int nwords, boolean constant) break; #endif - case type_CodeHeader: -#ifndef __i386__ + case CODE_HEADER_WIDETAG: +#ifndef LISP_FEATURE_X86 gc_abort(); /* no code headers in static space */ #else count = pscav_code((struct code*)addr); #endif break; - case type_FunctionHeader: - case type_ClosureFunctionHeader: - case type_ReturnPcHeader: + case SIMPLE_FUN_HEADER_WIDETAG: + case RETURN_PC_HEADER_WIDETAG: /* We should never hit any of these, 'cause they occur * buried in the middle of code objects. */ gc_abort(); break; -#ifdef __i386__ - case type_ClosureHeader: - case type_FuncallableInstanceHeader: - case type_ByteCodeFunction: - case type_ByteCodeClosure: +#ifdef LISP_FEATURE_X86 + case CLOSURE_HEADER_WIDETAG: + case FUNCALLABLE_INSTANCE_HEADER_WIDETAG: /* The function self pointer needs special care on the * x86 because it is the real entry point. */ { - lispobj fun = ((struct closure *)addr)->function - - RAW_ADDR_OFFSET; + lispobj fun = ((struct closure *)addr)->fun + - FUN_RAW_ADDR_OFFSET; pscav(&fun, 1, constant); - ((struct closure *)addr)->function = fun + RAW_ADDR_OFFSET; + ((struct closure *)addr)->fun = fun + FUN_RAW_ADDR_OFFSET; } count = 2; break; #endif - case type_WeakPointer: + case WEAK_POINTER_WIDETAG: /* Weak pointers get preserved during purify, 'cause I * don't feel like figuring out how to break them. */ pscav(addr+1, 2, constant); count = 4; break; - case type_Fdefn: + case FDEFN_WIDETAG: /* We have to handle fdefn objects specially, so we * can fix up the raw function address. */ count = pscav_fdefn((struct fdefn *)addr); @@ -1361,18 +1301,31 @@ static lispobj *pscav(lispobj *addr, int nwords, boolean constant) return addr; } -int purify(lispobj static_roots, lispobj read_only_roots) +int +purify(lispobj static_roots, lispobj read_only_roots) { lispobj *clean; int count, i; struct later *laters, *next; + struct thread *thread; + + if(all_threads->next) { + /* FIXME: there should be _some_ sensible error reporting + * convention. See following comment too */ + fprintf(stderr,"Can't purify when more than one thread exists\n"); + fflush(stderr); + return 0; + } #ifdef PRINTNOISE printf("[doing purification:"); fflush(stdout); #endif - - if (fixnum_value(SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX)) != 0) { +#ifdef LISP_FEATURE_GENCGC + gc_alloc_update_all_page_tables(); +#endif + for_each_thread(thread) + if (fixnum_value(SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX,thread)) != 0) { /* FIXME: 1. What does this mean? 2. It shouldn't be reporting * its error simply by a. printing a string b. to stdout instead * of stderr. */ @@ -1381,24 +1334,27 @@ int purify(lispobj static_roots, lispobj read_only_roots) return 0; } -#if defined(ibmrt) || defined(__i386__) +#if defined(LISP_FEATURE_X86) dynamic_space_free_pointer = - (lispobj*)SymbolValue(ALLOCATION_POINTER); + (lispobj*)SymbolValue(ALLOCATION_POINTER,0); #endif read_only_end = read_only_free = - (lispobj *)SymbolValue(READ_ONLY_SPACE_FREE_POINTER); + (lispobj *)SymbolValue(READ_ONLY_SPACE_FREE_POINTER,0); static_end = static_free = - (lispobj *)SymbolValue(STATIC_SPACE_FREE_POINTER); + (lispobj *)SymbolValue(STATIC_SPACE_FREE_POINTER,0); #ifdef PRINTNOISE printf(" roots"); fflush(stdout); #endif -#ifdef GENCGC - gc_assert((lispobj *)CONTROL_STACK_END > ((&read_only_roots)+1)); - setup_i386_stack_scav(((&static_roots)-2), (lispobj *)CONTROL_STACK_END); +#if (defined(LISP_FEATURE_GENCGC) && defined(LISP_FEATURE_X86)) + /* note this expects only one thread to be active. We'd have to + * stop all the others in the same way as GC does if we wanted + * PURIFY to work when >1 thread exists */ + setup_i386_stack_scav(((&static_roots)-2), + ((void *)all_threads->control_stack_end)); #endif pscav(&static_roots, 1, 0); @@ -1408,46 +1364,59 @@ int purify(lispobj static_roots, lispobj read_only_roots) printf(" handlers"); fflush(stdout); #endif - pscav((lispobj *) interrupt_handlers, - sizeof(interrupt_handlers) / sizeof(lispobj), + pscav((lispobj *) all_threads->interrupt_data->interrupt_handlers, + sizeof(all_threads->interrupt_data->interrupt_handlers) + / sizeof(lispobj), 0); #ifdef PRINTNOISE printf(" stack"); fflush(stdout); #endif -#ifndef __i386__ - pscav((lispobj *)control_stack, - current_control_stack_pointer - (lispobj *)CONTROL_STACK_START, +#ifndef LISP_FEATURE_X86 + pscav((lispobj *)all_threads->control_stack_start, + current_control_stack_pointer - + all_threads->control_stack_start, 0); #else -#ifdef GENCGC +#ifdef LISP_FEATURE_GENCGC pscav_i386_stack(); #endif -#ifdef WANT_CGC - gc_assert((lispobj *)control_stack_end > ((&read_only_roots)+1)); - carefully_pscav_stack(((&read_only_roots)+1), - (lispobj *)CONTROL_STACK_END); -#endif #endif #ifdef PRINTNOISE printf(" bindings"); fflush(stdout); #endif -#if !defined(ibmrt) && !defined(__i386__) - pscav(BINDING_STACK_START, - current_binding_stack_pointer - (lispobj *)BINDING_STACK_START, +#if !defined(LISP_FEATURE_X86) + pscav( (lispobj *)all_threads->binding_stack_start, + (lispobj *)current_binding_stack_pointer - + all_threads->binding_stack_start, 0); #else - pscav(BINDING_STACK_START, - (lispobj *)SymbolValue(BINDING_STACK_POINTER) - - (lispobj *)BINDING_STACK_START, + for_each_thread(thread) { + pscav( (lispobj *)thread->binding_stack_start, + (lispobj *)SymbolValue(BINDING_STACK_POINTER,thread) - + (lispobj *)thread->binding_stack_start, 0); + pscav( (lispobj *) (thread+1), + fixnum_value(SymbolValue(FREE_TLS_INDEX,0)) - + (sizeof (struct thread))/(sizeof (lispobj)), + 0); + } + + #endif -#ifdef SCAVENGE_READ_ONLY_SPACE - if (SymbolValue(SCAVENGE_READ_ONLY_SPACE) != type_UnboundMarker + /* The original CMU CL code had scavenge-read-only-space code + * controlled by the Lisp-level variable + * *SCAVENGE-READ-ONLY-SPACE*. It was disabled by default, and it + * wasn't documented under what circumstances it was useful or + * safe to turn it on, so it's been turned off in SBCL. If you + * want/need this functionality, and can test and document it, + * please submit a patch. */ +#if 0 + if (SymbolValue(SCAVENGE_READ_ONLY_SPACE) != UNBOUND_MARKER_WIDETAG && SymbolValue(SCAVENGE_READ_ONLY_SPACE) != NIL) { unsigned read_only_space_size = (lispobj *)SymbolValue(READ_ONLY_SPACE_FREE_POINTER) - @@ -1455,7 +1424,7 @@ int purify(lispobj static_roots, lispobj read_only_roots) fprintf(stderr, "scavenging read only space: %d bytes\n", read_only_space_size * sizeof(lispobj)); - pscav(READ_ONLY_SPACE_START, read_only_space_size, 0); + pscav( (lispobj *)READ_ONLY_SPACE_START, read_only_space_size, 0); } #endif @@ -1494,64 +1463,31 @@ int purify(lispobj static_roots, lispobj read_only_roots) fflush(stdout); #endif -#if defined(WANT_CGC) && defined(X86_CGC_ACTIVE_P) - if(SymbolValue(X86_CGC_ACTIVE_P) != T) { - os_zero((os_vm_address_t) DYNAMIC_SPACE_START, - (os_vm_size_t) DYNAMIC_SPACE_SIZE); - } -#else - os_zero((os_vm_address_t) DYNAMIC_SPACE_START, + os_zero((os_vm_address_t) current_dynamic_space, (os_vm_size_t) DYNAMIC_SPACE_SIZE); -#endif /* Zero the stack. Note that the stack is also zeroed by SUB-GC * calling SCRUB-CONTROL-STACK - this zeros the stack on the x86. */ -#ifndef __i386__ +#ifndef LISP_FEATURE_X86 os_zero((os_vm_address_t) current_control_stack_pointer, - (os_vm_size_t) (CONTROL_STACK_SIZE - - ((current_control_stack_pointer - - (lispobj *)CONTROL_STACK_START) * - sizeof(lispobj)))); -#endif - -#if defined(WANT_CGC) && defined(STATIC_BLUE_BAG) - { - lispobj bag = SymbolValue(STATIC_BLUE_BAG); - struct cons*cons = (struct cons*)static_free; - struct cons*pair = cons + 1; - static_free += 2*WORDS_PER_CONS; - if(bag == type_UnboundMarker) - bag = NIL; - cons->cdr = bag; - cons->car = (lispobj)pair | type_ListPointer; - pair->car = (lispobj)static_end; - pair->cdr = (lispobj)static_free; - bag = (lispobj)cons | type_ListPointer; - SetSymbolValue(STATIC_BLUE_BAG, bag); - } + (os_vm_size_t) + ((all_threads->control_stack_end - + current_control_stack_pointer) * sizeof(lispobj))); #endif /* It helps to update the heap free pointers so that free_heap can * verify after it's done. */ - SetSymbolValue(READ_ONLY_SPACE_FREE_POINTER, (lispobj)read_only_free); - SetSymbolValue(STATIC_SPACE_FREE_POINTER, (lispobj)static_free); + SetSymbolValue(READ_ONLY_SPACE_FREE_POINTER, (lispobj)read_only_free,0); + SetSymbolValue(STATIC_SPACE_FREE_POINTER, (lispobj)static_free,0); -#if !defined(ibmrt) && !defined(__i386__) - dynamic_space_free_pointer = DYNAMIC_SPACE_START; +#if !defined(LISP_FEATURE_X86) + dynamic_space_free_pointer = current_dynamic_space; + set_auto_gc_trigger(bytes_consed_between_gcs); #else -#if defined(WANT_CGC) && defined(X86_CGC_ACTIVE_P) - /* X86 using CGC */ - if(SymbolValue(X86_CGC_ACTIVE_P) != T) - SetSymbolValue(ALLOCATION_POINTER, (lispobj)DYNAMIC_SPACE_START); - else - cgc_free_heap(); -#else -#if defined GENCGC +#if defined LISP_FEATURE_GENCGC gc_free_heap(); #else - /* ibmrt using GC */ - SetSymbolValue(ALLOCATION_POINTER, (lispobj)DYNAMIC_SPACE_START); -#endif +#error unsupported case /* in CMU CL, was "ibmrt using GC" */ #endif #endif @@ -1559,6 +1495,5 @@ int purify(lispobj static_roots, lispobj read_only_roots) printf(" done]\n"); fflush(stdout); #endif - return 0; }