summaryrefslogtreecommitdiff
path: root/cv.h
Commit message (Collapse)AuthorAgeFilesLines
* [perl #89544] Non-eval closures don’t need CvOUTSIDEFather Chrysostomos2012-06-201-0/+5
| | | | | | | | | | A closure doesn’t need an outside pointer at run time, unless it has a string eval in it. CvOUTSIDE is only used at compilation time to look up variables by name. Since CvOUTSIDE is reference-counted, a closure can unnecessarily hang on to variables it is not using (see the test in the diff). So stop setting it when cloning a closure, unless it is needed for eval.
* cv.h: Add commentsFather Chrysostomos2012-06-081-0/+2
|
* 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.
* cv.h: comment typoFather Chrysostomos2011-10-161-1/+1
| | | | Commit 7c60e434 removed the ‘match’.
* Improve documentation of XS autoloadingFather Chrysostomos2011-10-111-0/+3
|
* Resolve XS AUTOLOAD-prototype conflictFather Chrysostomos2011-10-091-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Did you know that a subroutine’s prototype can be modified with s///? Don’t look: *AUTOLOAD = *Internals'SvREFCNT; my $f = "Just another "; eval{main->$f}; print prototype AUTOLOAD; $f =~ s/Just another /Perl hacker,\n/; print prototype AUTOLOAD; You did look, didn’t you? You must admit that’s creepy. The problem goes back to this: commit adb5a9ae91a0bed93d396bb0abda99831f9e2e6f Author: Doug MacEachern <dougm@covalent.net> Date: Sat Jan 6 01:30:05 2001 -0800 [patch] xsub AUTOLOAD fix/optimization Message-ID: <Pine.LNX.4.10.10101060924280.24460-100000@mojo.covalent.net> Allow AUTOLOAD to be an xsub and allow such xsubs to avoid use of $AUTOLOAD. p4raw-id: //depot/perl@8362 which includes this: + if (CvXSUB(cv)) { + /* rather than lookup/init $AUTOLOAD here + * only to have the XSUB do another lookup for $AUTOLOAD + * and split that value on the last '::', + * pass along the same data via some unused fields in the CV + */ + CvSTASH(cv) = stash; + SvPVX(cv) = (char *)name; /* cast to loose constness warning */ + SvCUR(cv) = len; + return gv; + } That ‘unused’ field is not unused. It’s where the prototype is stored. So, not only is it clobbering the prototype, it’s also leak- ing it by assigning over the top of SvPVX. Furthermore, it’s blindly assigning someone else’s string, which could be freed before it’s even used. Since it has been documented for a long time that SvPVX contains the name of the AUTOLOADed sub, and since the use of SvPVX for prototypes is documented nowhere, we have to preserve the former. So this commit makes the prototype and the sub name share the same buffer, in a manner resembling that which CvFILE used before I changed it with bad4ae38. There are two new internal macros, CvPROTO and CvPROTOLEN for retriev- ing the prototype.
* [perl #96126] Allocate CvFILE more simplyFather Chrysostomos2011-08-171-2/+9
| | | | | | | | | | | | | | | | | | | See the thread starting at: http://www.nntp.perl.org/group/perl.perl5.porters/2011/07/msg175161.html Instead of assuming that only Perl subs have mallocked CvFILEs and only under threads, resulting in various hackery to borrow parts of the SvPVX buffer where that assumption proves wrong, we can simply add another flag (DYNFILE) to indicate whether CvFILE is mallocked, instead of trying to use the ISXSUB flag for two purposes. This simplifies the code greatly, eliminating bug #96126 in the pro- cess (which had to do with sv_dup not knowing about the hackery that this commit removes). I removed that comment from cv_ckproto_len about CONSTSUBs doubling up the buffer field, as it is no longer relevant. But I still left the code as it is, since it’s better to do an explicit length check.
* perlapi.pod EnhancementsShlomi Fish2011-07-181-1/+6
| | | | | This is a patch to enhance perlapi.pod by providing Perl equivalents and clarifying documentation where appropriate.
* add CvSTASH_set() macro and make CvSTASH() rvalue onlyZefram2010-10-251-1/+2
| | | | | | Now that CvSTASH requires backreference bookkeeping, stop people from directly assigning to it (by using CvSTASH() as an lvalue), and instead force them to use CvSTASH_set().
* plugin mechanism to rewrite calls to a subroutineZefram2010-10-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | New magic type PERL_MAGIC_checkcall attaches a function to a CV, which will be called as the second half of the op checker for an entersub op calling that CV. Default state, in the absence of this magic, is to process the CV's prototype if it has one, or apply list context to all the arguments if not. New API functions cv_get_call_checker() and cv_set_call_checker() provide a clean interface to this facility, hiding the internal use of magic. Expose in the API the new functions rv2cv_op_cv(), ck_entersub_args_list(), ck_entersub_args_proto(), and ck_entersub_args_proto_or_list(), which are meaningful segments of standard entersub op checking and are likely to be useful in plugged-in call checker functions. Expose new API function op_contextualize(), which is a public interface to the internal scalar()/list()/scalarvoid() functions. This API is likely to be required in most plugged-in call checker functions. Incidentally add new function mg_free_type(), in the API, which will remove magic of one type from an SV. (mg_free() removes all magic, and there isn't anything else more selective.)
* add CvGV_set() macro and make CvGV() rvalue onlyDavid Mitchell2010-07-181-1/+2
| | | | | | Now that CvGV can sometimes be reference counted, stop people from directly assigning to it (by using CvGV as an lvalue), and instead force them to use CvGV_set()
* add CVf_CVGV_RC flagDavid Mitchell2010-07-181-4/+6
| | | | | | | | | | | | | after the recent commit 803f274831f937654d48f8cf0468521cbf8f5dff, the CvGV field is sometimes reference counted. Since it was intended that the reference counting would happen only for anonymous CVs, the CVf_ANON flag was co-opted to indicate whether RC was being used. This is not entirely robust; for example, sub __ANON__ {} is a non-anon sub which points to the same GV used by anon subs, which while itself doesn't directly break things, shows that the potential for breakage is there. So add a separate flag just to indicate the reference count status of the CvGV field.
* protect CvGV weakref with backrefDavid Mitchell2010-07-141-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Each CV usually has a pointer, CvGV(cv), back to the GV that corresponds to the CV's name (or to *foo::__ANON__ for anon CVs). This pointer wasn't reference counted, to avoid loops. This could leave it dangling if the GV is deleted. We fix this by: For named subs, adding backref magic to the GV, so that when the GV is freed, it can trigger processing the CV's CvGV field. This processing consists of: if it looks like the freeing of the GV is about to trigger freeing of the CV too, set it to NULL; otherwise make it point to *foo::__ANON__ (and set CvAONON(cv)). For anon subs, make CvGV a strong reference, i.e. increment the refcnt of *foo::__ANON__. This doesn't cause a loop, since in this case the __ANON__ glob doesn't point to the CV. This also avoids dangling pointers if someone does an explicit 'delete $foo::{__ANON__}'. Note that there was already some partial protection for CvGV with commit f1c32fec87699aee2eeb638f44135f21217d2127. This worked by anonymising any corresponding CV when freeing a stash or stash entry. This had two drawbacks. First it didn't fix CVs that were anonmous or that weren't currently pointed to by the GV (e.g. after local *foo), and second, it caused *all* CVs to get anonymised during cleanup, even the ones that would have been deleted shortly afterwards anyway. This commit effectively removes that former commit, while reusing a bit of the actual anonymising code.
* Reorder CVf_* flags to be numerically contiguous again.Nicholas Clark2010-06-091-3/+3
| | | | | The removal of CVf_ASSERTION in 584420f022db5722 and CVf_LOCKED in e95ab0c0d2aa1b35 left two gaps in the sequence of bits in use.
* Remove union _xivu from _XPVCV_COMMON, and hence structs xpvcv and xpvfmNicholas Clark2010-05-211-2/+3
| | | | | | | Replaced with xcv_depth and xfm_lines respectively. Both structures might benefit from some field re-ordering. Update the descriptive comments in the definition of union _xivu.
* In the SV body, exchange the positions of the NV and stash/magic.Nicholas Clark2010-05-211-1/+0
|
* Eliminate the remaining definitions for *_allocated structs.Nicholas Clark2009-08-221-6/+0
|
* Remove CVf_LOCKED and CvLOCKED*(), now that nothing sets that flag bit.Nicholas Clark2009-04-131-6/+1
|
* Convert all (CV *) casts to (const CV *). Convert (XPVCV*) casts to addNicholas Clark2008-10-271-13/+13
| | | | | MUTABLE_PTR(), to validate that there is no casting away of const. p4raw-id: //depot/perl@34610
* Update copyright years.Nicholas Clark2008-10-251-2/+2
| | | p4raw-id: //depot/perl@34585
* You can't (and shouldn't) use CvDEPTH on a PVFM.Nicholas Clark2008-07-311-2/+1
| | | p4raw-id: //depot/perl@34167
* Re: [PATCH] readable assertion names, now the restReini Urban2008-06-081-4/+4
| | | | | | From: "Reini Urban" <rurban@x-ray.at> Message-ID: <6910a60806080717h1aaaef1fh425a2ef21a62c9ed@mail.gmail.com> p4raw-id: //depot/perl@34030
* Deprecate (and remove core use of ) Nullav, Nullcv, Nullgv, Nullhe,Nicholas Clark2008-01-231-1/+5
| | | | | Nullhek and Nullhv. Nullop is going to be a bit less simple. p4raw-id: //depot/perl@33051
* factor out duplicate code in struct xpv*Marcus Holland-Moritz2007-12-301-77/+6
| | | | | Message-ID: <20071229181742.1933db40@r2d2> p4raw-id: //depot/perl@32783
* Remove support for assertions and -ARafael Garcia-Suarez2007-06-051-6/+1
| | | p4raw-id: //depot/perl@31333
* Update copyright years to include 2007. (Plus a couple of 2006s andNicholas Clark2007-01-021-2/+2
| | | | | earlier we missed in av.h and hv.h) p4raw-id: //depot/perl@29670
* It's good to be able to dump FORMATs too :-)Nicholas Clark2007-01-021-1/+2
| | | p4raw-id: //depot/perl@29665
* Move all the FBM data fields from the table into a struct xbm_s whichNicholas Clark2006-12-281-0/+5
| | | | | is part of the xnv union. p4raw-id: //depot/perl@29634
* Move the low/high cop sequences from NVX/IVX to a two U32 structureNicholas Clark2006-12-281-0/+4
| | | | | | in the xnv union. This frees up IVX for the PL_generation code, which in turn will allow SvCUR to return to its real purpose. p4raw-id: //depot/perl@29630
* stab at UNITCHECK blocksAlexander Gough2006-10-191-1/+1
| | | | | Message-ID: <20061019120412.GA12290@the.earth.li> p4raw-id: //depot/perl@29053
* Fix bug in DynaLoader, which has been passing a filename in dynamicNicholas Clark2006-05-021-0/+3
| | | | | | | storage to newXS() seemingly forever. This involves creating newXS_flags(), with the first flag being "arrange to copy the filename and free it at the right time". p4raw-id: //depot/perl@28063
* Make usage of :unique emit a deprecation warning.Rafael Garcia-Suarez2006-03-141-3/+1
| | | | | Remove its outdated documentation. p4raw-id: //depot/perl@27498
* Move the GvNAME HEK into the IV union - every GV is now 1 pointerNicholas Clark2006-03-051-0/+2
| | | | | smaller. p4raw-id: //depot/perl@27380
* xgv_stash can be stored as a union with the NV, reducing the size ofNicholas Clark2006-02-251-1/+4
| | | | | PVGVs by another pointer. p4raw-id: //depot/perl@27326
* Store the stash for our in the magic slot. This will allow us to useNicholas Clark2006-02-241-2/+8
| | | | | | PVMGs in pad names where previously PVGVs were used. In turn, this gives much greater flexibility for the layout of PVGVs. p4raw-id: //depot/perl@27312
* Goodbye PERL_XSUB_OLDSTYLE.Nicholas Clark2006-02-211-8/+1
| | | p4raw-id: //depot/perl@27260
* PVCVs don't need XNVs either.Nicholas Clark2006-02-201-1/+31
| | | | | | (And actually remove xcv_depth) (And fix the copy lengths in bodies_by_type) p4raw-id: //depot/perl@27249
* PVFMs don't need CvDEPTH, and PVCVs don't use SvIVX, so movingNicholas Clark2006-02-201-4/+12
| | | | | | | | | xcv_depth into the IV union saves 4(ish) bytes per CV and format. "ish" because it was a long, but has been changed to I32 (along with the corresponding field in struct block_sub) so as not to enlarge the IV union on platforms where sizeof(long) > sizeof(IV), or struct block_sub where sizeof(long) > sizeof(I32) p4raw-id: //depot/perl@27247
* xcv_root and xcv_xsub can also be merged into a union, providing a newNicholas Clark2006-02-201-5/+11
| | | | | flag is added to denote whether the PVCV is perl or XSUB. p4raw-id: //depot/perl@27244
* xcv_start and xcv_xsubany can be merged into a union, as they are neverNicholas Clark2006-02-201-5/+7
| | | | | both needed. p4raw-id: //depot/perl@27243
* Add a new CvISXSUB() macro, for abstracting the test as to whether aNicholas Clark2006-02-201-1/+1
| | | | | PVCV is perl or XS. p4raw-id: //depot/perl@27241
* Abolish BROKEN_UNION_INIT in B::C, as it works around problems inNicholas Clark2006-02-201-2/+1
| | | | | pre-ANSI C compilers, but pays in code duplication. p4raw-id: //depot/perl@27240
* Re-order CV flags to bring the 4 CVf_BUILTIN_ATTRS into adjacent bits,Nicholas Clark2006-02-201-12/+13
| | | | | | and make other flag bits that are paired in the code adjacent. Will produce tighter code on ARM; might help on other platforms too. p4raw-id: //depot/perl@27234
* Sync change 25229 to .h source filesRafael Garcia-Suarez2005-07-281-1/+1
| | | p4raw-id: //depot/perl@25233
* Change the IV to a union.Nicholas Clark2005-05-291-10/+5
| | | | | | | | Revert the NV union back to a plain NV Transpose the positions of IV and NV (NV is now first) Don't allocate the NV for PV,PVIV,PVAV and PVHV (last 2 non-allocations currently disabled by default) p4raw-id: //depot/perl@24617
* Reorder the union to cause Win32 compilers to use void * alignment forNicholas Clark2005-05-241-1/+1
| | | | | it. p4raw-id: //depot/perl@24569
* Re-order IVX slot in SV bodiesNicholas Clark2005-05-221-2/+12
| | | p4raw-id: //depot/perl@24542
* Add a union in place of xnv_nv, which allows AVs and HVs to re-useNicholas Clark2005-05-211-1/+10
| | | | | | | the memory to store pointers and integers. (Part 1 - will be reworked to be more efficient when IV or void* is 64 bit soon) p4raw-id: //depot/perl@24538
* Move the xpv_pv/xrv_rv member into the SV head, in a union withNicholas Clark2005-05-211-1/+0
| | | | | IV and UV. Avoid allocating a body for IVs and RVs. p4raw-id: //depot/perl@24531
* Update copyright noticesRafael Garcia-Suarez2004-03-161-1/+1
| | | p4raw-id: //depot/perl@22509