[sgen] Move `sgen_safe_name()` to client code.
[mono.git] / mono / metadata / sgen-copy-object.h
index adad2514d08dd2d54350ee2c7b9950aeb66b8320..8501a5354880dc938bcdd4a2566971c564fa52a7 100644 (file)
 
 #include "mono/utils/mono-compiler.h"
 
-extern long long stat_copy_object_called_nursery;
-extern long long stat_objects_copied_nursery;
+extern guint64 stat_copy_object_called_nursery;
+extern guint64 stat_objects_copied_nursery;
 
-extern long long stat_nursery_copy_object_failed_from_space;
-extern long long stat_nursery_copy_object_failed_forwarded;
-extern long long stat_nursery_copy_object_failed_pinned;
+extern guint64 stat_nursery_copy_object_failed_from_space;
+extern guint64 stat_nursery_copy_object_failed_forwarded;
+extern guint64 stat_nursery_copy_object_failed_pinned;
 
-extern long long stat_slots_allocated_in_vain;
+extern guint64 stat_slots_allocated_in_vain;
 
 /*
+ * Copies an object and enqueues it if a queue is given.
+ *
  * This function can be used even if the vtable of obj is not valid
  * anymore, which is the case in the parallel collector.
  */
@@ -63,8 +65,8 @@ par_copy_object_no_checks (char *destination, MonoVTable *vt, void *obj, mword o
                sgen_register_moved_object (obj, destination);
        obj = destination;
        if (queue) {
-               SGEN_LOG (9, "Enqueuing gray object %p (%s)", obj, sgen_safe_name (obj));
-               GRAY_OBJECT_ENQUEUE (queue, obj);
+               SGEN_LOG (9, "Enqueuing gray object %p (%s)", obj, sgen_client_object_safe_name (obj));
+               GRAY_OBJECT_ENQUEUE (queue, obj, sgen_vtable_get_descriptor (vt));
        }
 }
 
@@ -76,16 +78,21 @@ copy_object_no_checks (void *obj, SgenGrayQueue *queue)
 {
        MonoVTable *vt = ((MonoObject*)obj)->vtable;
        gboolean has_references = SGEN_VTABLE_HAS_REFERENCES (vt);
-       mword objsize = SGEN_ALIGN_UP (sgen_par_object_get_size (vt, (MonoObject*)obj));
+       mword objsize = SGEN_ALIGN_UP (sgen_client_par_object_get_size (vt, (MonoObject*)obj));
+       /* FIXME: Does this not mark the newly allocated object? */
        char *destination = COLLECTOR_SERIAL_ALLOC_FOR_PROMOTION (vt, obj, objsize, has_references);
 
        if (G_UNLIKELY (!destination)) {
+               /* FIXME: Is this path ever tested? */
                collector_pin_object (obj, queue);
                sgen_set_pinned_from_failed_allocation (objsize);
                return obj;
        }
 
-       par_copy_object_no_checks (destination, vt, obj, objsize, has_references ? queue : NULL);
+       if (!has_references)
+               queue = NULL;
+
+       par_copy_object_no_checks (destination, vt, obj, objsize, queue);
        /* FIXME: mark mod union cards if necessary */
 
        /* set the forwarding pointer */