[sgen] Always use a context specialized gray stack
authorVlad Brezae <brezaevlad@gmail.com>
Fri, 20 Jan 2017 15:02:36 +0000 (17:02 +0200)
committerVlad Brezae <brezaevlad@gmail.com>
Fri, 20 Jan 2017 15:04:47 +0000 (17:04 +0200)
mono/sgen/sgen-gc.c
mono/sgen/sgen-minor-scan-object.h

index 2e08369a23505d8475cc1d1891ddf15e70c91fad..e29ec1c92005b17b6e992cc71caa7247587fd7a5 100644 (file)
@@ -510,22 +510,9 @@ sgen_add_to_global_remset (gpointer ptr, GCObject *obj)
 gboolean
 sgen_drain_gray_stack (ScanCopyContext ctx)
 {
-       ScanObjectFunc scan_func = ctx.ops->scan_object;
-       SgenGrayQueue *queue = ctx.queue;
-
-       if (ctx.ops->drain_gray_stack)
-               return ctx.ops->drain_gray_stack (queue);
+       SGEN_ASSERT (0, ctx.ops->drain_gray_stack, "Why do we have a scan/copy context with a missing drain gray stack function?");
 
-       for (;;) {
-               GCObject *obj;
-               SgenDescriptor desc;
-               GRAY_OBJECT_DEQUEUE_PARALLEL (queue, &obj, &desc);
-               if (!obj)
-                       return TRUE;
-               SGEN_LOG (9, "Precise gray object scan %p (%s)", obj, sgen_client_vtable_get_name (SGEN_LOAD_VTABLE (obj)));
-               scan_func (obj, desc, queue);
-       }
-       return FALSE;
+       return ctx.ops->drain_gray_stack (ctx.queue);
 }
 
 /*
index cc3e7a4539e794037d54c6055196b2d9df815fef..2c357c3c9524c7d3e06b90cfb0aa354918f6e669 100644 (file)
@@ -13,6 +13,7 @@ extern guint64 stat_scan_object_called_nursery;
 #undef SERIAL_SCAN_OBJECT
 #undef SERIAL_SCAN_VTYPE
 #undef SERIAL_SCAN_PTR_FIELD
+#undef SERIAL_DRAIN_GRAY_STACK
 
 #if defined(SGEN_SIMPLE_NURSERY)
 
@@ -20,10 +21,12 @@ extern guint64 stat_scan_object_called_nursery;
 #define SERIAL_SCAN_OBJECT simple_nursery_serial_with_concurrent_major_scan_object
 #define SERIAL_SCAN_VTYPE simple_nursery_serial_with_concurrent_major_scan_vtype
 #define SERIAL_SCAN_PTR_FIELD simple_nursery_serial_with_concurrent_major_scan_ptr_field
+#define SERIAL_DRAIN_GRAY_STACK simple_nursery_serial_with_concurrent_major_drain_gray_stack
 #else
 #define SERIAL_SCAN_OBJECT simple_nursery_serial_scan_object
 #define SERIAL_SCAN_VTYPE simple_nursery_serial_scan_vtype
 #define SERIAL_SCAN_PTR_FIELD simple_nursery_serial_scan_ptr_field
+#define SERIAL_DRAIN_GRAY_STACK simple_nursery_serial_drain_gray_stack
 #endif
 
 #elif defined (SGEN_SPLIT_NURSERY)
@@ -32,10 +35,12 @@ extern guint64 stat_scan_object_called_nursery;
 #define SERIAL_SCAN_OBJECT split_nursery_serial_with_concurrent_major_scan_object
 #define SERIAL_SCAN_VTYPE split_nursery_serial_with_concurrent_major_scan_vtype
 #define SERIAL_SCAN_PTR_FIELD split_nursery_serial_with_concurrent_major_scan_ptr_field
+#define SERIAL_DRAIN_GRAY_STACK split_nursery_serial_with_concurrent_major_drain_gray_stack
 #else
 #define SERIAL_SCAN_OBJECT split_nursery_serial_scan_object
 #define SERIAL_SCAN_VTYPE split_nursery_serial_scan_vtype
 #define SERIAL_SCAN_PTR_FIELD split_nursery_serial_scan_ptr_field
+#define SERIAL_DRAIN_GRAY_STACK split_nursery_serial_drain_gray_stack
 #endif
 
 #else
@@ -95,8 +100,24 @@ SERIAL_SCAN_PTR_FIELD (GCObject *full_object, GCObject **ptr, SgenGrayQueue *que
        HANDLE_PTR (ptr, NULL);
 }
 
+static gboolean
+SERIAL_DRAIN_GRAY_STACK (SgenGrayQueue *queue)
+{
+        for (;;) {
+                GCObject *obj;
+                SgenDescriptor desc;
+
+                GRAY_OBJECT_DEQUEUE_SERIAL (queue, &obj, &desc);
+                if (!obj)
+                        return TRUE;
+
+                SERIAL_SCAN_OBJECT (obj, desc, queue);
+        }
+}
+
 #define FILL_MINOR_COLLECTOR_SCAN_OBJECT(ops)  do {                    \
                (ops)->scan_object = SERIAL_SCAN_OBJECT;                        \
                (ops)->scan_vtype = SERIAL_SCAN_VTYPE;                  \
                (ops)->scan_ptr_field = SERIAL_SCAN_PTR_FIELD;          \
+               (ops)->drain_gray_stack = SERIAL_DRAIN_GRAY_STACK;      \
        } while (0)