summaryrefslogtreecommitdiff
path: root/cop.h
Commit message (Collapse)AuthorAgeFilesLines
* replace "define\t" with "define " in most "normal" core files.Yves Orton2023-04-291-2/+2
| | | | | | | | | | | | | | | | | | | The main exceptions being dist/, ext/, and Configure related files, which will be updated in a subsequent commit. Files in the cpan/ directory are also omitted as they are not owned by the core. '#define' has seven characters, so following it with a \t makes it look like '#define ' when it is not, which then frustrates attempts to find where a given define is. If you *know* then you do a git grep -P 'define\s+WHATEVER' but if don't or you forget, you can get very confused trying to find where a given define is located. This fixes all such cases so they actually are 'define WHATEVER' instead. If this patch is getting in your way with blame analysis then view it with the -w option to blame.
* scope.c - improved RCPV support, SAVERCPV SAVEFREERCPVYves Orton2023-03-061-0/+25
| | | | | | | | | | | | | | | | | | | | | | | I misnamed some of the RCPV stuff when it was introduced. The macro which I called SAVERCPVFREE should have been called SAVERCPV, and there should also have been a SAVEFREERCPV macro. Note the naming system for these functions is a bit confusing. SAVEFREERCPV /just/ frees. SAVERCPV saves and restores (eg, its like local). SAVEFREESV is an exception. :-( and it behaves like SAVERCPV. See for instance SAVEPV or similar macros. There also should have been RCPV_REFCNT_dec() and RCPV_REFCNT_inc() macros. There was also missing documentation. This patch should fix all of these issues. Since this functionality has never been released in a production perl it should be fine to do these renames, nothing out there should use these macros yet. I noticed these oversights while fixing Scope::Upper, see also: https://github.com/Perl/perl5/issues/20861 https://rt.cpan.org/Ticket/Display.html?id=146897
* cop.h - fix incorrect var name in comment (PL_in_eval)Yves Orton2022-12-301-1/+1
| | | | | Someone missed an '_' in the name in the comment, the correct name is 'PL_in_eval' not 'PL in_eval'.
* Correct typos as per GH 20435James E Keenan2022-12-291-1/+1
| | | | | | | | | | | | | | | | | | | In GH 20435 many typos in our C code were corrected. However, this pull request was not applied to blead and developed merge conflicts. I extracted diffs for the individual modified files and applied them with 'git apply', excepting four files where patch conflicts were reported. Those files were: handy.h locale.c regcomp.c toke.c We can handle these in a subsequent commit. Also, had to run these two programs to keep 'make test_porting' happy: $ ./perl -Ilib regen/uconfig_h.pl $ ./perl -Ilib regen/regcomp.pl regnodes.h
* op.c - add support for empty RCPV strings.Yves Orton2022-11-231-5/+11
| | | | | | | | | | | | | | | | | Currently we have no need for an empty shared string, but there is no reason it should not be possible. This patch reworks the internals so it is possible to create one without triggering asserts. Currently we don't use this, but it seems reasonable that someone might want it in the future. Under DEBUGGING we will still assert if someone tries to create an empty RCPV unless the flag specifies it should be allowed. At the same time the docs for rcpv_new() have been cleaned up a bit to be more correct and reflect what actually happens inside. This changes things so that the len member of the RCPV structure is always non-zero in a well formed structure by accounting for the null we add to the end explicitly. The RCPV_LEN() macro continues to return the old value (not including the null).
* cop.h - get rid of the STRLEN* stuff from cop_warningsYves Orton2022-11-021-12/+7
| | | | | With RCPV strings we can use the RCPV_LEN() macro, and make this logic a little less weird.
* op.c - use refcounted pv pointers for cop_warningsYves Orton2022-11-011-1/+12
| | | | | | this allows multiple ops to share the same underlying warning bit vector. the vectors are not deduped, however they are efficiently copied and shared.
* cop.h - add support for refcounted filenames in cops under threadsYves Orton2022-11-011-5/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a weird bifurcation of the cop logic around threads. With threads we use a char * cop_file member, without it we use a GV * and replace cop_file with cop_filegv. The GV * code refcounts filenames and more or less efficiently shares the filename amongst many opcodes. However under threads we were simplify copying the filenames into each opcode. This is because in theory opcodes created in one thread can be destroyed in another. I say in theory because as far as I know the core code does not actually do this. But we have tests that you can construct a perl, clone it, and then destroy the original, and have the copy work just fine, this means that opcodes constructed in the main thread will be destroyed in the cloned thread. This in turn means that you can't put SV derived structures into the op-tree under threads. Which is why we can not use the GV * stategy under threads. As such this code adds a new struct/type RCPV, which is a refcounted string using shared memory. This is implemented in such a way that code that previously used a char * can continue to do so, as the refcounting data is located a specific offset before the char * pointer itself. This also allows the len data to embedded "into" the PV, which allows us to expose macros to acces the length of what is in theory a null terminated string. struct rcpv { UV refcount; STRLEN len; char pv[1]; }; typedef struct rcpv RCPV; The struct is sized appropriately on creation in rcpv_new() so that the pv member contains the full string plus a null byte. It then returns a pointer to the pv member of the struct. Thus the refcount and length and embedded at a predictable offset in front of the char *, which means we do not have to change any types for members using this. We provide three operations: rcpv_new(), rcpv_copy() and rcpv_free(), which roughly correspond with newSVpv(), SvREFCNT_inc(), SvREFCNT_dec(), and a handful of macros as well. We also expose SAVERCPVFREE which is similar to SAVEGENERICSV but operates on pv's constructed with rcpv_new(). Currently I have not restricted use of this logic to threaded perls. We simply do not use it in unthreaded perls, but I see no reason we couldn't normalize the code to use this in both cases, except possibly that actually the GV case is more efficient. Note that rcpv_new() does NOT use a hash table to dedup strings. Two calls to rcpv_new() with the same arguments will produce two distinct pointers with their own refcount data. Refcounting the cop_file data was Tony Cook's idea.
* op.c - copy cop_features to the COP inserted into the OP treeTony Cook2022-10-261-0/+2
| | | | | | | | | | | All current features are compile-time, so this hasn't been an issue, but my current implementation of the autovivification issue checks features at runtime, which failed to work correctly if non-bundle features were set. This commit fixes things so that run-time default-on features also work properly, by setting each COP's cop_features to the value of the bits set at the COP's compile time - ie the same approach as cop_hints.
* cop.h: Fix return type in CopLINE()'s apidoc entryTAKAI Kousuke2022-09-291-1/+1
| | | | CopLINE() actually returns `line_t` since a long time ago.
* avoid undefined behavior when calling setjmp()Tony Cook2022-09-081-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | From the standard: "An invocation of the setjmp macro shall appear only in one of the following contexts: - the entire controlling expression of a selection or iteration statement; - one operand of a relational or equality operator with the other operand an integer constant expression, with the resulting expression being the entire controlling expression of a selection or iteration statement; - the operand of a unary ! operator with the resulting expression being the entire controlling expression of a selection or iteration statement; or - the entire expression of an expression statement (possibly cast to void). If the invocation appears in any other context, the behavior is undefined." which does not include assignment. Fixes #20189
* cop.h - show function nameYves Orton2022-09-051-16/+16
| | | | | Also add SAFE_FUNCTION__ which ensures that the value is "UNKNOWN" on platforms that dont support __func__.
* cop.h - fix warnings about i across setjmpYves Orton2022-09-051-2/+7
| | | | We can just do the count before and after.
* cop.h - show a bit more debug out in JMPENV macros, and minor fixesYves Orton2022-08-311-12/+16
| | | | | | * Show the return from JMPENV_PUSH(). * use (v) consistently. * Line up backslashes.
* replace (0+(pointer)) with casts to the pointer typeTony Cook2022-07-181-3/+3
| | | | | Old versions (3.3.6) of gcc allowed assignment to such casts, but this is no longer an issue.
* cop.h: fix je_mustcatch code comment.David Mitchell2022-06-201-1/+1
| | | | | The comment explaining what the je_mustcatch field does was incorrectly updated in 1999! Change it back to what it was originally.
* s/JUMPENV/JMPENV/gDavid Mitchell2022-06-201-3/+3
| | | | | | Although one of the macros associated with the JMPENV facility is inconsistently called JMPENV_JUMP(), fix all code comments and debugging output to eliminate any references to JUMPENV.
* Follow on to 6d21409fd4b749511b9ec73e2dbaaff513f6eae8Karl Williamson2022-06-181-11/+11
| | | | | This was meant to be a part of the previous commit, but somehow got omitted.
* Change autodoc flagKarl Williamson2022-06-141-4/+4
| | | | | | This should be being used only in core, as its only use is for autodoc. Change the flag name to be more mnemonic, freeing up its current name for another use.
* cophh_fetch: Make sure doesn't pass eroneous flagsKarl Williamson2022-05-271-8/+13
| | | | Only one flag bit is valid; this clears all others.
* perlapi: Consolidate CopLABEL* entriesKarl Williamson2022-05-081-10/+8
| | | | Making these a single entry makes perlapi more concise.
* perlapi: Consolidate cop_hints_fetch* entriesKarl Williamson2022-05-081-35/+26
| | | | | | | | | | | | Making these a single entry makes perlapi more concise with less repetition, and clarifies the similarities and distinctions between the variant forms. Doing this showed me that some details had been glossed over, which this commit adds. This commit also changes the formal parameter name for one macro from "keypv" to "key" so all variants use the same names.
* perlapi: Consolidate cop_hints_exists* entriesKarl Williamson2022-05-081-34/+26
| | | | | | | | | | | | Making these a single entry makes perlapi more concise with less repetition, and clarifies the similarities and distinctions between the variant forms. Doing this showed me that some details had been glossed over, which this commit adds. This commit also changes the formal parameter name for one macro from "keypv" to "key" so all variants use the same names.
* perlapi: Consolidate cophh_exists* entriesKarl Williamson2022-05-081-34/+22
| | | | | | | | | | | | Making these a single entry makes perlapi more concise with less repetition, and clarifies the similarities and distinctions between the variant forms. Doing this showed me that some details had been glossed over, which this commit adds. This commit also changes the formal parameter name for one macro from "keypv" to "key" so all variants use the same names.
* perlapi: Consolidate cophh_fetch* entriesKarl Williamson2022-05-081-36/+27
| | | | | | | | | | | | Making these a single entry makes perlapi more concise with less repetition, and clarifies the similarities and distinctions between the variant forms. Doing this showed me that some details had been glossed over, which this commit adds. This commit also changes the formal parameter name for one macro from "keypv" to "key" so all variants use the same names.
* perlapi: Consolidate cophh_delete* entriesKarl Williamson2022-05-081-36/+26
| | | | | | | | | | | | Making these a single entry makes perlapi more concise with less repetition, and clarifies the similarities and distinctions between the variant forms. Doing this showed me that some details had been glossed over, which this commit adds. This commit also changes the formal parameter name for one macro from "keypv" to "key" so all variants use the same names.
* perlapi: Consolidate cophh_store* entriesKarl Williamson2022-05-081-41/+31
| | | | | | | | | | | | Making these a single entry makes perlapi more concise with less repetition, and clarifies the similarities and distinctions between the variant forms. Doing this showed me that some details had been glossed over, which this commit adds. This commit also changes the formal parameter name for one macro from "keypv" to "key" so all variants use the same names.
* Ensure that forbidden control flow messages about finally blocks say ↵Paul "LeoNerd" Evans2022-01-201-0/+4
| | | | "finally" and not "defer"
* correct the comment distinguishing between threaded/unthreaded cop macrosTony Cook2021-11-151-1/+4
|
* Add CopFILEAVn() and use it when cleaning up COP pointersTony Cook2021-11-151-2/+7
| | | | | | | | | | | | | | On threaded builds CopFILEAV() calls gv_fetchfile(), which always created the *{"::_<filenamehere"} glob, so the attempted clean up here could recreate the glob, even if it has already been removed when cleaning up a string eval. To avoid this, add CopFILEAVn() that never creates the glob, nor the AV so that the clean up never adds new objects. This change makes the check for PL_phase unnecessary, but that check is much cheaper than the call for gv_fetchfile_flags() that the macro hides, so retain the check.
* Remove NetWare supportDagfinn Ilmari Mannsåker2021-10-081-12/+3
| | | | The build has been broken since 2009.
* Create `defer` syntax and `OP_PUSHDEFER` opcodePaul "LeoNerd" Evans2021-08-251-0/+1
| | | | | | | | | | | | | | | Adds syntax `defer { BLOCK }` to create a deferred block; code that is deferred until the scope exits. This syntax is guarded by use feature 'defer'; Adds a new opcode, `OP_PUSHDEFER`, which is a LOGOP whose `op_other` field gives the start of an optree to be deferred until scope exit. That op pointer will be stored on the save stack and invoked as part of scope unwind. Included is support for `B::Deparse` to deparse the optree back into syntax.
* CxLVAL(): Save a '&' instr by casting to U8Karl Williamson2021-07-301-1/+1
|
* Rename G_ARRAY to G_LIST; provide back-compat when not(PERL_CORE)Paul "LeoNerd" Evans2021-06-021-4/+9
|
* Base *.[ch] files: Replace leading tabs with blanksMichael G Schwern2021-05-311-196/+196
| | | | | | | This is a rebasing by @khw of part of GH #18792, which I needed to get in now to proceed with other commits. It also strips trailing white space from the affected files.
* Add cop_hints_exists_*Leon Timmermans2021-03-151-0/+52
| | | | | These functions allow one to check for the existence of keys in the hints hash of a specific cop.
* Add cophh_exists_* functionsLeon Timmermans2021-03-151-0/+53
| | | | | These functions allow one to check for the existence of keys in a hints hash.
* Initial attempt at feature 'try'Paul "LeoNerd" Evans2021-02-041-1/+4
| | | | | | | | | * Add feature, experimental warning, keyword * Basic parsing * Basic implementation as optree fragment See also https://github.com/Perl/perl5/issues/18504
* Rename CxTRYBLOCK() to CxEVALBLOCK()Paul "LeoNerd" Evans2021-02-041-3/+7
| | | | | | CxTRYBLOCK would be confusing when we add a real CxTRY for try/catch Also renames the associated CXp_TRYBLOCK flag to CXp_EVALBLOCK
* Document various CopSTASHfoo functionsKarl Williamson2021-01-031-0/+17
|
* Document various CopFILEfoo functionsKarl Williamson2020-11-291-0/+26
|
* cop.h: Extend core-only portionKarl Williamson2020-11-291-1/+3
| | | | | This encloses some #defines in a PERL_CORE section, as their only use is in the macro immediately following, already confined to core.
* Various COPHH macros have a non-const parameterKarl Williamson2020-11-201-6/+6
| | | | | The pod says these are const, but they won't compile if actually called with one.
* Document PERL_SIKarl Williamson2020-11-111-0/+6
|
* autodoc.pl: Enhance apidoc_section featureKarl Williamson2020-11-061-3/+3
| | | | | | | | | | | This feature allows documentation destined for perlapi or perlintern to be split into sections of related functions, no matter where the documentation source is. Prior to this commit the line had to contain the exact text of the title of the section. Now it can be a $variable name that autodoc.pl expands to the title. It still has to be an exact match for the variable in autodoc, but now, the expanded text can be changed in autodoc alone, without other files needing to be updated at the same time.
* Remove redundant documentationKarl Williamson2020-09-051-29/+0
| | | | | | Now that we can get automatic links in perlapi, remove the redundant stripped-down documentation that goes there in favor of the better documentation in perlcall.
* Document IN_PERL_(RUN|COMPILE)TIMEKarl Williamson2020-09-051-3/+12
|
* Reorganize perlapiKarl Williamson2020-09-041-8/+0
| | | | | This uses a new organization of sections that I came up with. I asked for comments on p5p, but there were none.
* Change some =head1 to apidoc_section linesKarl Williamson2020-09-041-2/+2
| | | | | apidoc_section is slightly favored over head1, as it is known only to autodoc, and can't be confused with real pod.
* cop.h: remove obsolete commentDavid Mitchell2020-08-281-6/+0
| | | | | The macro which the comment describes is long gone, but the comment got missed.