[runtime] It's spring cleaning in MonoInternalThread. Remove 8 (yes, eight) unused...
[mono.git] / mono / metadata / sgen-cardtable.c
index 3b57a1a974a786f1261dc15fe1f7fc4961827180..6f852df9577bcbbfdd87c421f1621aacb10ebb03 100644 (file)
@@ -290,37 +290,37 @@ sgen_card_table_find_address_with_cards (char *cards_start, guint8 *cards, char
 }
 
 static void
-update_mod_union (guint8 *dest, gboolean init, guint8 *start_card, size_t num_cards)
+update_mod_union (guint8 *dest, guint8 *start_card, size_t num_cards)
 {
-       if (init) {
-               memcpy (dest, start_card, num_cards);
-       } else {
-               int i;
-               for (i = 0; i < num_cards; ++i)
-                       dest [i] |= start_card [i];
-       }
+       int i;
+       for (i = 0; i < num_cards; ++i)
+               dest [i] |= start_card [i];
 }
 
-static guint8*
-alloc_mod_union (size_t num_cards)
+guint8*
+sgen_card_table_alloc_mod_union (char *obj, mword obj_size)
 {
-       return sgen_alloc_internal_dynamic (num_cards, INTERNAL_MEM_CARDTABLE_MOD_UNION, TRUE);
+       size_t num_cards = cards_in_range ((mword) obj, obj_size);
+       guint8 *mod_union = sgen_alloc_internal_dynamic (num_cards, INTERNAL_MEM_CARDTABLE_MOD_UNION, TRUE);
+       memset (mod_union, 0, num_cards);
+       return mod_union;
 }
 
-guint8*
-sgen_card_table_update_mod_union_from_cards (guint8 *dest, guint8 *start_card, size_t num_cards)
+void
+sgen_card_table_free_mod_union (guint8 *mod_union, char *obj, mword obj_size)
 {
-       gboolean init = dest == NULL;
-
-       if (init)
-               dest = alloc_mod_union (num_cards);
-
-       update_mod_union (dest, init, start_card, num_cards);
+       size_t num_cards = cards_in_range ((mword) obj, obj_size);
+       sgen_free_internal_dynamic (mod_union, num_cards, INTERNAL_MEM_CARDTABLE_MOD_UNION);
+}
 
-       return dest;
+void
+sgen_card_table_update_mod_union_from_cards (guint8 *dest, guint8 *start_card, size_t num_cards)
+{
+       SGEN_ASSERT (0, dest, "Why don't we have a mod union?");
+       update_mod_union (dest, start_card, num_cards);
 }
 
