summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-07-10 13:13:03 +0100
committerDavid Mitchell <davem@iabyn.com>2017-07-27 11:30:22 +0100
commit4fa080dbc664ee90dd374a9a49ac0a4932421bd7 (patch)
treeaa1cca24eb2d9eefaa8184eff872f46b40da68ad
parent94184451ad29bb516512af1a14112b587a045451 (diff)
downloadperl-4fa080dbc664ee90dd374a9a49ac0a4932421bd7.tar.gz
OP_VALUES: reserve OPpMAYBE_LVSUB bit
This op doesn't use that bit, but it calls the function Perl_do_kv(), which is called by several different ops which *do* use that bit. So ensure no-one in future thinks that bit is spare in OP_VALUES.
-rw-r--r--doop.c3
-rw-r--r--lib/B/Op_private.pm4
-rw-r--r--opcode.h8
-rw-r--r--regen/op_private6
4 files changed, 14 insertions, 7 deletions
diff --git a/doop.c b/doop.c
index 010db089b7..f10269f61b 100644
--- a/doop.c
+++ b/doop.c
@@ -1282,6 +1282,9 @@ Perl_do_kv(pTHX)
|| PL_op->op_type == OP_VALUES
|| PL_op->op_type == OP_AVHVSWITCH);
+ assert(!( PL_op->op_type == OP_VALUES
+ && (PL_op->op_private & OPpMAYBE_LVSUB)));
+
(void)hv_iterinit(keys); /* always reset iterator regardless */
if (gimme == G_VOID)
diff --git a/lib/B/Op_private.pm b/lib/B/Op_private.pm
index 034f366523..bb69926b4f 100644
--- a/lib/B/Op_private.pm
+++ b/lib/B/Op_private.pm
@@ -136,7 +136,7 @@ $bits{$_}{6} = 'OPpLVAL_DEFER' for qw(aelem helem multideref);
$bits{$_}{7} = 'OPpLVAL_INTRO' for qw(aelem aslice cond_expr delete enteriter entersub gvsv helem hslice list lvavref lvref lvrefslice multideref padav padhv padrange padsv pushmark refassign rv2av rv2gv rv2hv rv2sv split);
$bits{$_}{2} = 'OPpLVREF_ELEM' for qw(lvref refassign);
$bits{$_}{3} = 'OPpLVREF_ITER' for qw(lvref refassign);
-$bits{$_}{3} = 'OPpMAYBE_LVSUB' for qw(aassign aelem akeys aslice av2arylen avhvswitch helem hslice keys kvaslice kvhslice multideref padav padhv pos rv2av rv2gv rv2hv substr vec);
+$bits{$_}{3} = 'OPpMAYBE_LVSUB' for qw(aassign aelem akeys aslice av2arylen avhvswitch helem hslice keys kvaslice kvhslice multideref padav padhv pos rv2av rv2gv rv2hv substr values vec);
$bits{$_}{4} = 'OPpMAYBE_TRUEBOOL' for qw(padhv ref rv2hv);
$bits{$_}{7} = 'OPpOFFBYONE' for qw(caller runcv wantarray);
$bits{$_}{5} = 'OPpOPEN_IN_CRLF' for qw(backtick open);
@@ -806,7 +806,7 @@ our %ops_using = (
OPpLVAL_DEFER => [qw(aelem helem multideref)],
OPpLVAL_INTRO => [qw(aelem aslice cond_expr delete enteriter entersub gvsv helem hslice list lvavref lvref lvrefslice multideref padav padhv padrange padsv pushmark refassign rv2av rv2gv rv2hv rv2sv split)],
OPpLVREF_ELEM => [qw(lvref refassign)],
- OPpMAYBE_LVSUB => [qw(aassign aelem akeys aslice av2arylen avhvswitch helem hslice keys kvaslice kvhslice multideref padav padhv pos rv2av rv2gv rv2hv substr vec)],
+ OPpMAYBE_LVSUB => [qw(aassign aelem akeys aslice av2arylen avhvswitch helem hslice keys kvaslice kvhslice multideref padav padhv pos rv2av rv2gv rv2hv substr values vec)],
OPpMAYBE_TRUEBOOL => [qw(padhv ref rv2hv)],
OPpMULTIDEREF_DELETE => [qw(multideref)],
OPpOFFBYONE => [qw(caller runcv wantarray)],
diff --git a/opcode.h b/opcode.h
index f3ba953016..f906437ea6 100644
--- a/opcode.h
+++ b/opcode.h
@@ -2588,7 +2588,7 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = {
0, /* avalues */
38, /* akeys */
0, /* each */
- 0, /* values */
+ 38, /* values */
38, /* keys */
100, /* delete */
104, /* exists */
@@ -2858,7 +2858,7 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = {
*/
EXTCONST U16 PL_op_private_bitdefs[] = {
- 0x0003, /* scalar, prototype, refgen, srefgen, readline, regcmaybe, regcreset, regcomp, substcont, chop, schop, defined, undef, study, preinc, i_preinc, predec, i_predec, postinc, i_postinc, postdec, i_postdec, negate, i_negate, not, complement, ucfirst, lcfirst, uc, lc, quotemeta, aeach, avalues, each, values, pop, shift, grepstart, grepwhile, mapstart, mapwhile, range, and, or, dor, andassign, orassign, dorassign, method, argcheck, argdefelem, method_named, method_super, method_redir, method_redir_super, entergiven, leavegiven, enterwhen, leavewhen, untie, tied, dbmclose, getsockname, getpeername, lstat, stat, readlink, readdir, telldir, rewinddir, closedir, localtime, alarm, require, dofile, entertry, ghbyname, gnbyname, gpbyname, shostent, snetent, sprotoent, sservent, gpwnam, gpwuid, ggrnam, ggrgid, lock, once, fc, anonconst */
+ 0x0003, /* scalar, prototype, refgen, srefgen, readline, regcmaybe, regcreset, regcomp, substcont, chop, schop, defined, undef, study, preinc, i_preinc, predec, i_predec, postinc, i_postinc, postdec, i_postdec, negate, i_negate, not, complement, ucfirst, lcfirst, uc, lc, quotemeta, aeach, avalues, each, pop, shift, grepstart, grepwhile, mapstart, mapwhile, range, and, or, dor, andassign, orassign, dorassign, method, argcheck, argdefelem, method_named, method_super, method_redir, method_redir_super, entergiven, leavegiven, enterwhen, leavewhen, untie, tied, dbmclose, getsockname, getpeername, lstat, stat, readlink, readdir, telldir, rewinddir, closedir, localtime, alarm, require, dofile, entertry, ghbyname, gnbyname, gpbyname, shostent, snetent, sprotoent, sservent, gpwnam, gpwuid, ggrnam, ggrgid, lock, once, fc, anonconst */
0x2dbc, 0x3ef9, /* pushmark */
0x00bd, /* wantarray, runcv */
0x0498, 0x18d0, 0x3fac, 0x3a68, 0x3185, /* const */
@@ -2870,7 +2870,7 @@ EXTCONST U16 PL_op_private_bitdefs[] = {
0x2dbc, 0x3ef8, 0x0614, 0x06b0, 0x2eac, 0x3be9, /* padhv */
0x2dbc, 0x1ab8, 0x03d6, 0x2eac, 0x30a8, 0x3fa4, 0x0003, /* rv2gv */
0x2dbc, 0x32d8, 0x03d6, 0x3fa4, 0x0003, /* rv2sv */
- 0x2eac, 0x0003, /* av2arylen, pos, akeys, keys */
+ 0x2eac, 0x0003, /* av2arylen, pos, akeys, values, keys */
0x301c, 0x0ef8, 0x0c54, 0x028c, 0x4168, 0x3fa4, 0x0003, /* rv2cv */
0x0614, 0x06b0, 0x0003, /* ref */
0x018f, /* bless, glob, sprintf, formline, unpack, pack, join, anonlist, anonhash, splice, warn, die, reset, exit, close, pipe_op, fileno, umask, binmode, tie, dbmopen, sselect, select, getc, read, enterwrite, sysopen, sysseek, sysread, syswrite, eof, tell, seek, truncate, fcntl, ioctl, send, recv, socket, sockpair, bind, connect, listen, accept, shutdown, gsockopt, ssockopt, open_dir, seekdir, gmtime, shmget, shmctl, shmread, shmwrite, msgget, msgctl, msgsnd, msgrcv, semop, semget, semctl, ghbyaddr, gnbyaddr, gpbynumber, gsbyname, gsbyport, syscall */
@@ -3073,7 +3073,7 @@ EXTCONST U8 PL_op_private_valid[] = {
/* AVALUES */ (OPpARG1_MASK),
/* AKEYS */ (OPpARG1_MASK|OPpMAYBE_LVSUB),
/* EACH */ (OPpARG1_MASK),
- /* VALUES */ (OPpARG1_MASK),
+ /* VALUES */ (OPpARG1_MASK|OPpMAYBE_LVSUB),
/* KEYS */ (OPpARG1_MASK|OPpMAYBE_LVSUB),
/* DELETE */ (OPpARG1_MASK|OPpKVSLICE|OPpSLICE|OPpLVAL_INTRO),
/* EXISTS */ (OPpARG1_MASK|OPpEXISTS_SUB),
diff --git a/regen/op_private b/regen/op_private
index 3a2a5d8b8c..8456f22e0a 100644
--- a/regen/op_private
+++ b/regen/op_private
@@ -429,10 +429,14 @@ addbits($_, 6 => qw(OPpOUR_INTRO OURINTR)) # Variable was in an our()
# We might be an lvalue to return
+# 'values' doesn't actually use this bit, but we reserve it here as
+# pp_values may call Perl_do_kv() which is shared among several ops which
+# do.
+
addbits($_, 3 => qw(OPpMAYBE_LVSUB LVSUB))
for qw(aassign rv2av rv2gv rv2hv padav padhv aelem helem aslice hslice
av2arylen keys akeys avhvswitch kvaslice kvhslice substr pos vec
- multideref);
+ multideref values);