Skip to content

Instantly share code, notes, and snippets.

@timo
Created May 11, 2014 17:24
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/52be9e43e985845f7201 to your computer and use it in GitHub Desktop.
Save timo/52be9e43e985845f7201 to your computer and use it in GitHub Desktop.
try to build a sp_get_*
diff --git a/3rdparty/dyncall b/3rdparty/dyncall
--- a/3rdparty/dyncall
+++ b/3rdparty/dyncall
@@ -1 +1 @@
-Subproject commit 5c4e85c290756b84eb55c9ed97f550555bcdc29d
+Subproject commit 5c4e85c290756b84eb55c9ed97f550555bcdc29d-dirty
diff --git a/src/6model/reprs/P6int.c b/src/6model/reprs/P6int.c
index 506c136..119b608 100644
--- a/src/6model/reprs/P6int.c
+++ b/src/6model/reprs/P6int.c
@@ -110,6 +110,22 @@ static void compose(MVMThreadContext *tc, MVMSTable *st, MVMObject *info_hash) {
}
}
+static void spesh(MVMThreadContext *tc, MVMSTable *st, MVMSpeshGraph *g, MVMSpeshBB *bb, MVMSpeshIns *ins) {
+ MVMP6opaqueREPRData * repr_data = (MVMP6opaqueREPRData *)st->REPR_data;
+ if (!repr_data)
+ return;
+ switch (ins->info->opcode) {
+ case MVM_OP_unbox_i: {
+ MVMSpeshOperand target = ins->operands[0];
+ MVMSpeshOperand source = ins->operands[1];
+ ins->info = MVM_op_get_op(MVM_OP_sp_get_i);
+ ins->operands = MVM_spesh_alloc(tc, g, 2 * sizeof(MVMSpeshOperand));
+ ins->operands[0] = target;
+ ins->operands[1] = source;
+ ins->operands[2].lit_i16 = offsetof( MVMP6int, body.value.i64 );
+ }
+ }
+}
/* Set the size of the STable. */
static void deserialize_stable_size(MVMThreadContext *tc, MVMSTable *st, MVMSerializationReader *reader) {
st->size = sizeof(MVMP6int);
@@ -190,7 +206,7 @@ static const MVMREPROps this_repr = {
NULL, /* gc_mark_repr_data */
gc_free_repr_data,
compose,
- NULL, /* spesh */
+ spesh,
"P6int", /* name */
MVM_REPR_ID_P6int,
0, /* refs_frames */
diff --git a/src/core/interp.c b/src/core/interp.c
index fd667d3..26ab1d7 100644
--- a/src/core/interp.c
+++ b/src/core/interp.c
@@ -4394,15 +4394,15 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
goto NEXT;
}
OP(sp_get_i):
- GET_REG(cur_op, 0).i64 = *((MVMint64 *)((char *)&GET_REG(cur_op, 2) + GET_UI16(cur_op, 4)));
+ GET_REG(cur_op, 0).i64 = *((MVMint64 *)((char *)GET_REG(cur_op, 2).o + GET_UI16(cur_op, 4)));
cur_op += 6;
goto NEXT;
OP(sp_get_n):
- GET_REG(cur_op, 0).n64 = *((MVMnum64 *)((char *)&GET_REG(cur_op, 2) + GET_UI16(cur_op, 4)));
+ GET_REG(cur_op, 0).n64 = *((MVMnum64 *)((char *)GET_REG(cur_op, 2).o + GET_UI16(cur_op, 4)));
cur_op += 6;
goto NEXT;
OP(sp_get_s):
- GET_REG(cur_op, 0).s = ((MVMString *)((char *)&GET_REG(cur_op, 2) + GET_UI16(cur_op, 4)));
+ GET_REG(cur_op, 0).s = ((MVMString *)((char *)GET_REG(cur_op, 2).o + GET_UI16(cur_op, 4)));
cur_op += 6;
goto NEXT;
OP(sp_get_o):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment