summaryrefslogtreecommitdiff
path: root/cop.h
Commit message (Collapse)AuthorAgeFilesLines
* revert smartmatch to 5.27.6 behaviourZefram2017-12-291-8/+16
| | | | | | | | | | | | | The pumpking has determined that the CPAN breakage caused by changing smartmatch [perl #132594] is too great for the smartmatch changes to stay in for 5.28. This reverts most of the merge in commit da4e040f42421764ef069371d77c008e6b801f45. All core behaviour and documentation is reverted. The removal of use of smartmatch from a couple of tests (that aren't testing smartmatch) remains. Customisation of a couple of CPAN modules to make them portable across smartmatch types remains. A small bugfix in scope.c also remains.
* internally change "when" to "whereso"Zefram2017-12-051-5/+5
| | | | | The names of ops, context types, functions, etc., all change in accordance with the change of keyword.
* remove unused CXp_FOR_DEF and OPpITER_DEFZefram2017-11-291-2/+0
| | | | | These were used to identify foreach loops that qualify as topicalizers. That's no longer a relevant classification.
* make loop control apply to "given"Zefram2017-11-291-8/+3
| | | | A "given" construct is now officially a one-iteration loop.
* revise block_givwhen for sole use by "when"Zefram2017-11-291-5/+4
| | | | This context frame type doesn't need to cater for "given" any more.
* better document macros taking literal stringsZefram2017-11-121-8/+8
| | | | | | | | | | When giving a function-style prototype for a macro taking a literal string parameter, put a string literal in place of a type for that parameter. This goofy appearance makes it obvious that this isn't really a function, and clues the reader in that the parameter can't actually be an arbitrary expression of the right type. Also change the nonsensical "NUL-terminated literal string" to "literal string" to describe these parameters. Fixes [perl #116286].
* make 'struct jmpenv' size independent of DEBUGGINGDavid Mitchell2017-08-231-2/+0
| | | | | | | | | | | | | | | | | | | | | | RT #131942 My commit v5.27.1-114-g9449f0d added a field je_old_stack_hwm to the jmpenv structure on debugging builds. However, one field in the interpreter structure is a JMPENV (rather than JMPENV*), so this can make the interpreter structure size vary on debugging and non-debugging builds. This is usually a no-no, since it breaks re.pm, which recompiles the various re functions with DEBUGGING enabled, even on non-debugging fields. This was supposed to be handled by the extra '!defined DEBUGGING_RE_ONLY' condition, and indeed all core XS modules including re.xs work ok. However, it seems to have broken several CPAN modules. I still don't understand why, but the easiest fix is to just always include the debugging je_old_stack_hwm field in all builds.
* PL_curstackinfo->si_stack_hwm: gently restoreDavid Mitchell2017-07-161-1/+2
| | | | | | | | | | | | | | | | | | RT #131732 With v5.27.1-66-g87058c3, I introduced a DEBUGGING-only mechanism in the runops loop for checking whether an op extended the stack by as many slots as values it returned on the stack. It did this by setting a high-water-mark just before calling each pp function, and checking its result on return. It saved and restored the old value of PL_curstackinfo->si_stack_hwm whenever it entered or left a runops loop or did a JMPENV_PUSH / JMPENV_POP. However, the restoring could restore to an old value that was smaller than the current value, leading to false-positive stack-extend panics. So only restore if the old value was larger. In particular this was causing false positives in DBI.
* save si_stack_hwm across JMPENV_PUSHDavid Mitchell2017-07-031-0/+18
| | | | | | | | | When continuing after an exception (JMPENV_PUSH() returns 3), restore the value of PL_curstackinfo->si_stack_hwm. This is a recently added variable on debugging builds that detects attempts to push stuff on the stack without extending it. After an exception its value may be invalid and trigger a false panic.
* paranoia: parenthesize macro parametersLukas Mai2017-06-241-1/+1
|
* fix #ifdef directives with extra tokensLukas Mai2017-06-241-1/+1
|
* add PL_curstackinfo->si_stack_hwmDavid Mitchell2017-06-241-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | On debugging builds only, add a mechanism for checking pp function calls for insufficient stack extending. It works by: * make the runops loop set a high-water-mark (HWM) variable equal to PL_stack_sp just before calling each pp function; * make EXTEND() etc update this HWM; * on return from the pp function, panic if PL_stack_sp is > HWM. This detects whether pp functions are pushing more items onto the stack than they are requesting space for. There's a possibility of false positives if the code is doing weird stuff like direct manipulation of stacks via PL_curstack, SWITCHSTACK() etc. It's also possible that one pp function "knows" that a previous pp function will have already grown the stack enough. Currently the only place in core that seems to do this is pp_enteriter, which allocates 1 stack slot so that pp_iter doesn't have to check each time it returns &PL_sv_yes/no. To accommodate this, the new macro EXTEND_SKIP() has been added, that tells perl that it's safely skipping an EXTEND() here.
* remove eval's usage of SvSCREAMDavid Mitchell2016-11-121-2/+6
| | | | | | | | Currently the SvSCREAM flag is set on the sv pointed to by cx->blk_eval.cur_text, to indicate that it is ref counted. Instead, use a spare bit in the blk_u16 field of the eval context. This is to reduce the number of odd special cases for the SvSCREAM flag.
* CX_POP_SAVEARRAY(): use more distinctive var nameDavid Mitchell2016-05-231-2/+2
| | | | | | | | | | | Under -Wshadow, CX_POP_SAVEARRAY's local var 'av' can generate this warning: warning: declaration shadows a local variable [-Wshadow] So rename it to cx_pop_savearay_av to reduce the risk of a clash. (See http://nntp.perl.org/group/perl.perl5.porters/236444)
* Improve code comments for some ctx stuffDavid Mitchell2016-03-301-6/+6
| | | | | | | | | * in pp_return(), some comments were out of date about how leave_adjust_stacks() is called ; * add a comment to all the functions that pp_return() tail-calls to the effect that they can be tail-called; * make it clearer when/why OPf_SPECIAL is set on OP_LEAVE; * CXt_LOOP_PLAIN can be a while loop as well as a plain block.
* silence -Wparentheses-equalityDavid Mitchell2016-03-281-2/+2
| | | | | | | | | | | | | | | | | | Clang has taken it upon itself to warn when an equality is wrapped in double parentheses, e.g. ((foo == bar)) Which is a bit dumb, as any code along the lines of #define isBAR (foo == BAR) if (isBAR) {} will trigger the warning. This commit shuts clang up by putting in a harmless cast: #define isBAR cBOOL(foo == BAR)
* perlapi: Clarify that a literal string must end in a NULKarl Williamson2016-02-031-8/+8
| | | | Some entries already had this. For those, it standardizes the text.
* make gimme consistently U8David Mitchell2016-02-031-1/+1
| | | | | | | | | | | | | The value of gimme stored in the context stack is U8. Make all other uses in the main core consistent with this. My primary motivation on this was that the new function cx_pushblock(), which I gave a 'U8 gimme' parameter, was generating warnings where callers were passing I32 gimme vars to it. Rather than play whack-a-mole, it seemed simpler to just uniformly use U8 everywhere. Porting/bench.pl shows a consistent reduction of about 2 instructions on the loop and sub benchmarks, so this change isn't harming performance.
* MULTICALL *shouldn't* clear savestackDavid Mitchell2016-02-031-4/+1
| | | | | | | | | | | | | | | | | | | About 25 commits ago in this branch I added a commit: MULTICALL should clear scope after each call To fix RT #116577, which reported that lexicals were only being freed at the end of the MULTICALL, not after each individual call to the sub. In that commit, I added a LEAVE_SCOPE() to the end of the MULTICALL() definition. However, after further thought I realise that's wrong. If a multicall sub does something like { my $x = $_*2; $x }, then the returned value would be freed before the XS code which calls MULTICALL() has a chance to do anything with it (e.g. test for truth, or add it to the return args or whatever). So I think popping the save stack should be the responsibility of the caller of MULTICALL(), rather than of MULTICALL() itself.
* add blk_old_tmpsfloor shortcutDavid Mitchell2016-02-031-0/+1
| | | | | | | | Add #define blk_old_tmpsfloor cx_u.cx_blk.blku_old_tmpsfloor to match all the other 'struct block' fields which have similar short cuts
* dMULTICALL: remove unused varsDavid Mitchell2016-02-031-17/+9
| | | | | | | | | | | | | | | | | | | | | | | | dMULTICALL declares several vars that are used either to maintain state across multiple calls, or to pass values to PUSHSUB etc, where those macros expected to obtain some of their args by values being implicitly passed via local vars. Since PUSHSUB has been replaced by cx_pushsub() which now has all parameters explicitly passed, there is no longer any need for those vars. So this commit eliminates them: newsp hasargs There are also a couple vars which are no longer used due to changes to the implementation over time; these can also be eliminated: cx multicall_cv Finally, this branch introduced a new var, saveix_floor; rename it to multicall_saveix_floor for consistency with other dMULTICALL vars. Although none of these vars are listed in the documentation, its possible that some code out there may rely on them in some way, and will need to be fixed up.
* convert CX_{PUSH|POP}{WHEN|GIVEN} to inline fnsDavid Mitchell2016-02-031-20/+0
| | | | Replace CX_PUSHGIVEN() with cx_pushgiven() etc.
* convert CX_PUSHLOOP*/POPLOOP to inline fnsDavid Mitchell2016-02-031-41/+0
| | | | Replace CX_PUSHLOOP_FOR() with cx_pushfloop_for() etc.
* convert CX_PUSHEVAL/POPEVAL to inline fnsDavid Mitchell2016-02-031-29/+0
| | | | | | Replace CX_PUSHEVAL() with cx_pusheval() etc. No functional changes.
* convert CX_PUSHFORMAT/POPFORMAT to inline fnsDavid Mitchell2016-02-031-27/+0
| | | | | | Replace CX_PUSHFORMAT() with cx_pushformat() etc. No functional changes.
* convert CX_PUSHSUB/POPSUB to inline fnsDavid Mitchell2016-02-031-81/+4
| | | | | | Replace CX_PUSHSUB() with cx_pushsub() etc. No functional changes.
* convert CX_PUSH/POP/TOPBLOCK to inline fnsDavid Mitchell2016-02-031-44/+7
| | | | | | Replace CX_PUSHBLOCK() with cx_pushblock() etc. No functional changes.
* rename PUSHBLOCK,PUSHSUB etc to CX_PUSHBLOCK etcDavid Mitchell2016-02-031-24/+24
| | | | | | | Earlier all the POPFOO macros were renamed to CX_POPFOO to reflect the changed API (like POPBLOCK no longer decremented cxstack_ix). Now rename the PUSH ones for consistency.
* eliminate PUSH/POPBASICBLK macrosDavid Mitchell2016-02-031-9/+0
| | | | | | These are both NOOPs now, and were introduced within this branch as a temporary measure while extra stuff needed doing when pushing or popping a CXt_BOCK (pp_enter/pp_leave).
* consolidate common code in PUSHLOOP_FOR,_PLAINDavid Mitchell2016-02-031-1/+1
|
* PUSHEVAL: make n param an SV rather than a stringDavid Mitchell2016-02-031-1/+1
| | | | | | | | | | Rather than doing cx->blk_eval.old_namesv = (n ? newSVpv(n,0) : NULL); make the caller responsible for creating and passing in the SV. Since only only place (pp_require) passes a non-null value, this saves the other places having to test for nullness.
* PUSHSUB: make retop a parameterDavid Mitchell2016-02-031-8/+8
| | | | | | Rather than doing cx->blk_sub.retop = NULL in PUSHSUB, then relying on the caller to subsequently change it to something more useful, make it an arg to PUSHSUB.
* PUSHEVAL: make retop a parameterDavid Mitchell2016-02-031-2/+2
| | | | | | Rather than doing cx->blk_eval.retop = NULL in PUSHEVAL, then relying on the caller to subsequently change it to something more useful, make it an arg to PUSHEVAL.
* PUSHFORMAT: don't use implicit argsDavid Mitchell2016-02-031-1/+1
| | | | | Make cv and gv explicit parameters of PUSHFORMAT(), rather than just assuming that there are such vars in scope.
* PUSHSUB: don't use implicit argsDavid Mitchell2016-02-031-7/+7
| | | | | Make cv and hasargs explicit parameters of PUSHSUB(), rather than just assuming that there are such vars in scope.
* PUSHBLOCK: don't use implicit argsDavid Mitchell2016-02-031-3/+3
| | | | | Make gimme a parameter of PUSHBLOCK() rather than just assuming that there's a 'gimme' var in scope.
* move PL_savestack_ix saving into PUSHBLOCKDavid Mitchell2016-02-031-9/+8
| | | | | | | | | | | | Currently blku_oldsaveix was being set by the various PUSHFOO macros, except for PUSHSUB and PUSHEVAL which expected their caller to do it manually. Now that all the main context state is stored on the context stack rather than than some on the save stack too, things are a lot simpler, and this messy transitional state can now be rationalised, whereby blku_oldsaveix is now always set by PUSHBLOCK; the exact value being specified by a new arg to PUSHBLOCK.
* PUSH_MULTICALL: use SAVEOP()David Mitchell2016-02-031-1/+1
| | | | | SAVEOP() should be more efficient than SAVEVPTR(PL_op), since it uses the dedicated SAVEt_OP.
* eliminate PERL_STACK_OVERFLOW_CHECKDavid Mitchell2016-02-031-6/+2
| | | | | | | | This macro is defined as NOOP on all platforms except for MacOS classic, where it was added as a hook to allow for OSes that have a small CPU stack size. Since pp_entersub et al don't actually use the CPU stack, this hook looks misconceived from the beginning. So remove all uses of it in the core.
* MULTICALL should clear scope after each callDavid Mitchell2016-02-031-0/+4
| | | | | | | RT #116577 Lexicals etc were only being freed at the end of the MULTICALL, not after each individual call to the sub.
* Document CxLVAL()David Mitchell2016-02-031-0/+12
|
* CX_POPFOO(): assert cx is of the right typeDavid Mitchell2016-02-031-0/+10
| | | | | At the start of each CX_POPFOO(cx) macro, add an assertion that cx is of type CXt_FOO.
* rename POPFOO() to CX_POPFOO()David Mitchell2016-02-031-27/+27
| | | | | | | | | | | | | | | | Rename all the context-popping macros such as POPBLOCK and POPSUB, by giving them a CX_ prefix. (Do TOPBLOCK too). This is principally to deliberately break any existing non-core use of these non-API macros, as their behaviour has changed in this branch. In particular, POPBLOCK(cx) no longer decrements the cxt stack pointer nor sets cx; instead, cx is now expected to already point to the stack frame which POPBLOCK should process. At the same time, giving them a CX_ prefix makes it clearer that these are all part of a family of macros that manipulate the context stack. The PUSHFOO() macros will be renamed in a later commit.
* factor out common actions in TOPBLOCK and POPBLOCKDavid Mitchell2016-02-031-9/+13
|
* tweak POPLOOP and CXt_LOOP_* orderDavid Mitchell2016-02-031-17/+18
| | | | | | | Re-arrange the order of the CXt_LOOP_* to make it easier for compilers to produce efficient code, and tweak POPLOOP so that the code for freeing ary and cur is shared (as they occupy the same position in the union).
* fix CxFOREACHDavid Mitchell2016-02-031-2/+2
| | | | | | It wasn't detecting CXt_LOOP_LAZYIV as a 'for' loop type. This only affected 'given' and 'break' (which need to distinguish between being in a 'given' block and being in a 'for' block).
* only set CXp_FOR_DEF with CXp_FOR_GVDavid Mitchell2016-02-031-0/+4
| | | | | | | | | | C<for (...)> is a special-case of C<for $pkg_var (...)>, so CXp_FOR_DEF should only be set when CXp_FOR_GV also is. So in pp_enteriter(), only test for (PL_op->op_private & OPpITER_DEF) in the GV branch and assert that it's otherwise unset. This is slightly more efficient in the non-GV branches. Also add some more commentary to the CXp_FOR_* flag definitions.
* give POP_SAVEARRAY() macro a cx argDavid Mitchell2016-02-031-2/+2
| | | | rather than just assuming that there's a 'cx' var in scope
* TOPBLOCK: make comment clear its used by goto tooDavid Mitchell2016-02-031-1/+1
|
* POPSUB_ARGS: move a code comment to the right lineDavid Mitchell2016-02-031-1/+1
|