* looking for sbcl@boinkor.net--2005/sbcl--main--0.9--patch-674 to compare with * comparing to sbcl@boinkor.net--2005/sbcl--main--0.9--patch-674 ................................... * modified files --- orig/package-data-list.lisp-expr +++ mod/package-data-list.lisp-expr @@ -2290,12 +2290,12 @@ "*BINDING-STACK-START*" "*CONTROL-STACK-START*" "*CONTROL-STACK-END*" "CONTROL-STACK-POINTER-VALID-P" - "DYNAMIC-SPACE-START" "DYNAMIC-SPACE-END" + "DEFAULT-DYNAMIC-SPACE-START" "DEFAULT-DYNAMIC-SPACE-END" #!+c-stack-is-control-stack "ALTERNATE-SIGNAL-STACK-START" - #!-gencgc "DYNAMIC-0-SPACE-START" - #!-gencgc "DYNAMIC-0-SPACE-END" - #!-gencgc "DYNAMIC-1-SPACE-START" - #!-gencgc "DYNAMIC-1-SPACE-END" + #!-gencgc "DEFAULT-DYNAMIC-0-SPACE-START" + #!-gencgc "DEFAULT-DYNAMIC-0-SPACE-END" + #!-gencgc "DEFAULT-DYNAMIC-1-SPACE-START" + #!-gencgc "DEFAULT-DYNAMIC-1-SPACE-END" "READ-ONLY-SPACE-START" "READ-ONLY-SPACE-END" "TARGET-BYTE-ORDER" "TARGET-HEAP-ADDRESS-SPACE" "STATIC-SPACE-START" "STATIC-SPACE-END" --- orig/src/code/gc.lisp +++ mod/src/code/gc.lisp @@ -24,7 +24,7 @@ #!-sb-fluid (declaim (inline current-dynamic-space-start)) #!+gencgc -(defun current-dynamic-space-start () sb!vm:dynamic-space-start) +(def-c-var-fun current-dynamic-space-start "dynamic_space_start") #!-gencgc (def-c-var-fun current-dynamic-space-start "current_dynamic_space") --- orig/src/code/room.lisp +++ mod/src/code/room.lisp @@ -218,8 +218,8 @@ (define-alien-routine "find_page_index" long (index long)) (define-alien-variable "page_table" (array (struct page) - #.(truncate (- dynamic-space-end - dynamic-space-start) + #.(truncate (- default-dynamic-space-end + default-dynamic-space-start) sb!vm:gencgc-page-size)))) ;;; Iterate over all the objects allocated in SPACE, calling FUN with --- orig/src/compiler/alpha/parms.lisp +++ mod/src/compiler/alpha/parms.lisp @@ -122,11 +122,11 @@ (def!constant static-space-start #x28000000) (def!constant static-space-end #x2c000000) -(def!constant dynamic-0-space-start #x30000000) -(def!constant dynamic-0-space-end #x3fff0000) +(def!constant default-dynamic-0-space-start #x30000000) +(def!constant default-dynamic-0-space-end #x3fff0000) -(def!constant dynamic-1-space-start #x40000000) -(def!constant dynamic-1-space-end #x4fff0000) +(def!constant default-dynamic-1-space-start #x40000000) +(def!constant default-dynamic-1-space-end #x4fff0000) ;;; FIXME nothing refers to either of these in alpha or x86 cmucl ;;; backend, so they could probably be removed. --- orig/src/compiler/generic/genesis.lisp +++ mod/src/compiler/generic/genesis.lisp @@ -3141,8 +3141,8 @@ sb!vm:static-space-start)) (*dynamic* (make-gspace :dynamic dynamic-core-space-id - #!+gencgc sb!vm:dynamic-space-start - #!-gencgc sb!vm:dynamic-0-space-start)) + #!+gencgc sb!vm:default-dynamic-space-start + #!-gencgc sb!vm:default-dynamic-0-space-start)) (*nil-descriptor* (make-nil-descriptor)) (*current-reversed-cold-toplevels* *nil-descriptor*) (*unbound-marker* (make-other-immediate-descriptor --- orig/src/compiler/hppa/parms.lisp +++ mod/src/compiler/hppa/parms.lisp @@ -68,10 +68,10 @@ (def!constant static-space-start #x28000000) (def!constant static-space-end #x2a000000) -(def!constant dynamic-0-space-start #x30000000) -(def!constant dynamic-0-space-end #x37fff000) -(def!constant dynamic-1-space-start #x38000000) -(def!constant dynamic-1-space-end #x3ffff000) +(def!constant default-dynamic-0-space-start #x30000000) +(def!constant default-dynamic-0-space-end #x37fff000) +(def!constant default-dynamic-1-space-start #x38000000) +(def!constant default-dynamic-1-space-end #x3ffff000) ;;; FIXME: WTF are these for? --- orig/src/compiler/mips/parms.lisp +++ mod/src/compiler/mips/parms.lisp @@ -78,10 +78,10 @@ (def!constant static-space-start #x06000000) (def!constant static-space-end #x08000000) - (def!constant dynamic-0-space-start #x08000000) - (def!constant dynamic-0-space-end #x0c000000) - (def!constant dynamic-1-space-start #x0c000000) - (def!constant dynamic-1-space-end #x10000000)) + (def!constant default-dynamic-0-space-start #x08000000) + (def!constant default-dynamic-0-space-end #x0c000000) + (def!constant default-dynamic-1-space-start #x0c000000) + (def!constant default-dynamic-1-space-end #x10000000)) #!+linux (progn @@ -95,10 +95,10 @@ (def!constant static-space-end #x10000000) ;; C runtime read/write segment starts at 0x10000000, heap and DSOs ;; start at 0x2a000000 - (def!constant dynamic-0-space-start #x30000000) - (def!constant dynamic-0-space-end #x50000000) - (def!constant dynamic-1-space-start #x50000000) - (def!constant dynamic-1-space-end #x70000000) + (def!constant default-dynamic-0-space-start #x30000000) + (def!constant default-dynamic-0-space-end #x50000000) + (def!constant default-dynamic-1-space-start #x50000000) + (def!constant default-dynamic-1-space-end #x70000000) (def!constant linkage-table-space-start #x70000000) (def!constant linkage-table-space-end #x71000000) --- orig/src/compiler/ppc/parms.lisp +++ mod/src/compiler/ppc/parms.lisp @@ -102,14 +102,14 @@ (progn #!+gencgc (progn - (def!constant dynamic-space-start #x4f000000) - (def!constant dynamic-space-end #x7efff000)) + (def!constant default-dynamic-space-start #x4f000000) + (def!constant default-dynamic-space-end #x7efff000)) #!-gencgc (progn - (def!constant dynamic-0-space-start #x4f000000) - (def!constant dynamic-0-space-end #x66fff000) - (def!constant dynamic-1-space-start #x67000000) - (def!constant dynamic-1-space-end #x7efff000)) + (def!constant default-dynamic-0-space-start #x4f000000) + (def!constant default-dynamic-0-space-end #x66fff000) + (def!constant default-dynamic-1-space-start #x67000000) + (def!constant default-dynamic-1-space-end #x7efff000)) (def!constant linkage-table-space-start #x0a000000) (def!constant linkage-table-space-end #x0b000000) @@ -119,15 +119,15 @@ (progn #!+gencgc (progn - (def!constant dynamic-space-start #x10000000) - (def!constant dynamic-space-end #x6ffff000)) + (def!constant default-dynamic-space-start #x10000000) + (def!constant default-dynamic-space-end #x6ffff000)) #!-gencgc (progn - (def!constant dynamic-0-space-start #x10000000) - (def!constant dynamic-0-space-end #x3ffff000) + (def!constant default-dynamic-0-space-start #x10000000) + (def!constant default-dynamic-0-space-end #x3ffff000) - (def!constant dynamic-1-space-start #x40000000) - (def!constant dynamic-1-space-end #x6ffff000)) + (def!constant default-dynamic-1-space-start #x40000000) + (def!constant default-dynamic-1-space-end #x6ffff000)) (def!constant linkage-table-space-start #x0a000000) --- orig/src/compiler/sparc/parms.lisp +++ mod/src/compiler/sparc/parms.lisp @@ -101,11 +101,11 @@ (def!constant static-space-start #x28000000) (def!constant static-space-end #x2c000000) - (def!constant dynamic-0-space-start #x30000000) - (def!constant dynamic-0-space-end #x38000000) + (def!constant default-dynamic-0-space-start #x30000000) + (def!constant default-dynamic-0-space-end #x38000000) - (def!constant dynamic-1-space-start #x40000000) - (def!constant dynamic-1-space-end #x48000000)) + (def!constant default-dynamic-1-space-start #x40000000) + (def!constant default-dynamic-1-space-end #x48000000)) #!+sunos ; might as well start by trying the same numbers (progn @@ -118,11 +118,11 @@ (def!constant static-space-start #x28000000) (def!constant static-space-end #x2c000000) - (def!constant dynamic-0-space-start #x30000000) - (def!constant dynamic-0-space-end #x38000000) + (def!constant default-dynamic-0-space-start #x30000000) + (def!constant default-dynamic-0-space-end #x38000000) - (def!constant dynamic-1-space-start #x40000000) - (def!constant dynamic-1-space-end #x48000000)) + (def!constant default-dynamic-1-space-start #x40000000) + (def!constant default-dynamic-1-space-end #x48000000)) ;; Size of one linkage-table entry in bytes. See comment in ;; src/runtime/sparc-arch.c --- orig/src/compiler/x86-64/parms.lisp +++ mod/src/compiler/x86-64/parms.lisp @@ -107,8 +107,8 @@ (def!constant static-space-start #x40000000) (def!constant static-space-end #x47fff000) -(def!constant dynamic-space-start #x1000000000) -(def!constant dynamic-space-end #x11ffff0000) +(def!constant default-dynamic-space-start #x1000000000) +(def!constant default-dynamic-space-end #x11ffff0000) (def!constant linkage-table-space-start #x60000000) (def!constant linkage-table-space-end #x63fff000) --- orig/src/compiler/x86/parms.lisp +++ mod/src/compiler/x86/parms.lisp @@ -160,8 +160,8 @@ (def!constant static-space-start #x05000000) (def!constant static-space-end #x07fff000) - (def!constant dynamic-space-start #x09000000) - (def!constant dynamic-space-end #x29000000) + (def!constant default-dynamic-space-start #x09000000) + (def!constant default-dynamic-space-end #x29000000) (def!constant linkage-table-space-start #x30000000) (def!constant linkage-table-space-end #x40000000)) @@ -174,8 +174,8 @@ (def!constant static-space-start #x05000000) (def!constant static-space-end #x07fff000) - (def!constant dynamic-space-start #x09000000) - (def!constant dynamic-space-end #x29000000) + (def!constant default-dynamic-space-start #x09000000) + (def!constant default-dynamic-space-end #x29000000) (def!constant linkage-table-space-start #x70000000) (def!constant linkage-table-space-end #x7ffff000)) @@ -188,8 +188,8 @@ (def!constant static-space-start #x40000000) (def!constant static-space-end #x42fff000) - (def!constant dynamic-space-start #x48000000) - (def!constant dynamic-space-end #xA0000000) + (def!constant default-dynamic-space-start #x48000000) + (def!constant default-dynamic-space-end #xA0000000) (def!constant linkage-table-space-start #xA2000000) (def!constant linkage-table-space-end #xA3000000)) @@ -202,8 +202,8 @@ (def!constant static-space-start #x30000000) (def!constant static-space-end #x37fff000) - (def!constant dynamic-space-start #x48000000) - (def!constant dynamic-space-end #x88000000) + (def!constant default-dynamic-space-start #x48000000) + (def!constant default-dynamic-space-end #x88000000) ;; In CMUCL: 0xB0000000->0xB1000000 (def!constant linkage-table-space-start #x90000000) @@ -217,8 +217,8 @@ (def!constant static-space-start #x50000000) (def!constant static-space-end #x5ffff000) - (def!constant dynamic-space-start #x80000000) - (def!constant dynamic-space-end #xA0000000) + (def!constant default-dynamic-space-start #x80000000) + (def!constant default-dynamic-space-end #xA0000000) ;; In CMUCL: 0xB0000000->0xB1000000 (def!constant linkage-table-space-start #xA0000000) @@ -232,8 +232,8 @@ (def!constant static-space-start #x30000000) (def!constant static-space-end #x37fff000) - (def!constant dynamic-space-start #x60000000) - (def!constant dynamic-space-end #x98000000) + (def!constant default-dynamic-space-start #x60000000) + (def!constant default-dynamic-space-end #x98000000) ;; In CMUCL: 0xB0000000->0xB1000000 (def!constant linkage-table-space-start #xA0000000) --- orig/src/runtime/GNUmakefile +++ mod/src/runtime/GNUmakefile @@ -39,7 +39,7 @@ COMMON_SRC = alloc.c backtrace.c breakpoint.c coreparse.c \ dynbind.c gc-common.c globals.c interr.c interrupt.c \ monitor.c os-common.c parse.c print.c purify.c \ - regnames.c run-program.c runtime.c save.c search.c \ + regnames.c relocate.c run-program.c runtime.c save.c search.c \ thread.c time.c util.c validate.c vars.c wrap.c C_SRC = $(COMMON_SRC) ${ARCH_SRC} ${OS_SRC} ${GC_SRC} --- orig/src/runtime/bsd-os.c +++ mod/src/runtime/bsd-os.c @@ -104,11 +104,11 @@ } os_vm_address_t -os_validate(os_vm_address_t addr, os_vm_size_t len) +os_validate(os_vm_address_t addr, os_vm_size_t len, int fixedp) { int flags = MAP_PRIVATE | MAP_ANON; - if (addr) + if (addr && fixedp) flags |= MAP_FIXED; addr = mmap(addr, len, OS_VM_PROT_ALL, flags, -1, 0); @@ -167,7 +167,7 @@ struct thread *th; if(in_range_p(addr, READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE) || in_range_p(addr, STATIC_SPACE_START , STATIC_SPACE_SIZE) || - in_range_p(addr, DYNAMIC_SPACE_START , DYNAMIC_SPACE_SIZE)) + in_range_p(addr, dynamic_space_start , DYNAMIC_SPACE_SIZE)) return 1; for_each_thread(th) { if((th->control_stack_start <= addr) && (addr < th->control_stack_end)) --- orig/src/runtime/cheneygc-internal.h +++ mod/src/runtime/cheneygc-internal.h @@ -4,6 +4,8 @@ extern lispobj *new_space; extern lispobj *new_space_free_pointer; +extern void *dynamic_0_space_start; +extern void *dynamic_1_space_start; /* predicates */ /* #if defined(DEBUG_SPACE_PREDICATES) */ --- orig/src/runtime/cheneygc.c +++ mod/src/runtime/cheneygc.c @@ -46,6 +46,9 @@ lispobj *new_space; lispobj *new_space_free_pointer; +void *dynamic_0_space_start; +void *dynamic_1_space_start; + static void scavenge_newspace(void); extern unsigned long bytes_consed_between_gcs; @@ -151,10 +154,10 @@ fprintf(stderr,"from_space = %lx\n", (unsigned long) current_dynamic_space); #endif - if (current_dynamic_space == (lispobj *) DYNAMIC_0_SPACE_START) - new_space = (lispobj *)DYNAMIC_1_SPACE_START; - else if (current_dynamic_space == (lispobj *) DYNAMIC_1_SPACE_START) - new_space = (lispobj *) DYNAMIC_0_SPACE_START; + if (current_dynamic_space == (lispobj *) dynamic_0_space_start) + new_space = (lispobj *)dynamic_1_space_start; + else if (current_dynamic_space == (lispobj *) dynamic_1_space_start) + new_space = (lispobj *) dynamic_0_space_start; else { lose("GC lossage. Current dynamic space is bogus!\n"); } @@ -569,7 +572,7 @@ gc_initialize_pointers(void) { /* FIXME: We do nothing here. We (briefly) misguidedly attempted - to set current_dynamic_space to DYNAMIC_0_SPACE_START here, + to set current_dynamic_space to dynamic_0_space_start here, forgetting that (a) actually it could be the other and (b) it's set in coreparse.c anyway. There's a FIXME note left here to note that current_dynamic_space is a violation of OAOO: we can @@ -625,7 +628,7 @@ #if defined(SUNOS) || defined(SOLARIS) /* don't want to force whole space into swapping mode... */ - os_validate(addr, length); + os_validate(addr, length, 1); #else os_protect(addr, length, OS_VM_PROT_ALL); #endif --- orig/src/runtime/coreparse.c +++ mod/src/runtime/coreparse.c @@ -39,6 +39,13 @@ #include "../../output/build-id.tmp" ; +void relocate(long *, long nwords, long *old_start, long displacement); +void relocation_fixup(long *fixup_ptr, + long n_fixup_words, + long *old_start, + long n_old_words, + long displacement); + int open_binary(char *filename, int mode) { @@ -100,10 +107,14 @@ return -1; } +/* kludge */ +static os_vm_address_t old_dynamic_space_start; + static void process_directory(int fd, u32 *ptr, int count, os_vm_offset_t file_offset) { struct ndir_entry *entry; + long static_space_len; FSHOW((stderr, "/process_directory(..), count=%d\n", count)); @@ -113,9 +124,19 @@ long offset = os_vm_page_size * (1 + entry->data_page); os_vm_address_t addr = (os_vm_address_t) (os_vm_page_size * entry->address); - lispobj *free_pointer = (lispobj *) addr + entry->nwords; + lispobj *free_pointer; long len = os_vm_page_size * entry->page_count; + if (id == DYNAMIC_CORE_SPACE_ID) { + old_dynamic_space_start = addr; +#ifdef LISP_FEATURE_GENCGC + addr = dynamic_space_start; +#else + if (addr != dynamic_1_space_start) + addr = dynamic_0_space_start; +#endif + } + if (len != 0) { os_vm_address_t real_addr; FSHOW((stderr, "/mapping %ld(0x%lx) bytes at 0x%lx\n", @@ -128,28 +149,28 @@ addr); } } + free_pointer = (lispobj *) addr + entry->nwords; FSHOW((stderr, "/space id = %ld, free pointer = 0x%lx\n", id, (unsigned long)free_pointer)); switch (id) { case DYNAMIC_CORE_SPACE_ID: -#ifdef LISP_FEATURE_GENCGC - if (addr != (os_vm_address_t)DYNAMIC_SPACE_START) { - fprintf(stderr, "in core: 0x%lx; in runtime: 0x%lx \n", - (long)addr, (long)DYNAMIC_SPACE_START); - lose("core/runtime address mismatch: DYNAMIC_SPACE_START\n"); - } -#else - if ((addr != (os_vm_address_t)DYNAMIC_0_SPACE_START) && - (addr != (os_vm_address_t)DYNAMIC_1_SPACE_START)) { - fprintf(stderr, "in core: 0x%lx; in runtime: 0x%lx or 0x%lx\n", - (long)addr, - (long)DYNAMIC_0_SPACE_START, - (long)DYNAMIC_1_SPACE_START); - lose("warning: core/runtime address mismatch: DYNAMIC_SPACE_START\n"); + if (addr != old_dynamic_space_start) { + fprintf(stderr, "relocating core to: 0x%lx; from: 0x%lx \n", + (long)addr, (long)old_dynamic_space_start); + relocate((long *) addr, + len / N_WORD_BYTES, + (long *) old_dynamic_space_start, + (long) addr - (long) old_dynamic_space_start); + /* kludge: we assume that static space comes before dynamic + * space, and both in one directory */ + relocation_fixup((long *) STATIC_SPACE_START, + static_space_len / N_WORD_BYTES, + (long *) old_dynamic_space_start, + len / N_WORD_BYTES, + (long) addr - (long) old_dynamic_space_start); } -#endif #if defined(ALLOCATION_POINTER) SetSymbolValue(ALLOCATION_POINTER, (lispobj)free_pointer,0); #else @@ -167,6 +188,7 @@ (long)addr, (long)STATIC_SPACE_START); lose("core/runtime address mismatch: STATIC_SPACE_START\n"); } + static_space_len = len; break; case READ_ONLY_CORE_SPACE_ID: if (addr != (os_vm_address_t)READ_ONLY_SPACE_START) { @@ -282,7 +304,15 @@ case INITIAL_FUN_CORE_ENTRY_TYPE_CODE: SHOW("INITIAL_FUN_CORE_ENTRY_TYPE_CODE case"); - initial_function = (lispobj)*ptr; + if (old_dynamic_space_start <= *ptr + && *ptr < (old_dynamic_space_start + DYNAMIC_SPACE_SIZE)) + { + initial_function + = (lispobj)*ptr + + (long) current_dynamic_space + - (long) old_dynamic_space_start; + } else + initial_function = (lispobj)*ptr; break; #ifdef LISP_FEATURE_GENCGC --- orig/src/runtime/gencgc-internal.h +++ mod/src/runtime/gencgc-internal.h @@ -24,6 +24,8 @@ #include "gencgc-alloc-region.h" #include "genesis/code.h" +extern void *dynamic_space_start; + #define PAGE_BYTES GENCGC_PAGE_SIZE void gc_free_heap(void); @@ -113,7 +115,7 @@ static inline boolean space_matches_p(lispobj obj, generation_index_t space) { - page_index_t page_index=(void*)obj - (void *)DYNAMIC_SPACE_START; + page_index_t page_index=(void*)obj - (void *)dynamic_space_start; return ((page_index >= 0) && ((page_index = ((unsigned long)page_index)/PAGE_BYTES) < NUM_PAGES) --- orig/src/runtime/gencgc.c +++ mod/src/runtime/gencgc.c @@ -159,6 +159,7 @@ /* To map addresses to page structures the address of the first page * is needed. */ static void *heap_base = NULL; +void *dynamic_space_start = NULL; #if N_WORD_BITS == 32 #define SIMPLE_ARRAY_WORD_WIDETAG SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG @@ -449,7 +450,7 @@ return; os_invalidate(addr, length); - new_addr = os_validate(addr, length); + new_addr = os_validate(addr, length, 1); if (new_addr == NULL || new_addr != addr) { lose("remap_free_pages: page moved, 0x%08x ==> 0x%08x", start, new_addr); } @@ -4309,7 +4310,7 @@ page_table[page].write_protected = 0; os_invalidate(page_start,PAGE_BYTES); - addr = os_validate(page_start,PAGE_BYTES); + addr = os_validate(page_start,PAGE_BYTES,1); if (addr == NULL || addr != page_start) { lose("gc_free_heap: page moved, 0x%08x ==> 0x%08x\n", page_start, @@ -4377,7 +4378,7 @@ scavtab[WEAK_POINTER_WIDETAG] = scav_weak_pointer; transother[SIMPLE_ARRAY_WIDETAG] = trans_boxed_large; - heap_base = (void*)DYNAMIC_SPACE_START; + heap_base = dynamic_space_start; /* Initialize each page structure. */ for (i = 0; i < NUM_PAGES; i++) { --- orig/src/runtime/globals.c +++ mod/src/runtime/globals.c @@ -47,7 +47,7 @@ /* For copying GCs, this points to the start of the dynamic space * currently in use (that will become the from_space when the next GC - * is done). For the GENCGC, it always points to DYNAMIC_SPACE_START. */ + * is done). For the GENCGC, it always points to dynamic_space_start. */ lispobj *current_dynamic_space; #if defined(LISP_FEATURE_SB_THREAD) --- orig/src/runtime/linux-os.c +++ mod/src/runtime/linux-os.c @@ -226,7 +226,7 @@ #endif os_vm_address_t -os_validate(os_vm_address_t addr, os_vm_size_t len) +os_validate(os_vm_address_t addr, os_vm_size_t len, int fixedp) { int flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE; os_vm_address_t actual; @@ -242,10 +242,10 @@ return 0; /* caller should check this */ } - if (addr && (addr!=actual)) { + if (addr && fixedp && (actual != addr)) { fprintf(stderr, "mmap: wanted %lu bytes at %p, actually mapped at %p\n", (unsigned long) len, addr, actual); - return 0; + lose("\n"); } #ifdef LISP_FEATURE_ALPHA @@ -297,10 +297,10 @@ if ((READ_ONLY_SPACE_START <= ad && ad < READ_ONLY_SPACE_END) || (STATIC_SPACE_START <= ad && ad < STATIC_SPACE_END) #if defined LISP_FEATURE_GENCGC - || (DYNAMIC_SPACE_START <= ad && ad < DYNAMIC_SPACE_END) + || (dynamic_space_start <= ad && ad < ((size_t) dynamic_space_start + DYNAMIC_SPACE_SIZE)) #else - || (DYNAMIC_0_SPACE_START <= ad && ad < DYNAMIC_0_SPACE_END) - || (DYNAMIC_1_SPACE_START <= ad && ad < DYNAMIC_1_SPACE_END) + || (dynamic_0_space_start <= ad && ad < ((size_t) dynamic_0_space_start + DYNAMIC_SPACE_SIZE)) + || (dynamic_1_space_start <= ad && ad < ((size_t) dynamic_1_space_start + DYNAMIC_SPACE_SIZE)) #endif ) return 1; --- orig/src/runtime/monitor.c +++ mod/src/runtime/monitor.c @@ -199,7 +199,7 @@ #endif #ifdef LISP_FEATURE_GENCGC - /* printf("DYNAMIC\t=\t0x%08lx\n", DYNAMIC_SPACE_START); */ + /* printf("DYNAMIC\t=\t0x%08lx\n", dynamic_space_start); */ #else printf("DYNAMIC\t=\t0x%08lx\n", (unsigned long)current_dynamic_space); #endif --- orig/src/runtime/os-common.c +++ mod/src/runtime/os-common.c @@ -47,7 +47,7 @@ * zero-filled. */ os_invalidate(block_start, block_size); - addr = os_validate(block_start, block_size); + addr = os_validate(block_start, block_size, 1); if (addr == NULL || addr != block_start) lose("os_zero: block moved! 0x%08x ==> 0x%08x\n", @@ -59,7 +59,7 @@ os_vm_address_t os_allocate(os_vm_size_t len) { - return os_validate((os_vm_address_t)NULL, len); + return os_validate((os_vm_address_t)NULL, len, 1); } void --- orig/src/runtime/os.h +++ mod/src/runtime/os.h @@ -71,9 +71,12 @@ /* It looks as though this function allocates 'len' bytes at 'addr', * or at an OS-chosen address if 'addr' is zero. * + * With fixedp, make sure the memory is allocated exactly to `addr', otherwise + * allow relocation to a different address. + * * FIXME: There was some documentation for these functions in * "hp-ux.c" in the old CMU CL code. Perhaps move/merge it in here. */ -extern os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len); +extern os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len, int fixedp); /* This function seems to undo the effect of os_validate(..). */ extern void os_invalidate(os_vm_address_t addr, os_vm_size_t len); --- orig/src/runtime/osf1-os.c +++ mod/src/runtime/osf1-os.c @@ -59,10 +59,10 @@ os_vm_address_t -os_validate(os_vm_address_t addr, os_vm_size_t len) +os_validate(os_vm_address_t addr, os_vm_size_t len, int fixedp) { int flags = MAP_PRIVATE|MAP_ANONYMOUS; - if (addr) flags |= MAP_FIXED; + if (addr && fixedp) flags |= MAP_FIXED; else flags |= MAP_VARIABLE; if((addr=mmap(addr,len,OS_VM_PROT_ALL,flags,-1,0)) == (os_vm_address_t) -1) --- orig/src/runtime/parse.c +++ mod/src/runtime/parse.c @@ -260,7 +260,7 @@ /* Search dynamic space. */ #if defined(LISP_FEATURE_GENCGC) - headerptr = (lispobj *)DYNAMIC_SPACE_START; + headerptr = (lispobj *)dynamic_space_start; count = (lispobj *)get_alloc_pointer() - headerptr; #else headerptr = (lispobj *)current_dynamic_space; --- orig/src/runtime/ppc-darwin-spacelist.h +++ mod/src/runtime/ppc-darwin-spacelist.h @@ -10,9 +10,9 @@ unsigned int space_start_locations[N_SEGMENTS_TO_PRODUCE] = { READ_ONLY_SPACE_START, STATIC_SPACE_START, #if defined(LISP_FEATURE_GENCGC) - DYNAMIC_SPACE_START, + DEFAULT_DYNAMIC_SPACE_START, #else - DYNAMIC_0_SPACE_START, DYNAMIC_1_SPACE_START, + DEFAULT_DYNAMIC_0_SPACE_START, DEFAULT_DYNAMIC_1_SPACE_START, #endif LINKAGE_TABLE_SPACE_START}; @@ -20,10 +20,10 @@ { READ_ONLY_SPACE_END - READ_ONLY_SPACE_START, STATIC_SPACE_END - STATIC_SPACE_START, #if defined(LISP_FEATURE_GENCGC) - DYNAMIC_SPACE_END - DYNAMIC_SPACE_START, + DYNAMIC_SPACE_SIZE, #else - DYNAMIC_0_SPACE_END - DYNAMIC_0_SPACE_START, - DYNAMIC_1_SPACE_END - DYNAMIC_1_SPACE_START, + DYNAMIC_SPACE_SIZE, + DYNAMIC_SPACE_SIZE, #endif LINKAGE_TABLE_SPACE_END - LINKAGE_TABLE_SPACE_START}; --- orig/src/runtime/purify.c +++ mod/src/runtime/purify.c @@ -97,7 +97,7 @@ ptr < (lispobj)dynamic_space_purify_pointer); #else /* Be more conservative, and remember, this is a maybe. */ - return (ptr >= (lispobj)DYNAMIC_SPACE_START + return (ptr >= (lispobj)dynamic_space_start && ptr < (lispobj)dynamic_space_purify_pointer); #endif --- orig/src/runtime/runtime.c +++ mod/src/runtime/runtime.c @@ -217,6 +217,22 @@ struct lisp_exception_frame exception_frame; #endif +#ifndef LISP_FEATURE_WIN32 + if (getenv("TEST_START")) { + long start = strtol(getenv("TEST_START"), 0, 16); + long end = strtol(getenv("TEST_END"), 0, 16); + printf("mapping from %lx to %lx\n", start, end); + if (mmap(start, + end - start, + OS_VM_PROT_ALL, + MAP_PRIVATE | MAP_ANON, + -1, + 0) + == MAP_FAILED) + exit(1); + } +#endif + /* the name of the core file we're to execute. Note that this is * a malloc'ed string which should be freed eventually. */ char *core = 0; @@ -239,8 +255,8 @@ * it must follow os_init(). -- WHN 2000-01-26 */ os_init(argv, envp); arch_init(); - gc_init(); validate(); + gc_init(); /* Parse our part of the command line (aka "runtime options"), * stripping out those options that we handle. */ --- orig/src/runtime/save.c +++ mod/src/runtime/save.c @@ -175,7 +175,7 @@ #ifdef LISP_FEATURE_GENCGC output_space(file, DYNAMIC_CORE_SPACE_ID, - (lispobj *)DYNAMIC_SPACE_START, + (lispobj *)dynamic_space_start, dynamic_space_free_pointer, core_start_pos); #else @@ -188,7 +188,7 @@ #else output_space(file, DYNAMIC_CORE_SPACE_ID, - (lispobj *)DYNAMIC_SPACE_START, + (lispobj *)dynamic_space_start, (lispobj *)SymbolValue(ALLOCATION_POINTER,0), core_start_pos); #endif --- orig/src/runtime/sunos-os.c +++ mod/src/runtime/sunos-os.c @@ -102,10 +102,12 @@ } } -os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len) +os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len, int fixedp) { int flags = MAP_PRIVATE | MAP_NORESERVE | KLUDGE_MAYBE_MAP_ANON; if (addr) + /* always use MAP_FIXED here even without `fixedp', since Solaris + * seems to ignore `addr' otherwise */ flags |= MAP_FIXED; addr = mmap(addr, len, @@ -178,10 +180,10 @@ if(in_range_p(addr, READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE) || in_range_p(addr, STATIC_SPACE_START , STATIC_SPACE_SIZE) || #ifdef LISP_FEATURE_GENCGC - in_range_p(addr, DYNAMIC_SPACE_START, DYNAMIC_SPACE_SIZE) + in_range_p(addr, dynamic_space_start, DYNAMIC_SPACE_SIZE) #else - in_range_p(addr, DYNAMIC_0_SPACE_START, DYNAMIC_SPACE_SIZE) || - in_range_p(addr, DYNAMIC_1_SPACE_START, DYNAMIC_SPACE_SIZE) + in_range_p(addr, dynamic_0_space_start, DYNAMIC_SPACE_SIZE) || + in_range_p(addr, dynamic_1_space_start, DYNAMIC_SPACE_SIZE) #endif ) return 1; --- orig/src/runtime/thread.c +++ mod/src/runtime/thread.c @@ -124,7 +124,7 @@ struct freeable_stack *new_freeable_stack = 0; if (thread_to_be_cleaned_up) { new_freeable_stack = (struct freeable_stack *) - os_validate(0, sizeof(struct freeable_stack)); + os_validate(0, sizeof(struct freeable_stack), 1); new_freeable_stack->os_thread = thread_to_be_cleaned_up->os_thread; new_freeable_stack->stack = (os_vm_address_t) thread_to_be_cleaned_up->control_stack_start; @@ -219,7 +219,7 @@ /* may as well allocate all the spaces at once: it saves us from * having to decide what to do if only some of the allocations * succeed */ - spaces=os_validate(0, THREAD_STRUCT_SIZE); + spaces=os_validate(0, THREAD_STRUCT_SIZE, 1); if(!spaces) return NULL; per_thread=(union per_thread_data *) @@ -314,7 +314,7 @@ #endif th->interrupt_data = (struct interrupt_data *) - os_validate(0,(sizeof (struct interrupt_data))); + os_validate(0,(sizeof (struct interrupt_data)),1); if (!th->interrupt_data) { free_thread_struct(th); return 0; --- orig/src/runtime/trymap.c +++ mod/src/runtime/trymap.c @@ -50,7 +50,7 @@ addr = mmap(requested_addr, hexparse(argv[2]), 0x7, - MAP_PRIVATE | MAP_ANON | MAP_FIXED, + MAP_PRIVATE | MAP_ANON, -1, 0); --- orig/src/runtime/validate.c +++ mod/src/runtime/validate.c @@ -26,7 +26,7 @@ static void ensure_space(lispobj *start, unsigned long size) { - if (os_validate((os_vm_address_t)start,(os_vm_size_t)size)==NULL) { + if (os_validate((os_vm_address_t)start,(os_vm_size_t)size,1)==NULL) { fprintf(stderr, "ensure_space: failed to validate %ld bytes at 0x%08lx\n", size, @@ -41,7 +41,7 @@ static void ensure_undefined_alien(void) { - os_vm_address_t start = os_validate(NULL, os_vm_page_size); + os_vm_address_t start = os_validate(NULL, os_vm_page_size, 1); if (start) { os_protect(start, os_vm_page_size, OS_VM_PROT_NONE); undefined_alien_address = start; @@ -60,17 +60,25 @@ ensure_space( (lispobj *)READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE); ensure_space( (lispobj *)STATIC_SPACE_START , STATIC_SPACE_SIZE); -#ifdef LISP_FEATURE_GENCGC - ensure_space( (lispobj *)DYNAMIC_SPACE_START , DYNAMIC_SPACE_SIZE); -#else - ensure_space( (lispobj *)DYNAMIC_0_SPACE_START , DYNAMIC_SPACE_SIZE); - ensure_space( (lispobj *)DYNAMIC_1_SPACE_START , DYNAMIC_SPACE_SIZE); -#endif #ifdef LISP_FEATURE_LINKAGE_TABLE ensure_space( (lispobj *)LINKAGE_TABLE_SPACE_START, LINKAGE_TABLE_SPACE_SIZE); #endif +#ifdef LISP_FEATURE_GENCGC + dynamic_space_start = os_validate( + DEFAULT_DYNAMIC_SPACE_START, DYNAMIC_SPACE_SIZE, 0); + if (dynamic_space_start == 0) + lose("failed to validate dynamic space"); +#else + dynamic_0_space_start = os_validate( + DEFAULT_DYNAMIC_0_SPACE_START, DYNAMIC_SPACE_SIZE, 0); + dynamic_1_space_start = os_validate( + DEFAULT_DYNAMIC_1_SPACE_START, DYNAMIC_SPACE_SIZE, 0); + if (dynamic_0_space_start == 0 || dynamic_1_space_start == 0) + lose("failed to validate dynamic space"); +#endif + #ifdef LISP_FEATURE_OS_PROVIDES_DLOPEN ensure_undefined_alien(); #endif --- orig/src/runtime/validate.h +++ mod/src/runtime/validate.h @@ -16,6 +16,14 @@ /* FIXME: genesis/constants.h also defines this with a constant value */ #define DYNAMIC_SPACE_START current_dynamic_space #endif +#ifndef LANGUAGE_ASSEMBLY +#ifdef LISP_FEATURE_GENCGC +extern void *dynamic_space_start; +#else +extern void *dynamic_0_space_start; +extern void *dynamic_1_space_start; +#endif +#endif #define BINDING_STACK_SIZE (1024*1024) /* chosen at random */ /* eventually choosable per-thread: */ @@ -23,9 +31,9 @@ /* constants derived from the fundamental constants in passed by GENESIS */ #ifdef LISP_FEATURE_GENCGC -#define DYNAMIC_SPACE_SIZE (DYNAMIC_SPACE_END - DYNAMIC_SPACE_START) +#define DYNAMIC_SPACE_SIZE (DEFAULT_DYNAMIC_SPACE_END - DEFAULT_DYNAMIC_SPACE_START) #else -#define DYNAMIC_SPACE_SIZE (DYNAMIC_0_SPACE_END - DYNAMIC_0_SPACE_START) +#define DYNAMIC_SPACE_SIZE (DEFAULT_DYNAMIC_0_SPACE_END - DEFAULT_DYNAMIC_0_SPACE_START) #endif #define READ_ONLY_SPACE_SIZE (READ_ONLY_SPACE_END - READ_ONLY_SPACE_START) #define STATIC_SPACE_SIZE (STATIC_SPACE_END - STATIC_SPACE_START) --- orig/src/runtime/win32-os.c +++ mod/src/runtime/win32-os.c @@ -138,8 +138,9 @@ * the memory as reserved (since we do lazy commits). */ +/* FIXME: implement fixedp */ os_vm_address_t -os_validate(os_vm_address_t addr, os_vm_size_t len) +os_validate(os_vm_address_t addr, os_vm_size_t len, int fixedp) { MEMORY_BASIC_INFORMATION mem_info; @@ -274,7 +275,7 @@ struct thread *th; if(in_range_p(addr, READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE) || in_range_p(addr, STATIC_SPACE_START , STATIC_SPACE_SIZE) || - in_range_p(addr, DYNAMIC_SPACE_START , DYNAMIC_SPACE_SIZE)) + in_range_p(addr, dynamic_space_start , DYNAMIC_SPACE_SIZE)) return 1; for_each_thread(th) { if(((os_vm_address_t)th->control_stack_start <= addr) && (addr < (os_vm_address_t)th->control_stack_end))