Skip to content

Commit

Permalink
Basic dumping of facts.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed May 8, 2014
1 parent f72aefb commit f4d2c85
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/spesh/dump.c
Expand Up @@ -153,6 +153,20 @@ static void dump_bb(MVMThreadContext *tc, DumpStr *ds, MVMSpeshGraph *g, MVMSpes
append(ds, "\n\n");
}

/* Dumps the facts table. */
static void dump_facts(MVMThreadContext *tc, DumpStr *ds, MVMSpeshGraph *g) {
MVMuint16 i, j, num_locals, num_facts;
num_locals = g->sf->body.num_locals;
for (i = 0; i < num_locals; i++) {
num_facts = g->fact_counts[i];
for (j = 0; j < num_facts; j++) {
MVMint32 usages = g->facts[i][j].usages;
MVMint32 flags = g->facts[i][j].flags;
appendf(ds, " r%d(%d): usages=%d, flags=%d\n", i, j, usages, flags);
}
}
}

/* Dump a spesh graph into string form, for debugging purposes. */
char * MVM_spesh_dump(MVMThreadContext *tc, MVMSpeshGraph *g) {
MVMSpeshBB *cur_bb;
Expand All @@ -177,6 +191,10 @@ char * MVM_spesh_dump(MVMThreadContext *tc, MVMSpeshGraph *g) {
cur_bb = cur_bb->linear_next;
}

/* Dump facts. */
append(&ds, "\nFacts:\n");
dump_facts(tc, &ds, g);

append(&ds, "\n");
append_null(&ds);
return ds.buffer;
Expand Down

0 comments on commit f4d2c85

Please sign in to comment.