[project @ 2000-12-31 16:58:05 by panne]
[ghc-hetmet.git] / ghc / rts / StgStartup.hc
index 997277a..5949c86 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgStartup.hc,v 1.7 2000/03/09 11:49:34 simonmar Exp $
+ * $Id: StgStartup.hc,v 1.13 2000/04/26 13:50:27 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -76,12 +76,15 @@ STGFUN(stg_stop_thread_entry)
      * tidy up the registers and return to the scheduler.
     */
 
-    /* Move Su just off the end of the stack, we're about to spam the
-     * STOP_FRAME with the return value.
+    /* Move Sp to the last word on the stack, and Su to just past the end
+     * of the stack.  We then place the return value at the top of the stack.
      */
+    Sp += sizeofW(StgStopFrame) - 1;
     Su = (StgUpdateFrame *)(Sp+1);  
     Sp[0] = R1.w;
 
+    CurrentTSO->what_next = ThreadComplete;
+
     SaveThreadState(); /* inline! */
 
     /* R1 contains the return value of the thread */
@@ -131,12 +134,14 @@ STGFUN(stg_enterStackTop)
    Special STG entry points for module registration.
 
    This stuff is problematic for Hugs, because it introduces a
-   dependency between the RTS and the program (ie. __init_Main).  So
+   dependency between the RTS and the program (ie. __init_PrelMain).  So
    we currently disable module initialisation for Hugs.
    -------------------------------------------------------------------------- */
 
 #ifndef INTERPRETER 
 
+extern F_ *init_stack;
+
 STGFUN(stg_init_ret)
 {
   FB_
@@ -144,14 +149,15 @@ STGFUN(stg_init_ret)
   FE_
 }
 
+/* On entry to stg_init:
+ *    init_stack[0] = &stg_init_ret;
+ *    init_stack[1] = __init_Something;
+ */
 STGFUN(stg_init)
 {
-  EF_(__init_Main);
-  EF_(__init_Prelude);
   FB_
-  PUSH_INIT_STACK(stg_init_ret);
-  PUSH_INIT_STACK(__init_Prelude);
-  JMP_(__init_Main);
+  Sp = BaseReg->rSp;
+  JMP_(POP_INIT_STACK());
   FE_
 }