X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fmips-assem.S;h=53863ce8fc221ab5299d09d9385bbd029e402a8b;hb=5e92e9ed61903658015c2a75c79a32ad41dbd29d;hp=b22bbd79a0b6a7aa3eb8740c7c6194efa2310726;hpb=5e2b057871cf47c795c75106899f5fb05dc3397e;p=sbcl.git diff --git a/src/runtime/mips-assem.S b/src/runtime/mips-assem.S index b22bbd7..53863ce 100644 --- a/src/runtime/mips-assem.S +++ b/src/runtime/mips-assem.S @@ -3,6 +3,7 @@ #include "globals.h" #include "genesis/fdefn.h" #include "genesis/closure.h" +#include "genesis/return-pc.h" #include "genesis/simple-fun.h" #include "genesis/static-symbols.h" @@ -152,37 +153,25 @@ symbol: lw reg_A5, 20(reg_CFP) /* Calculate LRA */ - la reg_LRA, lra + OTHER_POINTER_LOWTAG + la reg_LRA, lra - RETURN_PC_RETURN_POINT_OFFSET /* Indirect closure */ - lw reg_CODE, -1(reg_LEXENV) + lw reg_CODE, CLOSURE_FUN_OFFSET(reg_LEXENV) /* Jump into lisp land. */ - addu reg_LIP, reg_CODE, 6*4 - FUN_POINTER_LOWTAG + addu reg_LIP, reg_CODE, SIMPLE_FUN_CODE_OFFSET jr reg_LIP + .align 2 .set noreorder - .align 3 -#ifdef irix - /* This particular KLUDGE is kept here as a reminder; for more - details, see irix-asm-munge.c from CMUCL's lisp directory. - Other examples have been deleted from later in the file in the - hope that they will not be needed. */ -.globl mipsmungelra /* for our munging afterwards in irix-asm-munge */ -mipsmungelra: -#endif -lra: - .word RETURN_PC_HEADER_WIDETAG +lra: .word RETURN_PC_HEADER_WIDETAG /* Multiple value return spot, clear stack. */ move reg_CSP, reg_OCFP - nop + nop /* Single value return spot. */ - /* Pass one return value back to C land. */ - move v0, reg_A0 # reg_CFUNC - /* Nested lisp -> C calls may have clobbered gp. */ lw gp, framesize-16(sp) @@ -208,6 +197,11 @@ lra: break 0x10 1: .set reorder + /* Pass one return value back to C land. For a 64bit value, we may + need to clobber v1 aka reg_NL4. */ + move v0, reg_A0 # reg_CFUNC + move v1, reg_A1 # reg_NL4 + /* Restore C regs */ lw ra, framesize-8(sp) lw s8, framesize-12(sp) @@ -232,9 +226,11 @@ lra: * Transfering control from Lisp into C */ NESTED(call_into_c, 0, ra) - /* The stack frame was already set up from lisp. We have - to fake the correct gp value for this function, though. */ + /* The C stack frame was already set up from lisp, and the + argument registers as well. We have to fake the correct + gp value for this function, though. */ .set noreorder + /* reg_NL3 is AT. */ .set noat lui gp, %hi(_gp_disp) addiu gp, %lo(_gp_disp) @@ -244,22 +240,24 @@ lra: .set at .set reorder + /* Setup the lisp stack. */ move reg_OCFP, reg_CFP move reg_CFP, reg_CSP addu reg_CSP, reg_CFP, 32 - subu reg_LIP, reg_CODE - addu reg_LIP, OTHER_POINTER_LOWTAG - sw reg_LIP, (reg_CFP) - sw reg_CODE, 4(reg_CFP) - sw gp, 8(reg_CFP) - /* Set the pseudo-atomic flag. */ .set noreorder li reg_NL4, 0 addu reg_ALLOC, 1 .set reorder + /* Convert the return address to an offset and save it on the stack. */ + subu reg_NFP, reg_LIP, reg_CODE + addu reg_NFP, OTHER_POINTER_LOWTAG + sw reg_LRA, (reg_CFP) + sw reg_CODE, 4(reg_CFP) + sw gp, 8(reg_CFP) + /* Save LISP state. */ subu reg_A0, reg_ALLOC, 1 sw reg_A0, dynamic_space_free_pointer @@ -278,14 +276,20 @@ lra: 1: .set reorder /* Into C land we go. */ - move t9, reg_CFUNC + move t9, reg_CFUNC # reg_ALLOC jalr t9 - lw gp, 8(reg_CFP) - - li reg_NIL, NIL + lw gp, 8(reg_CFP) - /* Clear unsaved boxed descriptor regs */ + /* Pass 64bit return value to lisp land. */ + move reg_NL0, v0 # reg_CFUNC + move reg_NL1, v1 # reg_NL4 + + /* + * Clear boxed descriptor registers before allowing an interrupt. + * We can't rely on C saving some of those registers, they might + * have been GCed in the meanwhile. + */ li reg_A0, 0 # t0 li reg_A1, 0 # t1 li reg_A2, 0 # t2 @@ -294,7 +298,15 @@ lra: li reg_A5, 0 # t5 li reg_FDEFN, 0 # t6 li reg_LEXENV, 0 # t7 + /* + * reg_NFP and reg_OCFP are pointing to fixed locations and are + * preserved by C. + */ + li reg_LRA, 0 # s2 + li reg_L0, 0 # s3 li reg_L1, 0 # t8 + li reg_CODE, 0 # s8 + li reg_LIP, 0 # ra /* Turn on pseudo-atomic. */ .set noreorder @@ -312,9 +324,9 @@ lra: lw reg_BSP, current_binding_stack_pointer /* Restore LRA & CODE */ - lw reg_LIP, (reg_CFP) + lw reg_LRA, (reg_CFP) lw reg_CODE, 4(reg_CFP) - subu reg_LIP, OTHER_POINTER_LOWTAG + subu reg_LIP, reg_NFP, OTHER_POINTER_LOWTAG addu reg_LIP, reg_CODE /* Check for interrupt */ @@ -333,43 +345,69 @@ lra: jr reg_LIP END(call_into_c) - EXPORT(start_of_tramps) - /* + * Trampolines follow the Lisp calling convention. + * * The undefined-function trampoline. */ + .align 2 + .word SIMPLE_FUN_HEADER_WIDETAG /* header */ + .word undefined_tramp - SIMPLE_FUN_CODE_OFFSET /* self */ + .word NIL /* next */ + .word NIL /* name */ + .word NIL /* arglist */ + .word NIL /* type */ LEAF(undefined_tramp) - break 10 - .byte 4 - .byte UNDEFINED_FUN_ERROR - .byte 254 - .byte (0xc0 + sc_DescriptorReg) - .byte 1 + .set noreorder + b 1f + break trap_Cerror + /* Error data length. */ + .byte 4 + /* Error number. */ + .byte UNDEFINED_FUN_ERROR + /* Magic value 254 means a 16bit little endian value follows. + See debug-var-io.lisp. */ + .byte 254 + /* reg_FDEFN is #14. */ + .byte ((14 << 5) + sc_DescriptorReg) % 0x100 + .byte ((14 << 5) + sc_DescriptorReg) / 0x100 .align 2 + .set reorder +1: lw reg_CODE, FDEFN_FUN_OFFSET(reg_FDEFN) + lw reg_LIP, SIMPLE_FUN_CODE_OFFSET(reg_CODE) + jr reg_LIP END(undefined_tramp) /* * The closure trampoline. */ + .align 5 /* common MIPS cacheline size */ + .word 0 /* pad 1 */ + .word 0 /* pad 2 */ + .word SIMPLE_FUN_HEADER_WIDETAG /* header */ + .word closure_tramp - SIMPLE_FUN_CODE_OFFSET /* self */ + .word NIL /* next */ + .word NIL /* name */ + .word NIL /* arglist */ + .word NIL /* type */ LEAF(closure_tramp) lw reg_LEXENV, FDEFN_FUN_OFFSET(reg_FDEFN) - lw reg_L0, CLOSURE_FUN_OFFSET(reg_LEXENV) - addu reg_LIP, reg_L0, SIMPLE_FUN_CODE_OFFSET + lw reg_CODE, CLOSURE_FUN_OFFSET(reg_LEXENV) + addu reg_LIP, reg_CODE, SIMPLE_FUN_CODE_OFFSET jr reg_LIP END(closure_tramp) - EXPORT(end_of_tramps) - /* * Function-end breakpoint magic. */ + .align 2 LEAF(fun_end_breakpoint_guts) .set noreorder - .align 3 .word RETURN_PC_HEADER_WIDETAG - + b multiple_value_return nop + .set reorder move reg_OCFP, reg_CSP addu reg_CSP, 4 @@ -384,9 +422,6 @@ multiple_value_return: FEXPORT(fun_end_breakpoint_trap) break trap_FunEndBreakpoint -1: b 1b - nop - + b multiple_value_return EXPORT(fun_end_breakpoint_end) - .set reorder END(fun_end_breakpoint_guts)