From: Christophe Rhodes Date: Tue, 5 Apr 2005 16:38:14 +0000 (+0000) Subject: 0.8.21.18: X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=fd00d78accb69be3a626a29120ba17a18569b98c;p=sbcl.git 0.8.21.18: Patch from Thiemo Seufer / Peter van Eynde for MIPS assembly code ... maybe fixes stability problems. --- diff --git a/NEWS b/NEWS index fec42bf..a17a147 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ changes in sbcl-0.8.22 relative to sbcl-0.8.21: (reported by Baughn on #lisp) * a cross-compiler bug on non-x86 platforms has been identified and fixed. (thanks to Bruno Haible) + * improvements to the MIPS runtime code for increased stability. + (thanks to Thiemo Seufer) * fixed some bugs related to Unicode integration: ** the restarts for recovering from input and output encoding errors only appear when there is in fact such an error to diff --git a/make-config.sh b/make-config.sh index 6fd6eb4..09b059a 100644 --- a/make-config.sh +++ b/make-config.sh @@ -38,7 +38,7 @@ case `uname -m` in ppc) guessed_sbcl_arch=ppc ;; Power*Macintosh) guessed_sbcl_arch=ppc ;; parisc) guessed_sbcl_arch=hppa ;; - mips) guessed_sbcl_arch=mips ;; + mips*) guessed_sbcl_arch=mips ;; *) # If we're not building on a supported target architecture, we # we have no guess, but it's not an error yet, since maybe diff --git a/src/runtime/Config.mips-linux b/src/runtime/Config.mips-linux index fc7b5f7..b853340 100644 --- a/src/runtime/Config.mips-linux +++ b/src/runtime/Config.mips-linux @@ -7,15 +7,15 @@ # provided with absolutely no warranty. See the COPYING and CREDITS # files for more information. -CFLAGS += -g -O0 -LD = ld -LINKFLAGS = -v -g +CFLAGS += -Dmips -g +LD = ld +LINKFLAGS = -v -g -O2 NM = nm -p ASSEM_SRC = mips-assem.S ldso-stubs.S ARCH_SRC = mips-arch.c #undefineds.c -OS_SRC = linux-os.c mips-linux-os.c os-common.c +OS_SRC = linux-os.c mips-linux-os.c os-common.c OS_LIBS= -ldl GC_SRC= cheneygc.c diff --git a/src/runtime/globals.h b/src/runtime/globals.h index 7c48249..e8dd9de 100644 --- a/src/runtime/globals.h +++ b/src/runtime/globals.h @@ -43,8 +43,12 @@ extern void globals_init(void); #else /* LANGUAGE_ASSEMBLY */ #ifdef mips +#ifdef __linux__ +#define EXTERN(name,bytes) .globl name +#else #define EXTERN(name,bytes) .extern name bytes #endif +#endif /**/ #ifdef sparc #ifdef SVR4 diff --git a/src/runtime/mips-arch.c b/src/runtime/mips-arch.c index 9e7651d..1e442b4 100644 --- a/src/runtime/mips-arch.c +++ b/src/runtime/mips-arch.c @@ -40,8 +40,8 @@ emulate_branch(os_context_t *context, unsigned long inst) long opcode = inst >> 26; long r1 = (inst >> 21) & 0x1f; long r2 = (inst >> 16) & 0x1f; - long bdisp = (inst&(1<<15)) ? inst | (-1 << 16) : inst&0xffff; - long jdisp = (inst&(1<<25)) ? inst | (-1 << 26) : inst&0xffff; + long bdisp = ((inst&(1<<15)) ? inst | (-1 << 16) : inst&0x7fff) << 2; + long jdisp = (inst&0x3ffffff) << 2; long disp = 0; switch(opcode) { @@ -77,17 +77,14 @@ emulate_branch(os_context_t *context, unsigned long inst) != *os_context_register_addr(context, r2)) disp = bdisp; break; - case 0x6: /* ble */ + case 0x6: /* blez */ if(*os_context_register_addr(context, r1) - /* FIXME: One has to assume that the CMUCL gods of old have - got the sign issues right... but it might be worth - checking, someday */ <= *os_context_register_addr(context, r2)) disp = bdisp; break; case 0x7: /* bgtz */ if(*os_context_register_addr(context, r1) - >= *os_context_register_addr(context, r2)) + > *os_context_register_addr(context, r2)) disp = bdisp; break; case 0x2: /* j */ @@ -98,7 +95,7 @@ emulate_branch(os_context_t *context, unsigned long inst) *os_context_register_addr(context, 31) = *os_context_pc_addr(context) + 4; break; } - return (*os_context_pc_addr(context) + disp * 4); + return (*os_context_pc_addr(context) + disp); } void arch_skip_instruction(os_context_t *context) @@ -166,9 +163,9 @@ static sigset_t orig_sigmask; void arch_do_displaced_inst(os_context_t *context, unsigned int orig_inst) { - unsigned long *pc = (unsigned long *)*os_context_pc_addr(context); - unsigned long *break_pc, *next_pc; - unsigned long next_inst; + unsigned int *pc = (unsigned int *)*os_context_pc_addr(context); + unsigned int *break_pc, *next_pc; + unsigned int next_inst; int opcode; orig_sigmask = *os_context_sigmask_addr(context); @@ -186,7 +183,7 @@ void arch_do_displaced_inst(os_context_t *context, /* Put the original instruction back. */ *break_pc = orig_inst; - os_flush_icache((os_vm_address_t)break_pc, sizeof(unsigned long)); + os_flush_icache((os_vm_address_t)break_pc, sizeof(unsigned int)); skipped_break_addr = break_pc; /* Figure out where it goes. */ @@ -200,18 +197,18 @@ void arch_do_displaced_inst(os_context_t *context, displaced_after_inst = *next_pc; *next_pc = (trap_AfterBreakpoint << 16) | 0xd; - os_flush_icache((os_vm_address_t)next_pc, sizeof(unsigned long)); + os_flush_icache((os_vm_address_t)next_pc, sizeof(unsigned int)); } static void sigtrap_handler(int signal, siginfo_t *info, void *void_context) { os_context_t *context = arch_os_get_context(&void_context); sigset_t *mask; - int code; + unsigned int code; /* Don't disallow recursive breakpoint traps. Otherwise, we can't */ /* use debugger breakpoints anywhere in here. */ mask = os_context_sigmask_addr(context); - sigsetmask(mask); + sigprocmask(SIG_SETMASK, mask, NULL); code = ((*(int *) (*os_context_pc_addr(context))) >> 16) & 0x1f; switch (code) { @@ -243,7 +240,7 @@ static void sigtrap_handler(int signal, siginfo_t *info, void *void_context) sizeof(unsigned long)); skipped_break_addr = NULL; *(unsigned long *)(*os_context_pc_addr(context)) = displaced_after_inst; - os_flush_icache((os_vm_address_t) *os_context_pc_addr(context), sizeof(unsigned long)); + os_flush_icache((os_vm_address_t) *os_context_pc_addr(context), sizeof(unsigned int)); *os_context_sigmask_addr(context) = orig_sigmask; break; diff --git a/src/runtime/mips-arch.h b/src/runtime/mips-arch.h index 0e9a729..7cde570 100644 --- a/src/runtime/mips-arch.h +++ b/src/runtime/mips-arch.h @@ -3,13 +3,13 @@ static inline void -get_spinlock(lispobj *word,long value) +get_spinlock(volatile lispobj *word, long value) { *word=value; /* FIXME for threads */ } static inline void -release_spinlock(lispobj *word) +release_spinlock(volatile lispobj *word) { *word=0; } diff --git a/src/runtime/mips-assem.S b/src/runtime/mips-assem.S index 2cff8ef9..5bf5448 100644 --- a/src/runtime/mips-assem.S +++ b/src/runtime/mips-assem.S @@ -1,14 +1,13 @@ -#define LANGUAGE_ASSEMBLY - -#include "sbcl.h" +#include "sbcl.h" #include "lispregs.h" +#include "globals.h" #include "genesis/fdefn.h" #include "genesis/closure.h" #include "genesis/simple-fun.h" #include "genesis/static-symbols.h" #define zero $0 -#define at $1 +#define AT $1 #define v0 $2 #define v1 $3 #define a0 $4 @@ -40,21 +39,37 @@ #define s8 $30 #define ra $31 +/* + * NESTED - declare nested routine entry point + */ +#define NESTED(symbol, framesize, rpc) \ + .globl symbol; \ + .align 2; \ + .type symbol,@function; \ + .ent symbol,0; \ +symbol: .frame sp, framesize, rpc + +/* + * END - mark end of function + */ +#define END(function) \ + .end function; \ + .size function,.-function + + + .text /* * Function to transfer control into lisp. */ - .text - .globl call_into_lisp - .ent call_into_lisp -call_into_lisp: -#define framesize 12*4 +#define framesize 16*4 + NESTED(call_into_lisp, framesize, ra) subu sp, framesize - .frame sp, framesize, ra /* Save all the C regs. */ - .mask 0xc0ff0000, 0 + .mask 0xd0ff0000, -4 sw ra, framesize(sp) sw s8, framesize-4(sp) + sw gp, framesize-8(sp) sw s7, framesize-12(sp) sw s6, framesize-16(sp) sw s5, framesize-20(sp) @@ -110,9 +125,9 @@ pa1: .set reorder /* Pass in args */ - move reg_LEXENV, $4 - move reg_CFP, $5 - sll reg_NARGS, $6, 2 + move reg_LEXENV, a0 + move reg_CFP, a1 + sll reg_NARGS, a2, 2 lw reg_A0, 0(reg_CFP) lw reg_A1, 4(reg_CFP) lw reg_A2, 8(reg_CFP) @@ -128,7 +143,7 @@ pa1: /* Jump into lisp land. */ addu reg_LIP, reg_CODE, 6*4 - FUN_POINTER_LOWTAG - j reg_LIP + jr reg_LIP .set noreorder .align 3 @@ -179,6 +194,7 @@ pa2: /* Restore C regs */ lw ra, framesize(sp) lw s8, framesize-4(sp) + lw gp, framesize-8(sp) lw s7, framesize-12(sp) lw s6, framesize-16(sp) lw s5, framesize-20(sp) @@ -192,16 +208,17 @@ pa2: addu sp, framesize /* Back we go. */ - j ra + jr ra - .end call_into_lisp + END(call_into_lisp) /* * Transfering control from Lisp into C */ - .text .globl call_into_c - .ent call_into_c + .align 2 + .type call_into_c,@function + .ent call_into_c,0 call_into_c: /* Set up a stack frame. */ move reg_OCFP, reg_CFP @@ -243,7 +260,7 @@ pa3: /* Into C land we go. */ move t9, reg_CFUNC - jal t9 + jalr t9 nop lw gp, 12(reg_CFP) @@ -299,16 +316,14 @@ pa4: /* Return to LISP. */ j reg_LIP - .end call_into_c + END(call_into_c) - .text .globl start_of_tramps start_of_tramps: /* * The undefined-function trampoline. */ - .text .globl undefined_tramp .ent undefined_tramp undefined_tramp: @@ -324,7 +339,6 @@ undefined_tramp: /* * The closure trampoline. */ - .text .globl closure_tramp .ent closure_tramp closure_tramp: @@ -334,7 +348,6 @@ closure_tramp: j reg_LIP .end closure_tramp - .text .globl end_of_tramps end_of_tramps: @@ -343,7 +356,6 @@ end_of_tramps: * Function-end breakpoint magic. */ - .text .align 2 .set noreorder .globl function_end_breakpoint_guts @@ -371,67 +383,3 @@ fun_end_breakpoint_trap: .globl fun_end_breakpoint_end fun_end_breakpoint_end: .set reorder - -/* FIXME: I don't think the below are actually used anywhere */ - .text - .align 2 - .globl call_on_stack - .ent call_on_stack -call_on_stack: - subu sp, a1, 16 - jal a0 - break 0 - .end call_on_stack - - .globl save_state - .ent save_state -save_state: - subu sp, 40 - .frame sp, 40, ra - /* Save all the C regs. */ - .mask 0xc0ff0000, 0 - sw ra, 40(sp) - sw s8, 40-4(sp) - sw s7, 40-8(sp) - sw s6, 40-12(sp) - sw s5, 40-16(sp) - sw s4, 40-20(sp) - sw s3, 40-24(sp) - sw s2, 40-28(sp) - sw s1, 40-32(sp) - sw s0, 40-36(sp) - - /* Should also save the floating point state. */ - - move t0, a0 - move a0, sp - - jal t0 - -_restore_state: - - lw ra, 40(sp) - lw s8, 40-4(sp) - lw s7, 40-8(sp) - lw s6, 40-12(sp) - lw s5, 40-16(sp) - lw s4, 40-20(sp) - lw s3, 40-24(sp) - lw s2, 40-28(sp) - lw s1, 40-32(sp) - lw s0, 40-36(sp) - - addu sp, 40 - j ra - - .globl restore_state -restore_state: - move sp, a0 - move v0, a1 - j _restore_state - .end save_state - - - - - diff --git a/tools-for-build/ldso-stubs.lisp b/tools-for-build/ldso-stubs.lisp index 66e883b..500336b 100644 --- a/tools-for-build/ldso-stubs.lisp +++ b/tools-for-build/ldso-stubs.lisp @@ -116,24 +116,32 @@ ldso_stub__ ## fct ## $lazy_ptr: @\\ ;;; the fifth argument, as the first four are passed in registers ;;; and we apparently don't ever need to pass six arguments to a ;;; libc function. -- CSR, 2003-10-29 +;;; Expanded to 8 arguments regardless. -- ths, 2005-03-24 #!+mips " -#define LDSO_STUBIFY(fct) \\ -.globl ldso_stub__ ## fct ; \\ - .type ldso_stub__ ## fct,@function ; \\ -ldso_stub__ ## fct: ; \\ - addiu $29,-48 ; \\ - sw $28,40($29) ; \\ - sw $31,44($29) ; \\ - lw $25,64($29) ; \\ - sw $25,16($29) ; \\ - la $25, fct ; \\ - jalr $25 ; \\ - lw $31,44($29) ; \\ - lw $28,40($29) ; \\ - addiu $29,48 ; \\ - jr $31 ; \\ -.L ## fct ## e1: ; \\ - .size ldso_stub__ ## fct,.L ## fct ## e1-ldso_stub__ ## fct ;")) +#define LDSO_STUBIFY(fct) \\ + .globl ldso_stub__ ## fct ; \\ + .type ldso_stub__ ## fct,@function ; \\ + .ent ldso_stub__ ## fct ; \\ +ldso_stub__ ## fct: ; \\ + addiu $29,-48 ; \\ + sw $28,40($29) ; \\ + sw $31,44($29) ; \\ + lw $25,64($29) ; \\ + sw $25,16($29) ; \\ + lw $25,68($29) ; \\ + sw $25,20($29) ; \\ + lw $25,72($29) ; \\ + sw $25,24($29) ; \\ + lw $25,76($29) ; \\ + sw $25,28($29) ; \\ + la $25, fct ; \\ + jalr $25 ; \\ + lw $31,44($29) ; \\ + lw $28,40($29) ; \\ + addiu $29,48 ; \\ + jr $31 ; \\ + .end ldso_stub__ ## fct ; \\ + .size ldso_stub__ ## fct,.-ldso_stub__ ## fct ;")) (defvar *stubs* (append '("accept" diff --git a/version.lisp-expr b/version.lisp-expr index ac2a572..599e64b 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.8.21.17" +"0.8.21.18"