Specialise evac/scav for single-threaded, not minor, GC
[ghc-hetmet.git] / rts / sm / Scav.c
index 674078f..e08572a 100644 (file)
@@ -1076,15 +1076,12 @@ scavenge_static(void)
 
   while (1) {
       
-    ACQUIRE_SPIN_LOCK(&static_objects_sync);
-    
     /* get the next static object from the list.  Remember, there might
      * be more stuff on this list after each evacuation...
      * (static_objects is a global)
      */
-    p = static_objects;
+    p = gct->static_objects;
     if (p == END_OF_STATIC_LIST) {
-         RELEASE_SPIN_LOCK(&static_objects_sync);
          break;
     }
     
@@ -1099,11 +1096,9 @@ scavenge_static(void)
     /* Take this object *off* the static_objects list,
      * and put it on the scavenged_static_objects list.
      */
-    static_objects = *STATIC_LINK(info,p);
-    *STATIC_LINK(info,p) = scavenged_static_objects;
-    scavenged_static_objects = p;
-    
-    RELEASE_SPIN_LOCK(&static_objects_sync);
+    gct->static_objects = *STATIC_LINK(info,p);
+    *STATIC_LINK(info,p) = gct->scavenged_static_objects;
+    gct->scavenged_static_objects = p;
     
     switch (info -> type) {
       
@@ -1388,9 +1383,9 @@ scavenge_large (step_workspace *ws)
    Scavenge a block
    ------------------------------------------------------------------------- */
 
-#define MINOR_GC
+#define PARALLEL_GC
 #include "Scav.c-inc"
-#undef MINOR_GC
+#undef PARALLEL_GC
 #include "Scav.c-inc"
 
 /* ----------------------------------------------------------------------------
@@ -1426,8 +1421,8 @@ scavenge_find_global_work (void)
             // to scavenge the whole thing and then push it on
             // our scavd list.  This saves pushing out the
             // scan_bd block, which might be partial.
-            if (N == 0) {
-                scavenge_block0(bd, bd->start);
+            if (n_gc_threads == 1) {
+                scavenge_block1(bd, bd->start);
             } else {
                 scavenge_block(bd, bd->start);
             }
@@ -1485,8 +1480,8 @@ scavenge_find_local_work (void)
         // scavenge everything up to the free pointer.
         if (ws->scan != NULL && ws->scan < ws->scan_bd->free)
         {
-            if (N == 0) {
-                scavenge_block0(ws->scan_bd, ws->scan);
+            if (n_gc_threads == 1) {
+                scavenge_block1(ws->scan_bd, ws->scan);
             } else {
                 scavenge_block(ws->scan_bd, ws->scan);
             }
@@ -1526,8 +1521,8 @@ loop:
     work_to_do = rtsFalse;
 
     // scavenge static objects 
-    if (major_gc && static_objects != END_OF_STATIC_LIST) {
-       IF_DEBUG(sanity, checkStaticObjects(static_objects));
+    if (major_gc && gct->static_objects != END_OF_STATIC_LIST) {
+       IF_DEBUG(sanity, checkStaticObjects(gct->static_objects));
        scavenge_static();
     }
     
@@ -1559,11 +1554,6 @@ any_work (void)
 
     write_barrier();
 
-    // scavenge static objects 
-    if (major_gc && static_objects != END_OF_STATIC_LIST) {
-       return rtsTrue;
-    }
-    
     // scavenge objects in compacted generation
     if (mark_stack_overflowed || oldgen_scan_bd != NULL ||
        (mark_stack_bdescr != NULL && !mark_stack_empty())) {
@@ -1582,5 +1572,7 @@ any_work (void)
         if (ws->stp->todos) return rtsTrue;
     }
 
+    gct->no_work++;
+
     return rtsFalse;
 }