Skip to content

Commit

Permalink
Add a negated object literal spesh plugin guard
Browse files Browse the repository at this point in the history
This will be useful for specializing on "not Nil" in the Perl 6 spesh
plugin for assignment.
  • Loading branch information
jnthn committed Jun 23, 2018
1 parent 0c04e6c commit f125679
Show file tree
Hide file tree
Showing 8 changed files with 314 additions and 226 deletions.
299 changes: 156 additions & 143 deletions lib/MAST/Ops.nqp
Expand Up @@ -810,80 +810,82 @@ BEGIN {
2025,
2028,
2030,
2033,
2036,
2039,
2042,
2045,
2048,
2032,
2035,
2038,
2041,
2044,
2047,
2050,
2052,
2056,
2058,
2060,
2062,
2064,
2066,
2068,
2070,
2072,
2074,
2076,
2053,
2055,
2057,
2061,
2063,
2065,
2067,
2069,
2071,
2073,
2075,
2077,
2079,
2082,
2085,
2088,
2089,
2091,
2095,
2098,
2101,
2104,
2107,
2110,
2113,
2116,
2119,
2122,
2125,
2128,
2131,
2134,
2137,
2140,
2143,
2147,
2151,
2154,
2157,
2160,
2163,
2166,
2169,
2172,
2175,
2178,
2181,
2184,
2188,
2192,
2195,
2198,
2199,
2201,
2081,
2084,
2087,
2090,
2093,
2094,
2096,
2100,
2103,
2106,
2109,
2112,
2115,
2118,
2121,
2124,
2127,
2130,
2133,
2136,
2139,
2142,
2145,
2148,
2152,
2156,
2159,
2162,
2165,
2168,
2171,
2174,
2177,
2180,
2183,
2186,
2189,
2193,
2197,
2200,
2203,
2205,
2209,
2211,
2213,
2213,
2213,
2204,
2206,
2208,
2210,
2214,
2215,
2215,
2216,
2218,
2222);
2218,
2218,
2219,
2220,
2220,
2221,
2223,
2227);
MAST::Ops.WHO<@counts> := nqp::list_i(0,
2,
2,
Expand Down Expand Up @@ -1690,6 +1692,8 @@ BEGIN {
6,
3,
2,
2,
3,
3,
3,
3,
Expand Down Expand Up @@ -3796,6 +3800,11 @@ BEGIN {
58,
161,
65,
65,
65,
128,
152,
65,
128,
152,
65,
Expand Down Expand Up @@ -4795,81 +4804,83 @@ BEGIN {
'casattr_o', 803,
'atkey_u', 804,
'coerce_us', 805,
'sp_guard', 806,
'sp_guardconc', 807,
'sp_guardtype', 808,
'sp_guardsf', 809,
'sp_guardsfouter', 810,
'sp_guardobj', 811,
'sp_guardjustconc', 812,
'sp_guardjusttype', 813,
'sp_rebless', 814,
'sp_resolvecode', 815,
'sp_decont', 816,
'sp_getlex_o', 817,
'sp_getlex_ins', 818,
'sp_getlex_no', 819,
'sp_getarg_o', 820,
'sp_getarg_i', 821,
'sp_getarg_n', 822,
'sp_getarg_s', 823,
'sp_fastinvoke_v', 824,
'sp_fastinvoke_i', 825,
'sp_fastinvoke_n', 826,
'sp_fastinvoke_s', 827,
'sp_fastinvoke_o', 828,
'sp_paramnamesused', 829,
'sp_getspeshslot', 830,
'sp_findmeth', 831,
'sp_fastcreate', 832,
'sp_get_o', 833,
'sp_get_i64', 834,
'sp_get_i32', 835,
'sp_get_i16', 836,
'sp_get_i8', 837,
'sp_get_n', 838,
'sp_get_s', 839,
'sp_bind_o', 840,
'sp_bind_i64', 841,
'sp_bind_i32', 842,
'sp_bind_i16', 843,
'sp_bind_i8', 844,
'sp_bind_n', 845,
'sp_bind_s', 846,
'sp_p6oget_o', 847,
'sp_p6ogetvt_o', 848,
'sp_p6ogetvc_o', 849,
'sp_p6oget_i', 850,
'sp_p6oget_n', 851,
'sp_p6oget_s', 852,
'sp_p6obind_o', 853,
'sp_p6obind_i', 854,
'sp_p6obind_n', 855,
'sp_p6obind_s', 856,
'sp_deref_get_i64', 857,
'sp_deref_get_n', 858,
'sp_deref_bind_i64', 859,
'sp_deref_bind_n', 860,
'sp_getlexvia_o', 861,
'sp_getlexvia_ins', 862,
'sp_getstringfrom', 863,
'sp_getwvalfrom', 864,
'sp_jit_enter', 865,
'sp_boolify_iter', 866,
'sp_boolify_iter_arr', 867,
'sp_boolify_iter_hash', 868,
'sp_cas_o', 869,
'sp_atomicload_o', 870,
'sp_atomicstore_o', 871,
'prof_enter', 872,
'prof_enterspesh', 873,
'prof_enterinline', 874,
'prof_enternative', 875,
'prof_exit', 876,
'prof_allocated', 877,
'ctw_check', 878,
'coverage_log', 879,
'breakpoint', 880);
'speshguardnotobj', 806,
'sp_guard', 807,
'sp_guardconc', 808,
'sp_guardtype', 809,
'sp_guardsf', 810,
'sp_guardsfouter', 811,
'sp_guardobj', 812,
'sp_guardnotobj', 813,
'sp_guardjustconc', 814,
'sp_guardjusttype', 815,
'sp_rebless', 816,
'sp_resolvecode', 817,
'sp_decont', 818,
'sp_getlex_o', 819,
'sp_getlex_ins', 820,
'sp_getlex_no', 821,
'sp_getarg_o', 822,
'sp_getarg_i', 823,
'sp_getarg_n', 824,
'sp_getarg_s', 825,
'sp_fastinvoke_v', 826,
'sp_fastinvoke_i', 827,
'sp_fastinvoke_n', 828,
'sp_fastinvoke_s', 829,
'sp_fastinvoke_o', 830,
'sp_paramnamesused', 831,
'sp_getspeshslot', 832,
'sp_findmeth', 833,
'sp_fastcreate', 834,
'sp_get_o', 835,
'sp_get_i64', 836,
'sp_get_i32', 837,
'sp_get_i16', 838,
'sp_get_i8', 839,
'sp_get_n', 840,
'sp_get_s', 841,
'sp_bind_o', 842,
'sp_bind_i64', 843,
'sp_bind_i32', 844,
'sp_bind_i16', 845,
'sp_bind_i8', 846,
'sp_bind_n', 847,
'sp_bind_s', 848,
'sp_p6oget_o', 849,
'sp_p6ogetvt_o', 850,
'sp_p6ogetvc_o', 851,
'sp_p6oget_i', 852,
'sp_p6oget_n', 853,
'sp_p6oget_s', 854,
'sp_p6obind_o', 855,
'sp_p6obind_i', 856,
'sp_p6obind_n', 857,
'sp_p6obind_s', 858,
'sp_deref_get_i64', 859,
'sp_deref_get_n', 860,
'sp_deref_bind_i64', 861,
'sp_deref_bind_n', 862,
'sp_getlexvia_o', 863,
'sp_getlexvia_ins', 864,
'sp_getstringfrom', 865,
'sp_getwvalfrom', 866,
'sp_jit_enter', 867,
'sp_boolify_iter', 868,
'sp_boolify_iter_arr', 869,
'sp_boolify_iter_hash', 870,
'sp_cas_o', 871,
'sp_atomicload_o', 872,
'sp_atomicstore_o', 873,
'prof_enter', 874,
'prof_enterspesh', 875,
'prof_enterinline', 876,
'prof_enternative', 877,
'prof_exit', 878,
'prof_allocated', 879,
'ctw_check', 880,
'coverage_log', 881,
'breakpoint', 882);
MAST::Ops.WHO<@names> := nqp::list_s('no_op',
'const_i8',
'const_i16',
Expand Down Expand Up @@ -5676,12 +5687,14 @@ BEGIN {
'casattr_o',
'atkey_u',
'coerce_us',
'speshguardnotobj',
'sp_guard',
'sp_guardconc',
'sp_guardtype',
'sp_guardsf',
'sp_guardsfouter',
'sp_guardobj',
'sp_guardnotobj',
'sp_guardjustconc',
'sp_guardjusttype',
'sp_rebless',
Expand Down
13 changes: 13 additions & 0 deletions src/core/interp.c
Expand Up @@ -5384,6 +5384,10 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
GET_REG(cur_op, 0).s = MVM_coerce_u_s(tc, GET_REG(cur_op, 2).u64);
cur_op += 4;
goto NEXT;
OP(speshguardnotobj):
MVM_spesh_plugin_addguard_notobj(tc, GET_REG(cur_op, 0).o, GET_REG(cur_op, 2).o);
cur_op += 4;
goto NEXT;
OP(sp_guard): {
MVMObject *check = GET_REG(cur_op, 0).o;
MVMSTable *want = (MVMSTable *)tc->cur_frame
Expand Down Expand Up @@ -5441,6 +5445,15 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
MVM_spesh_deopt_one(tc, GET_UI32(cur_op, -4));
goto NEXT;
}
OP(sp_guardnotobj): {
MVMObject *check = GET_REG(cur_op, 0).o;
MVMObject *do_not_want = (MVMObject *)tc->cur_frame
->effective_spesh_slots[GET_UI16(cur_op, 2)];
cur_op += 8;
if (check == do_not_want)
MVM_spesh_deopt_one(tc, GET_UI32(cur_op, -4));
goto NEXT;
}
OP(sp_guardjustconc): {
MVMObject *check = GET_REG(cur_op, 0).o;
cur_op += 6;
Expand Down
4 changes: 2 additions & 2 deletions src/core/oplabels.h
Expand Up @@ -807,12 +807,14 @@ static const void * const LABELS[] = {
&&OP_casattr_o,
&&OP_atkey_u,
&&OP_coerce_us,
&&OP_speshguardnotobj,
&&OP_sp_guard,
&&OP_sp_guardconc,
&&OP_sp_guardtype,
&&OP_sp_guardsf,
&&OP_sp_guardsfouter,
&&OP_sp_guardobj,
&&OP_sp_guardnotobj,
&&OP_sp_guardjustconc,
&&OP_sp_guardjusttype,
&&OP_sp_rebless,
Expand Down Expand Up @@ -1023,8 +1025,6 @@ static const void * const LABELS[] = {
NULL,
NULL,
NULL,
NULL,
NULL,
&&OP_CALL_EXTOP,
&&OP_CALL_EXTOP,
&&OP_CALL_EXTOP,
Expand Down

0 comments on commit f125679

Please sign in to comment.