From ca15fa930e71d6a3a61c6be7b91df57b980d110d Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Tue, 18 Apr 2017 19:45:26 +0300 Subject: [PATCH] [sgen] Track down promoted size also with parallel minors --- mono/sgen/sgen-copy-object.h | 3 ++- mono/sgen/sgen-gc.h | 1 + mono/sgen/sgen-major-copy-object.h | 1 + mono/sgen/sgen-simple-nursery.c | 15 +++++++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mono/sgen/sgen-copy-object.h b/mono/sgen/sgen-copy-object.h index 925af17275d..bb97e4a6816 100644 --- a/mono/sgen/sgen-copy-object.h +++ b/mono/sgen/sgen-copy-object.h @@ -108,7 +108,7 @@ copy_object_no_checks_par (GCObject *obj, SgenGrayQueue *queue) */ gboolean has_references = SGEN_VTABLE_HAS_REFERENCES (vt); mword objsize = SGEN_ALIGN_UP (sgen_client_par_object_get_size (vt, obj)); - destination = major_collector.alloc_object_par (vt, objsize, has_references); + destination = COLLECTOR_PARALLEL_ALLOC_FOR_PROMOTION (vt, obj, objsize, has_references); par_copy_object_no_checks ((char*)destination, vt, obj, objsize); @@ -139,5 +139,6 @@ copy_object_no_checks_par (GCObject *obj, SgenGrayQueue *queue) #endif #undef COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION +#undef COLLECTOR_PARALLEL_ALLOC_FOR_PROMOTION #undef collector_pin_object #undef COPY_OR_MARK_PARALLEL diff --git a/mono/sgen/sgen-gc.h b/mono/sgen/sgen-gc.h index 27727a537b6..e3fe2ed2267 100644 --- a/mono/sgen/sgen-gc.h +++ b/mono/sgen/sgen-gc.h @@ -547,6 +547,7 @@ typedef struct { gboolean is_parallel; GCObject* (*alloc_for_promotion) (GCVTable vtable, GCObject *obj, size_t objsize, gboolean has_references); + GCObject* (*alloc_for_promotion_par) (GCVTable vtable, GCObject *obj, size_t objsize, gboolean has_references); SgenObjectOperations serial_ops; SgenObjectOperations serial_ops_with_concurrent_major; diff --git a/mono/sgen/sgen-major-copy-object.h b/mono/sgen/sgen-major-copy-object.h index e04bf9e063c..b110a75d847 100644 --- a/mono/sgen/sgen-major-copy-object.h +++ b/mono/sgen/sgen-major-copy-object.h @@ -19,5 +19,6 @@ } while (0) #define COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION sgen_minor_collector.alloc_for_promotion +#define COLLECTOR_PARALLEL_ALLOC_FOR_PROMOTION sgen_minor_collector.alloc_for_promotion_par #include "sgen-copy-object.h" diff --git a/mono/sgen/sgen-simple-nursery.c b/mono/sgen/sgen-simple-nursery.c index ee72408b76f..39d08abcf16 100644 --- a/mono/sgen/sgen-simple-nursery.c +++ b/mono/sgen/sgen-simple-nursery.c @@ -28,6 +28,19 @@ alloc_for_promotion (GCVTable vtable, GCObject *obj, size_t objsize, gboolean ha return major_collector.alloc_object (vtable, objsize, has_references); } +static inline GCObject* +alloc_for_promotion_par (GCVTable vtable, GCObject *obj, size_t objsize, gboolean has_references) +{ + /* + * FIXME + * Note that the stat is not precise. total_promoted_size incrementing is not atomic and + * even in that case, the same object might be promoted simultaneously by different workers + * leading to one of the allocated major object to be discarded. + */ + total_promoted_size += objsize; + return major_collector.alloc_object_par (vtable, objsize, has_references); +} + static SgenFragment* build_fragments_get_exclude_head (void) { @@ -72,6 +85,7 @@ init_nursery (SgenFragmentAllocator *allocator, char *start, char *end) #define collector_pin_object(obj, queue) sgen_pin_object (obj, queue); #define COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION alloc_for_promotion +#define COLLECTOR_PARALLEL_ALLOC_FOR_PROMOTION alloc_for_promotion_par #define COPY_OR_MARK_PARALLEL #include "sgen-copy-object.h" @@ -120,6 +134,7 @@ sgen_simple_nursery_init (SgenMinorCollector *collector, gboolean parallel) collector->is_parallel = parallel; collector->alloc_for_promotion = alloc_for_promotion; + collector->alloc_for_promotion_par = alloc_for_promotion_par; collector->prepare_to_space = prepare_to_space; collector->clear_fragments = clear_fragments; -- 2.11.4.GIT