summaryrefslogtreecommitdiff
path: root/cv.h
Commit message (Collapse)AuthorAgeFilesLines
* perlapi: Change some 'eg' to 'e.g.'Karl Williamson2015-09-031-1/+1
| | | | To make more standard
* 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.
* cv.h: Add CVf_ANONCONST flagFather Chrysostomos2015-01-191-1/+6
|
* Remove context param from set_padlistFather Chrysostomos2014-11-211-1/+1
| | | | It doesn’t need it.
* PoisonPADLIST should not be totally empty.Jarkko Hietaniemi2014-11-091-1/+1
| | | | (It is e.g. used as "... else PoisonPADLIST();" in sv.c)
* add xs_handshake APIDaniel Dragan2014-11-071-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This API elevates the amount of ABI compatibility protection between XS modules and the interp. It also makes each boot XSUB smaller in machine code by removing function calls and factoring out code into the new Perl_xs_handshake and Perl_xs_epilog functions. sv.c : - revise padlist duping code to reduce code bloat/asserts on DEBUGGING ext/DynaLoader/dlutils.c : - disable version checking so interp startup is faster, ABI mismatches are impossible because DynaLoader is never available as a shared library ext/XS-APItest/XSUB-redefined-macros.xs : - "" means dont check the version, so switch to " " to make the test in xsub_h.t pass, see ML thread "XS_APIVERSION_BOOTCHECK and XS_VERSION is CPP defined but "", mow what?" ext/re/re.xs : - disable API version checking until #123007 is resolved ParseXS/Utilities.pm : 109-standard_XS_defs.t : - remove context from S_croak_xs_usage similar to core commit cb077ed296 . CvGV doesn't need a context until 5.21.4 and commit ae77754ae2 and by then core's croak_xs_uage API has been long available and this backport doesn't need to account for newer perls - fix test where lack of having PERL_IMPLICIT_CONTEXT caused it to fail
* free up CvPADLIST slot for XSUBs for future useDaniel Dragan2014-10-311-1/+27
| | | | | | | | | | | | | | | | | | | CvRESERVED is a placeholder, it will be replaced with a sentinal value from future revised BOOTCHECK API. CvPADLIST_set was helpful during development of this patch, so keep it around for now. PoisonPADLIST's magic value is from PERL_POISON 0xEF pattern. Some PoisonPADLIST locations will get code from future BOOTCHECK API. Make padlist_dup a NN function to avoid overhead of calling it for XSUBs during closing. Perl_cv_undef_flags's else if (CvISXSUB(&cvbody)) is to avoid whitespace changes. Filed as perl [#123059].
* refactor Perl_cv_undef_flagsDaniel Dragan2014-10-291-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On VC 2003 32bits size of this function decreased from 0x321 bytes of machine code to 0x2d8. cv.h: - partially reorder Cv* macros to match XPVCV member order - create CvDEPTHunsafe which never uses SV head except for SvANY ptr since Perl_cv_undef_flags uses a fake SV head pad.c - remove var slabbed, frees a C auto/non-vol register, there are only 2 uses, on CvSTART branch, CvFLAGS is reused frm CvISXSUB test by optimizer - use a CV struct to fake a CV, to avoid rereading SvANY ptr after each func call, CVs can't be upgraded or have their bodies realloced - dont write NULL to CvFILE if CvFILE is NULL, also move NULL assignment so CPU address generation can be reused by compiler - refactor CvROOT/CvSTART/CvXSUB freeing conditionals to simplify code and dont check CvISXSUB twice - CvDEPTH requires a real CV*/CV*, since it checks the SV head with an assert, use CvDEPTHunsafe instead, and inline the assert using the real CV*. Also move runtime, non-debug "SvTYPE(cv) == SVt_PVCV" check to debug builds per ML post "about FC commit "CV-based slab allocation for ops"" - Perl_croak->Perl_croak_nocontext, remove push arg my_perl instruction - refactor CvPADLIST freeing for provision for future XSUB sub usage of CvPADLIST in a union - in CvOUTSIDE freeing, move NULL assignment so CPU address generation can be reused by compiler
* embed.fnc: cv_name is documentedFather Chrysostomos2014-09-241-0/+2
|
* Stop undef &foo from temporarily anonymisingFather Chrysostomos2014-09-151-0/+4
| | | | | Instead of setting aside the name, calling cv_undef, and then naming the sub anew, just pass a flag to tell cv_undef not to unname it.
* Add cv_set_call_checker_flagsFather Chrysostomos2014-09-151-0/+2
| | | | | | | | This is like cv_set_call_checker, except that it allows the caller to decide whether the call checker needs a GV. Currently the GV flag is recorded, but ck_subr does not do anything with it yet.
* For lexical subs, reify CvGV from CvSTASH and CvNAME_HEKFather Chrysostomos2014-09-151-8/+2
| | | | | From now on, the presence of a name hek implies a GV. Any access to CvGV will cause that implicit GV to be reified.
* Add CVf_LEXICAL flagFather Chrysostomos2014-09-151-0/+5
| | | | | Lexical subs will use this instead of CvNAMED to indicate that the name should not include the package.
* Consistent spaces after dots in perlintern.podFather Chrysostomos2013-12-291-10/+10
|
* perlapi: Consistent spaces after dotsFather Chrysostomos2013-12-291-1/+1
| | | | plus some typo fixes. I probably changed some things in perlintern, too.
* Add a const qualifier for the arg to the S_CvGV inline function in cv.h.Andy Dougherty2013-07-121-2/+2
| | | | | | In addition to correctly describing the behavior of S_CvGV, this avoids warnings in op.c:Perl_report_redefined_cv, where the old (CV *) cast removed the 'const' qualifier. Observed on OpenBSD 5.2 with gcc-4.2.1.
* CvNAME_HEK_setFather Chrysostomos2012-09-151-0/+9
|
* Allow CVs to point to HEKs rather than GVsFather Chrysostomos2012-09-151-1/+21
| | | | This will allow named lexical subs to exist independent of GVs.
* Unify CvDEPTH for formats and subsFather Chrysostomos2012-09-111-1/+0
| | | | | | | | As Dave Mitchell pointed out, while putting the CvDEPTH field for for- mats in the SvCUR slot might save memory for formats, it slows down sub calls because CvDEPTH is used on subs in very hot code paths. Checking the SvTYPE to determine which field to use should not be necessary.
* Move S_CvDEPTHp from cv.h to inline.h; shrink macrosFather Chrysostomos2012-08-211-16/+1
| | | | | This allows us to use assert() inside S_CvDEPTHp, so we no longer need GCC and non-GCC variants of the macro that calls it.
* sv.h: Don’t repeat _XPV_HEADFather Chrysostomos2012-08-171-5/+1
|
* Restore VC++ 6 build on WindowsSteve Hay2012-08-181-0/+4
| | | | | | | | | | | Commits bb02a38feb and 1bd3586145 resulted in VC++ 6 complaining "error C2099: initializer is not a constant" when initializing bodies_by_type in sv.c. Workaround the apparent compiler bug using a patch from Jan Dubois, amended to be compiler-specific as suggested by Nicholas Clark since anonymous unions are not valid C89. Date: Wed, 15 Aug 2012 00:55:06 -0700 Message-ID: <005a01cd7abb$498294e0$dc87bea0$@activestate.com>
* cv.h: macro parenthesesFather Chrysostomos2012-08-061-1/+1
| | | | | I forgot about -- having higher precedence than unary *. And then I forgot to test it, convincing myself I had. :-(
* Add a depth field to formatsFather Chrysostomos2012-08-051-3/+11
| | | | | Instead of lengthening the struct, we can reuse SvCUR, which is cur- rently unused.
* Eliminate PL_OP_SLAB_ALLOCFather Chrysostomos2012-07-121-4/+0
| | | | | | | | | | | | This commit eliminates the old slab allocator. It had bugs in it, in that ops would not be cleaned up properly after syntax errors. So why not fix it? Well, the new slab allocator *is* the old one fixed. Now that this is gone, we don’t have to worry as much about ops leak- ing when errors occur, because it won’t happen any more. Recent commits eliminated the only reason to hang on to it: PERL_DEBUG_READONLY_OPS required it.
* Define cv_forget_slab under PL_OP_SLAB_ALLOCFather Chrysostomos2012-06-291-0/+4
| | | | | Instead of using #ifndef every time we call cv_forget_slab, just define it as a no-op under PL_OP_SLAB_ALLOC.
* Add CVf_SLABBED flagFather Chrysostomos2012-06-291-0/+9
| | | | | This will indicate that a CV has a reference count on, and ownership of, a slab used for allocating ops.
* [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