Skip to content

Instantly share code, notes, and snippets.

@timo
Created May 26, 2023 11:39
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 timo/e0710330b99df029165c2c4b80b7103c to your computer and use it in GitHub Desktop.
Save timo/e0710330b99df029165c2c4b80b7103c to your computer and use it in GitHub Desktop.
diff --git a/src/core/oplist b/src/core/oplist
index 362f67e56..95b497273 100644
--- a/src/core/oplist
+++ b/src/core/oplist
@@ -476,7 +476,7 @@ ctxouter w(obj) r(obj) :pure
ctxcaller w(obj) r(obj) :pure
ctxlexpad w(obj) r(obj) :pure
curcode w(obj) :pure
-callercode w(obj) :pure :noinline
+callercode w(obj) :pure
add_I w(obj) r(obj) r(obj) r(obj) :pure
sub_I w(obj) r(obj) r(obj) r(obj) :pure
mul_I w(obj) r(obj) r(obj) r(obj) :pure
diff --git a/src/core/ops.c b/src/core/ops.c
index 54acf304e..69087efca 100644
--- a/src/core/ops.c
+++ b/src/core/ops.c
@@ -6794,7 +6794,7 @@ static const MVMOpInfo MVM_op_infos[] = {
0,
0,
0,
- 1,
+ 0,
0,
0,
0,
diff --git a/src/spesh/inline.c b/src/spesh/inline.c
index 4743555e7..8486c3951 100644
--- a/src/spesh/inline.c
+++ b/src/spesh/inline.c
@@ -474,6 +474,14 @@ static void rewrite_curcode(MVMThreadContext *tc, MVMSpeshGraph *g,
MVM_spesh_usages_add_by_reg(tc, g, code_ref_reg, ins);
}
+/* Make a callercode instruction turn into curcode so it refers to
+ * the inliner's code object */
+static void rewrite_callercode(MVMThreadContext *tc, MVMSpeshGraph *g,
+ MVMSpeshIns *ins, MVMuint16 num_locals) {
+ ins->operands[0].reg.orig += num_locals;
+ ins->info = MVM_op_get_op(MVM_OP_curcode);
+}
+
/* Rewrites a lexical lookup to an outer to be done via. a register holding
* the outer coderef. */
static void rewrite_outer_lookup(MVMThreadContext *tc, MVMSpeshGraph *g,
@@ -642,6 +650,9 @@ static MVMSpeshBB * merge_graph(MVMThreadContext *tc, MVMSpeshGraph *inliner,
else if (opcode == MVM_OP_curcode) {
rewrite_curcode(tc, inliner, ins, inliner->num_locals, code_ref_reg);
}
+ else if (opcode == MVM_OP_callercode) {
+ rewrite_callercode(tc, inliner, ins, inliner->num_locals);
+ }
else if (opcode == MVM_OP_sp_getlex_o && ins->operands[1].lex.outers > 0) {
rewrite_outer_lookup(tc, inliner, ins, inliner->num_locals,
MVM_OP_sp_getlexvia_o, code_ref_reg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment