[project @ 2001-07-22 03:28:25 by chak]
[ghc-hetmet.git] / ghc / rts / StgCRun.c
index 09a8016..be58430 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgCRun.c,v 1.18 2000/04/17 14:46:31 sewardj Exp $
+ * $Id: StgCRun.c,v 1.23 2000/12/04 12:31:21 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -139,7 +139,7 @@ extern StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg)
 #if STACK_DETAILS
    fprintf(stderr, 
            "== SB = %p   SP = %p(%p)   SU = %p   SpLim = %p(%p)\n", 
-           sb, sp, tso->sp,   su, basereg->rSpLim, tso->splim);
+           sb, sp, tso->sp,   su, basereg->rSpLim, tso->stack + RESERVED_STACK_WORDS);
 #endif
 
    if (su >= sb) goto postloop;
@@ -238,7 +238,7 @@ EXTFUN(StgReturn)
 StgThreadReturnCode
 StgRun(StgFunPtr f, StgRegTable *basereg) {
 
-    StgChar space[ RESERVED_C_STACK_BYTES + 4*sizeof(void *) ];
+    unsigned char space[ RESERVED_C_STACK_BYTES + 4*sizeof(void *) ];
     StgThreadReturnCode r;
 
     __asm__ volatile (
@@ -314,6 +314,7 @@ StgRun(StgFunPtr f, StgRegTable *basereg) {
    does the last paragraph above mean when it says "the top of the
    stack is used for globals"?  What globals?  --SDM
 
+   Updated info (GHC 4.08.2): not saving %i7 any more (see below).
    -------------------------------------------------------------------------- */
        
 #ifdef sparc_TARGET_ARCH
@@ -321,9 +322,11 @@ StgRun(StgFunPtr f, StgRegTable *basereg) {
 StgThreadReturnCode
 StgRun(StgFunPtr f, StgRegTable *basereg) {
 
-    StgChar space[RESERVED_C_STACK_BYTES+sizeof(void *)];
+    unsigned char space[RESERVED_C_STACK_BYTES];
+#if 0
     register void *i7 __asm__("%i7");
     ((void **)(space))[100] = i7;
+#endif
     f();
     __asm__ volatile (
            ".align 4\n"                
@@ -340,8 +343,15 @@ StgRun(StgFunPtr f, StgRegTable *basereg) {
      * terrible.  We could do much better by coding it directly in
      * assembler.
      */
+#if 0
+    /* updated 4.08.2: we don't save %i7 in the middle of the reserved
+     * space any more, since gcc tries to save its address across the
+     * call to f(), this gets clobbered in STG land and we end up
+     * dereferencing a bogus pointer in StgReturn.
+     */
     __asm__ volatile ("ld %1,%0" 
                      : "=r" (i7) : "m" (((void **)(space))[100]));
+#endif
     return (StgThreadReturnCode)R1.i;
 }