Skip to content

Commit

Permalink
WIP on removing lex vivification checks
Browse files Browse the repository at this point in the history
in theory we can know when a lex is guaranteed to
have already been accessed before by looking at
the dominator tree.

However, this still runs into the safety check
in the sp_getlex_live_o op while compiling rakudo.
  • Loading branch information
timo committed Jan 21, 2018
1 parent a74869e commit e5750c5
Show file tree
Hide file tree
Showing 8 changed files with 268 additions and 169 deletions.
212 changes: 109 additions & 103 deletions lib/MAST/Ops.nqp
Expand Up @@ -808,58 +808,59 @@ BEGIN {
2009,
2011,
2013,
2016,
2019,
2022,
2025,
2026,
2015,
2018,
2021,
2024,
2027,
2028,
2032,
2035,
2038,
2041,
2044,
2047,
2050,
2053,
2056,
2059,
2062,
2065,
2068,
2071,
2074,
2077,
2080,
2084,
2088,
2091,
2094,
2097,
2100,
2103,
2106,
2109,
2112,
2115,
2118,
2121,
2125,
2129,
2130,
2030,
2034,
2037,
2040,
2043,
2046,
2049,
2052,
2055,
2058,
2061,
2064,
2067,
2070,
2073,
2076,
2079,
2082,
2086,
2090,
2093,
2096,
2099,
2102,
2105,
2108,
2111,
2114,
2117,
2120,
2123,
2127,
2131,
2132,
2134,
2136,
2140,
2138,
2142,
2144,
2144,
2144,
2145,
2146,
2146,
2146,
2147,
2149);
2148,
2148,
2149,
2151);
MAST::Ops.WHO<@counts> := nqp::list_i(0,
2,
2,
Expand Down Expand Up @@ -1664,6 +1665,7 @@ BEGIN {
2,
2,
2,
2,
3,
3,
3,
Expand Down Expand Up @@ -3716,6 +3718,8 @@ BEGIN {
65,
66,
67,
66,
67,
82,
83,
66,
Expand Down Expand Up @@ -4667,66 +4671,67 @@ BEGIN {
'sp_resolvecode', 794,
'sp_decont', 795,
'sp_getlex_o', 796,
'sp_getlex_ins', 797,
'sp_getlex_no', 798,
'sp_getarg_o', 799,
'sp_getarg_i', 800,
'sp_getarg_n', 801,
'sp_getarg_s', 802,
'sp_fastinvoke_v', 803,
'sp_fastinvoke_i', 804,
'sp_fastinvoke_n', 805,
'sp_fastinvoke_s', 806,
'sp_fastinvoke_o', 807,
'sp_paramnamesused', 808,
'sp_getspeshslot', 809,
'sp_findmeth', 810,
'sp_fastcreate', 811,
'sp_get_o', 812,
'sp_get_i64', 813,
'sp_get_i32', 814,
'sp_get_i16', 815,
'sp_get_i8', 816,
'sp_get_n', 817,
'sp_get_s', 818,
'sp_bind_o', 819,
'sp_bind_i64', 820,
'sp_bind_i32', 821,
'sp_bind_i16', 822,
'sp_bind_i8', 823,
'sp_bind_n', 824,
'sp_bind_s', 825,
'sp_p6oget_o', 826,
'sp_p6ogetvt_o', 827,
'sp_p6ogetvc_o', 828,
'sp_p6oget_i', 829,
'sp_p6oget_n', 830,
'sp_p6oget_s', 831,
'sp_p6obind_o', 832,
'sp_p6obind_i', 833,
'sp_p6obind_n', 834,
'sp_p6obind_s', 835,
'sp_deref_get_i64', 836,
'sp_deref_get_n', 837,
'sp_deref_bind_i64', 838,
'sp_deref_bind_n', 839,
'sp_getlexvia_o', 840,
'sp_getlexvia_ins', 841,
'sp_jit_enter', 842,
'sp_boolify_iter', 843,
'sp_boolify_iter_arr', 844,
'sp_boolify_iter_hash', 845,
'sp_cas_o', 846,
'sp_atomicload_o', 847,
'sp_atomicstore_o', 848,
'prof_enter', 849,
'prof_enterspesh', 850,
'prof_enterinline', 851,
'prof_enternative', 852,
'prof_exit', 853,
'prof_allocated', 854,
'ctw_check', 855,
'coverage_log', 856);
'sp_getlex_live_o', 797,
'sp_getlex_ins', 798,
'sp_getlex_no', 799,
'sp_getarg_o', 800,
'sp_getarg_i', 801,
'sp_getarg_n', 802,
'sp_getarg_s', 803,
'sp_fastinvoke_v', 804,
'sp_fastinvoke_i', 805,
'sp_fastinvoke_n', 806,
'sp_fastinvoke_s', 807,
'sp_fastinvoke_o', 808,
'sp_paramnamesused', 809,
'sp_getspeshslot', 810,
'sp_findmeth', 811,
'sp_fastcreate', 812,
'sp_get_o', 813,
'sp_get_i64', 814,
'sp_get_i32', 815,
'sp_get_i16', 816,
'sp_get_i8', 817,
'sp_get_n', 818,
'sp_get_s', 819,
'sp_bind_o', 820,
'sp_bind_i64', 821,
'sp_bind_i32', 822,
'sp_bind_i16', 823,
'sp_bind_i8', 824,
'sp_bind_n', 825,
'sp_bind_s', 826,
'sp_p6oget_o', 827,
'sp_p6ogetvt_o', 828,
'sp_p6ogetvc_o', 829,
'sp_p6oget_i', 830,
'sp_p6oget_n', 831,
'sp_p6oget_s', 832,
'sp_p6obind_o', 833,
'sp_p6obind_i', 834,
'sp_p6obind_n', 835,
'sp_p6obind_s', 836,
'sp_deref_get_i64', 837,
'sp_deref_get_n', 838,
'sp_deref_bind_i64', 839,
'sp_deref_bind_n', 840,
'sp_getlexvia_o', 841,
'sp_getlexvia_ins', 842,
'sp_jit_enter', 843,
'sp_boolify_iter', 844,
'sp_boolify_iter_arr', 845,
'sp_boolify_iter_hash', 846,
'sp_cas_o', 847,
'sp_atomicload_o', 848,
'sp_atomicstore_o', 849,
'prof_enter', 850,
'prof_enterspesh', 851,
'prof_enterinline', 852,
'prof_enternative', 853,
'prof_exit', 854,
'prof_allocated', 855,
'ctw_check', 856,
'coverage_log', 857);
MAST::Ops.WHO<@names> := nqp::list_s('no_op',
'const_i8',
'const_i16',
Expand Down Expand Up @@ -5524,6 +5529,7 @@ BEGIN {
'sp_resolvecode',
'sp_decont',
'sp_getlex_o',
'sp_getlex_live_o',
'sp_getlex_ins',
'sp_getlex_no',
'sp_getarg_o',
Expand Down
26 changes: 26 additions & 0 deletions src/core/interp.c
Expand Up @@ -5364,6 +5364,32 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
cur_op += 6;
goto NEXT;
}
OP(sp_getlex_live_o): {
MVMFrame *f = tc->cur_frame;
MVMuint16 idx = GET_UI16(cur_op, 2);
MVMuint16 outers = GET_UI16(cur_op, 4);
MVMRegister found;
while (outers) {
if (!f->outer)
MVM_exception_throw_adhoc(tc, "getlex: outer index out of range");
f = f->outer;
outers--;
}
found = GET_LEX(cur_op, 2, f);
if (found.o == NULL) {
fprintf(stderr, "cur frame name: %s, outer frame name: %s\n",
MVM_string_utf8_encode_C_string(tc, tc->cur_frame->static_info->body.name),
MVM_string_utf8_encode_C_string(tc, f->static_info->body.name));

fprintf(stderr, "idx %d outers %d\n", idx, GET_UI16(cur_op, 4));
MVM_oops(tc, "getlex_live thought to be safe but wasn't");
}
GET_REG(cur_op, 0).o = found.o == NULL
? NULL
: found.o;
cur_op += 6;
goto NEXT;
}
OP(sp_getlex_ins): {
MVMFrame *f = tc->cur_frame;
MVMuint16 idx = GET_UI16(cur_op, 2);
Expand Down
2 changes: 1 addition & 1 deletion src/core/oplabels.h
Expand Up @@ -798,6 +798,7 @@ static const void * const LABELS[] = {
&&OP_sp_resolvecode,
&&OP_sp_decont,
&&OP_sp_getlex_o,
&&OP_sp_getlex_live_o,
&&OP_sp_getlex_ins,
&&OP_sp_getlex_no,
&&OP_sp_getarg_o,
Expand Down Expand Up @@ -1024,7 +1025,6 @@ static const void * const LABELS[] = {
NULL,
NULL,
NULL,
NULL,
&&OP_CALL_EXTOP,
&&OP_CALL_EXTOP,
&&OP_CALL_EXTOP,
Expand Down
1 change: 1 addition & 0 deletions src/core/oplist
Expand Up @@ -873,6 +873,7 @@ sp_resolvecode .s w(obj) r(obj)
# the case where we can't JIT-compile, but don't want to keep on logging.
sp_decont .s w(obj) r(obj) :pure :invokish
sp_getlex_o .s w(obj) rl(obj) :pure
sp_getlex_live_o .s w(obj) rl(obj) :pure
sp_getlex_ins .s w(`1) rl(`1) :pure
sp_getlex_no .s w(obj) str :pure :noinline

Expand Down
15 changes: 14 additions & 1 deletion src/core/ops.c
Expand Up @@ -10353,6 +10353,19 @@ static const MVMOpInfo MVM_op_infos[] = {
0,
{ MVM_operand_write_reg | MVM_operand_obj, MVM_operand_read_lex | MVM_operand_obj }
},
{
MVM_OP_sp_getlex_live_o,
"sp_getlex_live_o",
".s",
2,
1,
0,
0,
0,
0,
0,
{ MVM_operand_write_reg | MVM_operand_obj, MVM_operand_read_lex | MVM_operand_obj }
},
{
MVM_OP_sp_getlex_ins,
"sp_getlex_ins",
Expand Down Expand Up @@ -11132,7 +11145,7 @@ static const MVMOpInfo MVM_op_infos[] = {
},
};

static const unsigned short MVM_op_counts = 857;
static const unsigned short MVM_op_counts = 858;

MVM_PUBLIC const MVMOpInfo * MVM_op_get_op(unsigned short op) {
if (op >= MVM_op_counts)
Expand Down

0 comments on commit e5750c5

Please sign in to comment.