-guint8*
+void
 sgen_card_table_update_mod_union (guint8 *dest, char *obj, mword obj_size, size_t *out_num_cards)
 {
        guint8 *start_card = sgen_card_table_get_card_address ((mword)obj);
@@ -328,7 +328,6 @@ sgen_card_table_update_mod_union (guint8 *dest, char *obj, mword obj_size, size_
        guint8 *end_card = sgen_card_table_get_card_address ((mword)obj + obj_size - 1) + 1;
 #endif
        size_t num_cards;
-       guint8 *result = NULL;
 
 #ifdef SGEN_HAVE_OVERLAPPING_CARDS
        size_t rest;
@@ -337,9 +336,7 @@ sgen_card_table_update_mod_union (guint8 *dest, char *obj, mword obj_size, size_
 
        while (start_card + rest > SGEN_CARDTABLE_END) {
                size_t count = SGEN_CARDTABLE_END - start_card;
-               dest = sgen_card_table_update_mod_union_from_cards (dest, start_card, count);
-               if (!result)
-                       result = dest;
+               sgen_card_table_update_mod_union_from_cards (dest, start_card, count);
                dest += count;
                rest -= count;
                start_card = sgen_cardtable;
@@ -349,14 +346,10 @@ sgen_card_table_update_mod_union (guint8 *dest, char *obj, mword obj_size, size_
        num_cards = end_card - start_card;
 #endif
 
-       dest = sgen_card_table_update_mod_union_from_cards (dest, start_card, num_cards);
-       if (!result)
-               result = dest;
+       sgen_card_table_update_mod_union_from_cards (dest, start_card, num_cards);
 
        if (out_num_cards)
                *out_num_cards = num_cards;
-
-       return result;
 }
 
 #ifdef SGEN_HAVE_OVERLAPPING_CARDS
@@ -426,7 +419,7 @@ sgen_card_table_finish_minor_collection (void)
 }
 
 static void
-sgen_card_table_scan_remsets (SgenGrayQueue *queue)
+sgen_card_table_scan_remsets (ScanCopyContext ctx)
 {
        SGEN_TV_DECLARE (atv);
        SGEN_TV_DECLARE (btv);
@@ -443,11 +436,11 @@ sgen_card_table_scan_remsets (SgenGrayQueue *queue)
        sgen_card_table_clear_cards ();
 #endif
        SGEN_TV_GETTIME (atv);
-       sgen_major_collector_scan_card_table (queue);
+       sgen_get_major_collector ()->scan_card_table (FALSE, ctx);
        SGEN_TV_GETTIME (btv);
        last_major_scan_time = SGEN_TV_ELAPSED (atv, btv); 
        major_card_scan_time += last_major_scan_time;
-       sgen_los_scan_card_table (FALSE, queue);
+       sgen_los_scan_card_table (FALSE, ctx);
        SGEN_TV_GETTIME (atv);
        last_los_scan_time = SGEN_TV_ELAPSED (btv, atv);
        los_card_scan_time += last_los_scan_time;
@@ -557,7 +550,7 @@ find_next_card (guint8 *card_data, guint8 *end)
 }
 
 void
-sgen_cardtable_scan_object (char *obj, mword block_obj_size, guint8 *cards, gboolean mod_union, SgenGrayQueue *queue)
+sgen_cardtable_scan_object (char *obj, mword block_obj_size, guint8 *cards, gboolean mod_union, ScanCopyContext ctx)
 {
        MonoVTable *vt = (MonoVTable*)SGEN_LOAD_VTABLE (obj);
        MonoClass *klass = vt->klass;
@@ -635,19 +628,19 @@ LOOP_HEAD:
 
                        elem = first_elem = (char*)mono_array_addr_with_size_fast ((MonoArray*)obj, elem_size, index);
                        if (klass->element_class->valuetype) {
-                               ScanVTypeFunc scan_vtype_func = sgen_get_current_object_ops ()->scan_vtype;
+                               ScanVTypeFunc scan_vtype_func = ctx.ops->scan_vtype;
 
                                for (; elem < card_end; elem += elem_size)
-                                       scan_vtype_func (elem, desc, queue BINARY_PROTOCOL_ARG (elem_size));
+                                       scan_vtype_func (obj, elem, desc, ctx.queue BINARY_PROTOCOL_ARG (elem_size));
                        } else {
-                               CopyOrMarkObjectFunc copy_func = sgen_get_current_object_ops ()->copy_or_mark_object;
+                               CopyOrMarkObjectFunc copy_func = ctx.ops->copy_or_mark_object;
 
                                HEAVY_STAT (++los_array_cards);
                                for (; elem < card_end; elem += SIZEOF_VOID_P) {
                                        gpointer new, old = *(gpointer*)elem;
                                        if ((mod_union && old) || G_UNLIKELY (sgen_ptr_in_nursery (old))) {
                                                HEAVY_STAT (++los_array_remsets);
-                                               copy_func ((void**)elem, queue);
+                                               copy_func ((void**)elem, ctx.queue);
                                                new = *(gpointer*)elem;
                                                if (G_UNLIKELY (sgen_ptr_in_nursery (new)))
                                                        sgen_add_to_global_remset (elem, new);
@@ -672,9 +665,9 @@ LOOP_HEAD:
                HEAVY_STAT (++bloby_objects);
                if (cards) {
                        if (sgen_card_table_is_range_marked (cards, (mword)obj, block_obj_size))
-                               sgen_get_current_object_ops ()->scan_object (obj, sgen_obj_get_descriptor (obj), queue);
+                               ctx.ops->scan_object (obj, sgen_obj_get_descriptor (obj), ctx.queue);
                } else if (sgen_card_table_region_begin_scanning ((mword)obj, block_obj_size)) {
-                       sgen_get_current_object_ops ()->scan_object (obj, sgen_obj_get_descriptor (obj), queue);
+                       ctx.ops->scan_object (obj, sgen_obj_get_descriptor (obj), ctx.queue);
                }
 
                binary_protocol_card_scan (obj, sgen_safe_object_get_size ((MonoObject*)obj));