From: Daniel B. <da...@us...> - 2004-07-29 22:41:39
|
Update of /cvsroot/sbcl/sbcl/src/runtime In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13663/src/runtime Modified Files: gencgc.c x86-arch.h x86-assem.S x86-linux-os.c Log Message: 0.8.3.11 Inline allocation for GENCGC ... ... add allocation-inline, which does direct access to allocation region fields based on %fs (for threads) or &boxed_region (unithread), falling through to assembler routines and eventual call to alloc() if we've run out of space in the region ... relevant assembler glue, partly borrowed from CMUCL but with changes to do thread-local access when appropriate ... patch alloc() to use boxed_region instead of all_threads->region on unithread builds ... clean up cut/pasted code in allocation-notinline Index: gencgc.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/gencgc.c,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- gencgc.c 28 Jun 2004 16:27:31 -0000 1.56 +++ gencgc.c 29 Jul 2004 22:41:27 -0000 1.57 @@ -4008,8 +4008,12 @@ alloc(int nbytes) { struct thread *th=arch_os_get_current_thread(); - struct alloc_region *region= + struct alloc_region *region= +#ifdef LISP_FEATURE_SB_THREAD th ? &(th->alloc_region) : &boxed_region; +#else + &boxed_region; +#endif void *new_obj; void *new_free_pointer; Index: x86-arch.h =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/x86-arch.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- x86-arch.h 19 Jul 2004 23:44:45 -0000 1.4 +++ x86-arch.h 29 Jul 2004 22:41:27 -0000 1.5 @@ -8,6 +8,10 @@ #error genesis/config.h (or sbcl.h) must be incuded before this file #endif +#ifndef SBCL_GENESIS_CONFIG +#error genesis/config.h (or sbcl.h) must be incuded before this file +#endif + #define ARCH_HAS_STACK_POINTER /* FIXME: Do we also want Index: x86-assem.S =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/x86-assem.S,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- x86-assem.S 8 Jun 2004 14:49:28 -0000 1.17 +++ x86-assem.S 29 Jul 2004 22:41:27 -0000 1.18 @@ -658,155 +658,152 @@ popl %eax ret .size GNAME(alloc_16_to_edi),.-GNAME(alloc_16_to_edi) - - - .align align_4byte,0x90 - .globl GNAME(post_signal_tramp) - .type GNAME(post_signal_tramp),@function -GNAME(post_signal_tramp): - /* this is notionally the second half of a function whose first half - * doesn't exist. This is where call_into_lisp returns when called - * using return_to_lisp_function */ - addl $12,%esp /* clear call_into_lisp args from stack */ - popa /* restore registers */ - popl %ebp - ret - .size GNAME(post_signal_tramp),.-GNAME(post_signal_tramp) - -#ifdef GENCGC_INLINE_ALLOC /* LISP_FEATURE_GENCGC */ - -/* These routines are called from Lisp when an inline allocation - * overflows. Every register except the result needs to be preserved. - * We depend on C to preserve ebx, esi, edi, and ebp. - * But where necessary must save eax, ecx, edx. */ +/* Called from lisp when an inline allocation overflows. + Every register except the result needs to be preserved. + We depend on C to preserve ebx, esi, edi, and ebp. + But where necessary must save eax, ecx, edx. */ +#ifdef LISP_FEATURE_SB_THREAD +#define START_REGION %fs:THREAD_ALLOC_REGION_OFFSET +#define DISPLACEMENT $7 +#else +#define START_REGION boxed_region +#define DISPLACEMENT $6 +#endif + /* This routine handles an overflow with eax=crfp+size. So the - * size=eax-crfp. */ - .align align_4byte - .globl GNAME(alloc_overflow_eax) - .type GNAME(alloc_overflow_eax),@function + size=eax-crfp. */ + .align align_4byte + .globl GNAME(alloc_overflow_eax) + .type GNAME(alloc_overflow_eax),@function GNAME(alloc_overflow_eax): - pushl %ecx # Save ecx - pushl %edx # Save edx - /* Calculate the size for the allocation. */ - subl GNAME(current_region_free_pointer),%eax - pushl %eax # Push the size - call GNAME(alloc) - addl $4,%esp # pop the size arg. - popl %edx # Restore edx. - popl %ecx # Restore ecx. - addl $6,(%esp) # Adjust the return address to skip the next inst. - ret - .size GNAME(alloc_overflow_eax),.-GNAME(alloc_overflow_eax) + pushl %ecx # Save ecx + pushl %edx # Save edx + /* Calculate the size for the allocation. */ + subl START_REGION,%eax + pushl %eax # Push the size + call GNAME(alloc) + addl $4,%esp # pop the size arg. + popl %edx # Restore edx. + popl %ecx # Restore ecx. + addl DISPLACEMENT,(%esp) # Adjust the return address to skip the next inst. + ret + .size GNAME(alloc_overflow_eax),.-GNAME(alloc_overflow_eax) -/* This routine handles an overflow with ecx=crfp+size. So the - * size=ecx-crfp. */ - .align align_4byte - .globl GNAME(alloc_overflow_ecx) - .type GNAME(alloc_overflow_ecx),@function + .align align_4byte + .globl GNAME(alloc_overflow_ecx) + .type GNAME(alloc_overflow_ecx),@function GNAME(alloc_overflow_ecx): - pushl %eax # Save eax - pushl %edx # Save edx - /* Calculate the size for the allocation. */ - subl GNAME(current_region_free_pointer),%ecx - pushl %ecx # Push the size - call GNAME(alloc) - addl $4,%esp # pop the size arg. - movl %eax,%ecx # setup the destination. - popl %edx # Restore edx. - popl %eax # Restore eax. - addl $6,(%esp) # Adjust the return address to skip the next inst. - ret - .size GNAME(alloc_overflow_ecx),.-GNAME(alloc_overflow_ecx) + pushl %eax # Save eax + pushl %edx # Save edx + /* Calculate the size for the allocation. */ + subl START_REGION,%ecx + pushl %ecx # Push the size + call GNAME(alloc) + addl $4,%esp # pop the size arg. + movl %eax,%ecx # setup the destination. + popl %edx # Restore edx. + popl %eax # Restore eax. + addl DISPLACEMENT,(%esp) # Adjust the return address to skip the next inst. + ret + .size GNAME(alloc_overflow_ecx),.-GNAME(alloc_overflow_ecx) -/* This routine handles an overflow with edx=crfp+size. So the - * size=edx-crfp. */ - .align align_4byte - .globl GNAME(alloc_overflow_edx) - .type GNAME(alloc_overflow_edx),@function + .align align_4byte + .globl GNAME(alloc_overflow_edx) + .type GNAME(alloc_overflow_edx),@function GNAME(alloc_overflow_edx): - pushl %eax # Save eax - pushl %ecx # Save ecx - /* Calculate the size for the allocation. */ - subl GNAME(current_region_free_pointer),%edx - pushl %edx # Push the size - call GNAME(alloc) - addl $4,%esp # pop the size arg. - movl %eax,%edx # setup the destination. - popl %ecx # Restore ecx. - popl %eax # Restore eax. - addl $6,(%esp) # Adjust the return address to skip the next inst. - ret - .size GNAME(alloc_overflow_edx),.-GNAME(alloc_overflow_edx) + pushl %eax # Save eax + pushl %ecx # Save ecx + /* Calculate the size for the allocation. */ + subl START_REGION,%edx + pushl %edx # Push the size + call GNAME(alloc) + addl $4,%esp # pop the size arg. + movl %eax,%edx # setup the destination. + popl %ecx # Restore ecx. + popl %eax # Restore eax. + addl DISPLACEMENT,(%esp) # Adjust the return address to skip the next inst. + ret + .size GNAME(alloc_overflow_edx),.-GNAME(alloc_overflow_edx) /* This routine handles an overflow with ebx=crfp+size. So the - * size=ebx-crfp. */ - .align align_4byte - .globl GNAME(alloc_overflow_ebx) - .type GNAME(alloc_overflow_ebx),@function + size=ebx-crfp. */ + .align align_4byte + .globl GNAME(alloc_overflow_ebx) + .type GNAME(alloc_overflow_ebx),@function GNAME(alloc_overflow_ebx): - pushl %eax # Save eax - pushl %ecx # Save ecx - pushl %edx # Save edx - /* Calculate the size for the allocation. */ - subl GNAME(current_region_free_pointer),%ebx - pushl %ebx # Push the size - call GNAME(alloc) - addl $4,%esp # pop the size arg. - movl %eax,%ebx # setup the destination. - popl %edx # Restore edx. - popl %ecx # Restore ecx. - popl %eax # Restore eax. - addl $6,(%esp) # Adjust the return address to skip the next inst. - ret - .size GNAME(alloc_overflow_ebx),.-GNAME(alloc_overflow_ebx) + pushl %eax # Save eax + pushl %ecx # Save ecx + pushl %edx # Save edx + /* Calculate the size for the allocation. */ + subl START_REGION,%ebx + pushl %ebx # Push the size + call GNAME(alloc) + addl $4,%esp # pop the size arg. + movl %eax,%ebx # setup the destination. + popl %edx # Restore edx. + popl %ecx # Restore ecx. + popl %eax # Restore eax. + addl DISPLACEMENT,(%esp) # Adjust the return address to skip the next inst. + ret + .size GNAME(alloc_overflow_ebx),.-GNAME(alloc_overflow_ebx) /* This routine handles an overflow with esi=crfp+size. So the - * size=esi-crfp. */ - .align align_4byte - .globl GNAME(alloc_overflow_esi) - .type GNAME(alloc_overflow_esi),@function + size=esi-crfp. */ + .align align_4byte + .globl GNAME(alloc_overflow_esi) + .type GNAME(alloc_overflow_esi),@function GNAME(alloc_overflow_esi): - pushl %eax # Save eax - pushl %ecx # Save ecx - pushl %edx # Save edx - /* Calculate the size for the allocation. */ - subl GNAME(current_region_free_pointer),%esi - pushl %esi # Push the size - call GNAME(alloc) - addl $4,%esp # pop the size arg. - movl %eax,%esi # setup the destination. - popl %edx # Restore edx. - popl %ecx # Restore ecx. - popl %eax # Restore eax. - addl $6,(%esp) # Adjust the return address to skip the next inst. - ret - .size GNAME(alloc_overflow_esi),.-GNAME(alloc_overflow_esi) + pushl %eax # Save eax + pushl %ecx # Save ecx + pushl %edx # Save edx + /* Calculate the size for the allocation. */ + subl START_REGION,%esi + pushl %esi # Push the size + call GNAME(alloc) + addl $4,%esp # pop the size arg. + movl %eax,%esi # setup the destination. + popl %edx # Restore edx. + popl %ecx # Restore ecx. + popl %eax # Restore eax. + addl DISPLACEMENT,(%esp) # Adjust the return address to skip the next inst. + ret + .size GNAME(alloc_overflow_esi),.-GNAME(alloc_overflow_esi) -/* This routine handles an overflow with edi=crfp+size. So the - * size=edi-crfp. */ - .align align_4byte - .globl GNAME(alloc_overflow_edi) - .type GNAME(alloc_overflow_edi),@function + .align align_4byte + .globl GNAME(alloc_overflow_edi) + .type GNAME(alloc_overflow_edi),@function GNAME(alloc_overflow_edi): - pushl %eax # Save eax - pushl %ecx # Save ecx - pushl %edx # Save edx - /* Calculate the size for the allocation. */ - subl GNAME(current_region_free_pointer),%edi - pushl %edi # Push the size - call GNAME(alloc) - addl $4,%esp # pop the size arg. - movl %eax,%edi # setup the destination. - popl %edx # Restore edx. - popl %ecx # Restore ecx. - popl %eax # Restore eax. - addl $6,(%esp) # Adjust the return address to skip the next inst. - ret - .size GNAME(alloc_overflow_edi),.-GNAME(alloc_overflow_edi) + pushl %eax # Save eax + pushl %ecx # Save ecx + pushl %edx # Save edx + /* Calculate the size for the allocation. */ + subl START_REGION,%edi + pushl %edi # Push the size + call GNAME(alloc) + addl $4,%esp # pop the size arg. + movl %eax,%edi # setup the destination. + popl %edx # Restore edx. + popl %ecx # Restore ecx. + popl %eax # Restore eax. + addl DISPLACEMENT,(%esp) # Adjust the return address to skip the next inst. + ret + .size GNAME(alloc_overflow_edi),.-GNAME(alloc_overflow_edi) -#endif + .align align_4byte,0x90 + .globl GNAME(post_signal_tramp) + .type GNAME(post_signal_tramp),@function +GNAME(post_signal_tramp): + /* this is notionally the second half of a function whose first half + * doesn't exist. This is where call_into_lisp returns when called + * using return_to_lisp_function */ + addl $12,%esp /* clear call_into_lisp args from stack */ + popa /* restore registers */ + popl %ebp + ret + .size GNAME(post_signal_tramp),.-GNAME(post_signal_tramp) + .end Index: x86-linux-os.c =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/runtime/x86-linux-os.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- x86-linux-os.c 19 Jul 2004 23:44:45 -0000 1.20 +++ x86-linux-os.c 29 Jul 2004 22:41:27 -0000 1.21 @@ -70,8 +70,8 @@ int arch_os_thread_init(struct thread *thread) { stack_t sigstack; #ifdef LISP_FEATURE_SB_THREAD - /* this must be called from a function that has an exclusive lock - * on all_threads + /* FIXME Lock ordering rules: all_threads_lock must usually be + * held when getting modify_ldt_lock */ struct user_desc ldt_entry = { 1, 0, 0, /* index, address, length filled in later */ |