Skip to content

Commit

Permalink
0.8.21.18:
Browse files Browse the repository at this point in the history
	Patch from Thiemo Seufer / Peter van Eynde for MIPS assembly code
	... maybe fixes stability problems.
  • Loading branch information
csrhodes committed Apr 5, 2005
1 parent 8a85686 commit fd00d78
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 131 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion make-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/Config.mips-linux
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/runtime/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 13 additions & 16 deletions src/runtime/mips-arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 */
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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. */
Expand All @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/runtime/mips-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
128 changes: 38 additions & 90 deletions src/runtime/mips-assem.S
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -243,7 +260,7 @@ pa3:

/* Into C land we go. */
move t9, reg_CFUNC
jal t9
jalr t9
nop

lw gp, 12(reg_CFP)
Expand Down Expand Up @@ -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:
Expand All @@ -324,7 +339,6 @@ undefined_tramp:
/*
* The closure trampoline.
*/
.text
.globl closure_tramp
.ent closure_tramp
closure_tramp:
Expand All @@ -334,7 +348,6 @@ closure_tramp:
j reg_LIP
.end closure_tramp

.text
.globl end_of_tramps
end_of_tramps:

Expand All @@ -343,7 +356,6 @@ end_of_tramps:
* Function-end breakpoint magic.
*/

.text
.align 2
.set noreorder
.globl function_end_breakpoint_guts
Expand Down Expand Up @@ -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





Loading

0 comments on commit fd00d78

Please sign in to comment.