summaryrefslogtreecommitdiff
path: root/cop.h
Commit message (Collapse)AuthorAgeFilesLines
* add PERLSI_MULTICALLDavid Mitchell2015-06-191-1/+2
| | | | | | | | | | | | | | | | Currently when MULTICALL pushes a new stackinfo, it uses the si_type PERLSI_SORT. This is probably just a hangover from when the MULTICALL code was created from similar code used to implement sort. Change it to use the new PERLSI_MULTICALL si_type. The si_type value is mainly used for debugging/dumping purposes, apart from a few places where we check for whether this is the top stack (PERLSI_MAIN); or check for a sort BLOCK (cxix = 0, CXt_NULL, PERLSI_SORT). So this commit should have no immediate effect. It will in future however allow us to detect whether we have a sort or a true MULTICALL.
* RT #124156: death during unwinding causes crashDavid Mitchell2015-05-151-1/+11
| | | | | | | | | | | | | | | | | | | | | | | v5.19.3-139-g2537512 changed POPSUB and POPFORMAT so that they also unwind the relevant portion of the scope stack. This (sensible) change means that during exception handling, contexts and savestack frames are popped in lock-step, rather than all the contexts being popped followed by all the savestack contents. However, LEAVE_SCOPE() is now called by POPSUB/FORMAT, which can trigger destructors, tied method calls etc, which themselves may croak. The new unwinding will see the old sub context still on the context stack and call POPSUB on it again, leading to double frees etc. At this late stage in code freeze, the least invasive change is to use an unused bit in cx->blk_u16 to indicate that POPSUB has already been called on this context frame. Sometime later, this whole area of code really needs a thorough overhaul. The main issue is that if cxstack_ix-- is done too early, then calling destructors etc can overwrite the current context frame while we're still using using it; if cxstack_ix-- is done too late, then that stack frame can end up getting unwound twice.
* fix weird comment in cop.h blurbDavid Mitchell2015-05-051-1/+1
| | | | | | The original blurb which I added to the top of cop.h had an ambiguous statement in it that sometime later got "corrected" into the wrong meaning.
* Replace common Emacs file-local variables with dir-localsDagfinn Ilmari Mannsåker2015-03-221-6/+0
| | | | | | | | | | | | | | | | An empty cpan/.dir-locals.el stops Emacs using the core defaults for code imported from CPAN. Committer's work: To keep t/porting/cmp_version.t and t/porting/utils.t happy, $VERSION needed to be incremented in many files, including throughout dist/PathTools. perldelta entry for module updates. Add two Emacs control files to MANIFEST; re-sort MANIFEST. For: RT #124119.
* [perl #103260] Fix s/// with long stringsFather Chrysostomos2014-12-231-2/+2
| | | | | | | | | | | | | | | | | This is also the subject of perl #123071. The iteration count was stored in an I32 and was overflowing. If the maximum number of iterations possible overflowed, then it would become negative, and the substitution would fail immediately with ‘Substitu- tion loop’. I tried fixing this without increasing the size of the context stack entries on 64-bit builds (by skipping the loop check for long strings), but was unable to, because we have to return the number of iterations, which was also stored as I32. If we change just that one to SSize_t, we get an I32-sized alignment hole, so we might as well make maxiters a SSize_t as well, fixing the bug that way (the more straightforward way).
* foreach \$varFather Chrysostomos2014-10-111-1/+4
| | | | Some passing tests are still marked to-do. We need more tests still.
* NETWARE CopFILE_setnReini Urban2014-02-131-1/+1
| | | | broken since 5.8.9
* perlapi: Consistent spaces after dotsFather Chrysostomos2013-12-291-2/+2
| | | | plus some typo fixes. I probably changed some things in perlintern, too.
* Revert "[perl #119801] Stop @DB::dbline modifications from crashing"Father Chrysostomos2013-12-251-29/+15
| | | | | | This reverts commit c1cec775e9019cc8ae244d4db239a7ea5c0b343e. See ticket #120864.
* [perl #119801] Stop @DB::dbline modifications from crashingFather Chrysostomos2013-12-211-15/+29
| | | | | | | | | | | | | | | | | | | | | The cop address for each breakable line was being stored in the IVX slot of ${"_<$file"}[$line]. This value itself, writable from Perl space, was being used as the address of the op to be flagged, whenever a breakpoint was set. This meant writing to ${"_<$file"}[$line] and assigning a number (like 42) would cause perl to use 42 as an op address, and crash when trying to flag the op. Furthermore, since the array holding the lines could outlive the ops, setting a breakpoint on the op could write to freed memory or to an unrelated op (even a different type), potentially changing the beha- viour of unrelated code. This commit solves those pitfalls by moving breakpoints into a global breakpoint bitfield. Dbstate ops now have an extra field on the end holding a sequence number, representing which bit holds the breakpoint for that op.
* remove redundant Zero() from JMPENV_BOOTSTRAPDaniel Dragan2013-11-021-3/+4
| | | | | | | | | | | | | | | | | | | | | In commit 14dd3ad8c9 , a 3 NULL assigns were converted to a Zero() for what I guess was an optimization. This also caused the large je_buf to be zeroed even though je_buf was uninit before. At that time, JMPENV had 2 extra members that don't exist anymore. The 2 extra members in JMPENV were removed in commit 766f891612 . The comment about je_throw was made obsolete in commit 766f891612 so rework it. One function call free NULL assign is faster than a memset() call. je_buf is 0x40 bytes long on 32 bit VC2003 Win32 Perl. No need to zero it since je_buf is never read unless je_prev is not NULL. Also there is no need to zero the last 2 members je_ret and je_mustcatch since they are immediatley assigned to. Move PL_top_env assignment to near je_prev so compiler tries to optimize better since je_prev is the start of the struct and hopefully will calculate the pointer once. Also put some poisoning in case JMPENV gets new members in the future. To conditionally poison in a macro, PERL_POISON_EXPR is being introduced instead of 2 different definitions of JMPENV_BOOTSTRAP.
* Removed OP_IN_REGISTER and related defines.Brian Fraser2013-09-211-11/+0
| | | | | Added as an experiment in 462e5cf6, it never quite worked, and recently wasn't even using registers.
* [perl #119311] Keep CvDEPTH and savestack in syncFather Chrysostomos2013-08-271-5/+11
| | | | | | | | | | | | | | | | when unwinding sub and format calls. The comments in the added test file explain what the problem is. The fix is to call LEAVE_SCOPE in POPSUB and POPFORMAT (to free their lexicals) before lowering CvDEPTH. If the context has already been popped via cxstack_ix--, then LEAVE_SCOPE could overwrite it, so accessing cx after LEAVE_SCOPE is unsafe. Hence the changes to POPSUB and POPFORMAT are a bit involved. Some callers of POPSUB do a temporary cxstack_ix++ first so they can access cx afterwards. Two cases needed to be changed to work that way.
* Revert "[perl #117855] Store CopFILEGV in a pad under ithreads"Father Chrysostomos2013-08-091-14/+35
| | | | | | | | | | | | This reverts commit c82ecf346. It turn out to be faulty, because a location shared betweens threads (the cop) was holding a reference count on a pad entry in a particu- lar thread. So when you free the cop, how do you know where to do SvREFCNT_dec? In reverting c82ecf346, this commit still preserves the bug fix from 1311cfc0a7b, but shifts it around.
* Prevent __FILE__ corruption when ${"_<..."} is modifiedFather Chrysostomos2013-08-051-2/+2
| | | | | | | | | | | This fixes a longstanding bug under non-threaded builds that was extended to threaded builds by the previous commit. Modifying the SV slot of the file gv can cause CopFILE to violate memory discipline, giving random strings. Since the GV is named after the file, too, and since its name can- not be changed from Perl space, use that for CopFILE instead.
* [perl #117855] Store CopFILEGV in a pad under ithreadsFather Chrysostomos2013-08-051-35/+14
| | | | | | | | | | | | | | | | This saves having to allocate a separate string buffer for every cop (control op; every statement has one). Under non-threaded builds, every cop has a pointer to the GV for that source file, namely *{"_<filename"}. Under threaded builds, the name of the GV used to be stored instead. Now we store an offset into the per-interpreter PL_filegvpad, which points to the GV. This makes no significant speed difference, but it reduces mem- ory usage.
* G_METHOD_NAMED flag for call_method and call_svRuslan Zakirov2013-06-301-0/+1
| | | | | | | | | Can be used when it's known that method name has no package part - just method name. With flag set SV with precomputed hash value is used and pp_method_named is called instead of pp_method. Method lookup is faster.
* [perl #118305] make dtrace sub-entry probe support lexsubsFather Chrysostomos2013-06-211-2/+6
| | | | | | | | | | No tests, because I don’t know how to write them. See also <https://rt.perl.org/rt3/Ticket/Display.html?id=118305#txn-1221543>. I have tested this manually, so I know it works and no longer crashes. Hopefully someone else can follow this up with tests.
* [perl #117947] Verify lvalueness of XSUBs at run timeFather Chrysostomos2013-05-271-5/+8
| | | | | | | | | | | If the sub is not visible at compile time, the op tree is flagged such that pp_entersub will know whether to check the lvalueness of the called sub. That check has been in pp_entersub since da1dff9483c. When I moved it to pp_entersub in that commit, I only added it to the pure-Perl branch, not to the XS branch, allowing all XSUBs to be treated as lvalues if they are not visible at compile time.
* PUSH_MULTICALL_WITHDEPTH becomes ..._FLAGSDavid Mitchell2013-04-241-9/+13
| | | | | | | | | | | | | | | | | | | | | | | Two non-API macros were added with 5.17.1 to support the more complex calling conventions required by /({})/ code blocks: PUSH_MULTICALL_WITHDEPTH(the_cv, depth) CHANGE_MULTICALL_WITHDEPTH(the_cv, depth) which allowed us to do the same as the API versions, but to optionally not increment the caller depth, and to change the current CV. Replace these with two new macros: PUSH_MULTICALL_FLAGS(the_cv, flags) CHANGE_MULTICALL_FLAGS(the_cv, flags) which instead allow us to set extra flags in cx->cx_type. The depth increment skip is handled by the new CXp_SUB_RE_FAKE flag, and all (?{}) calls set the new CXp_SUB_RE flag. These two new flags will shortly allow us to change how caller() and __SUB__ handle code blocks.
* Eliminate PL_reg_state.re_reparsing, part 1David Mitchell2013-04-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PL_reg_state.re_reparsing is a hacky flag used to allow runtime code blocks to be included in patterns. Basically, since code blocks are now handled by the perl parser within literal patterns, runtime patterns are handled by taking the (assembled at runtime) pattern, and feeding it back through the parser via the equivalent of eval q{qr'the_pattern'}, so that run-time (?{..})'s appear to be literal code blocks. When this happens, the global flag PL_reg_state.re_reparsing is set, which modifies lexing and parsing in minor ways (such as whether \\ is stripped). Now, I'm in the slow process of trying to eliminate global regex state (i.e. gradually removing the fields of PL_reg_state), and also a change which will be coming a few commits ahead requires the info which this flag indicates to linger for longer (currently it is cleared immediately after the call to scan_str(). For those two reasons, this commit adds a new mechanism to indicate this: a new flag to eval_sv(), G_RE_REPARSING (which sets OPpEVAL_RE_REPARSING in the entereval op), which sets the EVAL_RE_REPARSING bit in PL_in_eval. Its still a yukky global flag hack, but its a *different* global flag hack now. For this commit, we add the new flag(s) but keep the old PL_reg_state.re_reparsing flag and assert that the two mechanisms always match. The next commit will remove re_reparsing.
* Silence a couple of warningsSteve Hay2013-01-141-1/+1
| | | | | ("'initializing' : conversion from 'I32' to 'U8', possible loss of data" and "formal parameter n different from declaration".)
* Remove redundant NULL checks.Eric Brine2013-01-031-2/+1
| | | | It's safe to pass NULLs to SvREFCNT_dec.
* uninline panic branch from POPSTACKDaniel Dragan2012-12-231-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | This commit saves machine instructions by preventing inlining, and keeps the error handling code for an extremely rare panic out of hot code. This should make the interp smaller and faster. Perl_error_log is a macro that has a very large expansion on threaded perls, 4 branches and possibly a call to Perl_PerlIO_stderr. POPSTACK 18 times, by asm, on my non DEBUGGING threaded Win32 32 bit Perl 5.17 -O1 compiled with VC 2003. POPSTACK is also used in some core XS modules, for example List::Util and PerlIO::encoding. The .text section of perl517.dll dropped from 0xc05ff bytes of x86 instructions to 0xc00ff after applying this for me. Perl_croak_popstack was made contextless to save a push/move instruction at each caller (less instructions in the instruction cache) and for more opportunity for the compiler to optimize. Since Perl_croak_popstack is a noreturn, some compilers may optimize it to just a conditional jump instruction. VC 2003 32 bit did this inside perl517.dll and from XS modules using POPSTACK. Perl_croak_popstack measures at 0x48 bytes of instructions under -O1 for me, so previously, those 0x48 minus the dTHX overhead would have been sitting in the caller because of macro expansion.
* Use SvREFCNT_dec_NN in various cop.h macrosFather Chrysostomos2012-12-051-6/+7
| | | | Many of these SVs are never null, and therefore need no null checks.
* make MULTICALL safe across cxstack reallocsDavid Mitchell2012-11-111-1/+2
| | | | | | | [perl #115602] MUTLICALL sets a local var, cx, to point to the current context stack frame. When a function is called, the context stack might be realloc()ed, in which case cx would point to freed memory.
* cop.h: Remove obsolete commentFather Chrysostomos2012-09-141-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 623e6609 (2 Apr 2006) added this to cop.h: +/* FIXME NATIVE_HINTS if this is changed from op_private (see perl.h) */ +#define CopHINTS_get(c) ((c)->op_private + 0) +#define CopHINTS_set(c, h) STMT_START { \ + (c)->op_private \ + = (U8)((h) & HINT_PRIVATE_MASK); \ + } STMT_END + d5ec2987 (20 May 2006) made this change, ignoring the FIXME: /* FIXME NATIVE_HINTS if this is changed from op_private (see perl.h) */ -#define CopHINTS_get(c) ((c)->op_private + 0) +#define CopHINTS_get(c) ((c)->cop_hints + 0) #define CopHINTS_set(c, h) STMT_START { \ - (c)->op_private \ - = (U8)((h) & HINT_PRIVATE_MASK); \ + (c)->cop_hints = (h); \ } STMT_END There is nothing to be fixed here, as vmsish.h uses ->op_private directly, instead of using the CopHINTS macros. Even having caller return cop_hints instead of op_private doesn’t hurt, as newly-created cops copy the vms hints from PL_hints to op_private. So assigning (caller $n)[8] to $^H will still work.
* Stop here-docs from gutting (caller $n)[6]Father Chrysostomos2012-08-271-0/+2
| | | | | | | | | (caller $n)[6] returns the text of the eval. Actually, it would return, not the text of the eval, but the text with all the here-doc bodies missing. In this commit, I’m abusing the SvSCREAM flag to indicate that the eval text stored in the context stack is refcounted.
* Use PADLIST in more placesFather Chrysostomos2012-08-211-2/+2
| | | | | Much code relies on the fact that PADLIST is typedeffed as AV. PADLIST should be treated as a distinct type.
* assert_(...)Father Chrysostomos2012-08-051-5/+1
| | | | | | | | This new macro expands to ‘assert(...),’ (with a trailing comma) under debugging builds; the empty string otherwise. It allows for the removal of some #ifdef DEBUGGINGs, which could not be avoided otherwise.
* Don’t let active formats be freedFather Chrysostomos2012-08-051-0/+2
| | | | | | | | | | | | | | This crashes: format FOO = @< undef *FOO . $~ = FOO; write The context stack needs to hold a reference count for formats, just as it does for subs.
* Recursive formats and closures in formats.Father Chrysostomos2012-08-051-0/+2
| | | | | | | | | | | | | | Formats called recursively were using the same set of lexicals, so the inner call would stomp on the outer calls vars, usually clearing them when exiting. Previous commits prepared a CvDEPTH field for formats. This commit sets it in P(USH|OP)FORMAT and pushes a new pad in enterwrite. This also allows closures to work properly in formats. Formerly they caused assertion failures in cv_clone. Now cv_clone’s assumptions about CvDEPTH on CvOUTSIDE and find_runcv are met when subs are embed- ded in formats.
* make calling of /(?{}) code blocks correctDavid Mitchell2012-06-131-3/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Formerly, it just updated PL_comppad, set PL_op to the first op of the code block, and did CALLRUNOPS(). This had a lot of problems, e.g. depth of recursion, and not having anything on the context stack for die/caller/next/goto etc to see, usually leading to segfaults. Make it so that it uses the MULTICALL API instead. This makes it push a new stack and a CxSUB context stack frame; it also makes us share code rather than rolling our own. MULTICALL had to be extended in two ways to make this work; but these have not yet been made part of the public API. First, it had to allow changing of the current CV while leaving the current CxSUB frame in place, and secondly it had to allow pushing a CV with a zero increment of CvDEPTH. This latter is to handle direct literal blocks: /(?{...})/ which are compiled into the same CV as the surrounding scope; therefore we need to push the same sub twice at the same depth (usually 1), i.e. $ ./perl -Dstv -e'sub f { /(?{$x})/ } f' ... (29912:-e:1) gvsv(main::x) STACK 0: MAIN CX 0: BLOCK => CX 1: SUB => <=== the same sub ... retop=leave STACK 1: SORT CX 0: SUB => UNDEF <==== ... as this retop=(null) (note that stack 1 is misidentified as SORT; this is a bug in MULTICALl to be fixed later). One has to be very careful with the save stack; /(?{})/ is designed not to introduce a new scope, so that the effects of 'local' etc accumulate across multiple block invocations (but get popped on backtracking). This is why we couldn't just do a POP_MULTICALL/PUSH_MULTICALL pair to change the current CV; the former would pop the save stack too. Note that in the current implementation, after calling out to the first code block, we leave the CxSUB and PL_comppad value in place, on the assumption that it may be soon re-used, and only pop the CxSUB at the end of S_regmatch(). However, when popping the savestack on backtracking, this will restore PL_comppad to its original value; so when calling a new code block with the same CV, we can't rely on PL_comppad still being correct. Also, this means that outside of a code block call, the context stack and PL_comppad are wrong; I can't think of anything within the regex code that could be using these; but it if it turns out not to be the case, then we'd have to change it so that after each code block call, we pop the CxSUB off the stack and restore PL_comppad, but without popping the save stack.
* cop.h: Clarify commentFather Chrysostomos2012-06-071-1/+2
|
* Obliterate CopSTASH_freeFather Chrysostomos2012-06-041-1/+0
| | | | It is unused outside the core, defined as a no-op, and undocumented.
* [perl #78742] Store CopSTASH in a pad under threadsFather Chrysostomos2012-06-041-38/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, a pointer to the cop’s stash was stored in cop->cop_stash under non-threaded perls, and the name and name length were stored in cop->cop_stashpv and cop->cop_stashlen under ithreads. Consequently, eval "__PACKAGE__" would end up returning the wrong package name under threads if the current package had been assigned over. This commit changes the way cops store their stash under threads. Now it is an offset (cop->cop_stashoff) into the new PL_stashpad array (just a mallocked block), which holds pointers to all stashes that have code compiled in them. I didn’t use the lexical pads, because CopSTASH(cop) won’t work unless PL_curpad is holding the right pad. And things start to get very hairy in pp_caller, since the correct pad isn’t anywhere easily accessible on the context stack (oldcomppad actually referring to the current comppad). The approach I’ve followed uses far less code, too. In addition to fixing the bug, this also saves memory. Instead of allocating a separate PV for every single statement (to hold the stash name), now all lines of code in a package can share the same stashpad slot. So, on a 32-bit OS X, that’s 16 bytes less memory per COP for short package names. Since stashoff is the same size as stashpv, there is no difference there. Each package now needs just 4 bytes in the stashpad for storing a pointer. For speed’s sake PL_stashpadix stores the index of the last-used stashpad offset. So only when switching packages is there a linear search through the stashpad.
* update the editor hints for spaces, not tabsRicardo Signes2012-05-291-2/+2
| | | | | This updates the editor hints in our files for Emacs and vim to request that tabs be inserted as spaces.
* [perl #112316] Make strict vars respect assignment from null pkgFather Chrysostomos2012-04-191-14/+21
| | | | | | Under threads, strict vars was not respecting glob assignment from a package with a null in its name if the name of the package assigned to was equal to the prefix of the current package up to the null.
* Label UTF8 cleanupBrian Fraser2012-03-251-0/+4
| | | | | This meant changing LABEL's definition in perly.y, so most of this commit is actually from the regened files.
* Provide as much diagnostic information as possible in "panic: ..." messages.Nicholas Clark2012-01-161-1/+1
| | | | | | | | | | | | | | | The convention is that when the interpreter dies with an internal error, the message starts "panic: ". Historically, many panic messages had been terse fixed strings, which means that the out-of-range values that triggered the panic are lost. Now we try to report these values, as such panics may not be repeatable, and the original error message may be the only diagnostic we get when we try to find the cause. We can't report diagnostics when the panic message is generated by something other than croak(), as we don't have *printf-style format strings. Don't attempt to report values in panics related to *printf buffer overflows, as attempting to format the values to strings may repeat or compound the original error.
* Groundwork to allow cops and pmops to store the UTF8 flagBrian Fraser2011-10-061-3/+15
| | | | | | | | | With threaded builds, cop.h and op.h get an extra member in their structs, to save the UTF-8ness of the stash's name. *STASH_set() checks for the flag, stores it through *STASH_flags(), and *STASH() uses the latter to fetch the correct scalar.
* remove index offsetting ($[)Zefram2011-09-091-24/+0
| | | | | | $[ remains as a variable. It no longer has compile-time magic. At runtime, it always reads as zero, accepts a write of zero, but dies on writing any other value.
* Use OPpDEREF for lvalue sub, such that the flags contains the deref type, ↵Gerard Goossen2011-09-011-1/+1
| | | | | | | instead of deriving it from the opchain. Also contains a test where using the opchain to determine the deref type fails.
* Rename store/fetch_cop_label as cop_*Father Chrysostomos2011-07-161-1/+1
| | | | | | | | This makes them consistent with other functions that put the basic datum type first (like hv_*, sv_*, cophh_*). Since fetch_cop_label is marked as experimental (M), this change should be OK.
* Change was_lvalue_sub back to X; spell out the only use of itFather Chrysostomos2011-07-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | OK, now I understand what’s happening. If there is a public macro (PUSHSUB) that contains a call to a pri- vate function (was_lvalue_sub), that function has to be exported, so that non-core code can call it. But if it is marked X, there is no was_lvalue_sub shorthand macro visible to non-core code, so when the PUSHSUB macro is expanded in such code, the was_lvalue_sub(...) bit becomes a call to the function literally named was_lvalue_sub, as opposed to Perl_lvalue_sub (and is compiled that way on forgiving platforms). Making it A makes that macro available to non-core code, but also implies that it is available for direct use by extensions, which is not the case with was_lvalue_sub. So, this commit makes it X again, but spells it out in PUSHSUB, so there is no need for the function’s macro to be available when PUSHSUB is expanded. Hence, there is no need for the was_lvalue_sub macro to exist, so this commit also removes it. See also these three commits: c73b0699db 7b70e81778 777d901444
* Propagate (non-)lvalue context through nested callsFather Chrysostomos2011-07-091-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, this code would fail: $foo = "foo"; sub foo :lvalue{ return index "foo","o" } sub bar :lvalue { foo } $x = bar; (It would fail for ‘return $]’ as well. Whether it’s a PADTMP or a read-only scalar makes no difference.) foo would think it was being called in true lvalue context, because the entersub op that called it (in bar) was marked that way, bar being an lvalue sub as well. The PUSHSUB macro in cop.h needed to be modified to account for dynamic, or indetermine, context (i.e., indeterminable at compile time). This happens when an entersub op is an argument to return or the last statement in a subroutine. In those cases it has to propa- gate the context from the caller. So what we now do is this: Both lvalue and in-args flags are turned on for an entersub op when op_lvalue is called with OP_LEAVESUBLV as the type. Then PUSHSUB copies into the context stack only those flags that are set both on the current entersub op and in the context stack for the previous sub call.
* [perl #7946] Lvalue subs do not autovivifyFather Chrysostomos2011-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit makes autovivification work with lvalue subs. It follows the same technique used by other autovivifiable ops (aelem, helem, tc.), except that, due to flag constraints, it uses a single flag and instead checks the op tree at run time to find out what sort of thing to vivify. The flag constraints are that these two flags: #define OPpENTERSUB_HASTARG 32 /* Called from OP tree. */ #define OPpENTERSUB_NOMOD 64 /* Immune to op_lvalue() for :attrlist. */ conflict with these: #define OPpDEREF (32|64) /* autovivify: Want ref to something: */ #define OPpDEREF_AV 32 /* Want ref to AV. */ #define OPpDEREF_HV 64 /* Want ref to HV. */ #define OPpDEREF_SV (32|64) /* Want ref to SV. */ Renumbering HASTARG and NOMOD is problematic, as there are places in op.c that change entersubs into rv2cvs, and the entersub and rv2cv flags would conflict. Setting the flags correctly when changing the type is hard and would result in subtle bugs if not done perfectly. Ops like ${...} don’t actually autovivify; it’s the op inside that does it. In those cases, the parent op is flagged with OPpDEREFed, and it skips get-magic, as it has already been called by the inner op. Since entersub is now marked as being an autovivifying op, ${...} in lvalue context ends up skipping get-magic if there is a foo() inside. And this affects even regular subs. So pp_leavesub and pp_return have to call get-magic; hence the new tests in gmagic.t.
* cop.h: pod: Fix broken linksKarl Williamson2011-05-181-4/+4
|
* struct subst; remove macro for obsolete fieldDavid Mitchell2011-02-181-1/+0
| | | | The field was removed a while ago, but the macro sb_once remained.
* Update old activestate links to point to git.Michael Stevens2011-01-201-2/+3
|