X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FStgCRun.c;h=51388510c6333a618e1b4832cae9b6e3a1a95e66;hb=ca5ded310c0a596be199a3da5f14be2fb2020687;hp=c1afc1655945678e309013ef6c596d4169831ffe;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/rts/StgCRun.c b/rts/StgCRun.c index c1afc16..5138851 100644 --- a/rts/StgCRun.c +++ b/rts/StgCRun.c @@ -50,6 +50,7 @@ * in libc.a clobbers $s6. */ #include "ghcconfig.h" +#ifndef USE_MINIINTERPRETER #ifdef alpha_HOST_ARCH #define alpha_EXTRA_CAREFUL register long fake_ra __asm__("$26"); @@ -60,6 +61,7 @@ register double fake_f8 __asm__("$f8"); register double fake_f9 __asm__("$f9"); #endif #endif +#endif /* include Stg.h first because we want real machine regs in here: we * have to get the value of R1 back from Stg land to C land intact. @@ -85,11 +87,13 @@ register double fake_f9 __asm__("$f9"); StgRegTable * StgRun(StgFunPtr f, StgRegTable *basereg STG_UNUSED) { while (f) { + /* XXX Disabled due to RtsFlags[]/RtsFlags mismatch IF_DEBUG(interpreter, debugBelch("Jumping to "); printPtr((P_)f); fflush(stdout); debugBelch("\n"); ); + */ f = (StgFunPtr) (f)(); } return (StgRegTable *)R1.p; @@ -103,6 +107,12 @@ StgFunPtr StgReturn(void) #else /* !USE_MINIINTERPRETER */ #ifdef LEADING_UNDERSCORE +#define STG_RUN "_StgRun" +#else +#define STG_RUN "StgRun" +#endif + +#ifdef LEADING_UNDERSCORE #define STG_RETURN "_StgReturn" #else #define STG_RETURN "StgReturn" @@ -203,8 +213,8 @@ StgRunIsImplementedInAssembler(void) /* * save callee-saves registers on behalf of the STG code. */ - ".globl StgRun\n" - "StgRun:\n\t" + ".globl " STG_RUN "\n" + STG_RUN ":\n\t" "subq %0, %%rsp\n\t" "movq %%rsp, %%rax\n\t" "addq %0-48, %%rax\n\t" @@ -224,7 +234,7 @@ StgRunIsImplementedInAssembler(void) "movq %%rdi,%%rax\n\t" "jmp *%%rax\n\t" - ".global " STG_RETURN "\n" + ".globl " STG_RETURN "\n" STG_RETURN ":\n\t" "movq %%rbx, %%rax\n\t" /* Return value in R1 */ @@ -328,13 +338,16 @@ StgRun(StgFunPtr f, StgRegTable *basereg) { ".align 4\n" ".global " STG_RETURN "\n" STG_RETURN ":" - : : : "l0","l1","l2","l3","l4","l5","l6","l7"); + : : "p" (space) : "l0","l1","l2","l3","l4","l5","l6","l7"); /* we tell the C compiler that l0-l7 are clobbered on return to * StgReturn, otherwise it tries to use these to save eg. the * address of space[100] across the call. The correct thing * to do would be to save all the callee-saves regs, but we * can't be bothered to do that. * + * We also explicitly mark space as used since gcc eliminates it + * otherwise. + * * The code that gcc generates for this little fragment is now * terrible. We could do much better by coding it directly in * assembler. @@ -894,4 +907,37 @@ StgRunIsImplementedInAssembler(void) #endif +/* ----------------------------------------------------------------------------- + MIPS architecture + -------------------------------------------------------------------------- */ + +#ifdef mips_HOST_ARCH + +StgThreadReturnCode +StgRun(StgFunPtr f, StgRegTable *basereg) +{ + register StgThreadReturnCode __v0 __asm__("$2"); + + __asm__ __volatile__( + " la $25, %1 \n" + " move $30, %2 \n" + " jr %1 \n" + " .align 3 \n" + " .globl " STG_RETURN " \n" + " .aent " STG_RETURN " \n" + STG_RETURN ": \n" + " move %0, $16 \n" + " move $3, $17 \n" + : "=r" (__v0), + : "r" (f), "r" (basereg) + "$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23", + "$25", "$28", "$30", + "$f20", "$f22", "$f24", "$f26", "$f28", "$f30", + "memory"); + + return __v0; +} + +#endif /* mips_HOST_ARCH */ + #endif /* !USE_MINIINTERPRETER */