From: stassats <sta...@us...> - 2015-08-23 22:31:37
|
The branch "master" has been updated in SBCL: via 0485dbba08a856cfd90c3b2dd0f541514721cd72 (commit) from 76ee3f3326569e8f27b4e022becc19b8c30e8bc5 (commit) - Log ----------------------------------------------------------------- commit 0485dbba08a856cfd90c3b2dd0f541514721cd72 Author: Stas Boukarev <sta...@gm...> Date: Mon Aug 24 01:16:56 2015 +0300 Remove unnecessary slots from the thread struct. Remove `nonpointer-data', it's not needed. Remove `selfptr', there's already `this'. Don't keep `state_...' slots on #+sb-safepoint. --- src/compiler/generic/objdef.lisp | 12 +++++------- src/runtime/thread.c | 9 +++++---- src/runtime/thread.h | 18 +++++------------- src/runtime/x86-assem.S | 12 ++++++++++-- src/runtime/x86-bsd-os.c | 3 --- src/runtime/x86-linux-os.c | 13 ------------- src/runtime/x86-sunos-os.c | 3 --- 7 files changed, 25 insertions(+), 45 deletions(-) diff --git a/src/compiler/generic/objdef.lisp b/src/compiler/generic/objdef.lisp index 2327d77..9fc6afb 100644 --- a/src/compiler/generic/objdef.lisp +++ b/src/compiler/generic/objdef.lisp @@ -428,15 +428,15 @@ #!+sb-thread (os-attr :c-type "pthread_attr_t *" :length #!+alpha 2 #!-alpha 1) - #!+sb-thread + #!+(and sb-thread (not sb-safepoint)) (state-sem :c-type "os_sem_t *" :length #!+alpha 2 #!-alpha 1) - #!+sb-thread + #!+(and sb-thread (not sb-safepoint)) (state-not-running-sem :c-type "os_sem_t *" :length #!+alpha 2 #!-alpha 1) - #!+sb-thread + #!+(and sb-thread (not sb-safepoint)) (state-not-running-waitcount :c-type "int" :length 1) - #!+sb-thread + #!+(and sb-thread (not sb-safepoint)) (state-not-stopped-sem :c-type "os_sem_t *" :length #!+alpha 2 #!-alpha 1) - #!+sb-thread + #!+(and sb-thread (not sb-safepoint)) (state-not-stopped-waitcount :c-type "int" :length 1) (control-stack-start :c-type "lispobj *" :length #!+alpha 2 #!-alpha 1 :special *control-stack-start*) @@ -468,8 +468,6 @@ (control-stack-pointer :c-type "lispobj *") #!+mach-exception-handler (mach-port-name :c-type "mach_port_name_t") - (nonpointer-data :c-type "struct nonpointer_thread_data *" :length #!+alpha 2 #!-alpha 1) - #!+(and sb-safepoint x86) (selfptr :c-type "struct thread *") ;; Context base pointer for running on top of system libraries built using ;; -fomit-frame-pointer. Currently truly required and implemented only ;; for (and win32 x86-64), but could be generalized to other platforms if diff --git a/src/runtime/thread.c b/src/runtime/thread.c index b5dcd80..bbb218f 100644 --- a/src/runtime/thread.c +++ b/src/runtime/thread.c @@ -688,8 +688,6 @@ create_thread_struct(lispobj initial_function) { ALIEN_STACK_SIZE); per_thread=(union per_thread_data *) (csp_page + THREAD_CSP_PAGE_SIZE); - struct nonpointer_thread_data *nonpointer_data - = (void *) &per_thread->dynamic_values[TLS_SIZE]; #ifdef LISP_FEATURE_SB_THREAD for(i = 0; i < (dynamic_values_bytes / sizeof(lispobj)); i++) @@ -725,17 +723,20 @@ create_thread_struct(lispobj initial_function) { * nonpointer data, because it's used for post_mortem and freed * separately */ th->os_attr=malloc(sizeof(pthread_attr_t)); - th->nonpointer_data = nonpointer_data; # ifndef LISP_FEATURE_SB_SAFEPOINT + struct nonpointer_thread_data *nonpointer_data + = (void *) &per_thread->dynamic_values[TLS_SIZE]; + th->state_sem=&nonpointer_data->state_sem; th->state_not_running_sem=&nonpointer_data->state_not_running_sem; th->state_not_stopped_sem=&nonpointer_data->state_not_stopped_sem; os_sem_init(th->state_sem, 1); os_sem_init(th->state_not_running_sem, 0); os_sem_init(th->state_not_stopped_sem, 0); -# endif th->state_not_running_waitcount = 0; th->state_not_stopped_waitcount = 0; +# endif + #endif th->state=STATE_RUNNING; #ifdef ALIEN_STACK_GROWS_DOWNWARD diff --git a/src/runtime/thread.h b/src/runtime/thread.h index e970654..a976b86 100644 --- a/src/runtime/thread.h +++ b/src/runtime/thread.h @@ -93,25 +93,17 @@ union per_thread_data { lispobj dynamic_values[1]; /* actually more like 4000 or so */ }; -/* A helper structure for data local to a thread, which is not pointer-sized. - * - * Originally, all layouting of these fields was done manually in C code - * with pointer arithmetic. We let the C compiler figure it out now. - * - * (Why is this not part of `struct thread'? Because that structure is - * declared using genesis, and we would run into issues with fields that - * are of unknown length.) - */ +/* The thread struct is generated from lisp during genesis and it + * needs to know the sizes of all its members, but some types may have + * arbitrary lengths, thus the pointers are stored instead. This + * structure is used to help allocation of those types, so that the + * pointers can be later shoved into the thread struct. */ struct nonpointer_thread_data { #if defined(LISP_FEATURE_SB_THREAD) && !defined(LISP_FEATURE_SB_SAFEPOINT) os_sem_t state_sem; os_sem_t state_not_running_sem; os_sem_t state_not_stopped_sem; -#else - /* An unused field follows, to ensure that the struct is non-empty - * for non-GCC compilers. */ - int unused; #endif }; diff --git a/src/runtime/x86-assem.S b/src/runtime/x86-assem.S index 278bfe3..901e7be 100644 --- a/src/runtime/x86-assem.S +++ b/src/runtime/x86-assem.S @@ -135,8 +135,16 @@ movl offset(reg), reg ; #elif defined(LISP_FEATURE_LINUX) || defined(LISP_FEATURE_SUNOS) || defined(LISP_FEATURE_FREEBSD) || \ defined(LISP_FEATURE_DRAGONFLY) - /* see comment in arch_os_thread_init */ -# define SBCL_THREAD_BASE_EA %fs:THREAD_SELFPTR_OFFSET + /* %fs:0 refers to the current thread. Useful! Less usefully, + * Linux/x86 isn't capable of reporting a faulting si_addr on a + * segment as defined above (whereas faults on the segment that %gs + * usually points are reported just fine...). + * But we have the thread's address stored in the THIS slot, + * so that within the thread + * movl %fs:THIS_OFFSET,x + * stores the absolute address of %fs:0 into x. + */ +# define SBCL_THREAD_BASE_EA %fs:THREAD_THIS_OFFSET # define MAYBE_FS(addr) addr #else /* perhaps there's an OS out there that actually supports %fs without diff --git a/src/runtime/x86-bsd-os.c b/src/runtime/x86-bsd-os.c index 337527f..b2e02e9 100644 --- a/src/runtime/x86-bsd-os.c +++ b/src/runtime/x86-bsd-os.c @@ -198,9 +198,6 @@ int arch_os_thread_init(struct thread *thread) { #endif #endif -#ifdef LISP_FEATURE_SB_SAFEPOINT - thread->selfptr = thread; -#endif #ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK stack_t sigstack; diff --git a/src/runtime/x86-linux-os.c b/src/runtime/x86-linux-os.c index 3934b33..892dd6a 100644 --- a/src/runtime/x86-linux-os.c +++ b/src/runtime/x86-linux-os.c @@ -105,19 +105,6 @@ int arch_os_thread_init(struct thread *thread) { thread->tls_cookie=n; pthread_mutex_unlock(&modify_ldt_lock); - /* now %fs:0 refers to the current thread. Useful! Less usefully, - * Linux/x86 isn't capable of reporting a faulting si_addr on a - * segment as defined above (whereas faults on the segment that %gs - * usually points are reported just fine...). As a special - * workaround, we store each thread structure's absolute address as - * as slot in itself, so that within the thread, - * movl %fs:SELFPTR_OFFSET,x - * stores the absolute address of %fs:0 into x. - */ -#ifdef LISP_FEATURE_SB_SAFEPOINT - thread->selfptr = thread; -#endif - if(n<0) return 0; #ifdef LISP_FEATURE_GCC_TLS current_thread = thread; diff --git a/src/runtime/x86-sunos-os.c b/src/runtime/x86-sunos-os.c index 0edd0b1..c5acfc1 100644 --- a/src/runtime/x86-sunos-os.c +++ b/src/runtime/x86-sunos-os.c @@ -103,9 +103,6 @@ int arch_os_thread_init(struct thread *thread) { thread->tls_cookie = sel; pthread_setspecific(specials,thread); -# ifdef LISP_FEATURE_SB_SAFEPOINT - thread->selfptr = thread; -# endif #endif #ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK ----------------------------------------------------------------------- hooks/post-receive -- SBCL |