From e693ce50779bd92b12ca879a145294381a24d660 Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Wed, 21 Jun 2017 13:43:39 +0300 Subject: [PATCH] [sgen] Use concurrent mark concurrently with parallel minors --- mono/sgen/sgen-gc.c | 17 ++++++++--------- mono/sgen/sgen-gc.h | 1 + mono/sgen/sgen-minor-copy-object.h | 10 +++++++++- mono/sgen/sgen-minor-scan-object.h | 7 +++++++ mono/sgen/sgen-simple-nursery.c | 13 +++++++++++++ 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/mono/sgen/sgen-gc.c b/mono/sgen/sgen-gc.c index a590153dd63..8f6ee8aa833 100644 --- a/mono/sgen/sgen-gc.c +++ b/mono/sgen/sgen-gc.c @@ -1659,15 +1659,14 @@ collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_ binary_protocol_collection_begin (gc_stats.minor_gc_count, GENERATION_NURSERY); - if (sgen_concurrent_collection_in_progress ()) { - /* FIXME Support parallel nursery collections with concurrent major */ - object_ops_nopar = &sgen_minor_collector.serial_ops_with_concurrent_major; - } else { - object_ops_nopar = &sgen_minor_collector.serial_ops; - if (sgen_minor_collector.is_parallel && sgen_nursery_size >= SGEN_PARALLEL_MINOR_MIN_NURSERY_SIZE) { - object_ops_par = &sgen_minor_collector.parallel_ops; - is_parallel = TRUE; - } + object_ops_nopar = sgen_concurrent_collection_in_progress () + ? &sgen_minor_collector.serial_ops_with_concurrent_major + : &sgen_minor_collector.serial_ops; + if (sgen_minor_collector.is_parallel && sgen_nursery_size >= SGEN_PARALLEL_MINOR_MIN_NURSERY_SIZE) { + object_ops_par = sgen_concurrent_collection_in_progress () + ? &sgen_minor_collector.parallel_ops_with_concurrent_major + : &sgen_minor_collector.parallel_ops; + is_parallel = TRUE; } if (do_verify_nursery || do_dump_nursery_content) diff --git a/mono/sgen/sgen-gc.h b/mono/sgen/sgen-gc.h index 0cc573aab76..2faad109d1e 100644 --- a/mono/sgen/sgen-gc.h +++ b/mono/sgen/sgen-gc.h @@ -552,6 +552,7 @@ typedef struct { SgenObjectOperations serial_ops; SgenObjectOperations serial_ops_with_concurrent_major; SgenObjectOperations parallel_ops; + SgenObjectOperations parallel_ops_with_concurrent_major; void (*prepare_to_space) (char *to_space_bitmap, size_t space_bitmap_size); void (*clear_fragments) (void); diff --git a/mono/sgen/sgen-minor-copy-object.h b/mono/sgen/sgen-minor-copy-object.h index 3ad10aac444..b1e07c167a6 100644 --- a/mono/sgen/sgen-minor-copy-object.h +++ b/mono/sgen/sgen-minor-copy-object.h @@ -15,10 +15,17 @@ #if defined(SGEN_SIMPLE_NURSERY) #ifdef SGEN_SIMPLE_PAR_NURSERY -/* Not supported with concurrent major yet */ + +#ifdef SGEN_CONCURRENT_MAJOR +#define SERIAL_COPY_OBJECT simple_par_nursery_with_concurrent_major_copy_object +#define SERIAL_COPY_OBJECT_FROM_OBJ simple_par_nursery_with_concurrent_major_copy_object_from_obj +#else #define SERIAL_COPY_OBJECT simple_par_nursery_copy_object #define SERIAL_COPY_OBJECT_FROM_OBJ simple_par_nursery_copy_object_from_obj +#endif + #else + #ifdef SGEN_CONCURRENT_MAJOR #define SERIAL_COPY_OBJECT simple_nursery_serial_with_concurrent_major_copy_object #define SERIAL_COPY_OBJECT_FROM_OBJ simple_nursery_serial_with_concurrent_major_copy_object_from_obj @@ -26,6 +33,7 @@ #define SERIAL_COPY_OBJECT simple_nursery_serial_copy_object #define SERIAL_COPY_OBJECT_FROM_OBJ simple_nursery_serial_copy_object_from_obj #endif + #endif #elif defined (SGEN_SPLIT_NURSERY) diff --git a/mono/sgen/sgen-minor-scan-object.h b/mono/sgen/sgen-minor-scan-object.h index b92d309f4ec..f0baac8f87e 100644 --- a/mono/sgen/sgen-minor-scan-object.h +++ b/mono/sgen/sgen-minor-scan-object.h @@ -19,10 +19,17 @@ extern guint64 stat_scan_object_called_nursery; #if defined(SGEN_SIMPLE_NURSERY) #ifdef SGEN_SIMPLE_PAR_NURSERY +#ifdef SGEN_CONCURRENT_MAJOR +#define SERIAL_SCAN_OBJECT simple_par_nursery_serial_with_concurrent_major_scan_object +#define SERIAL_SCAN_VTYPE simple_par_nursery_serial_with_concurrent_major_scan_vtype +#define SERIAL_SCAN_PTR_FIELD simple_par_nursery_serial_with_concurrent_major_scan_ptr_field +#define SERIAL_DRAIN_GRAY_STACK simple_par_nursery_serial_with_concurrent_major_drain_gray_stack +#else #define SERIAL_SCAN_OBJECT simple_par_nursery_serial_scan_object #define SERIAL_SCAN_VTYPE simple_par_nursery_serial_scan_vtype #define SERIAL_SCAN_PTR_FIELD simple_par_nursery_serial_scan_ptr_field #define SERIAL_DRAIN_GRAY_STACK simple_par_nursery_serial_drain_gray_stack +#endif #else #ifdef SGEN_CONCURRENT_MAJOR #define SERIAL_SCAN_OBJECT simple_nursery_serial_with_concurrent_major_scan_object diff --git a/mono/sgen/sgen-simple-nursery.c b/mono/sgen/sgen-simple-nursery.c index 5d39368402b..29ab4ed135d 100644 --- a/mono/sgen/sgen-simple-nursery.c +++ b/mono/sgen/sgen-simple-nursery.c @@ -129,6 +129,18 @@ fill_serial_with_concurrent_major_ops (SgenObjectOperations *ops) FILL_MINOR_COLLECTOR_SCAN_OBJECT (ops); } +#define SGEN_SIMPLE_PAR_NURSERY + +#include "sgen-minor-copy-object.h" +#include "sgen-minor-scan-object.h" + +static void +fill_parallel_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, gboolean parallel) { @@ -151,6 +163,7 @@ sgen_simple_nursery_init (SgenMinorCollector *collector, gboolean parallel) fill_serial_ops (&collector->serial_ops); fill_serial_with_concurrent_major_ops (&collector->serial_ops_with_concurrent_major); fill_parallel_ops (&collector->parallel_ops); + fill_parallel_with_concurrent_major_ops (&collector->parallel_ops_with_concurrent_major); /* * The nursery worker context is created first so it will have priority over -- 2.11.4.GIT