From 040e4e707e4f7bc9bda2ab78774fd9205c44ee1f Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Thu, 3 Apr 2003 15:33:21 +0000 Subject: [PATCH] 0.pre8.32 === Threads merge, 25 metres === struct thread now contains a control_stack_end element, eventually allowing for different threads to have different stack sizes --- src/code/debug-int.lisp | 15 +++++++-------- src/compiler/generic/objdef.lisp | 1 + src/compiler/x86/parms.lisp | 1 + src/runtime/gencgc.c | 5 +---- src/runtime/linux-os.c | 9 ++++----- src/runtime/purify.c | 7 ++----- src/runtime/thread.c | 2 ++ src/runtime/validate.h | 5 +++-- version.lisp-expr | 2 +- 9 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/code/debug-int.lisp b/src/code/debug-int.lisp index 44aa628c5..c705a4820 100644 --- a/src/code/debug-int.lisp +++ b/src/code/debug-int.lisp @@ -530,15 +530,14 @@ (let* ((control-stack-start (descriptor-sap sb!vm::*control-stack-start*)) (control-stack-end - (sap+ - (descriptor-sap sb!vm::*binding-stack-start*) -4))) - #!-stack-grows-downward-not-upward - (and (sap< x (current-sp)) + (descriptor-sap sb!vm::*control-stack-end*))) + #!-stack-grows-downward-not-upward + (and (sap< x (current-sp)) (sap<= control-stack-start - x) - (zerop (logand (sap-int x) #b11))) - #!+stack-grows-downward-not-upward - (and (sap>= x (current-sp)) + x) + (zerop (logand (sap-int x) #b11))) + #!+stack-grows-downward-not-upward + (and (sap>= x (current-sp)) (sap> control-stack-end x) (zerop (logand (sap-int x) #b11))))) diff --git a/src/compiler/generic/objdef.lisp b/src/compiler/generic/objdef.lisp index a2797e4f7..0e9d11e19 100644 --- a/src/compiler/generic/objdef.lisp +++ b/src/compiler/generic/objdef.lisp @@ -373,6 +373,7 @@ (binding-stack-start :c-type "lispobj *") (binding-stack-pointer :c-type "lispobj *") (control-stack-start :c-type "lispobj *") + (control-stack-end :c-type "lispobj *") (alien-stack-start :c-type "lispobj *") (alien-stack-pointer :c-type "lispobj *") (alloc-region :c-type "struct alloc_region" :length 5) diff --git a/src/compiler/x86/parms.lisp b/src/compiler/x86/parms.lisp index 8e3ee8ff1..4128ae95a 100644 --- a/src/compiler/x86/parms.lisp +++ b/src/compiler/x86/parms.lisp @@ -261,6 +261,7 @@ *binding-stack-pointer* *binding-stack-start* *control-stack-start* + *control-stack-end* ;; the floating point constants *fp-constant-0d0* diff --git a/src/runtime/gencgc.c b/src/runtime/gencgc.c index 10f56e101..af6b4ae08 100644 --- a/src/runtime/gencgc.c +++ b/src/runtime/gencgc.c @@ -3672,10 +3672,7 @@ garbage_collect_generation(int generation, int raise) preserve_pointer(regs.ebp); preserve_pointer(regs.eax); #endif - for (ptr = ((void **) - ((void *)th->control_stack_start - + THREAD_CONTROL_STACK_SIZE) - -1); + for (ptr = th->control_stack_end; #ifdef LISP_FEATURE_SB_THREAD ptr > regs.esp; #else diff --git a/src/runtime/linux-os.c b/src/runtime/linux-os.c index 8eb8d6f24..966924719 100644 --- a/src/runtime/linux-os.c +++ b/src/runtime/linux-os.c @@ -231,14 +231,13 @@ is_valid_lisp_addr(os_vm_address_t addr) { 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, STATIC_SPACE_START , STATIC_SPACE_SIZE) || in_range_p(addr, DYNAMIC_SPACE_START , DYNAMIC_SPACE_SIZE)) return 1; for_each_thread(th) { - if(in_range_p(addr, th->control_stack_start, - THREAD_CONTROL_STACK_SIZE) || - in_range_p(addr, th->binding_stack_start, - BINDING_STACK_SIZE)) + if((th->control_stack_start <= addr) && (addr < th->control_stack_end)) + return 1; + if(in_range_p(addr, th->binding_stack_start, BINDING_STACK_SIZE)) return 1; } return 0; diff --git a/src/runtime/purify.c b/src/runtime/purify.c index e061156d7..331f03bf5 100644 --- a/src/runtime/purify.c +++ b/src/runtime/purify.c @@ -1352,15 +1352,12 @@ purify(lispobj static_roots, lispobj read_only_roots) lose("PTRACE_GETREGS"); } setup_i386_stack_scav(regs.ebp, - ((void *)thread->control_stack_start) - +THREAD_CONTROL_STACK_SIZE); + ((void *)thread->control_stack_end)); } #endif #endif setup_i386_stack_scav(((&static_roots)-2), - ((void *)all_threads->control_stack_start) - +THREAD_CONTROL_STACK_SIZE); - + ((void *)all_threads->control_stack_end)); pscav(&static_roots, 1, 0); diff --git a/src/runtime/thread.c b/src/runtime/thread.c index ddcc8fdb3..f0814bedd 100644 --- a/src/runtime/thread.c +++ b/src/runtime/thread.c @@ -112,6 +112,7 @@ pid_t create_thread(lispobj initial_function) { STATIC_TLS_INIT(BINDING_STACK_START,binding_stack_start); STATIC_TLS_INIT(BINDING_STACK_POINTER,binding_stack_pointer); STATIC_TLS_INIT(CONTROL_STACK_START,control_stack_start); + STATIC_TLS_INIT(CONTROL_STACK_END,control_stack_end); STATIC_TLS_INIT(ALIEN_STACK,alien_stack_pointer); STATIC_TLS_INIT(PSEUDO_ATOMIC_ATOMIC,pseudo_atomic_atomic); STATIC_TLS_INIT(PSEUDO_ATOMIC_INTERRUPTED,pseudo_atomic_interrupted); @@ -122,6 +123,7 @@ pid_t create_thread(lispobj initial_function) { th->control_stack_start = spaces; th->binding_stack_start= (lispobj*)((void*)th->control_stack_start+THREAD_CONTROL_STACK_SIZE); + th->control_stack_end = th->binding_stack_start-1; th->alien_stack_start= (lispobj*)((void*)th->binding_stack_start+BINDING_STACK_SIZE); th->binding_stack_pointer=th->binding_stack_start; diff --git a/src/runtime/validate.h b/src/runtime/validate.h index 71278f99b..0c2546e5a 100644 --- a/src/runtime/validate.h +++ b/src/runtime/validate.h @@ -17,14 +17,15 @@ #define DYNAMIC_SPACE_SIZE ( DYNAMIC_SPACE_END - DYNAMIC_SPACE_START) #define READ_ONLY_SPACE_SIZE (READ_ONLY_SPACE_END - READ_ONLY_SPACE_START) #define STATIC_SPACE_SIZE ( STATIC_SPACE_END - STATIC_SPACE_START) -#define THREAD_CONTROL_STACK_SIZE (2*1024*1024) /* wired elsewhere-watch out */ +#define THREAD_CONTROL_STACK_SIZE (2*1024*1024) /* eventually this'll be choosable per-thread */ #if !defined(LANGUAGE_ASSEMBLY) #include #ifdef LISP_FEATURE_STACK_GROWS_DOWNWARD_NOT_UPWARD #define CONTROL_STACK_GUARD_PAGE(th) ((void *)(th->control_stack_start)) #else -#define CONTROL_STACK_GUARD_PAGE(th) (((void *)(th->control_stack_start))+THREAD_CONTROL_STACK_SIZE - os_vm_page_size) +#define CONTROL_STACK_GUARD_PAGE(th) \ + (((void *)(th->control_stack_end)) - os_vm_page_size) #endif extern void validate(void); diff --git a/version.lisp-expr b/version.lisp-expr index f2dcce9c2..23458d858 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -18,4 +18,4 @@ ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.pre8.31" +"0.pre8.32" -- 2.11.4.GIT