[sgen] Move `sgen_safe_name()` to client code.
authorMark Probst <mark.probst@gmail.com>
Tue, 23 Dec 2014 22:20:35 +0000 (14:20 -0800)
committerMark Probst <mark.probst@gmail.com>
Wed, 29 Apr 2015 17:57:47 +0000 (10:57 -0700)
14 files changed:
mono/metadata/sgen-client.h
mono/metadata/sgen-copy-object.h
mono/metadata/sgen-debug.c
mono/metadata/sgen-fin-weak-hash.c
mono/metadata/sgen-gc.c
mono/metadata/sgen-gc.h
mono/metadata/sgen-marksweep.c
mono/metadata/sgen-mono.c
mono/metadata/sgen-new-bridge.c
mono/metadata/sgen-nursery-allocator.c
mono/metadata/sgen-old-bridge.c
mono/metadata/sgen-pinning.c
mono/metadata/sgen-simple-nursery.c
mono/metadata/sgen-split-nursery.c

index b3e3460b258d11cdb23bf7c582d27772cd016a70..d5166657073f6f34a0480003f50f5604e5581b35 100644 (file)
@@ -73,6 +73,8 @@ gboolean sgen_client_cardtable_scan_object (char *obj, mword block_obj_size, gui
  */
 const char* sgen_client_description_for_internal_mem_type (int type);
 
+const char* sgen_client_object_safe_name (MonoObject *obj);
+
 void sgen_client_pre_collection_checks (void);
 
 gboolean sgen_client_handle_gc_debug (const char *opt);
index 826c0c67aa01d078e24a945dafd3bcfb9a7e8eb2..8501a5354880dc938bcdd4a2566971c564fa52a7 100644 (file)
@@ -65,7 +65,7 @@ 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));
+               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));
        }
 }
index 2a0721f6d6d1b3709562aaf515fc4f56f81043a4..5c604b2a7d338d7b6f509f33131216d365755b21 100644 (file)
@@ -32,6 +32,7 @@
 #include "metadata/sgen-protocol.h"
 #include "metadata/sgen-memory-governor.h"
 #include "metadata/sgen-pinning.h"
+#include "metadata/sgen-client.h"
 #include "metadata/threadpool-internals.h"
 
 #define LOAD_VTABLE    SGEN_LOAD_VTABLE
@@ -287,7 +288,7 @@ sgen_check_major_refs (void)
 #undef HANDLE_PTR
 #define HANDLE_PTR(ptr,obj)    do {    \
                if (*(ptr)) {   \
-                       g_assert (sgen_safe_name (*(ptr)) != NULL);     \
+                       g_assert (sgen_client_object_safe_name (*(ptr)) != NULL);       \
                }       \
        } while (0)
 
@@ -620,7 +621,7 @@ static gboolean scan_object_for_specific_ref_precise = TRUE;
 #define HANDLE_PTR(ptr,obj) do {               \
        if ((MonoObject*)*(ptr) == key) {       \
        g_print ("found ref to %p in object %p (%s) at offset %td\n",   \
-                       key, (obj), sgen_safe_name ((obj)), ((char*)(ptr) - (char*)(obj))); \
+                       key, (obj), sgen_client_object_safe_name ((MonoObject*)(obj)), ((char*)(ptr) - (char*)(obj))); \
        }                                                               \
        } while (0)
 
@@ -642,7 +643,7 @@ scan_object_for_specific_ref (char *start, MonoObject *key)
                for (i = 0; i < size / sizeof (mword); ++i) {
                        if (words [i] == (mword)key) {
                                g_print ("found possible ref to %p in object %p (%s) at offset %td\n",
-                                               key, start, sgen_safe_name (start), i * sizeof (mword));
+                                               key, start, sgen_client_object_safe_name ((MonoObject*)start), i * sizeof (mword));
                        }
                }
        }
index 85552777bf7346dd9c7969df0cc0c15ef24933e3..b9e853fa83739ea9d967d63409a7c2f13d60f32f 100644 (file)
@@ -31,6 +31,7 @@
 #include "metadata/sgen-gray.h"
 #include "metadata/sgen-protocol.h"
 #include "metadata/sgen-pointer-queue.h"
+#include "metadata/sgen-client.h"
 #include "utils/dtrace.h"
 #include "utils/mono-counters.h"
 
@@ -155,7 +156,7 @@ sgen_collect_bridge_objects (int generation, ScanCopyContext ctx)
                        /* insert it into the major hash */
                        sgen_hash_table_replace (&major_finalizable_hash, tagged_object_apply (copy, tag), NULL, NULL);
 
-                       SGEN_LOG (5, "Promoting finalization of object %p (%s) (was at %p) to major table", copy, sgen_safe_name (copy), object);
+                       SGEN_LOG (5, "Promoting finalization of object %p (%s) (was at %p) to major table", copy, sgen_client_object_safe_name ((MonoObject*)copy), object);
 
                        continue;
                } else if (copy != (char*)object) {
@@ -165,7 +166,7 @@ sgen_collect_bridge_objects (int generation, ScanCopyContext ctx)
                        /* register for reinsertion */
                        sgen_pointer_queue_add (&moved_fin_objects, tagged_object_apply (copy, tag));
 
-                       SGEN_LOG (5, "Updating object for finalization: %p (%s) (was at %p)", copy, sgen_safe_name (copy), object);
+                       SGEN_LOG (5, "Updating object for finalization: %p (%s) (was at %p)", copy, sgen_client_object_safe_name ((MonoObject*)copy), object);
 
                        continue;
                }
@@ -207,7 +208,7 @@ sgen_finalize_in_range (int generation, ScanCopyContext ctx)
                                num_ready_finalizers++;
                                sgen_queue_finalization_entry (copy);
                                /* Make it survive */
-                               SGEN_LOG (5, "Queueing object for finalization: %p (%s) (was at %p) (%d/%d)", copy, sgen_safe_name (copy), object, num_ready_finalizers, sgen_hash_table_num_entries (hash_table));
+                               SGEN_LOG (5, "Queueing object for finalization: %p (%s) (was at %p) (%d/%d)", copy, sgen_client_object_safe_name (copy), object, num_ready_finalizers, sgen_hash_table_num_entries (hash_table));
                                continue;
                        } else {
                                if (hash_table == &minor_finalizable_hash && !ptr_in_nursery (copy)) {
@@ -217,7 +218,7 @@ sgen_finalize_in_range (int generation, ScanCopyContext ctx)
                                        /* insert it into the major hash */
                                        sgen_hash_table_replace (&major_finalizable_hash, tagged_object_apply (copy, tag), NULL, NULL);
 
-                                       SGEN_LOG (5, "Promoting finalization of object %p (%s) (was at %p) to major table", copy, sgen_safe_name (copy), object);
+                                       SGEN_LOG (5, "Promoting finalization of object %p (%s) (was at %p) to major table", copy, sgen_client_object_safe_name (copy), object);
 
                                        continue;
                                } else if (copy != object) {
@@ -227,7 +228,7 @@ sgen_finalize_in_range (int generation, ScanCopyContext ctx)
                                        /* register for reinsertion */
                                        sgen_pointer_queue_add (&moved_fin_objects, tagged_object_apply (copy, tag));
 
-                                       SGEN_LOG (5, "Updating object for finalization: %p (%s) (was at %p)", copy, sgen_safe_name (copy), object);
+                                       SGEN_LOG (5, "Updating object for finalization: %p (%s) (was at %p)", copy, sgen_client_object_safe_name (copy), object);
 
                                        continue;
                                }
@@ -588,7 +589,7 @@ finalizers_for_domain (MonoDomain *domain, MonoObject **out_array, int out_size,
                        /* remove and put in out_array */
                        SGEN_HASH_TABLE_FOREACH_REMOVE (TRUE);
                        out_array [count ++] = object;
-                       SGEN_LOG (5, "Collecting object for finalization: %p (%s) (%d/%d)", object, sgen_safe_name (object), num_ready_finalizers, sgen_hash_table_num_entries (hash_table));
+                       SGEN_LOG (5, "Collecting object for finalization: %p (%s) (%d/%d)", object, sgen_client_object_safe_name (object), num_ready_finalizers, sgen_hash_table_num_entries (hash_table));
                        if (count == out_size)
                                return count;
                        continue;
@@ -815,7 +816,7 @@ sgen_remove_finalizers_for_domain (MonoDomain *domain, int generation)
                object = tagged_object_get_object (object);
 
                if (mono_object_domain (object) == domain) {
-                       SGEN_LOG (5, "Unregistering finalizer for object: %p (%s)", object, sgen_safe_name (object));
+                       SGEN_LOG (5, "Unregistering finalizer for object: %p (%s)", object, sgen_client_object_safe_name (object));
 
                        SGEN_HASH_TABLE_FOREACH_REMOVE (TRUE);
                        continue;
index fc00b61fb633a61afd5694be4bfe1ab1809fdbe2..51e6372b76a112f1debb6fec88089361699a097e 100644 (file)
@@ -372,13 +372,6 @@ NurseryClearPolicy nursery_clear_policy = CLEAR_AT_TLAB_CREATION;
 
 #define LOAD_VTABLE    SGEN_LOAD_VTABLE
 
-static const char*
-safe_name (void* obj)
-{
-       MonoVTable *vt = (MonoVTable*)LOAD_VTABLE (obj);
-       return vt->klass->name;
-}
-
 gboolean
 nursery_canaries_enabled (void)
 {
@@ -387,12 +380,6 @@ nursery_canaries_enabled (void)
 
 #define safe_object_get_size   sgen_safe_object_get_size
 
-const char*
-sgen_safe_name (void* obj)
-{
-       return safe_name (obj);
-}
-
 /*
  * ######################################################################
  * ########  Global data.
@@ -678,7 +665,7 @@ sgen_drain_gray_stack (int max_objs, ScanCopyContext ctx)
                        GRAY_OBJECT_DEQUEUE (queue, &obj, &desc);
                        if (!obj)
                                return TRUE;
-                       SGEN_LOG (9, "Precise gray object scan %p (%s)", obj, safe_name (obj));
+                       SGEN_LOG (9, "Precise gray object scan %p (%s)", obj, sgen_client_object_safe_name ((MonoObject*)obj));
                        scan_func (obj, desc, queue);
                }
        } while (max_objs < 0);
@@ -825,7 +812,7 @@ pin_objects_from_nursery_pin_queue (gboolean do_scan_objects, ScanCopyContext ct
                        scan_func (obj_to_pin, desc, queue);
                } else {
                        SGEN_LOG (4, "Pinned object %p, vtable %p (%s), count %d\n",
-                                       obj_to_pin, *(void**)obj_to_pin, safe_name (obj_to_pin), count);
+                                       obj_to_pin, *(void**)obj_to_pin, sgen_client_object_safe_name (obj_to_pin), count);
                        binary_protocol_pin (obj_to_pin,
                                        (gpointer)LOAD_VTABLE (obj_to_pin),
                                        safe_object_get_size (obj_to_pin));
@@ -1328,7 +1315,7 @@ scan_finalizer_entries (FinalizeReadyEntry *list, ScanCopyContext ctx)
        for (fin = list; fin; fin = fin->next) {
                if (!fin->object)
                        continue;
-               SGEN_LOG (5, "Scan of fin ready object: %p (%s)\n", fin->object, safe_name (fin->object));
+               SGEN_LOG (5, "Scan of fin ready object: %p (%s)\n", fin->object, sgen_client_object_safe_name (fin->object));
                copy_func (&fin->object, queue);
        }
 }
@@ -1771,7 +1758,7 @@ verify_nursery (void)
                if (do_dump_nursery_content) {
                        if (cur > hole_start)
                                SGEN_LOG (1, "HOLE [%p %p %d]", hole_start, cur, (int)(cur - hole_start));
-                       SGEN_LOG (1, "OBJ  [%p %p %d %d %s %d]", cur, cur + size, (int)size, (int)ss, sgen_safe_name ((MonoObject*)cur), (gpointer)LOAD_VTABLE (cur) == sgen_client_get_array_fill_vtable ());
+                       SGEN_LOG (1, "OBJ  [%p %p %d %d %s %d]", cur, cur + size, (int)size, (int)ss, sgen_client_object_safe_name ((MonoObject*)cur), (gpointer)LOAD_VTABLE (cur) == sgen_client_get_array_fill_vtable ());
                }
                if (nursery_canaries_enabled () && (MonoVTable*)SGEN_LOAD_VTABLE (cur) != sgen_client_get_array_fill_vtable ()) {
                        CHECK_CANARY_FOR_OBJECT (cur);
@@ -2220,7 +2207,7 @@ major_copy_or_mark_from_roots (size_t *old_next_pin_slot, CopyOrMarkFromRootsMod
                        if (SGEN_OBJECT_HAS_REFERENCES (bigobj->data))
                                GRAY_OBJECT_ENQUEUE (WORKERS_DISTRIBUTE_GRAY_QUEUE, bigobj->data, sgen_obj_get_descriptor (bigobj->data));
                        sgen_pin_stats_register_object ((char*) bigobj->data, safe_object_get_size ((MonoObject*) bigobj->data));
-                       SGEN_LOG (6, "Marked large object %p (%s) size: %lu from roots", bigobj->data, safe_name (bigobj->data), (unsigned long)sgen_los_object_size (bigobj));
+                       SGEN_LOG (6, "Marked large object %p (%s) size: %lu from roots", bigobj->data, sgen_client_object_safe_name ((MonoObject*)bigobj->data), (unsigned long)sgen_los_object_size (bigobj));
 
                        if (profile_roots)
                                add_profile_gc_root (&root_report, bigobj->data, MONO_PROFILE_GC_ROOT_PINNING | MONO_PROFILE_GC_ROOT_MISC, 0);
@@ -3013,7 +3000,7 @@ mono_gc_invoke_finalizers (void)
                        num_ready_finalizers--;
                        obj = entry->object;
                        entry->object = NULL;
-                       SGEN_LOG (7, "Finalizing object %p (%s)", obj, safe_name (obj));
+                       SGEN_LOG (7, "Finalizing object %p (%s)", obj, sgen_client_object_safe_name (obj));
                }
 
                UNLOCK_GC;
@@ -3024,7 +3011,7 @@ mono_gc_invoke_finalizers (void)
                g_assert (entry->object == NULL);
                count++;
                /* the object is on the stack so it is pinned */
-               /*g_print ("Calling finalizer for object: %p (%s)\n", entry->object, safe_name (entry->object));*/
+               /*g_print ("Calling finalizer for object: %p (%s)\n", entry->object, sgen_client_object_safe_name (entry->object));*/
                mono_gc_run_finalize (obj, NULL);
        }
        g_assert (!entry);
@@ -3443,7 +3430,7 @@ mono_gc_wbarrier_generic_nostore (gpointer ptr)
 void
 mono_gc_wbarrier_generic_store (gpointer ptr, MonoObject* value)
 {
-       SGEN_LOG (8, "Wbarrier store at %p to %p (%s)", ptr, value, value ? safe_name (value) : "null");
+       SGEN_LOG (8, "Wbarrier store at %p to %p (%s)", ptr, value, value ? sgen_client_object_safe_name (value) : "null");
        SGEN_UPDATE_REFERENCE_ALLOW_NULL (ptr, value);
        if (ptr_in_nursery (value))
                mono_gc_wbarrier_generic_nostore (ptr);
@@ -3458,7 +3445,7 @@ mono_gc_wbarrier_generic_store_atomic (gpointer ptr, MonoObject *value)
 {
        HEAVY_STAT (++stat_wbarrier_generic_store_atomic);
 
-       SGEN_LOG (8, "Wbarrier atomic store at %p to %p (%s)", ptr, value, value ? safe_name (value) : "null");
+       SGEN_LOG (8, "Wbarrier atomic store at %p to %p (%s)", ptr, value, value ? sgen_client_object_safe_name (value) : "null");
 
        InterlockedWritePointer (ptr, value);
 
index 41298b405304808b7d02f66d46f16c1adddc386f..69a24e9cece96edbcf453bf8f171ede6d940c0bb 100644 (file)
@@ -802,8 +802,6 @@ sgen_safe_object_get_size_unaligned (MonoObject *obj)
        return sgen_client_slow_object_get_size ((MonoVTable*)SGEN_LOAD_VTABLE (obj), obj);
 }
 
-const char* sgen_safe_name (void* obj);
-
 gboolean sgen_object_is_live (void *obj);
 
 void  sgen_init_fin_weak_hash (void);
index aa3cf492cf23a7bbdfb6c1d538aa03a791e8f52e..5ea7bbf495bda8df145b24861fa97715d0b9adb0 100644 (file)
@@ -44,6 +44,7 @@
 #include "metadata/sgen-pinning.h"
 #include "metadata/sgen-workers.h"
 #include "metadata/sgen-thread-pool.h"
+#include "metadata/sgen-client.h"
 
 #if defined(ARCH_MIN_MS_BLOCK_SIZE) && defined(ARCH_MIN_MS_BLOCK_SIZE_SHIFT)
 #define MS_BLOCK_SIZE  ARCH_MIN_MS_BLOCK_SIZE
index 5938023e9f6a34d63231fc9a69a428ddb493ff8b..5680b5be2efc9ea1cb6d0d593290170dffaf9682 100644 (file)
@@ -1493,6 +1493,13 @@ sgen_client_pre_collection_checks (void)
        }
 }
 
+const char*
+sgen_client_object_safe_name (MonoObject *obj)
+{
+       MonoVTable *vt = (MonoVTable*)SGEN_LOAD_VTABLE (obj);
+       return vt->klass->name;
+}
+
 /*
  * Initialization
  */
index a8bf84acc02b0f064b446e1a46d2361703901518..7c7b9c99975e6bddf4051fa3ecdbb00009a9cd8e 100644 (file)
@@ -48,6 +48,7 @@
 #include "sgen-bridge.h"
 #include "sgen-hash-table.h"
 #include "sgen-qsort.h"
+#include "sgen-client.h"
 #include "tabledefs.h"
 #include "utils/mono-logger-internal.h"
 #include "utils/mono-time.h"
@@ -1328,7 +1329,7 @@ processing_after_callback (int generation)
                        for (j = 0; j < api_sccs [i]->num_objs; ++j)
                                mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC,
                                        "OBJECT %s (%p) SCC [%d] %s",
-                                               sgen_safe_name (api_sccs [i]->objs [j]), api_sccs [i]->objs [j],
+                                               sgen_client_object_safe_name (api_sccs [i]->objs [j]), api_sccs [i]->objs [j],
                                                i,
                                                api_sccs [i]->is_alive  ? "ALIVE" : "DEAD");
                }
index 5bfc7a9f6ed43bd498ecff41cdeba26da98d637d..f158ef25107499700d83a7f5f2de1d966c757ed4 100644 (file)
@@ -823,7 +823,7 @@ sgen_build_nursery_fragments (GCMemSection *nursery_section, SgenGrayQueue *unpi
                SGEN_LOG (1, "Nursery fully pinned");
                for (pin_entry = pin_start; pin_entry < pin_end; ++pin_entry) {
                        void *p = *pin_entry;
-                       SGEN_LOG (3, "Bastard pinning obj %p (%s), size: %zd", p, sgen_safe_name (p), sgen_safe_object_get_size (p));
+                       SGEN_LOG (3, "Bastard pinning obj %p (%s), size: %zd", p, sgen_client_object_safe_name (p), sgen_safe_object_get_size (p));
                }
        }
        return fragment_total;
index c2f5db5bf942abb3eabb8d9e3d4eb8470fa32149..a56f2625e5c243ae09eb598cd15b74b8b1100f6b 100644 (file)
@@ -47,6 +47,7 @@
 #include "sgen-bridge.h"
 #include "sgen-hash-table.h"
 #include "sgen-qsort.h"
+#include "sgen-client.h"
 #include "utils/mono-logger-internal.h"
 #include "utils/mono-time.h"
 #include "utils/mono-compiler.h"
@@ -888,7 +889,7 @@ processing_after_callback (int generation)
                        for (j = 0; j < api_sccs [i]->num_objs; ++j)
                                mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC,
                                        "OBJECT %s (%p) SCC [%d] %s",
-                                               sgen_safe_name (api_sccs [i]->objs [j]), api_sccs [i]->objs [j],
+                                               sgen_client_object_safe_name (api_sccs [i]->objs [j]), api_sccs [i]->objs [j],
                                                i,
                                                api_sccs [i]->is_alive  ? "ALIVE" : "DEAD");
                }
index 2d7a8ca498c81f01374ad692d400d423fc24e07b..1aac69c679cf237d7cda1c2635a8a79f935072fb 100644 (file)
@@ -26,6 +26,7 @@
 #include "metadata/sgen-pinning.h"
 #include "metadata/sgen-protocol.h"
 #include "metadata/sgen-pointer-queue.h"
+#include "metadata/sgen-client.h"
 
 static SgenPointerQueue pin_queue;
 static size_t last_num_pinned = 0;
@@ -171,7 +172,7 @@ sgen_dump_pin_queue (void)
 
        for (i = 0; i < last_num_pinned; ++i) {
                void *ptr = pin_queue.data [i];
-               SGEN_LOG (3, "Bastard pinning obj %p (%s), size: %zd", ptr, sgen_safe_name (ptr), sgen_safe_object_get_size (ptr));
+               SGEN_LOG (3, "Bastard pinning obj %p (%s), size: %zd", ptr, sgen_client_object_safe_name (ptr), sgen_safe_object_get_size (ptr));
        }
 }
 
index 2cfb9d3211c0ee61f761c856ab1e2cda3ddda58f..d9816754c4533f1ddf7cf1344ac34d82373144d8 100644 (file)
@@ -28,6 +28,7 @@
 #include "metadata/sgen-gc.h"
 #include "metadata/sgen-protocol.h"
 #include "metadata/sgen-layout-stats.h"
+#include "metadata/sgen-client.h"
 
 static inline char*
 alloc_for_promotion (MonoVTable *vtable, char *obj, size_t objsize, gboolean has_references)
index f8312bfc15da53ce9e7c9377e6f38a4b358e1467..39220dbc1e9ae0cd85bb20b090ad2eb7f437a972 100644 (file)
@@ -31,6 +31,7 @@
 #include "metadata/sgen-gc.h"
 #include "metadata/sgen-protocol.h"
 #include "metadata/sgen-layout-stats.h"
+#include "metadata/sgen-client.h"
 #include "utils/mono-memory-model.h"
 
 /*