[project @ 2004-08-13 10:45:16 by simonmar]
[ghc-hetmet.git] / ghc / rts / HeapStackCheck.hc
index d3e6661..2254b5c 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: HeapStackCheck.hc,v 1.27 2002/12/11 15:36:42 simonmar Exp $
+ * $Id: HeapStackCheck.hc,v 1.31 2003/05/14 09:13:59 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2002
  *
 #include "StgRun.h"    /* for StgReturn and register saving */
 #include "Schedule.h"   /* for context_switch */
 #include "RtsFlags.h"
+#include "RtsUtils.h"
 #include "Apply.h"
 
 #include <stdio.h>
 
+#ifdef mingw32_TARGET_OS
+#include <stdlib.h>
+#endif
+
 /* Stack/Heap Check Failure
  * ------------------------
  *
 
 INFO_TABLE_RET( stg_enter_info, stg_enter_ret, 
                MK_SMALL_BITMAP(1/*framesize*/, 0/*bitmap*/),
-               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_LEN*/, 
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
                RET_SMALL,, EF_, 0, 0);
 EXTFUN(stg_enter_ret)
 {
@@ -491,7 +496,7 @@ EXTFUN(stg_gc_noregs)
 
 INFO_TABLE_RET( stg_gc_void_info, stg_gc_void_ret, 
                MK_SMALL_BITMAP(0/*framesize*/, 0/*bitmap*/),
-               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_LEN*/, 
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
                RET_SMALL,, EF_, 0, 0);
 
 EXTFUN(stg_gc_void_ret)
@@ -506,7 +511,7 @@ EXTFUN(stg_gc_void_ret)
 
 INFO_TABLE_RET( stg_gc_unpt_r1_info, stg_gc_unpt_r1_ret, 
                MK_SMALL_BITMAP(1/*framesize*/, 0/*bitmap*/),
-               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_LEN*/, 
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
                RET_SMALL,, EF_, 0, 0);
 
 EXTFUN(stg_gc_unpt_r1_ret)
@@ -532,7 +537,7 @@ EXTFUN(stg_gc_unpt_r1)
 
 INFO_TABLE_RET(        stg_gc_unbx_r1_info, stg_gc_unbx_r1_ret, 
                MK_SMALL_BITMAP(1/*framesize*/, 1/*bitmap*/),
-               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_LEN*/, 
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
                RET_SMALL,, EF_, 0, 0);
 
 /* the 1 is a bitmap - i.e. 1 non-pointer word on the stack. */
@@ -560,7 +565,7 @@ EXTFUN(stg_gc_unbx_r1)
 
 INFO_TABLE_RET(        stg_gc_f1_info, stg_gc_f1_ret, 
                MK_SMALL_BITMAP(1/*framesize*/, 1/*bitmap*/),
-               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_LEN*/, 
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
                RET_SMALL,, EF_, 0, 0);
 
 EXTFUN(stg_gc_f1_ret)
@@ -596,7 +601,7 @@ EXTFUN(stg_gc_f1)
 
 INFO_TABLE_RET(        stg_gc_d1_info, stg_gc_d1_ret, 
                MK_SMALL_BITMAP(DBL_WORDS/*framesize*/, DBL_BITMAP/*bitmap*/),
-               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_LEN*/, 
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
                RET_SMALL,, EF_, 0, 0);
 
 EXTFUN(stg_gc_d1_ret)
@@ -633,7 +638,7 @@ EXTFUN(stg_gc_d1)
 
 INFO_TABLE_RET( stg_gc_l1_info, stg_gc_l1_ret, 
                MK_SMALL_BITMAP(LLI_WORDS/*framesize*/, LLI_BITMAP/*bitmap*/),
-               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_LEN*/, 
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
                RET_SMALL,, EF_, 0, 0);
 
 EXTFUN(stg_gc_l1_ret)
@@ -659,7 +664,7 @@ EXTFUN(stg_gc_l1)
 
 INFO_TABLE_RET( stg_ut_1_0_unreg_info, stg_ut_1_0_unreg_ret, 
                MK_SMALL_BITMAP(1/*size*/, 0/*BITMAP*/),
-               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_LEN*/, 
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
                RET_SMALL,, EF_, 0, 0);
 
 EXTFUN(stg_ut_1_0_unreg_ret)
@@ -753,7 +758,7 @@ EXTFUN(__stg_gc_fun)
 
 INFO_TABLE_RET( stg_gc_fun_info,stg_gc_fun_ret,
                MK_SMALL_BITMAP(0/*framesize*/, 0/*bitmap*/),
-               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_LEN*/, 
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
                RET_FUN,, EF_, 0, 0);
 
 EXTFUN(stg_gc_fun_ret)
@@ -805,6 +810,7 @@ EXTFUN(stg_gc_fun_ret)
 // it's not a big deal.
 
 #define RESTORE_EVERYTHING                     \
+    L1   = PK_Word64(Sp+19);                   \
     D2   = PK_DBL(Sp+17);                      \
     D1   = PK_DBL(Sp+15);                      \
     F4   = PK_FLT(Sp+14);                      \
@@ -819,12 +825,13 @@ EXTFUN(stg_gc_fun_ret)
     R3.w = Sp[5];                              \
     R2.w = Sp[4];                              \
     R1.w = Sp[3];                              \
-    Sp += 19;
+    Sp += 21;
 
-#define RET_OFFSET (-17)
+#define RET_OFFSET (-19)
 
 #define SAVE_EVERYTHING                                \
-    Sp -= 19;                                  \
+    Sp -= 21;                                  \
+    ASSIGN_Word64(Sp+19,L1);                   \
     ASSIGN_DBL(Sp+17,D2);                      \
     ASSIGN_DBL(Sp+15,D1);                      \
     ASSIGN_FLT(Sp+14,F4);                      \
@@ -845,7 +852,7 @@ EXTFUN(stg_gc_fun_ret)
 
 INFO_TABLE_RET( stg_gc_gen_info, stg_gc_gen_ret, 
                0/*bitmap*/,
-               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_LEN*/, 
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
                RET_DYN,, EF_, 0, 0);
 
 /* bitmap in the above info table is unused, the real one is on the stack. 
@@ -973,7 +980,7 @@ FN_(stg_block_1)
 
 INFO_TABLE_RET( stg_block_takemvar_info,  stg_block_takemvar_ret,
                MK_SMALL_BITMAP(1/*framesize*/, 0/*bitmap*/),
