From 11eaf772667ae2ad57b9e9ba29864317c7908eca Mon Sep 17 00:00:00 2001 From: sewardj Date: Fri, 8 Feb 2002 14:04:29 +0000 Subject: [PATCH] [project @ 2002-02-08 14:04:29 by sewardj] Back out rev 1.28. In retrospect saving the pre-messed-with %esp in a global location is thread/reentrancy unsafe and a brain-dead thing to do, and we can't think of a clean way to fix this. So am backing it out. --- ghc/rts/StgCRun.c | 47 +++++++++++------------------------------------ 1 file changed, 11 insertions(+), 36 deletions(-) diff --git a/ghc/rts/StgCRun.c b/ghc/rts/StgCRun.c index 3f9273a..a9501c4 100644 --- a/ghc/rts/StgCRun.c +++ b/ghc/rts/StgCRun.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgCRun.c,v 1.28 2002/02/06 15:48:56 sewardj Exp $ + * $Id: StgCRun.c,v 1.29 2002/02/08 14:04:29 sewardj Exp $ * * (c) The GHC Team, 1998-2000 * @@ -115,8 +115,6 @@ EXTFUN(StgReturn) StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg) { - static volatile void* stg_esp_saved_before_stack_align; - unsigned char space[ RESERVED_C_STACK_BYTES + 4*sizeof(void *) ]; StgThreadReturnCode r; @@ -125,7 +123,7 @@ StgRun(StgFunPtr f, StgRegTable *basereg) { * save callee-saves registers on behalf of the STG code. */ "movl %%esp, %%eax\n\t" - "addl %5, %%eax\n\t" + "addl %4, %%eax\n\t" "movl %%ebx,0(%%eax)\n\t" "movl %%esi,4(%%eax)\n\t" "movl %%edi,8(%%eax)\n\t" @@ -133,53 +131,30 @@ StgRun(StgFunPtr f, StgRegTable *basereg) { /* * Set BaseReg */ - "movl %4,%%ebx\n\t" + "movl %3,%%ebx\n\t" /* - * grab the function argument from the stack - */ - "movl %3,%%eax\n\t" - /* - * Get %%esp 8-aligned, first saving the current value. This - * moves it down another zero or four bytes, depending on - * whether it was already aligned or not. This is a bit - * subtle -- we must not have a swizzled %esp at any place - * where we might refer to one of the %digit parameters to - * this piece of assembly code, since gcc may generate - * %esp-relative stack offsets which will then be wrong. - */ - "movl %%esp, %6\n\t" - "subl $4, %%esp\n\t" - "andl $0xFFFFFFF8, %%esp\n\t" - /* - * And finally, jump to the function argument. + * grab the function argument from the stack, and jump to it. */ + "movl %2,%%eax\n\t" "jmp *%%eax\n\t" ".global " STG_RETURN "\n" STG_RETURN ":\n\t" - /* - * Restore %%esp to pre-alignment state. - */ - "movl %2, %%esp\n" - /* - * Move return value from R1 to %%eax - */ - "movl %%esi, %%eax\n\t" + + "movl %%esi, %%eax\n\t" /* Return value in R1 */ + /* * restore callee-saves registers. (Don't stomp on %%eax!) */ "movl %%esp, %%edx\n\t" - "addl %5, %%edx\n\t" + "addl %4, %%edx\n\t" "movl 0(%%edx),%%ebx\n\t" /* restore the registers saved above */ "movl 4(%%edx),%%esi\n\t" "movl 8(%%edx),%%edi\n\t" "movl 12(%%edx),%%ebp\n\t" - : "=&a" (r), "=m" (space), - "=m" (stg_esp_saved_before_stack_align) - : "m" (f), "m" (basereg), "i" (RESERVED_C_STACK_BYTES), - "m" (stg_esp_saved_before_stack_align) - + : "=&a" (r), "=m" (space) + : "m" (f), "m" (basereg), "i" (RESERVED_C_STACK_BYTES) : "edx" /* stomps on %edx */ ); -- 1.7.10.4