Skip to content

Commit

Permalink
Include SC identifiers in bytecode dump.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed May 13, 2014
1 parent 1f22a12 commit 2360aaa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/6model/reprs/MVMCompUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ struct MVMCompUnitBody {
* all are resolved, this pointer itself becomes NULL. */
MVMSerializationContextBody **scs_to_resolve;

/* List of SC handle string indexes. */
MVMint32 *sc_handle_idxs;

/* HLL configuration for this compilation unit. */
MVMHLLConfig *hll_config;
MVMString *hll_name;
Expand Down
8 changes: 4 additions & 4 deletions src/6model/sc.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ void MVM_sc_set_description(MVMThreadContext *tc, MVMSerializationContext *sc, M
MVMint64 MVM_sc_find_object_idx(MVMThreadContext *tc, MVMSerializationContext *sc, MVMObject *obj) {
MVMObject **roots;
MVMint64 i, count;
MVMint32 cached = obj->header.sc_forward_u.sc.idx;
/*MVMint32 cached = obj->header.sc_forward_u.sc.idx;
if (cached >= 0)
return cached;
return cached;*/
roots = sc->body->root_objects;
count = sc->body->num_objects;
for (i = 0; i < count; i++)
Expand All @@ -105,9 +105,9 @@ MVMint64 MVM_sc_find_object_idx(MVMThreadContext *tc, MVMSerializationContext *s
/* Given an SC, looks up the index of an STable that is in its root set. */
MVMint64 MVM_sc_find_stable_idx(MVMThreadContext *tc, MVMSerializationContext *sc, MVMSTable *st) {
MVMuint64 i;
MVMint32 cached = st->header.sc_forward_u.sc.idx;
/*MVMint32 cached = st->header.sc_forward_u.sc.idx;
if (cached >= 0)
return cached;
return cached;*/
for (i = 0; i < sc->body->num_stables; i++)
if (sc->body->root_stables[i] == st)
return i;
Expand Down
2 changes: 2 additions & 0 deletions src/core/bytecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ static void deserialize_sc_deps(MVMThreadContext *tc, MVMCompUnit *cu, ReaderSta
/* Allocate SC lists in compilation unit. */
cu_body->scs = malloc(rs->expected_scs * sizeof(MVMSerializationContext *));
cu_body->scs_to_resolve = malloc(rs->expected_scs * sizeof(MVMSerializationContextBody *));
cu_body->sc_handle_idxs = malloc(rs->expected_scs * sizeof(MVMint32));
cu_body->num_scs = rs->expected_scs;

/* Resolve all the things. */
Expand All @@ -318,6 +319,7 @@ static void deserialize_sc_deps(MVMThreadContext *tc, MVMCompUnit *cu, ReaderSta
cleanup_all(tc, rs);
MVM_exception_throw_adhoc(tc, "String heap index beyond end of string heap");
}
cu_body->sc_handle_idxs[i] = sh_idx;
handle = cu_body->strings[sh_idx];

/* See if we can resolve it. */
Expand Down
7 changes: 7 additions & 0 deletions src/core/bytecodedump.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ char * MVM_bytecode_dump(MVMThreadContext *tc, MVMCompUnit *cu) {

a("\nMoarVM dump of binary compilation unit:\n\n");

for (k = 0; k < cu->body.num_scs; k++) {
char *tmpstr = MVM_string_utf8_encode_C_string(
tc, cu->body.strings[cu->body.sc_handle_idxs[k]]);
a(" SC_%u : %s\n", k, tmpstr);
free(tmpstr);
}

for (k = 0; k < cu->body.num_callsites; k++) {
MVMCallsite *callsite = cu->body.callsites[k];
MVMuint16 arg_count = callsite->arg_count;
Expand Down

0 comments on commit 2360aaa

Please sign in to comment.