-               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_LEN*/, 
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
                RET_SMALL,, IF_, 0, 0);
 
 IF_(stg_block_takemvar_ret)
@@ -997,7 +1004,7 @@ FN_(stg_block_takemvar)
 
 INFO_TABLE_RET( stg_block_putmvar_info,  stg_block_putmvar_ret,
                MK_SMALL_BITMAP(2/*framesize*/, 0/*bitmap*/),
-               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_LEN*/, 
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
                RET_SMALL,, IF_, 0, 0);
 
 IF_(stg_block_putmvar_ret)
@@ -1020,3 +1027,36 @@ FN_(stg_block_putmvar)
   BLOCK_GENERIC;
   FE_
 }
+
+#ifdef mingw32_TARGET_OS
+INFO_TABLE_RET( stg_block_async_info,  stg_block_async_ret,
+               MK_SMALL_BITMAP(0/*framesize*/, 0/*bitmap*/),
+               0/*SRT*/, 0/*SRT_OFF*/, 0/*SRT_BITMAP*/, 
+               RET_SMALL,, IF_, 0, 0);
+
+IF_(stg_block_async_ret)
+{
+  StgAsyncIOResult* ares;
+  int len,errC;
+  FB_
+  ares = CurrentTSO->block_info.async_result;
+  len  = ares->len;
+  errC = ares->errCode;
+  CurrentTSO->block_info.async_result = NULL;
+  STGCALL1(free,ares);
+  R1.w = len;
+  *Sp = (W_)errC;
+  JMP_(ENTRY_CODE(Sp[1]));
+  FE_
+}
+
+FN_(stg_block_async)
+{
+  FB_
+  Sp -= 1;
+  Sp[0] = (W_)&stg_block_async_info;
+  BLOCK_GENERIC;
+  FE_
+}
+
+#endif