summaryrefslogtreecommitdiff
path: root/intrpvar.h
Commit message (Collapse)AuthorAgeFilesLines
* replace all instances of PERL_IMPLICIT_CONTEXT with MULTIPLICITYTomasz Konojacki2021-06-091-2/+2
| | | | | | | | | | | | Since the removal of PERL_OBJECT (acfe0abcedaf592fb4b9cb69ce3468308ae99d91) PERL_IMPLICIT_CONTEXT and MULTIPLICITY have been synonymous and they're being used interchangeably. To simplify the code, this commit replaces all instances of PERL_IMPLICIT_CONTEXT with MULTIPLICITY. PERL_IMPLICIT_CONTEXT will stay defined for compatibility with XS modules.
* perlapi: Fix grammarKarl Williamson2021-04-211-2/+2
|
* intrpvar.h: Add clarifying commentKarl Williamson2021-03-101-0/+2
|
* style: Detabify indentation of the C code maintained by the core.Michael G. Schwern2021-01-171-19/+19
| | | | | | | | | | | This just detabifies to get rid of the mixed tab/space indentation. Applying consistent indentation and dealing with other tabs are another issue. Done with `expand -i`. * vutil.* left alone, it's part of version. * Left regen managed files alone for now.
* Fix broken PERL_MEM_LOG under threadsKarl Williamson2020-12-191-0/+6
| | | | | | | | | | | | | This fixes GH #18341 There are problems with getenv() on threaded perls wchich can lead to incorrect results when compiled with PERL_MEM_LOG. Commit 0b83dfe6dd9b0bda197566adec923f16b9a693cd fixed this for some platforms, but as Tony Cook, pointed out there may be standards-compliant platforms that that didn't fix. The detailed comments outline the issues and (complicated) full solution.
* perlapi: PL_sv_yes and kin are read-onlyKarl Williamson2020-11-251-5/+6
|
* perlapi: Remove per-thread section; move to real scnsKarl Williamson2020-11-251-5/+67
| | | | | Instead of having a grab bag section of all interpreter variables, move their documentation to the section that they actually fit under.
* perlapi: Move PL_dowarn to Warnings sectionKarl Williamson2020-11-251-0/+6
|
* perlapi: PL_runops is documented in perlgutsKarl Williamson2020-11-061-8/+0
|
* intrpvar.h: Don't define an undef symbolKarl Williamson2020-11-021-1/+3
| | | | | This symbol needs MULTIPLICTY for its target to actually be defined. Discovered by Devel::PPPort
* Document PL_SvKarl Williamson2020-09-221-1/+13
|
* Change some =head1 to apidoc_section linesKarl Williamson2020-09-041-1/+1
| | | | | apidoc_section is slightly favored over head1, as it is known only to autodoc, and can't be confused with real pod.
* Add missing removal of FCRYPT macro use after rebaseTodd Rinaldo2020-07-301-6/+0
| | | | Fixup for #17624
* Fixing intrpvar.h from recent mergeNicolas R2020-07-301-3/+0
| | | | | This was broken with the change from a04ef3ff46f2526da1484bdd80995415ac7e1969
* Remove obsolete FCRYPT ifdefs and associated PL_cryptseen (#17624)Richard Leach2020-07-301-0/+3
| | | Co-authored-by: Karl Williamson <khw@cpan.org>
* intrpvar.h -reorder PERLVARS to close x86-64 alignment holesRichard Leach2020-07-301-28/+30
|
* Remove PERL_GLOBAL_STRUCTDagfinn Ilmari Mannsåker2020-07-201-2/+0
| | | | | | | | This was originally added for MinGW, which no longer needs it, and only still used by Symbian, which is now removed. This also leaves perlapi.[ch] empty, but we keep the header for CPAN backwards compatibility.
* Make PL_utf8_foldclosures interpreter levelKarl Williamson2020-06-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | This resolves #17774. This ticket is because the fixes in GH #17154 failed to get every case, leaving this one outlier to be fixed by this commit. The text in https://github.com/Perl/perl5/issues/17154 gives extensive details as to the problem. But briefly, in an attempt to speed up interpreter cloning, I moved certain SVs from interpreter level to global level in e80a0113c4a8036dfb22aec44d0a9feb65d36fed (v5.27.11, March 2018). This was doable, we thought, because the content of these SVs is constant throughout the life of the program, so no need to copy them when cloning a new interpreter or thread. However when an interpreter exits, all its SVs get cleaned up, which caused these to become garbage in applications where another interpreter remains running. This circumstance is rare enough that the bug wasn't reported until September 2019, #17154. I made an initial attempt to fix the problem, and closed that ticket, but I overlooked one of the variables, which was reported in #17774, which this commit addresses. Effectively the behavior is reverted to the way it was before e80a0113c4a8036dfb22aec44d0a9feb65d36fed.
* optimize sort by inlining comparison functionsTomasz Konojacki2020-03-091-2/+0
| | | | | | | | This makes special-cased forms such as sort { $b <=> $a } even faster. Also, since this commit removes PL_sort_RealCmp, it fixes the issue with nested sort calls mentioned in gh #16129
* Fixup POSIX::mbtowc, wctombKarl Williamson2020-02-191-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit enhances these functions so that on threaded perls, they use mbrtowc and wcrtomb when available, making them thread safe. The substitution isn't completely transparent, as no effort is made to hide any differences in errno setting upon error. And there may be slight differences in edge case behavior on some platforms. This commit also changes the behaviors so that they take a scalar parameter instead of a char *, and this might be 'undef' or not be forceable into a valid PV. If not a PV, the functions initialize the shift state. Previously the shift state was always reinitialized with every call, which meant these could not work on locales with shift states. In addition, there were several issues in mbtowc and wctomb that this commit fixes. mbtowc and wctomb, when used, are now run with a semaphore. This avoids races if called at the same time in another thread. The returned wide character from mbtowc() could well have been garbage. The final parameter to mbtowc is now optional, as passing an SV allows us to determine the length without the need for an extra parameter. It is now used only to restrict the parsing of the string to shorter than the actual length. wctomb would segfault if the string parameter was shared or hadn't been pre-allocated with a string of sufficient length to hold the result.
* POSIX::mblen() Make thread-safe; allow shift state controlKarl Williamson2020-02-191-0/+4
| | | | | | | | | | | | | | | | | | | This commit changes the behavior so that it takes a scalar parameter instead of a char *, and thus might not be forceable into a valid PV. When not a PV, the shift state is reinitialized, like calling mblen with a NULL first parameter. Previously the shift state was always reinitialized with every call, which meant this could not work on locales with shift states. This commit also changes to use mbrlen() on threaded perls transparently (mostly), when available, to achieve thread-safe operation. It is not completely transparent because mbrlen (under the very rare stateful locales) returns a different value when it's resetting the shift state. It also may set errno differently upon errors, and no effort is made to hide that difference. Also mbrlen on some platforms can handle partial characters. [perl #133928] showed that someone was having trouble with shift states.
* Note that certain flags are documentedKarl Williamson2019-12-171-0/+5
| | | | | | | | | | | This is useful in Devel::PPPort for generating its api-info data. That useful feature of D:P allows someone to find out what was the first release of Perl to have a function, macro, or flag. And whether using ppport.h backports it further. I went through apidoc.pod and looked for flags that were documented but that D:P didn't know about. This commit adds entries for each so that D:P can find them.
* Revert "Move PL_check to the interp vars to fix threading issues"Tony Cook2019-12-161-1/+0
| | | | | and the associated commits, at least until a way to make wrap_op_checker() work is available.
* Move PL_check to the interp vars to fix threading issuesStefan Seifert2019-12-121-0/+1
| | | | Fixes issue #14816
* Move regex global variables to interpreter levelKarl Williamson2019-11-261-0/+35
| | | | | | | | | | | | | | | | | | | | | | | This is part of fixing gh #17154 This scenario from the ticket (https://github.com/Perl/perl5/issues/17154#issuecomment-558877358) shows why this fix is necessary: main interpreter initializes PL_AboveLatin1 to an SV it owns loads threads::lite and creates a new thread/interpreter which initializes PL_AboveLatin1 to a SV owned by the new interpreter threads::lite child interpreter finishes, freeing all of its SVs, PL_AboveLatin1 is now invalid main interpreter uses a regexp that relies on PL_AboveLatin1, dies horribly. By making these interpreter level variables, this is avoided. There is extra copying, but it is just the SV headers, as the real data is kept as static C arrays.
* add explicit 1-arg and 3-arg sig handler functionsDavid Mitchell2019-11-181-1/+5
| | | | | | | Currently, whether the OS-level signal handler function is declared as 1-arg or 3-arg depends on the configuration. Add explicit versions of these functions, principally so that POSIX.xs can call which version of the handler it wants regardless of configuration: see next commit.
* Remove swashes from coreKarl Williamson2019-11-061-8/+0
| | | | Also references to the term.
* intrpvar.h: Add variable for use in tr///Karl Williamson2019-11-061-0/+2
| | | | This is part of this branch of changes.
* Rmv more deprecated characlassify/case change macrosKarl Williamson2019-10-311-1/+0
| | | | These were missed by 059703b088f44d5665f67fba0b9d80cad89085fd.
* PATCH: [perl #134405] Compiler warnings in bleadKarl Williamson2019-09-121-0/+4
| | | | | | | | | | | | | | This was caused by functions that should have been deprecated all along, and now are. But they are still called in places. In most instances one deprecated function is a wrapper for another. In one instance, the calling of the function is to just make sure that mathoms.o gets linked to. The solution adopted here, some of which was suggested by Tony Cook, is to use #pragmas to silence the warnings. By doing this around the entirety of mathoms.c, future issues will most likely be avoided. And there are unlikely to enough future cases outside of mathoms to cause a problem.
* Remove redundant documentation for PL_parserKarl Williamson2019-09-021-9/+0
|
* (perl #132777) APIify and document PL_perl_destruct_levelTony Cook2019-08-081-2/+22
| | | | | This is documented in perlembed. It's only rarely used on CPAN but it's pretty basic.
* (perl #132777) document (sort of) and APIify PL_runopsTony Cook2019-08-081-0/+8
| | | | | | | This is documented in perlguts in such a way that it appears be effectively API, so APIify it. It's used on CPAN in a small number of modules.
* (perl #132777) document and APIify PL_parserTony Cook2019-08-081-0/+8
| | | | | Used in a few places on CPAN, either to check or modify the compilation error count, or to do a little parsing via bufptr.
* (perl #132777) document and APIify PL_defgvTony Cook2019-08-081-0/+8
| | | | This is used occasionally on CPAN, typically to access $_.
* (perl #132777) APIify and document PL_curstashTony Cook2019-08-081-0/+7
| | | | | | per leont: I can't think of any reason not to make PL_curstash API, it's both common, useful, simple, and highly unlikely to ever need change.
* (perl #132777) document and add PL_curcop to the APITony Cook2019-08-081-0/+9
| | | | | | PL_curcop is used fairly widely on CPAN, mostly to get the current line number and file, to check lexical hints, or to check the stash.
* (perl #132777) document PL_exit_flagsTony Cook2019-08-081-0/+31
| | | | | PL_exit_flags is referred to in perlembed, perldiag and two perldeltas, so APIify and document it.
* Add some comments around taintingKarl Williamson2019-05-241-1/+1
|
* intrpvar.h: Add emphasis to commentKarl Williamson2019-04-181-1/+1
|
* fix thread issue with PERL_GLOBAL_STRUCTDavid Mitchell2019-02-191-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | The MY_CXT subsystem allows per-thread pseudo-static data storage. Part of the implementation for this involves each XS module being assigned a unique index in its my_cxt_index static var when first loaded. Because PERL_GLOBAL_STRUCT bans any static vars, under those builds there is instead a table which maps the MY_CXT_KEY identifying string to index. Unfortunately, this table was allocated per-interpreter rather than globally, meaning if multiple threads tried to load the same XS module, crashes could ensue. This manifested itself in failures in ext/XS-APItest/t/keyword_plugin_threads.t The fix is relatively straightforward: allocate PL_my_cxt_keys globally rather than per-interpreter. Also record the size of this struct in a new var, PL_my_cxt_keys_size, rather than doing double duty on PL_my_cxt_size.
* Add variable for if the current UTF-8 locale is TurkicKarl Williamson2019-02-051-0/+1
| | | | It currently is always set false, until later in this series of commits.
* Make global two interpreter variablesKarl Williamson2018-07-141-4/+0
| | | | | These variables are constant, once initialized, through the life of a program, so having them be per instance is a waste of time and space
* Use compiled-in C structure for inverted case foldsKarl Williamson2018-03-311-4/+0
| | | | | | | | | | This commit changes to use the C data structures generated by the previous commit to compute what characters fold to a given one. This is used to find out what things should match under /i. This now avoids the expensive start up cost of switching to perl utf8_heavy.pl, loading a file from disk, and constructing a hash from it.
* Remove obsolete variablesKarl Williamson2018-03-311-1/+0
| | | | | These were for when some of the Posix character classes were implemented as swashes, which is no longer the case, so these can be removed.
* Use charnames inversion listsKarl Williamson2018-03-311-2/+0
| | | | | | | | This commit makes the inversion lists for parsing character name global instead of interpreter level, so can be initialized once per process, and no copies are created upon new thread instantiation. More importantly, this is another instance where utf8_heavy.pl no longer needs to be loaded, and the definition files read from disk.
* Move case change invlists from interpreter to globalKarl Williamson2018-03-261-6/+0
| | | | | These are now constant through the life of the program, so don't need to be duplicated at each new thread instantiation.
* Move UTF-8 case changing data into coreKarl Williamson2018-03-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this commit, if a program wanted to compute the case-change of a character above 0xFF, the C code would switch to perl, loading lib/utf8heavy.pl and then read another file from disk, and then create a hash. Future references would use the hash, but the start up cost is quite large. There are five case change types, uc, lc, tc, fc, and simple fc. Only the first encountered requires loading of utf8_heavy, but each required switching to utf8_heavy, and reading the appropriate file from disk. This commit changes these functions to use compiled-in C data structures (inversion maps) to represent the data. To look something up requires a binary search instead of a hash lookup. An individual hash lookup tends to be faster than a binary search, but the differences are small for small sizes. I did some benchmarking some years ago, (commit message 87367d5f9dc9bbf7db1a6cf87820cea76571bf1a) and the results were that for fewer than 512 entries, the binary search was just as fast as a hash, if not actually faster. Now, I've done some more benchmarks on blead, using the tool benchmark.pl, which wasn't available back then. The results below indicate that the differences are minimal up through 2047 entries, which all Unicode properties are well within. A hash, PL_foldclosures, is still constructed at runtime for the case of regular expression /i matching, and this could be generated at Perl compile time, as a further enhancement for later. But reading a file from disk is no longer required to do this. ======================= benchmarking results ======================= Key: Ir Instruction read Dr Data read Dw Data write COND conditional branches IND indirect branches _m branch predict miss _m1 level 1 cache miss _mm last cache (e.g. L3) miss - indeterminate percentage (e.g. 1/0) The numbers represent raw counts per loop iteration. "\x{10000}" =~ qr/\p{CWKCF}/" swash invlist Ratio % fetch search ------ ------- ------- Ir 2259.0 2264.0 99.8 Dr 665.0 664.0 100.2 Dw 406.0 404.0 100.5 COND 406.0 405.0 100.2 IND 17.0 15.0 113.3 COND_m 8.0 8.0 100.0 IND_m 4.0 4.0 100.0 Ir_m1 8.9 17.0 52.4 Dr_m1 4.5 3.4 132.4 Dw_m1 1.9 1.2 158.3 Ir_mm 0.0 0.0 100.0 Dr_mm 0.0 0.0 100.0 Dw_mm 0.0 0.0 100.0 These were constructed by using the file whose contents are below, which uses the property in Unicode that currently has the largest number of entries in its inversion list, > 1600. The test was run on blead -O2, no debugging, no threads. Then the cut-off boundary was changed from 512 to 2047 for when we use a hash vs an inversion list, and the test run again. This yields the difference between a hash fetch and an inversion list binary search ===================== The benchmark file is below =============== no warnings 'once'; my @benchmarks; push @benchmarks, 'swash' => { desc => '"\x{10000}" =~ qr/\p{CWKCF}/"', setup => 'no warnings "once"; my $re = qr/\p{CWKCF}/; my $a = "\x{10000}";', code => '$a =~ $re;', }; \@benchmarks;
* Don't include interpreter variable unless usedKarl Williamson2018-03-161-0/+2
| | | | | | | This adds an #ifdef around this variable, so that it isn't defined unless used. Spotted by Daniel Dragan.
* Make Unicode data structures globalKarl Williamson2018-03-141-24/+0
| | | | | | | | | | These structures are read-only, use const C strings, and are truly global, so no need to have them be interpreter level. This saves duplicating and freeing them as threads come and go. In doing this, I noticed that not every one was properly being copied/deallocated, so this fixes some potential unreported bugs, and leaks.