Skip to content

Commit

Permalink
JIT getcodeobj
Browse files Browse the repository at this point in the history
Was actually timotimo++'s patch, I included a fix for
curcode which derefed *tc->cur_frame->code_ref, which
isn't necessary.
  • Loading branch information
bdw committed Aug 30, 2014
1 parent 9c670c9 commit b7987fa
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/core/frame.c
Expand Up @@ -843,6 +843,8 @@ void MVM_frame_unwind_to(MVMThreadContext *tc, MVMFrame *frame, MVMuint8 *abs_ad

/* Gets a code object for a frame, lazily deserializing it if needed. */
MVMObject * MVM_frame_get_code_object(MVMThreadContext *tc, MVMCode *code) {
if (REPR(code)->ID != MVM_REPR_ID_MVMCode)
MVM_exception_throw_adhoc(tc, "getcodeobj needs a code ref");
if (!code->body.code_object) {
MVMStaticFrame *sf = code->body.sf;
if (sf->body.code_obj_sc_dep_idx > 0) {
Expand Down
5 changes: 1 addition & 4 deletions src/core/interp.c
Expand Up @@ -2819,10 +2819,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
goto NEXT;
OP(getcodeobj): {
MVMObject *obj = GET_REG(cur_op, 2).o;
if (REPR(obj)->ID == MVM_REPR_ID_MVMCode)
GET_REG(cur_op, 0).o = MVM_frame_get_code_object(tc, (MVMCode *)obj);
else
MVM_exception_throw_adhoc(tc, "getcodeobj needs a code ref");
GET_REG(cur_op, 0).o = MVM_frame_get_code_object(tc, (MVMCode *)obj);
cur_op += 4;
goto NEXT;
}
Expand Down
1 change: 0 additions & 1 deletion src/jit/emit_x64.dasc
Expand Up @@ -550,7 +550,6 @@ void MVM_jit_emit_primitive(MVMThreadContext *tc, MVMJitGraph *jg,
case MVM_OP_curcode: {
MVMint16 dst = ins->operands[0].reg.orig;
| mov TMP1, aword FRAME->code_ref;
| mov TMP1, aword [TMP1]
| mov aword WORK[dst], TMP1;
break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/jit/graph.c
Expand Up @@ -264,6 +264,7 @@ static void * op_to_func(MVMThreadContext *tc, MVMint16 opcode) {
case MVM_OP_nfafromstatelist: return &MVM_nfa_from_statelist;
case MVM_OP_hllize: return &MVM_hll_map;
case MVM_OP_clone: return &MVM_repr_clone;
case MVM_OP_getcodeobj: return &MVM_frame_get_code_object;
case MVM_OP_isbig_I: return &MVM_bigint_is_big;
case MVM_OP_add_I: return &MVM_bigint_add;
case MVM_OP_sub_I: return &MVM_bigint_sub;
Expand Down Expand Up @@ -938,6 +939,7 @@ static MVMint32 jgb_consume_ins(MVMThreadContext *tc, JitGraphBuilder *jgb,
break;
}
case MVM_OP_shift_o:
case MVM_OP_getcodeobj:
case MVM_OP_pop_o: {
MVMint16 dst = ins->operands[0].reg.orig;
MVMint32 invocant = ins->operands[1].reg.orig;
Expand Down

0 comments on commit b7987fa

Please sign in to comment.