[project @ 2003-08-19 16:32:23 by simonmar]
[ghc-hetmet.git] / ghc / rts / PrimOps.hc
index f16a63b..45717e5 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: PrimOps.hc,v 1.106 2003/03/24 14:46:54 simonmar Exp $
+ * $Id: PrimOps.hc,v 1.110 2003/07/23 13:39:11 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2002
  *
@@ -188,7 +188,7 @@ StgWord GHC_ZCCReturnable_static_info[1];
 #define PUSHED(m)   Sp -= (m); JMP_(ENTRY_CODE(Sp[m]));
 
 # define RET_P(a)     PUSH(1,a); PUSHED(1)
-# define RET_N(a)     PUSH(1,a); PUSHED(2)
+# define RET_N(a)     PUSH(1,a); PUSHED(1)
 
 # define RET_PP(a,b)   PUSH(2,a); PUSH(1,b); PUSHED(2)
 # define RET_NN(a,b)   PUSH(2,a); PUSH(1,b); PUSHED(2)
@@ -368,7 +368,6 @@ FN_(atomicModifyMutVarzh_fast)
    r->payload[0] = z;
 
    RET_P(r);
-   JMP_(ENTRY_CODE(Sp[0]));
    FE_
 }
 
@@ -1064,8 +1063,7 @@ FN_(forkProcesszh_fast)
 
   R1.i = RET_STGCALL1(StgInt, forkProcess, CurrentTSO);
 
-  JMP_(ENTRY_CODE(Sp[0]));
-
+  RET_N(R1.i);
   FE_
 }
 
@@ -1642,6 +1640,10 @@ FN_(delayzh_fast)
     ares->len     = 0;
     ares->errCode = 0;
     CurrentTSO->block_info.async_result = ares;
+    /* Having all async-blocked threads reside on the blocked_queue simplifies matters, so
+     * change the status to OnDoProc & put the delayed thread on the blocked_queue.
+     */
+    CurrentTSO->why_blocked = BlockedOnDoProc;
     APPEND_TO_BLOCKED_QUEUE(CurrentTSO);
 #else
     target = (R1.i / (TICK_MILLISECS*1000)) + getourtimeofday();
@@ -1678,7 +1680,7 @@ FN_(asyncReadzh_fast)
     CurrentTSO->why_blocked = BlockedOnRead;
     ACQUIRE_LOCK(&sched_mutex);
     /* could probably allocate this on the heap instead */
-    ares = (StgAsyncIOResult*)RET_STGCALL2(P_,stgMallocBytes,sizeof(StgAsyncIOResult), "asyncWritezh_fast");
+    ares = (StgAsyncIOResult*)RET_STGCALL2(P_,stgMallocBytes,sizeof(StgAsyncIOResult), "asyncReadzh_fast");
     reqID = RET_STGCALL5(W_,addIORequest,R1.i,FALSE,R2.i,R3.i,(char*)R4.p);
     ares->reqID   = reqID;
     ares->len     = 0;
@@ -1711,4 +1713,26 @@ FN_(asyncWritezh_fast)
     JMP_(stg_block_async);
   FE_
 }
+
+FN_(asyncDoProczh_fast)
+{
+  StgAsyncIOResult* ares;
+  unsigned int reqID;
+  FB_
+    /* args: R1.i = proc, R2.i = param */
+    ASSERT(CurrentTSO->why_blocked == NotBlocked);
+    CurrentTSO->why_blocked = BlockedOnDoProc;
+    ACQUIRE_LOCK(&sched_mutex);
+    /* could probably allocate this on the heap instead */
+    ares = (StgAsyncIOResult*)RET_STGCALL2(P_,stgMallocBytes,sizeof(StgAsyncIOResult), "asyncDoProczh_fast");
+    reqID = RET_STGCALL2(W_,addDoProcRequest,R1.p,R2.p);
+    ares->reqID   = reqID;
+    ares->len     = 0;
+    ares->errCode = 0;
+    CurrentTSO->block_info.async_result = ares;
+    APPEND_TO_BLOCKED_QUEUE(CurrentTSO);
+    RELEASE_LOCK(&sched_mutex);
+    JMP_(stg_block_async);
+  FE_
+}
 #endif