[sgen] Remove some redundancy with nursery section
authorVlad Brezae <brezaevlad@gmail.com>
Wed, 5 Apr 2017 22:18:27 +0000 (01:18 +0300)
committerVlad Brezae <brezaevlad@gmail.com>
Mon, 15 May 2017 09:52:51 +0000 (12:52 +0300)
mono/sgen/sgen-debug.c
mono/sgen/sgen-gc.c
mono/sgen/sgen-gc.h
mono/sgen/sgen-nursery-allocator.c

index e7a316c440a20c49d36a40972fbe10bf697ddd32..93ab45e7a8d3b4895af652d53acdf86b5609206a 100644 (file)
@@ -1065,10 +1065,10 @@ void
 sgen_dump_section (GCMemSection *section, const char *type)
 {
        char *start = section->data;
-       char *end = section->data + section->size;
+       char *end = section->end_data;
        char *occ_start = NULL;
 
-       fprintf (heap_dump_file, "<section type=\"%s\" size=\"%lu\">\n", type, (unsigned long)section->size);
+       fprintf (heap_dump_file, "<section type=\"%s\" size=\"%lu\">\n", type, (unsigned long)(section->end_data - section->data));
 
        while (start < end) {
                guint size;
@@ -1083,7 +1083,6 @@ sgen_dump_section (GCMemSection *section, const char *type)
                        start += sizeof (void*); /* should be ALLOC_ALIGN, really */
                        continue;
                }
-               g_assert (start < section->next_data);
 
                if (!occ_start)
                        occ_start = start;
index ce86cf4ea059201926941516bd04a6ef7bae37e2..8662ffbc1e4bd41188bdd27957ec4f9851008a40 100644 (file)
@@ -530,7 +530,7 @@ pin_objects_from_nursery_pin_queue (gboolean do_scan_objects, ScanCopyContext ct
        void **start =  sgen_pinning_get_entry (section->pin_queue_first_entry);
        void **end = sgen_pinning_get_entry (section->pin_queue_last_entry);
        void *start_nursery = section->data;
-       void *end_nursery = section->next_data;
+       void *end_nursery = section->end_data;
        void *last = NULL;
        int count = 0;
        void *search_start;
@@ -971,8 +971,7 @@ alloc_nursery (void)
        data = (char *)major_collector.alloc_heap (alloc_size, alloc_size, sgen_nursery_bits);
        sgen_update_heap_boundaries ((mword)data, (mword)(data + sgen_nursery_size));
        SGEN_LOG (4, "Expanding nursery size (%p-%p): %lu, total: %lu", data, data + alloc_size, (unsigned long)sgen_nursery_size, (unsigned long)sgen_gc_get_total_heap_allocation ());
-       section->data = section->next_data = data;
-       section->size = alloc_size;
+       section->data = data;
        section->end_data = data + sgen_nursery_size;
        scan_starts = (alloc_size + SCAN_START_SIZE - 1) / SCAN_START_SIZE;
        section->scan_starts = (char **)sgen_alloc_internal_dynamic (sizeof (char*) * scan_starts, INTERNAL_MEM_SCAN_STARTS, TRUE);
@@ -1598,8 +1597,6 @@ static gboolean
 collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_queue)
 {
        gboolean needs_major, is_parallel = FALSE;
-       size_t max_garbage_amount;
-       char *nursery_next;
        mword fragment_total;
        SgenGrayQueue gc_thread_gray_queue;
        SgenObjectOperations *object_ops_nopar, *object_ops_par = NULL;
@@ -1643,13 +1640,8 @@ collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_
 
        degraded_mode = 0;
        objects_pinned = 0;
-       nursery_next = sgen_nursery_alloc_get_upper_alloc_bound ();
-       /* FIXME: optimize later to use the higher address where an object can be present */
-       nursery_next = MAX (nursery_next, sgen_get_nursery_end ());
 
-       SGEN_LOG (1, "Start nursery collection %d %p-%p, size: %d", gc_stats.minor_gc_count, sgen_get_nursery_start (), nursery_next, (int)(nursery_next - sgen_get_nursery_start ()));
-       max_garbage_amount = nursery_next - sgen_get_nursery_start ();
-       g_assert (nursery_section->size >= max_garbage_amount);
+       SGEN_LOG (1, "Start nursery collection %d %p-%p, size: %d", gc_stats.minor_gc_count, nursery_section->data, nursery_section->end_data, (int)(nursery_section->end_data - nursery_section->data));
 
        /* world must be stopped already */
        TV_GETTIME (btv);
@@ -1657,8 +1649,6 @@ collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_
 
        sgen_client_pre_collection_checks ();
 
-       nursery_section->next_data = nursery_next;
-
        major_collector.start_nursery_collection ();
 
        sgen_memgov_minor_collection_start ();
@@ -1673,7 +1663,7 @@ collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_
        /* pin from pinned handles */
        sgen_init_pinning ();
        sgen_client_binary_protocol_mark_start (GENERATION_NURSERY);
-       pin_from_roots (sgen_get_nursery_start (), nursery_next, ctx);
+       pin_from_roots (nursery_section->data, nursery_section->end_data, ctx);
        /* pin cemented objects */
        sgen_pin_cemented_objects ();
        /* identify pinned objects */
@@ -1713,7 +1703,7 @@ collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_
        TV_GETTIME (atv);
        time_minor_scan_pinned += TV_ELAPSED (btv, atv);
 
-       enqueue_scan_from_roots_jobs (&gc_thread_gray_queue, sgen_get_nursery_start (), nursery_next, is_parallel ? object_ops_par : object_ops_nopar, is_parallel);
+       enqueue_scan_from_roots_jobs (&gc_thread_gray_queue, nursery_section->data, nursery_section->end_data, is_parallel ? object_ops_par : object_ops_nopar, is_parallel);
 
        if (is_parallel) {
                gray_queue_redirect (&gc_thread_gray_queue);
@@ -1844,12 +1834,6 @@ major_copy_or_mark_from_roots (SgenGrayQueue *gc_thread_gray_queue, size_t *old_
        TV_GETTIME (btv);
        time_major_pre_collection_fragment_clear += TV_ELAPSED (atv, btv);
 
-       if (!sgen_collection_is_concurrent ())
-               nursery_section->next_data = sgen_get_nursery_end ();
-       /* we should also coalesce scanning from sections close to each other
-        * and deal with pointers outside of the sections later.
-        */
-
        objects_pinned = 0;
 
        sgen_client_pre_collection_checks ();
@@ -2945,7 +2929,7 @@ sgen_gc_get_used_size (void)
        gint64 tot = 0;
        LOCK_GC;
        tot = los_memory_usage;
-       tot += nursery_section->next_data - nursery_section->data;
+       tot += nursery_section->end_data - nursery_section->data;
        tot += major_collector.get_used_size ();
        /* FIXME: account for pinned objects */
        UNLOCK_GC;
index 5fbfda2c67a5d3e871ac9037cbda791138cc22e6..c45f1677b638cb72859e6b886256e8e888e03aec 100644 (file)
@@ -60,9 +60,6 @@ NurseryClearPolicy sgen_get_nursery_clear_policy (void);
 typedef struct _GCMemSection GCMemSection;
 struct _GCMemSection {
        char *data;
-       mword size;
-       /* pointer where more data could be allocated if it fits */
-       char *next_data;
        char *end_data;
        /*
         * scan starts is an array of pointers to objects equally spaced in the allocation area
@@ -904,7 +901,6 @@ mword sgen_build_nursery_fragments (GCMemSection *nursery_section, SgenGrayQueue
 void sgen_init_nursery_allocator (void);
 void sgen_nursery_allocator_init_heavy_stats (void);
 void sgen_init_allocator (void);
-char* sgen_nursery_alloc_get_upper_alloc_bound (void);
 void* sgen_nursery_alloc (size_t size);
 void* sgen_nursery_alloc_range (size_t size, size_t min_size, size_t *out_alloc_size);
 gboolean sgen_can_alloc_size (size_t size);
index 41e9478dcbc94ddf4264b3bbb6cc50d18423fb55..8442ac525d32509eb7b8b61f7b036dd7af1b3d81 100644 (file)
@@ -799,13 +799,6 @@ sgen_build_nursery_fragments (GCMemSection *nursery_section, SgenGrayQueue *unpi
        return fragment_total;
 }
 
-char *
-sgen_nursery_alloc_get_upper_alloc_bound (void)
-{
-       /*FIXME we need to calculate the collector upper bound as well, but this must be done in the previous GC. */
-       return sgen_nursery_end;
-}
-
 /*** Nursery memory allocation ***/
 void
 sgen_nursery_retire_region (void *address, ptrdiff_t size)