Skip to content

Instantly share code, notes, and snippets.

@bdw
Created August 29, 2014 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdw/ce249b2ba2849d4f17e6 to your computer and use it in GitHub Desktop.
Save bdw/ce249b2ba2849d4f17e6 to your computer and use it in GitHub Desktop.
getcodeobj patch
diff --git a/src/core/frame.c b/src/core/frame.c
index 7669e39..41673b1 100644
--- a/src/core/frame.c
+++ b/src/core/frame.c
@@ -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) {
diff --git a/src/core/interp.c b/src/core/interp.c
index a19d558..676ac96 100644
--- a/src/core/interp.c
+++ b/src/core/interp.c
@@ -2818,10 +2818,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;
}
diff --git a/src/jit/graph.c b/src/jit/graph.c
index 4495e46..b9b2250 100644
--- a/src/jit/graph.c
+++ b/src/jit/graph.c
@@ -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;
@@ -931,6 +932,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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment