Skip to content

Commit

Permalink
[sgen-bridge] Compare SCCs between bridge implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
schani committed May 2, 2014
1 parent c6a3beb commit 0aba200
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mono/metadata/sgen-bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ sgen_bridge_processing_finish (int generation)
bridge_callbacks.cross_references (bridge_processor.num_sccs, bridge_processor.api_sccs,
bridge_processor.num_xrefs, bridge_processor.api_xrefs);

if (compare_bridge_processors ())
sgen_compare_bridge_processor_results (&bridge_processor, &compare_to_bridge_processor);

SGEN_TV_GETTIME (btv);

null_weak_links_to_dead_objects (&bridge_processor, generation);
Expand Down
59 changes: 59 additions & 0 deletions mono/metadata/sgen-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,4 +908,63 @@ sgen_check_for_xdomain_refs (void)
scan_object_for_xdomain_refs (bigobj->data, sgen_los_object_size (bigobj), NULL);
}

gboolean
sgen_compare_bridge_processor_results (SgenBridgeProcessor *a, SgenBridgeProcessor *b)
{
int i;
SgenHashTable obj_to_a_scc = SGEN_HASH_TABLE_INIT (INTERNAL_MEM_BRIDGE_DEBUG, INTERNAL_MEM_BRIDGE_DEBUG, sizeof (int), mono_aligned_addr_hash, NULL);

g_assert (a->num_sccs == b->num_sccs);
g_assert (a->num_xrefs == b->num_xrefs);

/*
* First we build a hash of each object in `a` to its respective SCC index within
* `a`. Along the way we also assert that no object is more than one SCC.
*/
for (i = 0; i < a->num_sccs; ++i) {
int j;
MonoGCBridgeSCC *scc = a->api_sccs [i];

g_assert (scc->num_objs > 0);

for (j = 0; j < scc->num_objs; ++j) {
MonoObject *obj = scc->objs [j];
gboolean new_entry = sgen_hash_table_replace (&obj_to_a_scc, obj, &i, NULL);
g_assert (new_entry);
}
}

/*
* Now we check whether each of the objects in `b` are in `a`, and whether the SCCs
* of `b` contain the same sets of objects as those of `a`.
*/
for (i = 0; i < b->num_sccs; ++i) {
MonoGCBridgeSCC *scc = b->api_sccs [i];
MonoGCBridgeSCC *a_scc;
int *a_scc_index_ptr;
int a_scc_index;
int j;

g_assert (scc->num_objs > 0);
a_scc_index_ptr = sgen_hash_table_lookup (&obj_to_a_scc, scc->objs [0]);
g_assert (a_scc_index_ptr);
a_scc_index = *a_scc_index_ptr;

g_print ("A SCC %d -> B SCC %d\n", a_scc_index, i);

a_scc = a->api_sccs [a_scc_index];
g_assert (a_scc->num_objs == scc->num_objs);

for (j = 1; j < scc->num_objs; ++j) {
a_scc_index_ptr = sgen_hash_table_lookup (&obj_to_a_scc, scc->objs [j]);
g_assert (a_scc_index_ptr);
g_assert (*a_scc_index_ptr == a_scc_index);
}
}

sgen_hash_table_clean (&obj_to_a_scc);

return TRUE;
}

#endif /*HAVE_SGEN_GC*/
3 changes: 3 additions & 0 deletions mono/metadata/sgen-gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ enum {
INTERNAL_MEM_BRIDGE_HASH_TABLE_ENTRY,
INTERNAL_MEM_BRIDGE_ALIVE_HASH_TABLE,
INTERNAL_MEM_BRIDGE_ALIVE_HASH_TABLE_ENTRY,
INTERNAL_MEM_BRIDGE_DEBUG,
INTERNAL_MEM_JOB_QUEUE_ENTRY,
INTERNAL_MEM_TOGGLEREF_DATA,
INTERNAL_MEM_CARDTABLE_MOD_UNION,
Expand Down Expand Up @@ -848,6 +849,8 @@ void sgen_new_bridge_init (SgenBridgeProcessor *collector) MONO_INTERNAL;
void sgen_set_bridge_implementation (const char *name) MONO_INTERNAL;
void sgen_bridge_set_dump_prefix (const char *prefix) MONO_INTERNAL;

gboolean sgen_compare_bridge_processor_results (SgenBridgeProcessor *a, SgenBridgeProcessor *b) MONO_INTERNAL;

typedef mono_bool (*WeakLinkAlivePredicateFunc) (MonoObject*, void*);

void sgen_null_links_with_predicate (int generation, WeakLinkAlivePredicateFunc predicate, void *data) MONO_INTERNAL;
Expand Down
1 change: 1 addition & 0 deletions mono/metadata/sgen-internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ description_for_type (int type)
case INTERNAL_MEM_BRIDGE_HASH_TABLE_ENTRY: return "bridge-hash-table-entry";
case INTERNAL_MEM_BRIDGE_ALIVE_HASH_TABLE: return "bridge-alive-hash-table";
case INTERNAL_MEM_BRIDGE_ALIVE_HASH_TABLE_ENTRY: return "bridge-alive-hash-table-entry";
case INTERNAL_MEM_BRIDGE_DEBUG: return "bridge-debug";
case INTERNAL_MEM_JOB_QUEUE_ENTRY: return "job-queue-entry";
case INTERNAL_MEM_TOGGLEREF_DATA: return "toggleref-data";
case INTERNAL_MEM_CARDTABLE_MOD_UNION: return "cardtable-mod-union";
Expand Down

0 comments on commit 0aba200

Please sign in to comment.