Skip to content

Commit

Permalink
A spesh op like sp_bind/get_i64 with an extra pointer deref
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Nov 30, 2015
1 parent 469ba64 commit c7706c4
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 35 deletions.
66 changes: 47 additions & 19 deletions lib/MAST/Ops.nqp
Expand Up @@ -747,16 +747,20 @@ BEGIN {
1854,
1857,
1860,
1861,
1863,
1865,
1867,
1867,
1867,
1868,
1866,
1869,
1869,
1870);
1872,
1873,
1875,
1877,
1879,
1879,
1879,
1880,
1881,
1881,
1882);
MAST::Ops.WHO<@counts> := nqp::list_i(0,
2,
2,
Expand Down Expand Up @@ -1500,6 +1504,10 @@ BEGIN {
3,
3,
3,
3,
3,
3,
3,
1,
2,
2,
Expand Down Expand Up @@ -3371,6 +3379,18 @@ BEGIN {
65,
16,
57,
34,
65,
16,
50,
65,
16,
65,
33,
16,
65,
49,
16,
66,
34,
65,
Expand Down Expand Up @@ -4126,17 +4146,21 @@ BEGIN {
'sp_p6obind_i', 740,
'sp_p6obind_n', 741,
'sp_p6obind_s', 742,
'sp_jit_enter', 743,
'sp_boolify_iter', 744,
'sp_boolify_iter_arr', 745,
'sp_boolify_iter_hash', 746,
'prof_enter', 747,
'prof_enterspesh', 748,
'prof_enterinline', 749,
'prof_enternative', 750,
'prof_exit', 751,
'prof_allocated', 752,
'ctw_check', 753);
'sp_deref_get_i64', 743,
'sp_deref_get_n', 744,
'sp_deref_bind_i64', 745,
'sp_deref_bind_n', 746,
'sp_jit_enter', 747,
'sp_boolify_iter', 748,
'sp_boolify_iter_arr', 749,
'sp_boolify_iter_hash', 750,
'prof_enter', 751,
'prof_enterspesh', 752,
'prof_enterinline', 753,
'prof_enternative', 754,
'prof_exit', 755,
'prof_allocated', 756,
'ctw_check', 757);
MAST::Ops.WHO<@names> := nqp::list_s('no_op',
'const_i8',
'const_i16',
Expand Down Expand Up @@ -4880,6 +4904,10 @@ BEGIN {
'sp_p6obind_i',
'sp_p6obind_n',
'sp_p6obind_s',
'sp_deref_get_i64',
'sp_deref_get_n',
'sp_deref_bind_i64',
'sp_deref_bind_n',
'sp_jit_enter',
'sp_boolify_iter',
'sp_boolify_iter_arr',
Expand Down
28 changes: 28 additions & 0 deletions src/core/interp.c
Expand Up @@ -5116,6 +5116,34 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
cur_op += 6;
goto NEXT;
}
OP(sp_deref_get_i64): {
MVMObject *o = GET_REG(cur_op, 2).o;
MVMint64 **target = ((MVMint64 **)((char *)o + GET_UI16(cur_op, 4)));
GET_REG(cur_op, 0).i64 = **target;
cur_op += 6;
goto NEXT;
}
OP(sp_deref_get_n): {
MVMObject *o = GET_REG(cur_op, 2).o;
MVMnum64 **target = ((MVMnum64 **)((char *)o + GET_UI16(cur_op, 4)));
GET_REG(cur_op, 0).n64 = **target;
cur_op += 6;
goto NEXT;
}
OP(sp_deref_bind_i64): {
MVMObject *o = GET_REG(cur_op, 0).o;
MVMint64 **target = ((MVMint64 **)((char *)o + GET_UI16(cur_op, 4)));
**target = GET_REG(cur_op, 2).i64;
cur_op += 6;
goto NEXT;
}
OP(sp_deref_bind_n): {
MVMObject *o = GET_REG(cur_op, 0).o;
MVMnum64 **target = ((MVMnum64 **)((char *)o + GET_UI16(cur_op, 4)));
**target = GET_REG(cur_op, 2).n64;
cur_op += 6;
goto NEXT;
}
OP(sp_jit_enter): {
if (tc->cur_frame->spesh_cand->jitcode == NULL) {
MVM_exception_throw_adhoc(tc, "Try to enter NULL jitcode");
Expand Down
8 changes: 4 additions & 4 deletions src/core/oplabels.h
Expand Up @@ -744,6 +744,10 @@ static const void * const LABELS[] = {
&&OP_sp_p6obind_i,
&&OP_sp_p6obind_n,
&&OP_sp_p6obind_s,
&&OP_sp_deref_get_i64,
&&OP_sp_deref_get_n,
&&OP_sp_deref_bind_i64,
&&OP_sp_deref_bind_n,
&&OP_sp_jit_enter,
&&OP_sp_boolify_iter,
&&OP_sp_boolify_iter_arr,
Expand Down Expand Up @@ -1021,10 +1025,6 @@ static const void * const LABELS[] = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
&&OP_CALL_EXTOP,
&&OP_CALL_EXTOP,
&&OP_CALL_EXTOP,
Expand Down
6 changes: 6 additions & 0 deletions src/core/oplist
Expand Up @@ -824,6 +824,12 @@ sp_p6obind_i .s r(obj) int16 r(int64)
sp_p6obind_n .s r(obj) int16 r(num64)
sp_p6obind_s .s r(obj) int16 r(str)

# Follow a pointer at an offset to an object and get/store a value there.
sp_deref_get_i64 .s w(int64) r(obj) int16 :pure
sp_deref_get_n .s w(num64) r(obj) int16 :pure
sp_deref_bind_i64 .s r(obj) r(int64) int16
sp_deref_bind_n .s r(obj) r(num64) int16

# Enter the JIT
sp_jit_enter .s w(obj)

Expand Down
46 changes: 45 additions & 1 deletion src/core/ops.c
Expand Up @@ -8165,6 +8165,50 @@ static const MVMOpInfo MVM_op_infos[] = {
0,
{ MVM_operand_read_reg | MVM_operand_obj, MVM_operand_int16, MVM_operand_read_reg | MVM_operand_str }
},
{
MVM_OP_sp_deref_get_i64,
"sp_deref_get_i64",
".s",
3,
1,
0,
0,
0,
{ MVM_operand_write_reg | MVM_operand_int64, MVM_operand_read_reg | MVM_operand_obj, MVM_operand_int16 }
},
{
MVM_OP_sp_deref_get_n,
"sp_deref_get_n",
".s",
3,
1,
0,
0,
0,
{ MVM_operand_write_reg | MVM_operand_num64, MVM_operand_read_reg | MVM_operand_obj, MVM_operand_int16 }
},
{
MVM_OP_sp_deref_bind_i64,
"sp_deref_bind_i64",
".s",
3,
0,
0,
0,
0,
{ MVM_operand_read_reg | MVM_operand_obj, MVM_operand_read_reg | MVM_operand_int64, MVM_operand_int16 }
},
{
MVM_OP_sp_deref_bind_n,
"sp_deref_bind_n",
".s",
3,
0,
0,
0,
0,
{ MVM_operand_read_reg | MVM_operand_obj, MVM_operand_read_reg | MVM_operand_num64, MVM_operand_int16 }
},
{
MVM_OP_sp_jit_enter,
"sp_jit_enter",
Expand Down Expand Up @@ -8285,7 +8329,7 @@ static const MVMOpInfo MVM_op_infos[] = {
},
};

static const unsigned short MVM_op_counts = 754;
static const unsigned short MVM_op_counts = 758;

MVM_PUBLIC const MVMOpInfo * MVM_op_get_op(unsigned short op) {
if (op >= MVM_op_counts)
Expand Down
26 changes: 15 additions & 11 deletions src/core/ops.h
Expand Up @@ -744,17 +744,21 @@
#define MVM_OP_sp_p6obind_i 740
#define MVM_OP_sp_p6obind_n 741
#define MVM_OP_sp_p6obind_s 742
#define MVM_OP_sp_jit_enter 743
#define MVM_OP_sp_boolify_iter 744
#define MVM_OP_sp_boolify_iter_arr 745
#define MVM_OP_sp_boolify_iter_hash 746
#define MVM_OP_prof_enter 747
#define MVM_OP_prof_enterspesh 748
#define MVM_OP_prof_enterinline 749
#define MVM_OP_prof_enternative 750
#define MVM_OP_prof_exit 751
#define MVM_OP_prof_allocated 752
#define MVM_OP_ctw_check 753
#define MVM_OP_sp_deref_get_i64 743
#define MVM_OP_sp_deref_get_n 744
#define MVM_OP_sp_deref_bind_i64 745
#define MVM_OP_sp_deref_bind_n 746
#define MVM_OP_sp_jit_enter 747
#define MVM_OP_sp_boolify_iter 748
#define MVM_OP_sp_boolify_iter_arr 749
#define MVM_OP_sp_boolify_iter_hash 750
#define MVM_OP_prof_enter 751
#define MVM_OP_prof_enterspesh 752
#define MVM_OP_prof_enterinline 753
#define MVM_OP_prof_enternative 754
#define MVM_OP_prof_exit 755
#define MVM_OP_prof_allocated 756
#define MVM_OP_ctw_check 757

#define MVM_OP_EXT_BASE 1024
#define MVM_OP_EXT_CU_LIMIT 1024
Expand Down

0 comments on commit c7706c4

Please sign in to comment.