2 * sgen-bridge.c: Simple generational GC.
4 * Copyright 2011 Novell, Inc (http://www.novell.com)
5 * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
6 * Copyright 2001-2003 Ximian, Inc
7 * Copyright 2003-2010 Novell, Inc.
8 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
17 #include "sgen/sgen-gc.h"
18 #include "sgen-bridge-internals.h"
19 #include "sgen/sgen-hash-table.h"
20 #include "sgen/sgen-qsort.h"
21 #include "sgen/sgen-client.h"
22 #include "utils/mono-logger-internals.h"
45 * Bridge data for a single managed object
47 * FIXME: Optimizations:
49 * Don't allocate a srcs array for just one source. Most objects have
50 * just one source, so use the srcs pointer itself.
52 typedef struct _HashEntry {
53 GCObject *obj; /* This is a duplicate - it's already stored in the hash table */
60 // "Source" managed objects pointing at this destination
63 // Index in sccs array of SCC this object was folded into
70 } HashEntryWithAccounting;
72 // The graph of managed objects/HashEntries is reduced to a graph of strongly connected components
77 // How many bridged objects does this SCC hold references to?
78 int num_bridge_entries;
80 // Index in global sccs array of SCCs holding pointers to this SCC
81 DynIntArray xrefs; /* these are incoming, not outgoing */
84 // Maps managed objects to corresponding HashEntry stricts
85 static SgenHashTable hash_table = SGEN_HASH_TABLE_INIT (INTERNAL_MEM_OLD_BRIDGE_HASH_TABLE, INTERNAL_MEM_OLD_BRIDGE_HASH_TABLE_ENTRY, sizeof (HashEntry), mono_aligned_addr_hash, NULL);
87 static int current_time;
89 static gboolean bridge_accounting_enabled = FALSE;
91 static SgenBridgeProcessor *bridge_processor;
99 dyn_array_init (DynArray *da)
107 dyn_array_uninit (DynArray *da, int elem_size)
109 if (da->capacity <= 0)
112 sgen_free_internal_dynamic (da->data, elem_size * da->capacity, INTERNAL_MEM_BRIDGE_DATA);
117 dyn_array_ensure_capacity (DynArray *da, int capacity, int elem_size)
119 int old_capacity = da->capacity;
122 if (capacity <= old_capacity)
125 if (da->capacity == 0)
127 while (capacity > da->capacity)
130 new_data = (char *)sgen_alloc_internal_dynamic (elem_size * da->capacity, INTERNAL_MEM_BRIDGE_DATA, TRUE);
131 memcpy (new_data, da->data, elem_size * da->size);
132 sgen_free_internal_dynamic (da->data, elem_size * old_capacity, INTERNAL_MEM_BRIDGE_DATA);
137 dyn_array_add (DynArray *da, int elem_size)
141 dyn_array_ensure_capacity (da, da->size + 1, elem_size);
143 p = da->data + da->size * elem_size;
150 dyn_array_int_init (DynIntArray *da)
152 dyn_array_init (&da->array);
156 dyn_array_int_uninit (DynIntArray *da)
158 dyn_array_uninit (&da->array, sizeof (int));
162 dyn_array_int_size (DynIntArray *da)
164 return da->array.size;
168 dyn_array_int_set_size (DynIntArray *da, int size)
170 da->array.size = size;
174 dyn_array_int_add (DynIntArray *da, int x)
176 int *p = (int *)dyn_array_add (&da->array, sizeof (int));
181 dyn_array_int_get (DynIntArray *da, int x)
183 return ((int*)da->array.data)[x];
187 dyn_array_int_set (DynIntArray *da, int idx, int val)
189 ((int*)da->array.data)[idx] = val;
193 dyn_array_int_ensure_capacity (DynIntArray *da, int capacity)
195 dyn_array_ensure_capacity (&da->array, capacity, sizeof (int));
199 dyn_array_int_set_all (DynIntArray *dst, DynIntArray *src)
201 dyn_array_int_ensure_capacity (dst, src->array.size);
202 memcpy (dst->array.data, src->array.data, src->array.size * sizeof (int));
203 dst->array.size = src->array.size;
209 dyn_array_ptr_init (DynPtrArray *da)
211 dyn_array_init (&da->array);
215 dyn_array_ptr_uninit (DynPtrArray *da)
217 dyn_array_uninit (&da->array, sizeof (void*));
221 dyn_array_ptr_size (DynPtrArray *da)
223 return da->array.size;
227 dyn_array_ptr_set_size (DynPtrArray *da, int size)
229 da->array.size = size;
233 dyn_array_ptr_get (DynPtrArray *da, int x)
235 return ((void**)da->array.data)[x];
239 dyn_array_ptr_add (DynPtrArray *da, void *ptr)
241 void **p = (void **)dyn_array_add (&da->array, sizeof (void*));
245 #define dyn_array_ptr_push dyn_array_ptr_add
248 dyn_array_ptr_pop (DynPtrArray *da)
251 int size = da->array.size;
253 p = dyn_array_ptr_get (da, size - 1);
261 dyn_array_scc_init (DynSCCArray *da)
263 dyn_array_init (&da->array);
267 dyn_array_scc_uninit (DynSCCArray *da)
269 dyn_array_uninit (&da->array, sizeof (SCC));
273 dyn_array_scc_size (DynSCCArray *da)
275 return da->array.size;
279 dyn_array_scc_add (DynSCCArray *da)
281 return (SCC *)dyn_array_add (&da->array, sizeof (SCC));
285 dyn_array_scc_get_ptr (DynSCCArray *da, int x)
287 return &((SCC*)da->array.data)[x];
292 static DynIntArray merge_array;
295 dyn_array_int_contains (DynIntArray *da, int x)
298 for (i = 0; i < dyn_array_int_size (da); ++i)
299 if (dyn_array_int_get (da, i) == x)
306 dyn_array_int_merge (DynIntArray *dst, DynIntArray *src)
310 dyn_array_int_ensure_capacity (&merge_array, dyn_array_int_size (dst) + dyn_array_int_size (src));
311 dyn_array_int_set_size (&merge_array, 0);
313 for (i = j = 0; i < dyn_array_int_size (dst) || j < dyn_array_int_size (src); ) {
314 if (i < dyn_array_int_size (dst) && j < dyn_array_int_size (src)) {
315 int a = dyn_array_int_get (dst, i);
316 int b = dyn_array_int_get (src, j);
318 dyn_array_int_add (&merge_array, a);
321 dyn_array_int_add (&merge_array, a);
325 dyn_array_int_add (&merge_array, b);
328 } else if (i < dyn_array_int_size (dst)) {
329 dyn_array_int_add (&merge_array, dyn_array_int_get (dst, i));
332 dyn_array_int_add (&merge_array, dyn_array_int_get (src, j));
337 if (dyn_array_int_size (&merge_array) > dyn_array_int_size (dst)) {
338 dyn_array_int_set_all (dst, &merge_array);
343 dyn_array_int_merge_one (DynIntArray *array, int value)
347 int size = dyn_array_int_size (array);
349 for (i = 0; i < size; ++i) {
350 if (dyn_array_int_get (array, i) == value)
352 else if (dyn_array_int_get (array, i) > value)
356 dyn_array_int_ensure_capacity (array, size + 1);
359 tmp = dyn_array_int_get (array, i);
360 for (; i < size; ++i) {
361 dyn_array_int_set (array, i, value);
363 tmp = dyn_array_int_get (array, i + 1);
365 dyn_array_int_set (array, size, value);
367 dyn_array_int_set (array, size, value);
370 dyn_array_int_set_size (array, size + 1);
375 enable_accounting (void)
377 SgenHashTable table = SGEN_HASH_TABLE_INIT (INTERNAL_MEM_BRIDGE_HASH_TABLE, INTERNAL_MEM_BRIDGE_HASH_TABLE_ENTRY, sizeof (HashEntryWithAccounting), mono_aligned_addr_hash, NULL);
378 bridge_accounting_enabled = TRUE;
382 static MonoGCBridgeObjectKind
383 class_kind (MonoClass *klass)
385 return bridge_callbacks.bridge_class_kind (klass);
389 get_hash_entry (GCObject *obj, gboolean *existing)
391 HashEntry *entry = (HashEntry *)sgen_hash_table_lookup (&hash_table, obj);
402 memset (&new_entry, 0, sizeof (HashEntry));
405 dyn_array_ptr_init (&new_entry.srcs);
406 new_entry.finishing_time = -1;
407 new_entry.scc_index = -1;
409 sgen_hash_table_replace (&hash_table, obj, &new_entry, NULL);
411 return (HashEntry *)sgen_hash_table_lookup (&hash_table, obj);
415 add_source (HashEntry *entry, HashEntry *src)
417 dyn_array_ptr_add (&entry->srcs, src);
423 GCObject *obj G_GNUC_UNUSED;
428 SGEN_HASH_TABLE_FOREACH (&hash_table, GCObject *, obj, HashEntry *, entry) {
429 int entry_size = dyn_array_ptr_size (&entry->srcs);
430 total_srcs += entry_size;
431 if (entry_size > max_srcs)
432 max_srcs = entry_size;
433 dyn_array_ptr_uninit (&entry->srcs);
434 } SGEN_HASH_TABLE_FOREACH_END;
436 sgen_hash_table_clean (&hash_table);
438 dyn_array_int_uninit (&merge_array);
439 //g_print ("total srcs %d - max %d\n", total_srcs, max_srcs);
443 register_bridge_object (GCObject *obj)
445 HashEntry *entry = get_hash_entry (obj, NULL);
446 entry->is_bridge = TRUE;
451 register_finishing_time (HashEntry *entry, int t)
453 g_assert (entry->finishing_time < 0);
454 entry->finishing_time = t;
458 object_is_live (GCObject **objp)
460 GCObject *obj = *objp;
461 GCObject *fwd = SGEN_OBJECT_IS_FORWARDED (obj);
464 return sgen_hash_table_lookup (&hash_table, fwd) == NULL;
466 if (!sgen_object_is_live (obj))
468 return sgen_hash_table_lookup (&hash_table, obj) == NULL;
471 static DynPtrArray registered_bridges;
472 static DynPtrArray dfs_stack;
474 static int dfs1_passes, dfs2_passes;
478 #define HANDLE_PTR(ptr,obj) do { \
479 GCObject *dst = (GCObject*)*(ptr); \
480 if (dst && !object_is_live (&dst)) { \
481 dyn_array_ptr_push (&dfs_stack, obj_entry); \
482 dyn_array_ptr_push (&dfs_stack, get_hash_entry (dst, NULL)); \
487 dfs1 (HashEntry *obj_entry)
490 g_assert (dyn_array_ptr_size (&dfs_stack) == 0);
492 dyn_array_ptr_push (&dfs_stack, NULL);
493 dyn_array_ptr_push (&dfs_stack, obj_entry);
499 obj_entry = (HashEntry *)dyn_array_ptr_pop (&dfs_stack);
503 src = (HashEntry *)dyn_array_ptr_pop (&dfs_stack);
505 obj = obj_entry->obj;
506 desc = sgen_obj_get_descriptor_safe (obj);
509 //g_print ("link %s -> %s\n", sgen_safe_name (src->obj), sgen_safe_name (obj));
510 add_source (obj_entry, src);
512 //g_print ("starting with %s\n", sgen_safe_name (obj));
515 if (obj_entry->is_visited)
518 obj_entry->is_visited = TRUE;
520 dyn_array_ptr_push (&dfs_stack, obj_entry);
521 /* NULL marks that the next entry is to be finished */
522 dyn_array_ptr_push (&dfs_stack, NULL);
525 #include "sgen/sgen-scan-object.h"
527 obj_entry = (HashEntry *)dyn_array_ptr_pop (&dfs_stack);
529 //g_print ("finish %s\n", sgen_safe_name (obj_entry->obj));
530 register_finishing_time (obj_entry, current_time++);
532 } while (dyn_array_ptr_size (&dfs_stack) > 0);
536 scc_add_xref (SCC *src, SCC *dst)
538 g_assert (src != dst);
539 g_assert (src->index != dst->index);
541 if (dyn_array_int_contains (&dst->xrefs, src->index))
543 if (src->num_bridge_entries) {
544 dyn_array_int_merge_one (&dst->xrefs, src->index);
547 dyn_array_int_merge (&dst->xrefs, &src->xrefs);
548 for (i = 0; i < dyn_array_int_size (&dst->xrefs); ++i)
549 g_assert (dyn_array_int_get (&dst->xrefs, i) != dst->index);
554 scc_add_entry (SCC *scc, HashEntry *entry)
556 g_assert (entry->scc_index < 0);
557 entry->scc_index = scc->index;
558 if (entry->is_bridge)
559 ++scc->num_bridge_entries;
562 static DynSCCArray sccs;
563 static SCC *current_scc;
566 dfs2 (HashEntry *entry)
570 g_assert (dyn_array_ptr_size (&dfs_stack) == 0);
572 dyn_array_ptr_push (&dfs_stack, entry);
575 entry = (HashEntry *)dyn_array_ptr_pop (&dfs_stack);
578 if (entry->scc_index >= 0) {
579 if (entry->scc_index != current_scc->index)
580 scc_add_xref (dyn_array_scc_get_ptr (&sccs, entry->scc_index), current_scc);
584 scc_add_entry (current_scc, entry);
586 for (i = 0; i < dyn_array_ptr_size (&entry->srcs); ++i)
587 dyn_array_ptr_push (&dfs_stack, dyn_array_ptr_get (&entry->srcs, i));
588 } while (dyn_array_ptr_size (&dfs_stack) > 0);
592 compare_hash_entries (const HashEntry *e1, const HashEntry *e2)
594 return e2->finishing_time - e1->finishing_time;
597 DEF_QSORT_INLINE(hash_entries, HashEntry*, compare_hash_entries)
599 static gint64 step_1, step_2, step_3, step_4, step_5, step_6;
600 static int fist_pass_links, second_pass_links, sccs_links;
601 static int max_sccs_links = 0;
604 register_finalized_object (GCObject *obj)
606 g_assert (sgen_need_bridge_processing ());
607 dyn_array_ptr_push (®istered_bridges, obj);
613 dyn_array_ptr_set_size (®istered_bridges, 0);
617 processing_stw_step (void)
621 SGEN_TV_DECLARE (atv);
622 SGEN_TV_DECLARE (btv);
624 if (!dyn_array_ptr_size (®istered_bridges))
627 SGEN_TV_GETTIME (btv);
631 dyn_array_ptr_init (&dfs_stack);
632 dyn_array_int_init (&merge_array);
636 First we insert all bridges into the hash table and then we do dfs1.
638 It must be done in 2 steps since the bridge arrays doesn't come in reverse topological order,
639 which means that we can have entry N pointing to entry N + 1.
641 If we dfs1 entry N before N + 1 is registered we'll not consider N + 1 for this bridge
642 pass and not create the required xref between the two.
644 bridge_count = dyn_array_ptr_size (®istered_bridges);
645 for (i = 0; i < bridge_count ; ++i)
646 register_bridge_object ((GCObject *)dyn_array_ptr_get (®istered_bridges, i));
648 for (i = 0; i < bridge_count; ++i)
649 dfs1 (get_hash_entry ((GCObject *)dyn_array_ptr_get (®istered_bridges, i), NULL));
651 SGEN_TV_GETTIME (atv);
652 step_2 = SGEN_TV_ELAPSED (btv, atv);
655 static int num_registered_bridges, hash_table_size;
658 processing_build_callback_data (int generation)
661 int num_sccs, num_xrefs;
662 int max_entries, max_xrefs;
663 GCObject *obj G_GNUC_UNUSED;
665 HashEntry **all_entries;
666 MonoGCBridgeSCC **api_sccs;
667 MonoGCBridgeXRef *api_xrefs;
668 SGEN_TV_DECLARE (atv);
669 SGEN_TV_DECLARE (btv);
671 g_assert (bridge_processor->num_sccs == 0 && bridge_processor->num_xrefs == 0);
672 g_assert (!bridge_processor->api_sccs && !bridge_processor->api_xrefs);
674 if (!dyn_array_ptr_size (®istered_bridges))
677 g_assert (bridge_processing_in_progress);
679 SGEN_TV_GETTIME (atv);
681 /* alloc and fill array of all entries */
683 all_entries = (HashEntry **)sgen_alloc_internal_dynamic (sizeof (HashEntry*) * hash_table.num_entries, INTERNAL_MEM_BRIDGE_DATA, TRUE);
686 SGEN_HASH_TABLE_FOREACH (&hash_table, GCObject *, obj, HashEntry *, entry) {
687 g_assert (entry->finishing_time >= 0);
688 all_entries [j++] = entry;
689 fist_pass_links += dyn_array_ptr_size (&entry->srcs);
690 } SGEN_HASH_TABLE_FOREACH_END;
691 g_assert (j == hash_table.num_entries);
692 hash_table_size = hash_table.num_entries;
694 /* sort array according to decreasing finishing time */
695 qsort_hash_entries (all_entries, hash_table.num_entries);
697 SGEN_TV_GETTIME (btv);
698 step_3 = SGEN_TV_ELAPSED (atv, btv);
700 /* second DFS pass */
702 dyn_array_scc_init (&sccs);
703 for (i = 0; i < hash_table.num_entries; ++i) {
704 HashEntry *entry = all_entries [i];
705 if (entry->scc_index < 0) {
706 int index = dyn_array_scc_size (&sccs);
707 current_scc = dyn_array_scc_add (&sccs);
708 current_scc->index = index;
709 current_scc->num_bridge_entries = 0;
710 current_scc->api_index = -1;
711 dyn_array_int_init (¤t_scc->xrefs);
718 * Compute the weight of each object. The weight of an object is its size plus the size of all
719 * objects it points do. When the an object is pointed by multiple objects we distribute it's weight
720 * equally among them. This distribution gives a rough estimate of the real impact of making the object
723 * The reasoning for this model is that complex graphs with single roots will have a bridge with very high
724 * value in comparison to others.
726 * The all_entries array has all objects topologically sorted. To correctly propagate the weights it must be
727 * done in reverse topological order - so we calculate the weight of the pointed-to objects before processing
728 * pointer-from objects.
730 * We log those objects in the opposite order for no particular reason. The other constrain is that it should use the same
731 * direction as the other logging loop that records live/dead information.
733 if (bridge_accounting_enabled) {
734 for (i = hash_table.num_entries - 1; i >= 0; --i) {
736 HashEntryWithAccounting *entry = (HashEntryWithAccounting*)all_entries [i];
738 entry->weight += (double)sgen_safe_object_get_size (entry->entry.obj);
739 w = entry->weight / dyn_array_ptr_size (&entry->entry.srcs);
740 for (j = 0; j < dyn_array_ptr_size (&entry->entry.srcs); ++j) {
741 HashEntryWithAccounting *other = (HashEntryWithAccounting *)dyn_array_ptr_get (&entry->entry.srcs, j);
745 for (i = 0; i < hash_table.num_entries; ++i) {
746 HashEntryWithAccounting *entry = (HashEntryWithAccounting*)all_entries [i];
747 if (entry->entry.is_bridge) {
748 MonoClass *klass = SGEN_LOAD_VTABLE (entry->entry.obj)->klass;
749 mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "OBJECT %s::%s (%p) weight %f", klass->name_space, klass->name, entry->entry.obj, entry->weight);
754 for (i = 0; i < hash_table.num_entries; ++i) {
755 HashEntry *entry = all_entries [i];
756 second_pass_links += dyn_array_ptr_size (&entry->srcs);
759 SGEN_TV_GETTIME (atv);
760 step_4 = SGEN_TV_ELAPSED (btv, atv);
762 //g_print ("%d sccs\n", sccs.size);
764 dyn_array_ptr_uninit (&dfs_stack);
766 /* init data for callback */
769 for (i = 0; i < dyn_array_scc_size (&sccs); ++i) {
770 SCC *scc = dyn_array_scc_get_ptr (&sccs, i);
771 g_assert (scc->index == i);
772 if (scc->num_bridge_entries)
774 sccs_links += dyn_array_int_size (&scc->xrefs);
775 max_sccs_links = MAX (max_sccs_links, dyn_array_int_size (&scc->xrefs));
778 api_sccs = (MonoGCBridgeSCC **)sgen_alloc_internal_dynamic (sizeof (MonoGCBridgeSCC*) * num_sccs, INTERNAL_MEM_BRIDGE_DATA, TRUE);
781 for (i = 0; i < dyn_array_scc_size (&sccs); ++i) {
782 SCC *scc = dyn_array_scc_get_ptr (&sccs, i);
783 if (!scc->num_bridge_entries)
786 api_sccs [j] = (MonoGCBridgeSCC *)sgen_alloc_internal_dynamic (sizeof (MonoGCBridgeSCC) + sizeof (MonoObject*) * scc->num_bridge_entries, INTERNAL_MEM_BRIDGE_DATA, TRUE);
787 api_sccs [j]->is_alive = FALSE;
788 api_sccs [j]->num_objs = scc->num_bridge_entries;
789 scc->num_bridge_entries = 0;
790 scc->api_index = j++;
792 num_xrefs += dyn_array_int_size (&scc->xrefs);
795 SGEN_HASH_TABLE_FOREACH (&hash_table, GCObject *, obj, HashEntry *, entry) {
796 if (entry->is_bridge) {
797 SCC *scc = dyn_array_scc_get_ptr (&sccs, entry->scc_index);
798 api_sccs [scc->api_index]->objs [scc->num_bridge_entries++] = (MonoObject*)entry->obj;
800 } SGEN_HASH_TABLE_FOREACH_END;
802 api_xrefs = (MonoGCBridgeXRef *)sgen_alloc_internal_dynamic (sizeof (MonoGCBridgeXRef) * num_xrefs, INTERNAL_MEM_BRIDGE_DATA, TRUE);
804 for (i = 0; i < dyn_array_scc_size (&sccs); ++i) {
806 SCC *scc = dyn_array_scc_get_ptr (&sccs, i);
807 if (!scc->num_bridge_entries)
809 for (k = 0; k < dyn_array_int_size (&scc->xrefs); ++k) {
810 SCC *src_scc = dyn_array_scc_get_ptr (&sccs, dyn_array_int_get (&scc->xrefs, k));
811 if (!src_scc->num_bridge_entries)
813 api_xrefs [j].src_scc_index = src_scc->api_index;
814 api_xrefs [j].dst_scc_index = scc->api_index;
819 SGEN_TV_GETTIME (btv);
820 step_5 = SGEN_TV_ELAPSED (atv, btv);
825 max_entries = max_xrefs = 0;
826 for (i = 0; i < dyn_array_scc_size (&sccs); ++i) {
827 SCC *scc = dyn_array_scc_get_ptr (&sccs, i);
828 if (scc->num_bridge_entries)
830 if (scc->num_bridge_entries > max_entries)
831 max_entries = scc->num_bridge_entries;
832 if (dyn_array_int_size (&scc->xrefs) > max_xrefs)
833 max_xrefs = dyn_array_int_size (&scc->xrefs);
834 dyn_array_int_uninit (&scc->xrefs);
837 dyn_array_scc_uninit (&sccs);
839 sgen_free_internal_dynamic (all_entries, sizeof (HashEntry*) * hash_table.num_entries, INTERNAL_MEM_BRIDGE_DATA);
842 /* Empty the registered bridges array */
843 num_registered_bridges = dyn_array_ptr_size (®istered_bridges);
844 dyn_array_ptr_set_size (®istered_bridges, 0);
846 SGEN_TV_GETTIME (atv);
847 step_6 = SGEN_TV_ELAPSED (btv, atv);
849 //g_print ("%d sccs containing bridges - %d max bridge objects - %d max xrefs\n", j, max_entries, max_xrefs);
851 bridge_processor->num_sccs = num_sccs;
852 bridge_processor->api_sccs = api_sccs;
853 bridge_processor->num_xrefs = num_xrefs;
854 bridge_processor->api_xrefs = api_xrefs;
858 processing_after_callback (int generation)
861 int num_sccs = bridge_processor->num_sccs;
862 MonoGCBridgeSCC **api_sccs = bridge_processor->api_sccs;
864 if (bridge_accounting_enabled) {
865 for (i = 0; i < num_sccs; ++i) {
866 for (j = 0; j < api_sccs [i]->num_objs; ++j) {
867 GCVTable vtable = SGEN_LOAD_VTABLE (api_sccs [i]->objs [j]);
868 mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC,
869 "OBJECT %s.%s (%p) SCC [%d] %s",
870 sgen_client_vtable_get_namespace (vtable), sgen_client_vtable_get_name (vtable), api_sccs [i]->objs [j],
872 api_sccs [i]->is_alive ? "ALIVE" : "DEAD");
877 mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_OLD_BRIDGE num-objects %d num_hash_entries %d sccs size %d init %.2fms df1 %.2fms sort %.2fms dfs2 %.2fms setup-cb %.2fms free-data %.2fms links %d/%d/%d/%d dfs passes %d/%d",
878 num_registered_bridges, hash_table_size, dyn_array_scc_size (&sccs),
885 fist_pass_links, second_pass_links, sccs_links, max_sccs_links,
886 dfs1_passes, dfs2_passes);
888 step_1 = 0; /* We must cleanup since this value is used as an accumulator. */
889 fist_pass_links = second_pass_links = sccs_links = max_sccs_links = 0;
890 dfs1_passes = dfs2_passes = 0;
894 describe_pointer (GCObject *obj)
899 for (i = 0; i < dyn_array_ptr_size (®istered_bridges); ++i) {
900 if (obj == dyn_array_ptr_get (®istered_bridges, i)) {
901 printf ("Pointer is a registered bridge object.\n");
906 entry = (HashEntry *)sgen_hash_table_lookup (&hash_table, obj);
910 printf ("Bridge hash table entry %p:\n", entry);
911 printf (" is bridge: %d\n", (int)entry->is_bridge);
912 printf (" is visited: %d\n", (int)entry->is_visited);
916 sgen_old_bridge_init (SgenBridgeProcessor *collector)
918 collector->reset_data = reset_data;
919 collector->processing_stw_step = processing_stw_step;
920 collector->processing_build_callback_data = processing_build_callback_data;
921 collector->processing_after_callback = processing_after_callback;
922 collector->class_kind = class_kind;
923 collector->register_finalized_object = register_finalized_object;
924 collector->describe_pointer = describe_pointer;
925 collector->enable_accounting = enable_accounting;
927 bridge_processor = collector;