Skip to content

Commit 3a502cf

Browse files
BrzVladfilipnavara
authored andcommitted
[mono] Add a few bridge tests (dotnet#113703)
* [mono][sgen] Fix DUMP_GRAPH debug option build for tarjan bridge * [mono][sgen] Don't create ScanData* during debug dumping of SCCs It serves no purpose and it would later crash the runtime since we didn't patch the lockword back in place. * [mono][sgen] Fix some null deref crashes in DUMP_GRAPH debug option * [mono][tests] Add bridge tests These are ported from some of the bridge tests we had on mono/mono. In order to test them we compare between the output of the new and the tarjan bridge.
1 parent a052530 commit 3a502cf

File tree

5 files changed

+472
-21
lines changed

5 files changed

+472
-21
lines changed

src/mono/mono/metadata/sgen-tarjan-bridge.c

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -400,16 +400,7 @@ static const char*
400400
safe_name_bridge (GCObject *obj)
401401
{
402402
GCVTable vt = SGEN_LOAD_VTABLE (obj);
403-
return vt->klass->name;
404-
}
405-
406-
static ScanData*
407-
find_or_create_data (GCObject *obj)
408-
{
409-
ScanData *entry = find_data (obj);
410-
if (!entry)
411-
entry = create_data (obj);
412-
return entry;
403+
return m_class_get_name (vt->klass);
413404
}
414405
#endif
415406

@@ -700,11 +691,11 @@ compute_low_index (ScanData *data, GCObject *obj)
700691
obj = bridge_object_forward (obj);
701692
other = find_data (obj);
702693

703-
#if DUMP_GRAPH
704-
printf ("\tcompute low %p ->%p (%s) %p (%d / %d, color %p)\n", data->obj, obj, safe_name_bridge (obj), other, other ? other->index : -2, other ? other->low_index : -2, other->color);
705-
#endif
706694
if (!other)
707695
return;
696+
#if DUMP_GRAPH
697+
printf ("\tcompute low %p ->%p (%s) %p (%d / %d, color %p)\n", data->obj, obj, safe_name_bridge (obj), other, other ? other->index : -2, other->low_index, other->color);
698+
#endif
708699

709700
g_assert (other->state != INITIAL);
710701

@@ -794,7 +785,7 @@ create_scc (ScanData *data)
794785
#if DUMP_GRAPH
795786
printf ("|SCC %p rooted in %s (%p) has bridge %d\n", color_data, safe_name_bridge (data->obj), data->obj, found_bridge);
796787
printf ("\tloop stack: ");
797-
for (int i = 0; i < dyn_array_ptr_size (&loop_stack); ++i) {
788+
for (i = 0; i < dyn_array_ptr_size (&loop_stack); ++i) {
798789
ScanData *other = dyn_array_ptr_get (&loop_stack, i);
799790
printf ("(%d/%d)", other->index, other->low_index);
800791
}
@@ -838,10 +829,12 @@ create_scc (ScanData *data)
838829
g_assert (found);
839830

840831
#if DUMP_GRAPH
841-
printf ("\tpoints-to-colors: ");
842-
for (int i = 0; i < dyn_array_ptr_size (&color_data->other_colors); i++)
843-
printf ("%p ", dyn_array_ptr_get (&color_data->other_colors, i));
844-
printf ("\n");
832+
if (color_data) {
833+
printf ("\tpoints-to-colors: ");
834+
for (i = 0; i < dyn_array_ptr_size (&color_data->other_colors); i++)
835+
printf ("%p ", dyn_array_ptr_get (&color_data->other_colors, i));
836+
printf ("\n");
837+
}
845838
#endif
846839
}
847840

@@ -966,8 +959,11 @@ dump_color_table (const char *why, gboolean do_index)
966959
printf (" bridges: ");
967960
for (j = 0; j < dyn_array_ptr_size (&cd->bridges); ++j) {
968961
GCObject *obj = dyn_array_ptr_get (&cd->bridges, j);
969-
ScanData *data = find_or_create_data (obj);
970-
printf ("%d ", data->index);
962+
ScanData *data = find_data (obj);
963+
if (!data)
964+
printf ("%p ", obj);
965+
else
966+
printf ("%p(%d) ", obj, data->index);
971967
}
972968
}
973969
printf ("\n");
@@ -1027,7 +1023,7 @@ processing_stw_step (void)
10271023
#if defined (DUMP_GRAPH)
10281024
printf ("----summary----\n");
10291025
printf ("bridges:\n");
1030-
for (int i = 0; i < bridge_count; ++i) {
1026+
for (i = 0; i < bridge_count; ++i) {
10311027
ScanData *sd = find_data (dyn_array_ptr_get (&registered_bridges, i));
10321028
printf ("\t%s (%p) index %d color %p\n", safe_name_bridge (sd->obj), sd->obj, sd->index, sd->color);
10331029
}

0 commit comments

Comments
 (0)