summaryrefslogtreecommitdiff
path: root/opcode.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2023-01-19 14:11:28 +0000
committerYves Orton <demerphq@gmail.com>2023-02-28 20:53:51 +0800
commitfecade69c526caa9c157a2405486b9089047fc72 (patch)
treed51961de6f06d4700c5bc8f6d6d96e855018999a /opcode.h
parent214a9432e04871da2b88eba02ea3f1148a99f9c8 (diff)
downloadperl-fecade69c526caa9c157a2405486b9089047fc72.tar.gz
eval_sv(): call pp_entereval() via runops
Like the previous commit which did it for amagic_call() and call_sv(), this commit makes executing the faked-up OP_ENTEREVAL be executed as part of the runops loop rather than as a separate call. This is to allow shortly fixing up for a reference-counted stack. (CALLRUNOPS() will reify the stack if necessary, while the raw call to pp_entereval() won't fix up the stack unless its part of the runops loop too.) However, this is a bit more complex than call_sv() etc in that there is a good reason for calling pp_entereval() separately. The faked up OP_ENTEREVAL has its op_next set to NULL - this is the op which would normally be returned on failure of the eval compilation. By seeing whether the retuned value from pp_entereval() is NULL or not, eval_sv() can tell whether compilation failed. On the other hand, if pp_entereval() was made to be called as part of the runops loop, then the runops loop *always* finishes with PL_op set to NULL. So we can no lo longer distinguish between compile-failed and compile-succeeded-and-eval-ran-to-completion. This commit moves the entereval into the runops loop, but restores the ability to distinguish in a slightly hacky way. It adds a new private flag for OP_ENTEREVAL - OPpEVAL_EVALSV - which indicates to pp_entereval() that it was called from eval_sv(). And of course eval_sv() sets this flag on the OPpEVAL_EVALSV op it fakes up. If pp_entereval() fails to compile, then if that flag is set, it pushes a null pointer onto the argument stack before returning. Thus by checking whether *PL_stack_sp is NULL or not on return from CALLRUNOPS(), eval_sv() regains the ability to distinguish the two cases.
Diffstat (limited to 'opcode.h')
-rw-r--r--opcode.h164
1 files changed, 83 insertions, 81 deletions
diff --git a/opcode.h b/opcode.h
index a5bd0053f9..391e6ec9a5 100644
--- a/opcode.h
+++ b/opcode.h
@@ -2367,6 +2367,7 @@ END_EXTERN_C
#define OPpCONST_BARE 0x40
#define OPpCOREARGS_SCALARMOD 0x40
#define OPpENTERSUB_DB 0x40
+#define OPpEVAL_EVALSV 0x40
#define OPpEXISTS_SUB 0x40
#define OPpFLIP_LINENUM 0x40
#define OPpINDEX_BOOLNEG 0x40
@@ -2451,6 +2452,7 @@ EXTCONST char PL_op_private_labels[] = {
'E','A','R','L','Y','C','V','\0',
'E','L','E','M','\0',
'E','N','T','E','R','E','D','\0',
+ 'E','V','A','L','S','V','\0',
'E','X','I','S','T','S','\0',
'F','A','K','E','\0',
'F','I','N','A','L','L','Y','\0',
@@ -2536,14 +2538,14 @@ EXTCONST char PL_op_private_labels[] = {
EXTCONST I16 PL_op_private_bitfields[] = {
0, 8, -1,
0, 8, -1,
- 0, 668, -1,
+ 0, 675, -1,
0, 8, -1,
0, 8, -1,
- 0, 675, -1,
- 0, 664, -1,
- 1, -1, 0, 625, 1, 39, 2, 312, -1,
+ 0, 682, -1,
+ 0, 671, -1,
+ 1, -1, 0, 632, 1, 39, 2, 319, -1,
4, -1, 1, 185, 2, 192, 3, 199, -1,
- 4, -1, 0, 625, 1, 39, 2, 312, 3, 131, -1,
+ 4, -1, 0, 632, 1, 39, 2, 319, 3, 131, -1,
};
@@ -2939,17 +2941,17 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = {
[OP_LOCK] = 0,
[OP_ONCE] = 0,
[OP_CUSTOM] = -1,
- [OP_COREARGS] = 230,
- [OP_AVHVSWITCH] = 234,
+ [OP_COREARGS] = 231,
+ [OP_AVHVSWITCH] = 235,
[OP_RUNCV] = 3,
[OP_FC] = 0,
[OP_PADCV] = -1,
[OP_INTROCV] = -1,
[OP_CLONECV] = -1,
- [OP_PADRANGE] = 236,
- [OP_REFASSIGN] = 238,
- [OP_LVREF] = 244,
- [OP_LVREFSLICE] = 250,
+ [OP_PADRANGE] = 237,
+ [OP_REFASSIGN] = 239,
+ [OP_LVREF] = 245,
+ [OP_LVREFSLICE] = 251,
[OP_LVAVREF] = 16,
[OP_ANONCONST] = 0,
[OP_ISA] = 12,
@@ -2959,7 +2961,7 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = {
[OP_LEAVETRYCATCH] = -1,
[OP_POPTRY] = -1,
[OP_CATCH] = 0,
- [OP_PUSHDEFER] = 251,
+ [OP_PUSHDEFER] = 252,
[OP_IS_BOOL] = 0,
[OP_IS_WEAK] = 0,
[OP_WEAKEN] = 0,
@@ -2970,9 +2972,9 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = {
[OP_CEIL] = 78,
[OP_FLOOR] = 78,
[OP_IS_TAINTED] = 0,
- [OP_HELEMEXISTSOR] = 253,
- [OP_METHSTART] = 255,
- [OP_INITFIELD] = 257,
+ [OP_HELEMEXISTSOR] = 254,
+ [OP_METHSTART] = 256,
+ [OP_INITFIELD] = 258,
};
@@ -2992,84 +2994,84 @@ 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, 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, 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, is_bool, is_weak, weaken, unweaken, is_tainted */
- 0x39dc, 0x4ad9, /* pushmark */
+ 0x3abc, 0x4bb9, /* pushmark */
0x00bd, /* wantarray, runcv */
- 0x0558, 0x1b70, 0x4b8c, 0x4728, 0x3f05, /* const */
- 0x39dc, 0x4059, /* gvsv */
+ 0x0558, 0x1b70, 0x4c6c, 0x4808, 0x3fe5, /* const */
+ 0x3abc, 0x4139, /* gvsv */
0x19d5, /* 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, smartmatch, lslice, xor, isa */
- 0x39dc, 0x4ad8, 0x03d7, /* padsv */
- 0x39dc, 0x4ad8, 0x0003, /* padsv_store, lvavref */
- 0x39dc, 0x4ad8, 0x06d4, 0x3acc, 0x48a9, /* padav */
- 0x39dc, 0x4ad8, 0x06d4, 0x0770, 0x3acc, 0x48a8, 0x3541, /* padhv */
- 0x39dc, 0x1d58, 0x03d6, 0x3acc, 0x3e28, 0x4b84, 0x0003, /* rv2gv */
- 0x39dc, 0x4058, 0x03d6, 0x4b84, 0x0003, /* rv2sv */
- 0x3acc, 0x0003, /* av2arylen, akeys, values, keys */
- 0x3d9c, 0x1198, 0x0ef4, 0x014c, 0x4e88, 0x4b84, 0x0003, /* rv2cv */
+ 0x3abc, 0x4bb8, 0x03d7, /* padsv */
+ 0x3abc, 0x4bb8, 0x0003, /* padsv_store, lvavref */
+ 0x3abc, 0x4bb8, 0x06d4, 0x3bac, 0x4989, /* padav */
+ 0x3abc, 0x4bb8, 0x06d4, 0x0770, 0x3bac, 0x4988, 0x3621, /* padhv */
+ 0x3abc, 0x1e38, 0x03d6, 0x3bac, 0x3f08, 0x4c64, 0x0003, /* rv2gv */
+ 0x3abc, 0x4138, 0x03d6, 0x4c64, 0x0003, /* rv2sv */
+ 0x3bac, 0x0003, /* av2arylen, akeys, values, keys */
+ 0x3e7c, 0x1198, 0x0ef4, 0x014c, 0x4f68, 0x4c64, 0x0003, /* rv2cv */
0x06d4, 0x0770, 0x0003, /* ref, blessed */
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 */
- 0x423c, 0x4158, 0x2cf4, 0x2c30, 0x0003, /* backtick */
+ 0x431c, 0x4238, 0x2dd4, 0x2d10, 0x0003, /* backtick */
0x06d5, /* subst */
- 0x129c, 0x23d8, 0x0ad4, 0x49ec, 0x2768, 0x5164, 0x08e1, /* trans, transr */
+ 0x129c, 0x24b8, 0x0ad4, 0x4acc, 0x2848, 0x5244, 0x08e1, /* trans, transr */
0x10dc, 0x05f8, 0x0067, /* sassign */
- 0x0d98, 0x0c94, 0x0b90, 0x3acc, 0x06c8, 0x0067, /* aassign */
- 0x4f30, 0x0003, /* chomp, schomp, scomplement, sin, cos, exp, log, sqrt, int, hex, oct, abs, ord, chr, chroot, rmdir, refaddr, reftype, ceil, floor */
- 0x39dc, 0x4ad8, 0x3454, 0x4f30, 0x0003, /* undef */
- 0x06d4, 0x3acc, 0x0003, /* pos */
- 0x4f30, 0x0067, /* pow, multiply, i_multiply, divide, i_divide, modulo, i_modulo, add, i_add, subtract, i_subtract */
+ 0x0d98, 0x0c94, 0x0b90, 0x3bac, 0x06c8, 0x0067, /* aassign */
+ 0x5010, 0x0003, /* chomp, schomp, scomplement, sin, cos, exp, log, sqrt, int, hex, oct, abs, ord, chr, chroot, rmdir, refaddr, reftype, ceil, floor */
+ 0x3abc, 0x4bb8, 0x3534, 0x5010, 0x0003, /* undef */
+ 0x06d4, 0x3bac, 0x0003, /* pos */
+ 0x5010, 0x0067, /* pow, multiply, i_multiply, divide, i_divide, modulo, i_modulo, add, i_add, subtract, i_subtract */
0x1658, 0x0067, /* repeat */
- 0x3cb8, 0x4f30, 0x0067, /* concat */
- 0x39dc, 0x0338, 0x1d54, 0x4f30, 0x4c6c, 0x0003, /* multiconcat */
- 0x4f30, 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 */
- 0x4f30, 0x5089, /* left_shift, right_shift, nbit_and, nbit_xor, nbit_or, ncomplement */
- 0x5089, /* bit_and, bit_xor, bit_or, sbit_and, sbit_xor, sbit_or, complement */
- 0x06d4, 0x4f30, 0x0003, /* length */
- 0x4490, 0x3acc, 0x012b, /* substr */
- 0x3acc, 0x0067, /* vec */
- 0x3c38, 0x06d4, 0x4f30, 0x018f, /* index, rindex */
- 0x39dc, 0x4058, 0x06d4, 0x3acc, 0x48a8, 0x4b84, 0x0003, /* rv2av */
+ 0x3d98, 0x5010, 0x0067, /* concat */
+ 0x3abc, 0x0338, 0x1e34, 0x5010, 0x4d4c, 0x0003, /* multiconcat */
+ 0x5010, 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 */
+ 0x5010, 0x5169, /* left_shift, right_shift, nbit_and, nbit_xor, nbit_or, ncomplement */
+ 0x5169, /* bit_and, bit_xor, bit_or, sbit_and, sbit_xor, sbit_or, complement */
+ 0x06d4, 0x5010, 0x0003, /* length */
+ 0x4570, 0x3bac, 0x012b, /* substr */
+ 0x3bac, 0x0067, /* vec */
+ 0x3d18, 0x06d4, 0x5010, 0x018f, /* index, rindex */
+ 0x3abc, 0x4138, 0x06d4, 0x3bac, 0x4988, 0x4c64, 0x0003, /* rv2av */
0x025f, /* aelemfast, aelemfast_lex, aelemfastlex_store */
- 0x39dc, 0x38d8, 0x03d6, 0x3acc, 0x0067, /* aelem, helem */
- 0x39dc, 0x3acc, 0x48a9, /* aslice, hslice */
- 0x3acd, /* kvaslice, kvhslice */
- 0x39dc, 0x47f8, 0x35f4, 0x0003, /* delete */
- 0x4db8, 0x0003, /* exists */
- 0x39dc, 0x4058, 0x06d4, 0x0770, 0x3acc, 0x48a8, 0x4b84, 0x3541, /* rv2hv */
- 0x39dc, 0x38d8, 0x1314, 0x1c70, 0x3acc, 0x4b84, 0x0003, /* multideref */
- 0x39dc, 0x4058, 0x0410, 0x36ec, 0x2a69, /* split */
- 0x39dc, 0x2499, /* list */
- 0x39dc, 0x4ad8, 0x0214, 0x4f30, 0x018f, /* emptyavhv */
- 0x15b0, 0x322c, 0x4588, 0x3324, 0x3fc1, /* sort */
- 0x322c, 0x0003, /* reverse */
+ 0x3abc, 0x39b8, 0x03d6, 0x3bac, 0x0067, /* aelem, helem */
+ 0x3abc, 0x3bac, 0x4989, /* aslice, hslice */
+ 0x3bad, /* kvaslice, kvhslice */
+ 0x3abc, 0x48d8, 0x36d4, 0x0003, /* delete */
+ 0x4e98, 0x0003, /* exists */
+ 0x3abc, 0x4138, 0x06d4, 0x0770, 0x3bac, 0x4988, 0x4c64, 0x3621, /* rv2hv */
+ 0x3abc, 0x39b8, 0x1314, 0x1d50, 0x3bac, 0x4c64, 0x0003, /* multideref */
+ 0x3abc, 0x4138, 0x0410, 0x37cc, 0x2b49, /* split */
+ 0x3abc, 0x2579, /* list */
+ 0x3abc, 0x4bb8, 0x0214, 0x5010, 0x018f, /* emptyavhv */
+ 0x15b0, 0x330c, 0x4668, 0x3404, 0x40a1, /* sort */
+ 0x330c, 0x0003, /* reverse */
0x06d4, 0x0003, /* grepwhile */
- 0x3778, 0x0003, /* flip, flop */
- 0x39dc, 0x0003, /* cond_expr */
- 0x39dc, 0x1198, 0x03d6, 0x014c, 0x4e88, 0x4b84, 0x2b41, /* entersub */
- 0x42f8, 0x0003, /* leavesub, leavesublv, leavewrite, leaveeval */
+ 0x3858, 0x0003, /* flip, flop */
+ 0x3abc, 0x0003, /* cond_expr */
+ 0x3abc, 0x1198, 0x03d6, 0x014c, 0x4f68, 0x4c64, 0x2c21, /* entersub */
+ 0x43d8, 0x0003, /* leavesub, leavesublv, leavewrite, leaveeval */
0x02aa, 0x0003, /* argelem */
- 0x295c, 0x2838, 0x0003, /* argdefelem */
+ 0x2a3c, 0x2918, 0x0003, /* argdefelem */
0x00bc, 0x018f, /* caller */
- 0x2675, /* nextstate, dbstate */
- 0x387c, 0x42f9, /* leave */
- 0x39dc, 0x4058, 0x120c, 0x4605, /* enteriter */
- 0x4605, /* iter */
- 0x387c, 0x0067, /* leaveloop */
- 0x529c, 0x0003, /* last, next, redo, dump, goto */
- 0x423c, 0x4158, 0x2cf4, 0x2c30, 0x018f, /* open */
- 0x2010, 0x226c, 0x2128, 0x1ee4, 0x0003, /* ftrread, ftrwrite, ftrexec, fteread, ftewrite, fteexec */
- 0x2010, 0x226c, 0x2128, 0x0003, /* ftis, ftsize, ftmtime, ftatime, ftctime, ftrowned, fteowned, ftzero, ftsock, ftchr, ftblk, ftfile, ftdir, ftpipe, ftsuid, ftsgid, ftsvtx, ftlink, fttty, fttext, ftbinary */
- 0x4f31, /* wait, getppid, time */
- 0x4394, 0x0fb0, 0x082c, 0x5008, 0x2584, 0x0003, /* entereval */
- 0x3b9c, 0x0018, 0x14c4, 0x13e1, /* coreargs */
- 0x3acc, 0x00c7, /* avhvswitch */
- 0x39dc, 0x01fb, /* padrange */
- 0x39dc, 0x4ad8, 0x04f6, 0x33ac, 0x1ac8, 0x0067, /* refassign */
- 0x39dc, 0x4ad8, 0x04f6, 0x33ac, 0x1ac8, 0x0003, /* lvref */
- 0x39dd, /* lvrefslice */
- 0x1dfc, 0x0003, /* pushdefer */
+ 0x2755, /* nextstate, dbstate */
+ 0x395c, 0x43d9, /* leave */
+ 0x3abc, 0x4138, 0x120c, 0x46e5, /* enteriter */
+ 0x46e5, /* iter */
+ 0x395c, 0x0067, /* leaveloop */
+ 0x537c, 0x0003, /* last, next, redo, dump, goto */
+ 0x431c, 0x4238, 0x2dd4, 0x2d10, 0x018f, /* open */
+ 0x20f0, 0x234c, 0x2208, 0x1fc4, 0x0003, /* ftrread, ftrwrite, ftrexec, fteread, ftewrite, fteexec */
+ 0x20f0, 0x234c, 0x2208, 0x0003, /* ftis, ftsize, ftmtime, ftatime, ftctime, ftrowned, fteowned, ftzero, ftsock, ftchr, ftblk, ftfile, ftdir, ftpipe, ftsuid, ftsgid, ftsvtx, ftlink, fttty, fttext, ftbinary */
+ 0x5011, /* wait, getppid, time */
+ 0x1c78, 0x4474, 0x0fb0, 0x082c, 0x50e8, 0x2664, 0x0003, /* entereval */
+ 0x3c7c, 0x0018, 0x14c4, 0x13e1, /* coreargs */
+ 0x3bac, 0x00c7, /* avhvswitch */
+ 0x3abc, 0x01fb, /* padrange */
+ 0x3abc, 0x4bb8, 0x04f6, 0x348c, 0x1ac8, 0x0067, /* refassign */
+ 0x3abc, 0x4bb8, 0x04f6, 0x348c, 0x1ac8, 0x0003, /* lvref */
+ 0x3abd, /* lvrefslice */
+ 0x1edc, 0x0003, /* pushdefer */
0x131c, 0x0003, /* helemexistsor */
- 0x2d9c, 0x0003, /* methstart */
- 0x3088, 0x2ee4, 0x0003, /* initfield */
+ 0x2e7c, 0x0003, /* methstart */
+ 0x3168, 0x2fc4, 0x0003, /* initfield */
};
@@ -3426,7 +3428,7 @@ EXTCONST U8 PL_op_private_valid[] = {
[OP_REQUIRE] = (OPpARG1_MASK),
[OP_DOFILE] = (OPpARG1_MASK),
[OP_HINTSEVAL] = (0),
- [OP_ENTEREVAL] = (OPpARG1_MASK|OPpEVAL_HAS_HH|OPpEVAL_UNICODE|OPpEVAL_BYTES|OPpEVAL_COPHH|OPpEVAL_RE_REPARSING),
+ [OP_ENTEREVAL] = (OPpARG1_MASK|OPpEVAL_HAS_HH|OPpEVAL_UNICODE|OPpEVAL_BYTES|OPpEVAL_COPHH|OPpEVAL_RE_REPARSING|OPpEVAL_EVALSV),
[OP_LEAVEEVAL] = (OPpARG1_MASK|OPpREFCOUNTED),
[OP_ENTERTRY] = (OPpARG1_MASK),
[OP_LEAVETRY] = (0),