[sgen] Add option for parallel nursery collector
[mono.git] / mono / sgen / sgen-simple-nursery.c
index 62c14a5392bc394ffef8420e9741629b458d1b2b..2222a12d75a94b27c11d614b6028dd0895f19834 100644 (file)
@@ -1,5 +1,6 @@
-/*
- * sgen-simple-nursery.c: Simple always promote nursery.
+/**
+ * \file
+ * Simple always promote nursery.
  *
  * Copyright 2001-2003 Ximian, Inc
  * Copyright 2003-2010 Novell, Inc.
@@ -18,6 +19,7 @@
 #include "mono/sgen/sgen-protocol.h"
 #include "mono/sgen/sgen-layout-stats.h"
 #include "mono/sgen/sgen-client.h"
+#include "mono/utils/mono-memory-model.h"
 
 static inline GCObject*
 alloc_for_promotion (GCVTable vtable, GCObject *obj, size_t objsize, gboolean has_references)
@@ -61,18 +63,40 @@ init_nursery (SgenFragmentAllocator *allocator, char *start, char *end)
 
 /******************************************Copy/Scan functins ************************************************/
 
+#define collector_pin_object(obj, queue) sgen_pin_object (obj, queue);
+#define COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION alloc_for_promotion
+
+#include "sgen-copy-object.h"
+
 #define SGEN_SIMPLE_NURSERY
 
-#define SERIAL_COPY_OBJECT simple_nursery_serial_copy_object
-#define SERIAL_COPY_OBJECT_FROM_OBJ simple_nursery_serial_copy_object_from_obj
+#include "sgen-minor-copy-object.h"
+#include "sgen-minor-scan-object.h"
+
+static void
+fill_serial_ops (SgenObjectOperations *ops)
+{
+       ops->copy_or_mark_object = SERIAL_COPY_OBJECT;
+       FILL_MINOR_COLLECTOR_SCAN_OBJECT (ops);
+}
+
+#define SGEN_CONCURRENT_MAJOR
 
 #include "sgen-minor-copy-object.h"
 #include "sgen-minor-scan-object.h"
 
+static void
+fill_serial_with_concurrent_major_ops (SgenObjectOperations *ops)
+{
+       ops->copy_or_mark_object = SERIAL_COPY_OBJECT;
+       FILL_MINOR_COLLECTOR_SCAN_OBJECT (ops);
+}
+
 void
-sgen_simple_nursery_init (SgenMinorCollector *collector)
+sgen_simple_nursery_init (SgenMinorCollector *collector, gboolean parallel)
 {
        collector->is_split = FALSE;
+       collector->is_parallel = parallel;
 
        collector->alloc_for_promotion = alloc_for_promotion;
 
@@ -83,8 +107,8 @@ sgen_simple_nursery_init (SgenMinorCollector *collector)
        collector->build_fragments_finish = build_fragments_finish;
        collector->init_nursery = init_nursery;
 
-       FILL_MINOR_COLLECTOR_COPY_OBJECT (collector);
-       FILL_MINOR_COLLECTOR_SCAN_OBJECT (collector);
+       fill_serial_ops (&collector->serial_ops);
+       fill_serial_with_concurrent_major_ops (&collector->serial_ops_with_concurrent_major);
 }