[project @ 1999-03-15 16:53:10 by simonm]
authorsimonm <unknown>
Mon, 15 Mar 1999 16:53:11 +0000 (16:53 +0000)
committersimonm <unknown>
Mon, 15 Mar 1999 16:53:11 +0000 (16:53 +0000)
Specialise STATIC_LINK() for {FUN,THUNK,IND}_STATIC.

ghc/includes/ClosureMacros.h
ghc/rts/GC.c

index f2352d9..a1c9f50 100644 (file)
@@ -1,5 +1,5 @@
 /* ----------------------------------------------------------------------------
- * $Id: ClosureMacros.h,v 1.8 1999/03/11 11:21:45 simonm Exp $
+ * $Id: ClosureMacros.h,v 1.9 1999/03/15 16:53:10 simonm Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -318,6 +318,14 @@ SET_STATIC_HDR(PrelBase_CZh_closure,PrelBase_CZh_info,costCentreStack,const);
 #define STATIC_LINK(info,p) \
    (*stgCast(StgClosure**,&((p)->payload[info->layout.payload.ptrs + \
                                        info->layout.payload.nptrs])))
+/* These macros are optimised versions of the above for certain
+ * closure types.  They *must* be equivalent to the generic
+ * STATIC_LINK.
+ */
+#define FUN_STATIC_LINK(p)   ((p)->payload[0])
+#define THUNK_STATIC_LINK(p) ((p)->payload[2])
+#define IND_STATIC_LINK(p)   ((p)->payload[1])
+
 #define STATIC_LINK2(info,p) \
    (*stgCast(StgClosure**,&((p)->payload[info->layout.payload.ptrs + \
                                        info->layout.payload.nptrs + 1])))
index 59a3da1..680c8e5 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: GC.c,v 1.51 1999/03/15 16:30:27 simonm Exp $
+ * $Id: GC.c,v 1.52 1999/03/15 16:53:11 simonm Exp $
  *
  * (c) The GHC Team 1998-1999
  *
@@ -1288,30 +1288,35 @@ loop:
     q = ((StgInd*)q)->indirectee;
     goto loop;
 
-    /* ToDo: optimise STATIC_LINK for known cases.
-       - FUN_STATIC       : payload[0]
-       - THUNK_STATIC     : payload[1]
-       - IND_STATIC       : payload[1]
-    */
   case THUNK_STATIC:
+    if (info->srt_len > 0 && major_gc && 
+       THUNK_STATIC_LINK((StgClosure *)q) == NULL) {
+      THUNK_STATIC_LINK((StgClosure *)q) = static_objects;
+      static_objects = (StgClosure *)q;
+    }
+    return q;
+
   case FUN_STATIC:
-    if (info->srt_len == 0) {  /* small optimisation */
-      return q;
+    if (info->srt_len > 0 && major_gc && 
+       FUN_STATIC_LINK((StgClosure *)q) == NULL) {
+      FUN_STATIC_LINK((StgClosure *)q) = static_objects;
+      static_objects = (StgClosure *)q;
     }
-    /* fall through */
-  case CONSTR_STATIC:
+    return q;
+
   case IND_STATIC:
-    /* don't want to evacuate these, but we do want to follow pointers
-     * from SRTs  - see scavenge_static.
-     */
+    if (major_gc && IND_STATIC_LINK((StgClosure *)q) == NULL) {
+      IND_STATIC_LINK((StgClosure *)q) = static_objects;
+      static_objects = (StgClosure *)q;
+    }
+    return q;
 
-    /* put the object on the static list, if necessary.
-     */
+  case CONSTR_STATIC:
     if (major_gc && STATIC_LINK(info,(StgClosure *)q) == NULL) {
       STATIC_LINK(info,(StgClosure *)q) = static_objects;
       static_objects = (StgClosure *)q;
     }
-    /* fall through */
+    return q;
 
   case CONSTR_INTLIKE:
   case CONSTR_CHARLIKE: