diff options
author | David Mitchell <davem@iabyn.com> | 2021-10-07 17:15:47 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2021-10-07 17:31:33 +0100 |
commit | 07a6208729c01c230010594c3e08a946ab0ccbef (patch) | |
tree | c22730559b0cda43ef9ea337f896c6aeb0f2eb1e /opcode.h | |
parent | 2b0c7afada71b2d42dd50ec342a0e9878e4e2ef2 (diff) | |
download | perl-07a6208729c01c230010594c3e08a946ab0ccbef.tar.gz |
add OPpUSEINT op_private flag bit
The bitwise ops, such as a '<<', have an op_private flag that is set
when compiled within the scope of 'use integer;'.
Unfortunately, due to historical reasons, the defined flag that
indicates this bit (bit 0) is HINT_INTEGER rather than an OPpfoo define.
But HINT_INTEGER is supposed to represent a bit within PL_hints, not a bit
within op_private. If someone reorganised the flags in PL_hints at some
point, it would mess up bitwise ops.
So this commit:
1) adds a new flag, OPpUSEINT, to indicate the bit within op_private.
2) Changes this flag's value from 0x1 to 0x4 to force it to be different
than HINT_INTEGER - thus potentially flushing out any misuse of this
flag anywhere (in core or XS code).
3) tells regen/op_private that the lower two bits of op_private in bitwise
ops don't contain the argument count. They never did, but not
specifying that in regen/op_private meant that the debugging code in
op_free() never spotted the unknown bit 0 sometimes being set.
4) Also tell that debugging code to skip the test if the op is banned.
This fixes a new fail in dist/Safe/t/safeops.t which was croaking
about a banned op having an unrecognised op_private flag bit set
before ck_bitop() had a chance to delete the arg count in op_private.
Diffstat (limited to 'opcode.h')
-rw-r--r-- | opcode.h | 240 |
1 files changed, 122 insertions, 118 deletions
@@ -2246,6 +2246,7 @@ END_EXTERN_C #define OPpSORT_REVERSE 0x04 #define OPpSPLIT_IMPLIM 0x04 #define OPpTRANS_IDENTICAL 0x04 +#define OPpUSEINT 0x04 #define OPpARGELEM_MASK 0x06 #define OPpARG3_MASK 0x07 #define OPpPADRANGE_COUNTSHIFT 0x07 @@ -2432,6 +2433,7 @@ EXTCONST char PL_op_private_labels[] = { 'T','A','R','G','\0', 'T','A','R','G','M','Y','\0', 'U','N','I','\0', + 'U','S','E','I','N','T','\0', 'U','S','E','_','S','V','O','P','\0', 'U','T','F','\0', 'k','e','y','\0', @@ -2455,11 +2457,11 @@ EXTCONST char PL_op_private_labels[] = { EXTCONST I16 PL_op_private_bitfields[] = { 0, 8, -1, 0, 8, -1, - 0, 581, -1, + 0, 588, -1, 0, 8, -1, 0, 8, -1, - 0, 588, -1, - 0, 577, -1, + 0, 595, -1, + 0, 584, -1, 1, -1, 0, 545, 1, 30, 2, 295, -1, 4, -1, 1, 176, 2, 183, 3, 190, -1, 4, -1, 0, 545, 1, 30, 2, 295, 3, 122, -1, @@ -2540,8 +2542,8 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = { 84, /* concat */ 87, /* multiconcat */ 93, /* stringify */ - 80, /* left_shift */ - 80, /* right_shift */ + 95, /* left_shift */ + 95, /* right_shift */ 12, /* lt */ 12, /* i_lt */ 12, /* gt */ @@ -2563,20 +2565,20 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = { 12, /* seq */ 12, /* sne */ 12, /* scmp */ - 12, /* bit_and */ - 12, /* bit_xor */ - 12, /* bit_or */ - 80, /* nbit_and */ - 80, /* nbit_xor */ - 80, /* nbit_or */ - 12, /* sbit_and */ - 12, /* sbit_xor */ - 12, /* sbit_or */ + 97, /* bit_and */ + 97, /* bit_xor */ + 97, /* bit_or */ + 95, /* nbit_and */ + 95, /* nbit_xor */ + 95, /* nbit_or */ + 97, /* sbit_and */ + 97, /* sbit_xor */ + 97, /* sbit_or */ 0, /* negate */ 0, /* i_negate */ 0, /* not */ - 0, /* complement */ - 75, /* ncomplement */ + 97, /* complement */ + 95, /* ncomplement */ 75, /* scomplement */ 12, /* smartmatch */ 93, /* atan2 */ @@ -2591,11 +2593,11 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = { 75, /* hex */ 75, /* oct */ 75, /* abs */ - 95, /* length */ - 98, /* substr */ - 101, /* vec */ - 103, /* index */ - 103, /* rindex */ + 98, /* length */ + 101, /* substr */ + 104, /* vec */ + 106, /* index */ + 106, /* rindex */ 52, /* sprintf */ 52, /* formline */ 75, /* ord */ @@ -2606,30 +2608,30 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = { 0, /* uc */ 0, /* lc */ 0, /* quotemeta */ - 107, /* rv2av */ - 114, /* aelemfast */ - 114, /* aelemfast_lex */ - 115, /* aelem */ - 120, /* aslice */ - 123, /* kvaslice */ + 110, /* rv2av */ + 117, /* aelemfast */ + 117, /* aelemfast_lex */ + 118, /* aelem */ + 123, /* aslice */ + 126, /* kvaslice */ 0, /* aeach */ 0, /* avalues */ 40, /* akeys */ 0, /* each */ 40, /* values */ 40, /* keys */ - 124, /* delete */ - 128, /* exists */ - 130, /* rv2hv */ - 115, /* helem */ - 120, /* hslice */ - 123, /* kvhslice */ - 138, /* multideref */ + 127, /* delete */ + 131, /* exists */ + 133, /* rv2hv */ + 118, /* helem */ + 123, /* hslice */ + 126, /* kvhslice */ + 141, /* multideref */ 52, /* unpack */ 52, /* pack */ - 145, /* split */ + 148, /* split */ 52, /* join */ - 150, /* list */ + 153, /* list */ 12, /* lslice */ 52, /* anonlist */ 52, /* anonhash */ @@ -2638,50 +2640,50 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = { 0, /* pop */ 0, /* shift */ 93, /* unshift */ - 152, /* sort */ - 157, /* reverse */ + 155, /* sort */ + 160, /* reverse */ 0, /* grepstart */ - 159, /* grepwhile */ + 162, /* grepwhile */ 0, /* mapstart */ 0, /* mapwhile */ 0, /* range */ - 161, /* flip */ - 161, /* flop */ + 164, /* flip */ + 164, /* flop */ 0, /* and */ 0, /* or */ 12, /* xor */ 0, /* dor */ - 163, /* cond_expr */ + 166, /* cond_expr */ 0, /* andassign */ 0, /* orassign */ 0, /* dorassign */ - 165, /* entersub */ - 172, /* leavesub */ - 172, /* leavesublv */ + 168, /* entersub */ + 175, /* leavesub */ + 175, /* leavesublv */ 0, /* argcheck */ - 174, /* argelem */ + 177, /* argelem */ 0, /* argdefelem */ - 176, /* caller */ + 179, /* caller */ 52, /* warn */ 52, /* die */ 52, /* reset */ -1, /* lineseq */ - 178, /* nextstate */ - 178, /* dbstate */ + 181, /* nextstate */ + 181, /* dbstate */ -1, /* unstack */ -1, /* enter */ - 179, /* leave */ + 182, /* leave */ -1, /* scope */ - 181, /* enteriter */ - 185, /* iter */ + 184, /* enteriter */ + 188, /* iter */ -1, /* enterloop */ - 186, /* leaveloop */ + 189, /* leaveloop */ -1, /* return */ - 188, /* last */ - 188, /* next */ - 188, /* redo */ - 188, /* dump */ - 188, /* goto */ + 191, /* last */ + 191, /* next */ + 191, /* redo */ + 191, /* dump */ + 191, /* goto */ 52, /* exit */ 0, /* method */ 0, /* method_named */ @@ -2694,7 +2696,7 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = { 0, /* leavewhen */ -1, /* break */ -1, /* continue */ - 190, /* open */ + 193, /* open */ 52, /* close */ 52, /* pipe_op */ 52, /* fileno */ @@ -2710,7 +2712,7 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = { 52, /* getc */ 52, /* read */ 52, /* enterwrite */ - 172, /* leavewrite */ + 175, /* leavewrite */ -1, /* prtf */ -1, /* print */ -1, /* say */ @@ -2740,33 +2742,33 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = { 0, /* getpeername */ 0, /* lstat */ 0, /* stat */ - 195, /* ftrread */ - 195, /* ftrwrite */ - 195, /* ftrexec */ - 195, /* fteread */ - 195, /* ftewrite */ - 195, /* fteexec */ - 200, /* ftis */ - 200, /* ftsize */ - 200, /* ftmtime */ - 200, /* ftatime */ - 200, /* ftctime */ - 200, /* ftrowned */ - 200, /* fteowned */ - 200, /* ftzero */ - 200, /* ftsock */ - 200, /* ftchr */ - 200, /* ftblk */ - 200, /* ftfile */ - 200, /* ftdir */ - 200, /* ftpipe */ - 200, /* ftsuid */ - 200, /* ftsgid */ - 200, /* ftsvtx */ - 200, /* ftlink */ - 200, /* fttty */ - 200, /* fttext */ - 200, /* ftbinary */ + 198, /* ftrread */ + 198, /* ftrwrite */ + 198, /* ftrexec */ + 198, /* fteread */ + 198, /* ftewrite */ + 198, /* fteexec */ + 203, /* ftis */ + 203, /* ftsize */ + 203, /* ftmtime */ + 203, /* ftatime */ + 203, /* ftctime */ + 203, /* ftrowned */ + 203, /* fteowned */ + 203, /* ftzero */ + 203, /* ftsock */ + 203, /* ftchr */ + 203, /* ftblk */ + 203, /* ftfile */ + 203, /* ftdir */ + 203, /* ftpipe */ + 203, /* ftsuid */ + 203, /* ftsgid */ + 203, /* ftsvtx */ + 203, /* ftlink */ + 203, /* fttty */ + 203, /* fttext */ + 203, /* ftbinary */ 93, /* chdir */ 93, /* chown */ 75, /* chroot */ @@ -2786,17 +2788,17 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = { 0, /* rewinddir */ 0, /* closedir */ -1, /* fork */ - 204, /* wait */ + 207, /* wait */ 93, /* waitpid */ 93, /* system */ 93, /* exec */ 93, /* kill */ - 204, /* getppid */ + 207, /* getppid */ 93, /* getpgrp */ 93, /* setpgrp */ 93, /* getpriority */ 93, /* setpriority */ - 204, /* time */ + 207, /* time */ -1, /* tms */ 0, /* localtime */ 52, /* gmtime */ @@ -2816,8 +2818,8 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = { 0, /* require */ 0, /* dofile */ -1, /* hintseval */ - 205, /* entereval */ - 172, /* leaveeval */ + 208, /* entereval */ + 175, /* leaveeval */ 0, /* entertry */ -1, /* leavetry */ 0, /* ghbyname */ @@ -2855,18 +2857,18 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = { 0, /* lock */ 0, /* once */ -1, /* custom */ - 211, /* coreargs */ - 215, /* avhvswitch */ + 214, /* coreargs */ + 218, /* avhvswitch */ 3, /* runcv */ 0, /* fc */ -1, /* padcv */ -1, /* introcv */ -1, /* clonecv */ - 217, /* padrange */ - 219, /* refassign */ - 225, /* lvref */ - 231, /* lvrefslice */ - 232, /* lvavref */ + 220, /* padrange */ + 222, /* refassign */ + 228, /* lvref */ + 234, /* lvrefslice */ + 235, /* lvavref */ 0, /* anonconst */ 12, /* isa */ 0, /* cmpchain_and */ @@ -2894,13 +2896,13 @@ 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, pop, shift, grepstart, mapstart, mapwhile, range, and, or, dor, andassign, orassign, dorassign, argcheck, argdefelem, method, 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, cmpchain_and, cmpchain_dup, entertrycatch, catch, pushdefer */ + 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, ucfirst, lcfirst, uc, lc, quotemeta, aeach, avalues, each, pop, shift, grepstart, mapstart, mapwhile, range, and, or, dor, andassign, orassign, dorassign, argcheck, argdefelem, method, 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, cmpchain_and, cmpchain_dup, entertrycatch, catch, pushdefer */ 0x2fdc, 0x40d9, /* pushmark */ 0x00bd, /* wantarray, runcv */ 0x0438, 0x1a50, 0x418c, 0x3d28, 0x3505, /* const */ 0x2fdc, 0x3659, /* gvsv */ 0x18b5, /* gv */ - 0x0067, /* gelem, lt, i_lt, gt, i_gt, le, i_le, ge, i_ge, eq, i_eq, ne, i_ne, ncmp, i_ncmp, slt, sgt, sle, sge, seq, sne, scmp, bit_and, bit_xor, bit_or, sbit_and, sbit_xor, sbit_or, smartmatch, lslice, xor, isa */ + 0x0067, /* gelem, lt, i_lt, gt, i_gt, le, i_le, ge, i_ge, eq, i_eq, ne, i_ne, ncmp, i_ncmp, slt, sgt, sle, sge, seq, sne, scmp, smartmatch, lslice, xor, isa */ 0x2fdc, 0x40d8, 0x03d7, /* padsv */ 0x2fdc, 0x40d8, 0x05b4, 0x30cc, 0x3ea9, /* padav */ 0x2fdc, 0x40d8, 0x05b4, 0x0650, 0x30cc, 0x3ea8, 0x2b41, /* padhv */ @@ -2912,16 +2914,18 @@ EXTCONST U16 PL_op_private_bitdefs[] = { 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 */ 0x383c, 0x3758, 0x2894, 0x27d0, 0x0003, /* backtick */ 0x05b5, /* subst */ - 0x117c, 0x21b8, 0x09b4, 0x3fec, 0x2548, 0x4684, 0x07c1, /* trans, transr */ + 0x117c, 0x21b8, 0x09b4, 0x3fec, 0x2548, 0x4764, 0x07c1, /* trans, transr */ 0x0fbc, 0x04d8, 0x0067, /* sassign */ 0x0c78, 0x0b74, 0x0a70, 0x30cc, 0x05a8, 0x0067, /* aassign */ - 0x4530, 0x0003, /* chomp, schomp, ncomplement, scomplement, sin, cos, exp, log, sqrt, int, hex, oct, abs, ord, chr, chroot, rmdir */ + 0x4530, 0x0003, /* chomp, schomp, scomplement, sin, cos, exp, log, sqrt, int, hex, oct, abs, ord, chr, chroot, rmdir */ 0x05b4, 0x30cc, 0x0003, /* pos */ - 0x4530, 0x0067, /* pow, multiply, i_multiply, divide, i_divide, modulo, i_modulo, add, i_add, subtract, i_subtract, left_shift, right_shift, nbit_and, nbit_xor, nbit_or */ + 0x4530, 0x0067, /* pow, multiply, i_multiply, divide, i_divide, modulo, i_modulo, add, i_add, subtract, i_subtract */ 0x1538, 0x0067, /* repeat */ 0x32b8, 0x4530, 0x0067, /* concat */ 0x2fdc, 0x0218, 0x1c34, 0x4530, 0x426c, 0x0003, /* multiconcat */ 0x4530, 0x018f, /* stringify, atan2, rand, srand, crypt, push, unshift, flock, chdir, chown, unlink, chmod, utime, rename, link, symlink, mkdir, waitpid, system, exec, kill, getpgrp, setpgrp, getpriority, setpriority, sleep */ + 0x4530, 0x4689, /* left_shift, right_shift, nbit_and, nbit_xor, nbit_or, ncomplement */ + 0x4689, /* bit_and, bit_xor, bit_or, sbit_and, sbit_xor, sbit_or, complement */ 0x05b4, 0x4530, 0x0003, /* length */ 0x3a90, 0x30cc, 0x012b, /* substr */ 0x30cc, 0x0067, /* vec */ @@ -2951,7 +2955,7 @@ EXTCONST U16 PL_op_private_bitdefs[] = { 0x2fdc, 0x3658, 0x10ec, 0x3c05, /* enteriter */ 0x3c05, /* iter */ 0x2e7c, 0x0067, /* leaveloop */ - 0x47bc, 0x0003, /* last, next, redo, dump, goto */ + 0x489c, 0x0003, /* last, next, redo, dump, goto */ 0x383c, 0x3758, 0x2894, 0x27d0, 0x018f, /* open */ 0x1df0, 0x204c, 0x1f08, 0x1cc4, 0x0003, /* ftrread, ftrwrite, ftrexec, fteread, ftewrite, fteexec */ 0x1df0, 0x204c, 0x1f08, 0x0003, /* ftis, ftsize, ftmtime, ftatime, ftctime, ftrowned, fteowned, ftzero, ftsock, ftchr, ftblk, ftfile, ftdir, ftpipe, ftsuid, ftsgid, ftsvtx, ftlink, fttty, fttext, ftbinary */ @@ -3041,8 +3045,8 @@ EXTCONST U8 PL_op_private_valid[] = { /* CONCAT */ (OPpARG2_MASK|OPpTARGET_MY|OPpCONCAT_NESTED), /* MULTICONCAT */ (OPpARG1_MASK|OPpMULTICONCAT_STRINGIFY|OPpTARGET_MY|OPpMULTICONCAT_FAKE|OPpMULTICONCAT_APPEND|OPpLVAL_INTRO), /* STRINGIFY */ (OPpARG4_MASK|OPpTARGET_MY), - /* LEFT_SHIFT */ (OPpARG2_MASK|OPpTARGET_MY), - /* RIGHT_SHIFT */ (OPpARG2_MASK|OPpTARGET_MY), + /* LEFT_SHIFT */ (OPpUSEINT|OPpTARGET_MY), + /* RIGHT_SHIFT */ (OPpUSEINT|OPpTARGET_MY), /* LT */ (OPpARG2_MASK), /* I_LT */ (OPpARG2_MASK), /* GT */ (OPpARG2_MASK), @@ -3064,20 +3068,20 @@ EXTCONST U8 PL_op_private_valid[] = { /* SEQ */ (OPpARG2_MASK), /* SNE */ (OPpARG2_MASK), /* SCMP */ (OPpARG2_MASK), - /* BIT_AND */ (OPpARG2_MASK), - /* BIT_XOR */ (OPpARG2_MASK), - /* BIT_OR */ (OPpARG2_MASK), - /* NBIT_AND */ (OPpARG2_MASK|OPpTARGET_MY), - /* NBIT_XOR */ (OPpARG2_MASK|OPpTARGET_MY), - /* NBIT_OR */ (OPpARG2_MASK|OPpTARGET_MY), - /* SBIT_AND */ (OPpARG2_MASK), - /* SBIT_XOR */ (OPpARG2_MASK), - /* SBIT_OR */ (OPpARG2_MASK), + /* BIT_AND */ (OPpUSEINT), + /* BIT_XOR */ (OPpUSEINT), + /* BIT_OR */ (OPpUSEINT), + /* NBIT_AND */ (OPpUSEINT|OPpTARGET_MY), + /* NBIT_XOR */ (OPpUSEINT|OPpTARGET_MY), + /* NBIT_OR */ (OPpUSEINT|OPpTARGET_MY), + /* SBIT_AND */ (OPpUSEINT), + /* SBIT_XOR */ (OPpUSEINT), + /* SBIT_OR */ (OPpUSEINT), /* NEGATE */ (OPpARG1_MASK), /* I_NEGATE */ (OPpARG1_MASK), /* NOT */ (OPpARG1_MASK), - /* COMPLEMENT */ (OPpARG1_MASK), - /* NCOMPLEMENT */ (OPpARG1_MASK|OPpTARGET_MY), + /* COMPLEMENT */ (OPpUSEINT), + /* NCOMPLEMENT */ (OPpUSEINT|OPpTARGET_MY), /* SCOMPLEMENT */ (OPpARG1_MASK|OPpTARGET_MY), /* SMARTMATCH */ (OPpARG2_MASK), /* ATAN2 */ (OPpARG4_MASK|OPpTARGET_MY), |