[project @ 2000-08-15 14:18:43 by simonmar]
authorsimonmar <unknown>
Tue, 15 Aug 2000 14:18:43 +0000 (14:18 +0000)
committersimonmar <unknown>
Tue, 15 Aug 2000 14:18:43 +0000 (14:18 +0000)
Make the TSO structure shorter by 2 words:

- remove splim.  It was always equal to &(tso->stack) +
  RESERVED_STACK_WORDS.

- make two enum fields 16 bits each instead of 32.

ghc/includes/StgMacros.h
ghc/includes/TSO.h
ghc/rts/GC.c
ghc/rts/Schedule.c
ghc/rts/StgCRun.c

index 3cbcf8e..c112dd8 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgMacros.h,v 1.32 2000/08/02 14:13:27 rrt Exp $
+ * $Id: StgMacros.h,v 1.33 2000/08/15 14:18:43 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -684,7 +684,6 @@ SaveThreadState(void)
   tso = CurrentTSO;
   tso->sp       = Sp;
   tso->su       = Su;
-  tso->splim    = SpLim;
   CloseNursery(Hp);
 
 #ifdef REG_CurrentTSO
@@ -710,7 +709,7 @@ LoadThreadState (void)
   tso = CurrentTSO;
   Sp    = tso->sp;
   Su    = tso->su;
-  SpLim = tso->splim;
+  SpLim = (P_)&(tso->stack) + RESERVED_STACK_WORDS;
   OpenNursery(Hp,HpLim);
 
 #ifdef REG_CurrentNursery
@@ -727,6 +726,8 @@ LoadThreadState (void)
    Module initialisation
    -------------------------------------------------------------------------- */
 
+#if 1 /* old init stuff */
+
 #define PUSH_INIT_STACK(reg_function)          \
        *(Sp++) = (W_)reg_function
 
@@ -753,6 +754,29 @@ LoadThreadState (void)
        JMP_(POP_INIT_STACK());                 \
        FE_ }
 
+#else 
+
+#define PUSH_INIT_STACK(reg_function) /* nothing */
+#define POP_INIT_STACK()             /* nothing */
+#define REGISTER_IMPORT(reg_mod_name) /* nothing */
+
+#define START_MOD_INIT(reg_mod_name)           \
+       FN_(reg_mod_name) {                     \
+            EF_(StgReturn);                    \
+            TEXT_SET(hs_init_set, reg_mod_name); \
+           FB_;                
+           /* extern decls go here, followed by init code */
+
+#define REGISTER_FOREIGN_EXPORT(reg_fe_binder) \
+        STGCALL1(getStablePtr,reg_fe_binder)
+       
+       
+#define END_MOD_INIT()                         \
+           JMP_(StgReturn);                    \
+       FE_ }                                   \
+
+#endif
+
 /* -----------------------------------------------------------------------------
    Support for _ccall_GC_ and _casm_GC.
    -------------------------------------------------------------------------- */
index 6572a7e..282e9c4 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: TSO.h,v 1.16 2000/05/26 10:14:33 sewardj Exp $
+ * $Id: TSO.h,v 1.17 2000/08/15 14:18:43 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -147,6 +147,10 @@ typedef union {
  * storage manager, and won't be copied during garbage collection.
  */
 
+/* 
+ * ToDo: make this structure sensible on a non-32-bit arch.
+ */
+
 typedef struct StgTSO_ {
   StgHeader          header;
 
@@ -154,11 +158,12 @@ typedef struct StgTSO_ {
   StgMutClosure *    mut_link;      /* TSO's are mutable of course! */
   struct StgTSO_*    global_link;    /* Links all threads together */
   
-  StgTSOWhatNext     what_next;
-  StgTSOBlockReason  why_blocked;
+  StgTSOWhatNext     what_next   : 16;
+  StgTSOBlockReason  why_blocked : 16;
   StgTSOBlockInfo    block_info;
   struct StgTSO_*    blocked_exceptions;
   StgThreadID        id;
+
   StgTSOTickyInfo    ticky; 
   StgTSOProfInfo     prof;
   StgTSOParInfo      par;
@@ -169,7 +174,6 @@ typedef struct StgTSO_ {
   StgWord            max_stack_size; /* maximum stack size in *words* */
   StgPtr             sp;
   StgUpdateFrame*    su;
-  StgPtr             splim;
   
   StgWord            stack[0];
 } StgTSO;
@@ -181,7 +185,6 @@ typedef struct StgTSO_ {
 
       tso->stack < tso->sp < tso->stack+tso->stack_size
       tso->stack_size <= tso->max_stack_size
-      tso->splim == tso->stack + RESERVED_STACK_WORDS;
       
       RESERVED_STACK_WORDS is large enough for any heap-check or
       stack-check failure.
index 0d2872b..0600f97 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: GC.c,v 1.83 2000/05/26 08:42:59 simonmar Exp $
+ * $Id: GC.c,v 1.84 2000/08/15 14:18:43 simonmar Exp $
  *
  * (c) The GHC Team 1998-1999
  *
@@ -1637,7 +1637,6 @@ loop:
        /* relocate the stack pointers... */
        new_tso->su = (StgUpdateFrame *) ((StgPtr)new_tso->su + diff);
        new_tso->sp = (StgPtr)new_tso->sp + diff;
-       new_tso->splim = (StgPtr)new_tso->splim + diff;
        
        relocate_TSO(tso, new_tso);
 
index 32c9ca4..39cd819 100644 (file)
@@ -1,5 +1,5 @@
 /* ---------------------------------------------------------------------------
- * $Id: Schedule.c,v 1.75 2000/08/15 11:48:06 simonmar Exp $
+ * $Id: Schedule.c,v 1.76 2000/08/15 14:18:43 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -1360,7 +1360,6 @@ createThread_(nat size, rtsBool have_lock)
   tso->why_blocked  = NotBlocked;
   tso->blocked_exceptions = NULL;
 
-  tso->splim        = (P_)&(tso->stack) + RESERVED_STACK_WORDS;
   tso->stack_size   = stack_size;
   tso->max_stack_size = round_to_mblocks(RtsFlags.GcFlags.maxStkSize) 
                               - TSO_STRUCT_SIZEW;
@@ -2086,7 +2085,6 @@ threadStackOverflow(StgTSO *tso)
   diff = (P_)new_sp - (P_)tso->sp; /* In *words* */
   dest->su    = (StgUpdateFrame *) ((P_)dest->su + diff);
   dest->sp    = new_sp;
-  dest->splim = (P_)dest->splim + (nat)((P_)dest - (P_)tso);
   dest->stack_size = new_stack_size;
        
   /* and relocate the update frame list */
index ad567da..23a2e13 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgCRun.c,v 1.19 2000/08/07 23:37:23 qrczak Exp $
+ * $Id: StgCRun.c,v 1.20 2000/08/15 14:18:43 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;