diff options
author | Jim Cromie <jim.cromie@gmail.com> | 2014-11-02 14:00:47 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-11-02 17:15:04 -0800 |
commit | 21b66d1ce5e03b3996596fe9b97b8ce0ce854a95 (patch) | |
tree | cded1e37cc3cf99e2cd392a3b078692240b23a9d /opcode.h | |
parent | 10884df96723d4c5a0a8a5da8e25401124174ed9 (diff) | |
download | perl-21b66d1ce5e03b3996596fe9b97b8ce0ce854a95.tar.gz |
end the pp_mapstart trickery
Current codebase wires Perl_pp_mapstart to Perl_unimplemented_op (by
regen/opcode.pl) [1], but then avoids runtime panics by Perl_ck_grep
changing all OP_MAPSTART nodes to use PL_ppaddr[OP_GREPSTART] [2].
This is all too clever by half, so this patch undoes the trickery, and
treats these 2 OPS like 93bad3fd5548 did for OP_AELEMFAST and \1_LEX.
I cant glean a reason for this historical arrangement:
Looking at regen/opcode.pl blamelog..
65bca31a68 added Perl_unimplemented_op() used by 3 'unreachable' ops,
and replaced a 'panic: mapstart' diag with a common one, so the trick
goes further back.
c78ff9799bf moved a minimal/DIEing pp_mapstart implementation to
mathoms.c from pp_ctl.c. Perl_ck_grep also did the GREPSTART patching
back then.
f54cb97a39f did minor tweaks to a full pp_mapstart implementation. I
couldnt find the commit between it and c78ff that changed pp_mapstart
to a DIEing one, or I fat-fingered it, or I got distracted.
looking at ck-grep(), the code doing [2] is from 22c35a8c23 in 1998.
So anyway, I tried the following, it worked, it seems the historical
reason is no longer relevant.
[1] change regen/opcode.pl generated mapping
-#define Perl_pp_mapstart Perl_unimplemented_op
+#define Perl_pp_mapstart Perl_pp_grepstart
this sets PL_ppaddr[OP_MAPSTART] = PL_ppaddr[OP_GREPSTART] during
init, which makes the optype trickery in ck_grep[2] unneeded.
[2] Drop re-type-ing of MAPSTARTs as GREPSTARTs by Perl_ck_grep(OP* o)
Given 1, mapstart & grepstart share code, so just leave optype alone.
Diffstat (limited to 'opcode.h')
-rw-r--r-- | opcode.h | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -44,7 +44,7 @@ #define Perl_pp_keys Perl_do_kv #define Perl_pp_rv2hv Perl_pp_rv2av #define Perl_pp_pop Perl_pp_shift -#define Perl_pp_mapstart Perl_unimplemented_op +#define Perl_pp_mapstart Perl_pp_grepstart #define Perl_pp_dor Perl_pp_defined #define Perl_pp_andassign Perl_pp_and #define Perl_pp_orassign Perl_pp_or @@ -1106,7 +1106,7 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */ Perl_pp_reverse, Perl_pp_grepstart, Perl_pp_grepwhile, - Perl_pp_mapstart, /* implemented by Perl_unimplemented_op */ + Perl_pp_mapstart, /* implemented by Perl_pp_grepstart */ Perl_pp_mapwhile, Perl_pp_range, Perl_pp_flip, |