summaryrefslogtreecommitdiff
path: root/embed.h
Commit message (Collapse)AuthorAgeFilesLines
* regcomp.c: Extract out code into a separate functionKarl Williamson2014-01-221-0/+1
| | | | This is in preparation for it to be called from a 2nd place.
* sv_buf_to_rw can be staticFather Chrysostomos2014-01-171-1/+3
| | | | | sv_buf_to_ro needs to be non-static because op.c uses it, but sv_buf_to_rw is only called from sv.c.
* PERL_DEBUG_READONLY_COWFather Chrysostomos2014-01-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | Make perls compiled with -Accflags=-DPERL_DEBUG_READONLY_COW to turn COW buffer violations into crashes. We do this using mmap to allocate memory and then mprotect to mark memory as read-only when buffers are shared. We have to do this at the safesysmalloc level, because some code does SvPV_set with buffers it allocates on its own via safemalloc(). Unfortunately this means many things are allocated using mmap that will never be marked read-only, slowing things down considerably, but I see no other way. Because munmap and mprotect need to know the length, we use the existing sTHX/perl_memory_debug_header mechanism used already by PERL_TRACK_MEMPOOL and store the size there (as PERL_POISON already does when PERL_TRACK_MEMPOOL is enabled). perl_memory_debug_header is a struct positioned at the beginning of every allocated buffer, for tracking things.
* IDStart and IDCont no longer go out to diskKarl Williamson2014-01-091-1/+1
| | | | | | | These are the base names for various macros used in parsing identifiers. Prior to this patch, parsing a code point above Latin1 caused loading disk files. This patch causes all the information to be compiled into the Perl binary.
* isWORDCHAR_uni(), isDIGIT_utf8() etc no longer go out to diskKarl Williamson2014-01-091-1/+1
| | | | | | | Previous commits in this series have caused all the POSIX classes to be completely specified at C compile time. This allows us to revise the base function used by all these macros to use these definitions, avoiding reading them in from disk.
* Move initialization of PL_XPosix_ptrs[] to perl.cKarl Williamson2014-01-091-1/+3
| | | | | | | This was performed unconditionally in regcomp.c. However, future commits will use this from other code. Almost all (but not completely all) Perl code uses regular expressions, so only rarely will this small amount of initialization be performed when it currently isn't.
* regexec.c: Guard against malformed UTF-8 in [...]Karl Williamson2014-01-011-1/+1
| | | | | | | | | The code that handles bracketed character classes assumed that the string being matched against did not have the too-short malformation; this could lead to reading beyond-the-end-of-buffer. (It did check for other malformations.) This is solved by changing the function that operates on bracketed character classes to take and use an extra parameter, the actaul buffer end.
* Remove no-longer used inversion list functionKarl Williamson2013-12-311-1/+0
| | | | | | | | | | | The function _invlist_invert_prop() is hereby removed. The recent changes to allow \p{} to match above-Unicode means that no special handling of properties need be done when inverting. This function was accessible to XS code that cheated by using #defines to pretend it was something it wasn't, but it also has been marked as subject to change since its inception, and never appeared in any documentation.
* Change format of mktables output binary property tablesKarl Williamson2013-12-311-0/+1
| | | | | | | | | mktables now outputs the tables for binary properties as inversion lists, with a size as the first element. This means simpler handling of these tables in the core, including removal of an entire pass over them (it was done just to get the size). These tables are marked as for internal use by the Perl core only, so their format is changeable at will.
* Purge sfio support, which has been broken for a decade.Nicholas Clark2013-12-271-1/+1
| | | | | | | | | | | The last Perl release that built with -Dusesfio was v5.8.0, and even that failed many regression tests. Every subsequent release fails to build, and in the decade that has passed we have had no bug reports about this. So it's safe to delete all the code. The Configure related code will be purged in a subsequent commit. 2 references to sfio intentionally remain in fakesdio.h and nostdio.h, as these appear to be for using its stdio API-compatibility layer.
* [perl #115736] fix undocumented param from newATTRSUB_flagsDaniel Dragan2013-12-231-2/+1
| | | | | flags param was poorly designed and didn't have a formal api. Replace it with the bool it really is. See #115736 for details.
* mg.c: Extract code into a function.Karl Williamson2013-11-261-0/+1
| | | | | This is in preparation for the same code to be used in additional places. There should be no logic changes.
* [perl #120463] s/// and tr/// with wide delimitersFather Chrysostomos2013-11-141-1/+1
| | | | | | | | | | | | | | | | | | | | | $ perl -Mutf8 -e 's αaαα' Substitution replacement not terminated at -e line 1. What is happening is that the first scan goes past the delimiter at the end of the pattern. Then a single byte is compared (the previous character against the first byte of the opening delimiter) to see whether the parser needs to step back one byte before scanning the second part. That means you can do the equivalent of s/foo/|bar|g if / is replaced with a wide character: $ perl -l -Mutf8 -e '$_ = "a"; s αaα|b|; print' b This commit fixes it by giving toke.c:S_scan_str an extra parameter, so it can tell the callers that need this (scan_subst and scan_trans) where to start scanning the replacement.
* fix multi-eval of Perl_custom_op_xop in XopENTRYDaniel Dragan2013-11-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 1830b3d9c8 introduced a flaw where XopENTRY calls Perl_custom_op_xop twice to retrieve the same XOP *. This is inefficient and causes extra machine code. Since I found no CPAN or upstream=blead usage of Perl_custom_op_xop, and its previous docs say it isn't 100% public, it is being converted to a macro. Most usage of Perl_custom_op_xop is to conditionally fetch a member of the XOP struct, which was previously implemented by XopENTRY. Move the XopENTRY logic and picking defaults to an expanded version of Perl_custom_op_xop. The union allows Perl_custom_op_get_field to return its result in 1 register, since the union is similar to a void * or IV, but with the machine code overhead of casting, if any, being done in the callee (Perl_custom_op_get_field), not the caller. Perl_custom_op_get_field can also return the XOP * without looking inside it to implement Perl_custom_op_xop. XopENTRYCUSTOM is a wrapper around Perl_custom_op_get_field with XopENTRY-like usage. XopENTRY is used by the OP_* macros, which are heavily used (but rarely called, since custom ops are rare) by Perl lang warnings system. The vararg warning arguments are usually evaluted no matter if the warning will be printed to STDERR or not. Since some people like to ignore warnings or run no strict; and warnings branches are frequent in pp_*, it is beneficial to make the OP_* macros smaller in machine code. The design of Perl_custom_op_get_field supports these goals. This commit does not pass judgement on Ben Morrow's unclear public or private API designation of Perl_custom_op_xop, and whether Perl_custom_op_xop should deprecated and removed from public API. It was trivial to leave a form of Perl_custom_op_xop in the new design. XOPe enums are identical to XOPf constants so no conversion has to be done between the field selector parameter and the field flag to test in machine code. ASSUME and NOT_REACHED are being introduced. The closest to the 2 previously was "assert(0)". Perl has not used ASSUME or CC specific versions of it before. Clang, GCC >= 4.5, and Visual C are supported. For completeness, ARMCC's __promise was added, but Perl is not known to have any support for ARMCC by this commiter. This patch is part of perl #115032.
* Make &CORE::exit respect vmsish exit hintFather Chrysostomos2013-11-081-1/+0
| | | | | | | | | by removing the hint from the exit op itself and just having pp_exit look in the cop hint hash, where it is already stored (as a result of having been in %^H at compile time). &CORE:: subs intentionally lack a nextstate op (cop) so they can see the hints in the caller’s nextstate op.
* Fix &CORE::exit/die under vmsish "hushed"Father Chrysostomos2013-11-081-1/+0
| | | | | | | This commit makes them behave like exit and die without the ampersand by moving the OPpHUSH_VMSISH hint from exit/die op to the current statement (nextstate/cop) instead. &CORE:: subs intentionally lack a nextstate op, so they can see the hints in the caller’s nextstate op.
* Fix qx, `` and <<`` overridesFather Chrysostomos2013-11-061-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This resolves two RT tickets: • #115330 is that qx and `` overrides do not support interpolation. • #119827 is that <<`` does not support readpipe overrides at all. The obvious fix for #115330 fixes #119827 at the same time. When quote-like operators are parsed, after the string has been scanned S_sublex_push is called, which decides which of two paths to follow: 1) For things not requiring interpolation, the string is passed to tokeq (originally called q, it handles double backslashes and back- slashed delimiters) and returned to the parser immediately. 2) For anything that interpolates, the lexer enters a special inter- polation mode (LEX_INTERPPUSH) and goes through a more complex sequence over the next few calls (e.g., qq"a.$b.c" is turned into ‘stringify ( "a." . $ b . ".c" )’). When commit e3f73d4ed (Oct 2006, perl 5.10) added support for overrid- ing `` and qx with a readpipe sub, it did so by creating an entersub op in toke.c and making S_sublex_push follow path no. 1, taking the result if tokeq and inserting it into the already-constructed op tree for the sub call. That approach caused interpolation to be skipped when qx or `` is overridden. Furthermore it didn’t touch <<`` at all. The easiest solution is to let toke.c follow its normal path and create a backtick op (instead of trying to half-intercept it), and to deal with override lookup afterwards in ck_backtick, the same way require overrides are handled. Since <<`` also turns into a backtick op, it gets handled too that way.
* Split ck_open into two functionsFather Chrysostomos2013-11-061-0/+1
| | | | | | It is used for two op types, but only a small portion of it applies to both, so we can put that in a static function. This makes the next commit easier.
* Put common override code into gv_overrideFather Chrysostomos2013-11-061-0/+1
| | | | | | | | | | | | When I moved the three occurrences of this code in op.c into a static function, I did not realise at the time that it also occurred thre etimes in toke.c. So now it is in a new non-static function in gv.c. Only two of the instances in toke.c could be changed to use this func- tion, as the otherwise is a little different. I couldn’t see a simple way of factoring its requirements in.
* Move the function to set $^X to its own filePeter Martini2013-11-041-0/+1
| | | | | | | This also moves the indirect dependency on stdbool.h to its own file, rather than being pulled in for all of perl.c, for those cases where one may want to test using other definitions of bool.
* Make mro code pass precomputed hash valuesFather Chrysostomos2013-11-041-1/+1
| | | | | | | | where possible This involved adding hv_fetchhek and hv_storehek macros and changing S_mro_clean_isarev to accept a hash parameter and expect HVhek_UTF8 instead of SVf_UTF8.
* [perl #119797] Fix if/else in lvalue subFather Chrysostomos2013-10-231-1/+1
| | | | | | | | | | | | | | | | | When if/else/unless is the last thing in an lvalue sub, the lvalue context is not always propagated properly and scope exit tries to copy things, including arrays, resulting in ‘Bizarre copy of ARRAY’. This commit fixes the bizarre copy by flagging any leave op that is part of an lvalue sub’s return sequence, using the OPpLEAVE flag added for this purpose in the previous commit. Then pp_leave uses that flag to avoid copying return values, but protects them via the mortals stack just like pp_leavesublv (actually pp_ctl.c:S_return_lvalues). For ‘if’ and ‘unless’ without ‘else’, the lvalue context was not being propagated, resulting in arrays’ getting flattened despite the lvalue context. op_lvalue_flags in op.c needed to handle AND and OR ops, which ‘if’ and ‘unless’ compile to, to make this work.
* Adding a prototype attribute.Peter Martini2013-10-161-1/+2
| | | | | | | | | | | | | | | This attribute adds an additional way of declaring a prototype for a sub, making sub foo($$) and sub foo : prototype($$) equivalent. The intent is to keep the functionality of prototypes while allowing other modules to use the syntactic space it currently occupies for other purposes. The attribute is supported in attributes.xs to allow attributes::->import to work, but if its defined inline via something like sub foo : prototype($$) {}, it will not call out to the attributes module. For: RT #119251
* regcomp.c: Remove unused parameter in static functionKarl Williamson2013-09-241-1/+1
| | | | | This parameter is no longer used, since a few commits ago in this series.
* Teach regex optimizer to handle above-Latin1Karl Williamson2013-09-241-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until this commit, the regular expression optimizer has essentially punted on above-Latin1 code points. Under some circumstances, they would be taken into account, more or less, but often, the generated synthetic start class would end up matching all above-Latin1 code points. With the advent of inversion lists, it becomes feasible to actually fully handle such code points, as inversion lists are a convenient way to express arbitrary lists of code points and take their union, intersection, etc. This commit changes the optimizer to use inversion lists for operating on the code points the synthetic start class can match. I don't much understand the overall operation of the optimizer. I'm told that previous porters found that perturbing it caused unexpected behaviors. I had promised to get this change in 5.18, but didn't. I'm trying to get it in early enough into the 5.20 preliminary series that any problems will surface before 5.20 ships. This commit doesn't change the macro level logic, but does significantly change various micro level things. Thus the 'and' and 'or' subroutines have been rewritten to use inversion lists. I'm pretty confident that they do what their names suggest. I re-derived the equations for what these operations should do, getting the same results in some cases, but extending others where the previous code mostly punted. The derivations are given in comments in the respective routines. Some of the code is greatly simplified, as it no longer has to treat above-Latin1 specially. It is now feasible for /i matching of above-Latin1 code points to know explicitly the folds that should be in the synthetic start class. But more prepatory work needs to be done before putting that into place. ...
* regcomp.c: Add some static functionsKarl Williamson2013-09-241-0/+9
| | | | | | | | | This commit adds some functions that are currently unused, but will be used in a future commit. This commit is essentially to make the differences smaller in that commit, as 'diff' is getting confused and not outputting the logical differences. The functions are added in a block at the beginning of the file to avoid the 'diff' issues. A later white-space only commit will move them to more appropriate positions.
* regcomp.c: Add parameter to static functionKarl Williamson2013-09-241-1/+1
| | | | | | | This parameter will be used in future commits. This commit is really only to make the difference listing smaller in those, by committing separately just the book-keeping parts. This parameter requires also passing the aTHX_ thread parameter
* Make typedef fully typedefKarl Williamson2013-09-241-3/+0
| | | | | | | | | | | | | | | | | | | | | | The regcomp.c struct RExC_state_t has not been usable fully as a typedef, requiring the 'struct' at times. This has caused me, and I presume others, wasted time when we forget to use it under those circumstances when it should be used, but it's never been a big enough issue to cause me to spend tuits on it. But, working on something else, I finally came to the realization of what the problem is. It is because proto.h is #included before regcomp.h is, and so functions that are declared in proto.h that have something that is a RExC_state_t as a parameter don't know that it is a typedef because that is defined in regcomp.h. A way around this is already used for other similar structures, and that is to declare them in perl.h which is always read in before proto.h, leaving the definitions to regcomp.h. Thus proto.h knows enough to compile. The structure was already declared in perl.h; just not typedef'd. Otherwise proto.h would not know about it at all. This patch moves two regcomp.c related declarations in perl.h to the same section as the others, and changes the one for RExC_state_t to be a typedef. All the 'struct' uses are removed.
* regcomp.c: Change names of some static functionsKarl Williamson2013-09-241-5/+5
| | | | | | | | | | | | | | | | | The term 'class' is very overloaded in regex code and documentation. perlrecharclass.pod calls the dot (matching any char) a class, and calls the [] form "bracketed character classes". There are other meanings as well. This is the first commit in a short series that removes some of those overloadings. One instance of class is the "synthetic start class", generated by the regex optimizer to be a list of all the code points a sucessful match could possibly start with. This is useful in more quickly finding where to start looking in matching against a target string. Prior to this commit, the routines that referred to this began with 'cl_', and the formal parameters were 'cl', which could mean any class. This commit changes those instances of 'cl' to 'ssc' to indicate this is the only type of class that is being handled.
* regcomp.c: Rework static function call; commentsKarl Williamson2013-09-241-1/+1
| | | | | | The previous commit just extracted out code into a function. This commit renames a parameter for clarity, combines two parameters to make the interface cleaner, and adds and moves comments around.
* regcomp.c: Extract code into separate functionKarl Williamson2013-09-241-0/+1
| | | | | | A future commit will use this functionality from a second place. For now, just cut and paste, and do the minimal ancillary work to get it to compile and pass.
* Add regnode struct for synthetic start classKarl Williamson2013-09-241-0/+3
| | | | | | | | | | | | As part of extending the regular expression optimizer to properly handle above Latin1 code points, I need an inversion list to contain which code points the synthetic start class (ssc) matches. The ssc currently is the same as a locale-aware ANYOF node, which uses the struct of a regular ANYOF node, plus some extra fields at the end. This commit creates a new typedef for ssc use, which is the locale-aware ANYOF node, plus an extra SV* at the end to hold the inversion list.
* regcomp.c: Extract code into separate functionKarl Williamson2013-09-241-0/+1
| | | | | This is in preparation for it to be called from more than one place, in a future commit.
* Removed DUMP_FDS and dump_fds()Brian Fraser2013-09-211-3/+0
| | | | | | If perl was compiled with -DDUMP_FDS, it would define dump_fds and add it to the API, although even then nothing used it. dump_fds() itself was buggy, only checking for fds 0 through 32.
* toke.c, S_scan_ident(): Don't take a "end of buffer" argument, use PL_bufendBrian Fraser2013-09-181-1/+1
| | | | | | | | | | | | | | | All but one of scan_ident()'s callers already passed PL_bufend as the removed argument; The one deviant was intuit_more(), which was setting the "end of buffer" argument, to the next close-bracket. This commit modifies intuit_more() to temporarily set PL_bufend and then restore it. This was done as groundwork for the following commit, which will add more uses of PEEKSPACE() to scan_ident() in order to fix some whitespace and line number bugs, and PEEKSPACE() modifies PL_bufend directly if it encounters a newline at the end of the buffer -- that last bit being why changing intuit_more() to modify-and-restore PL_bufend is safe, since the end of the buffer will always be a ']'
* gv.c: Split part of find_default_stash into gv_is_in_main.Brian Fraser2013-09-111-0/+1
| | | | | gv_is_in_main() checks if an unqualified identifier is in the main:: stash.
* gv.c: Rename magicalize_gv into gv_magicalize, make it more specific.Brian Fraser2013-09-111-1/+1
| | | | | Namely, gv_magicalize no longer stores the GV into the stash, which is gv_fetchpvn_flags' job.
* gv.c, gv_fetchpvn_flags: Split another chunk of magic-checking code.Brian Fraser2013-09-111-0/+1
| | | | | | This bit is called when a GV already exists, but it's name is length-one and it's on the main:: stash, so it might have multiple kinds of magic, like $! and %!, or @+ and %+.
* gv.c: Move the code that magicalizes new globs into magicalize_gv().Brian Fraser2013-09-111-0/+1
|
* gv.c: Begin splitting gv_fetchpvn_flags into smaller helper functions.Brian Fraser2013-09-111-0/+2
| | | | | This commit takes a chunk of code out of gv_fetchpvn_flags and turns it into two fuctions: parse_gv_stash_name and find_default_stash.
* [perl #117265] correctly handle overloaded stringsTony Cook2013-09-091-1/+1
|
* Put AV defelem creation code in one placeFather Chrysostomos2013-09-061-0/+1
|
* [perl #115768] improve (caller)[2] line numbersFather Chrysostomos2013-09-011-1/+1
| | | | | | | | | | | | | warn and die have special code (closest_cop) to find a nulled nextstate op closest to the warn or die op, to get the line number from it. This commit extends that capability to caller, so that if (1) { foo(); } sub foo { warn +(caller)[2] } shows the right line number.
* utf8.c: Remove wrapper functions.Karl Williamson2013-08-291-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that the Unicode data is stored in native character set order, it is rare to need to work with the Unicode order. Traditionally, the real work was done in functions that worked with the Unicode order, and wrapper functions (or macros) were used to translate to/from native. There are two groups of functions: one that translates from code point to UTF-8, and the other group goes the opposite direction. This commit changes the base function that translates from UTF-8 to code point to output native instead of Unicode. Those extremely rare instances where Unicode output is needed instead will have to hand-wrap calls to this function with a translation macro, as now described in the API pod. Prior to this, it was the other way, the native was wrapped, and the rare, strict Unicode wasn't. This eliminates a layer of function call overhead for a common case. The base function that translates from code point to UTF-8 retains its Unicode input, as that is more natural to process. However, it is de-emphasized in the pod, with the functionality description moved to the pod for a native input wrapper function. And, those wrappers are now macros in all cases; previously there was function call overhead sometimes. (Equivalent exported functions are retained, however, for XS code that uses the Perl_foo() form.) I had hoped to rebase this commit, squashing it with an earlier commit in this series, eliminating the use of a temporary function name change, but the work involved turns out to be large, with no real payoff.
* utf8.c: Stop using two functionsKarl Williamson2013-08-291-0/+2
| | | | | | | | | | | | | | | | | This is in preparation for deprecating these functions, to force any code that has been using these functions to change. Since the Unicode tables are now stored in native order, these functions should only rarely be needed. However, the functionality of these is needed, and in actuality, on ASCII platforms, the native functions are #defined to these. So what this commit does is rename the functions to something else, and create wrappers with the old names, so that anyone using them will get the deprecation when it actually goes into effect: we are waiting for CPAN files distributed with the core to change before doing the deprecation. According to cpan.grep.me, this should affect fewer than 10 additional CPAN distributions.
* Convert uvuni_to_utf8() to functionKarl Williamson2013-08-291-0/+1
| | | | | | | Code should almost never be dealing with non-native code points This is in preparation for later deprecation when our CPAN modules have been converted away from using it.
* utf8.c: Swap which fcn wraps the otherKarl Williamson2013-08-291-1/+1
| | | | This is in preparation for the current wrapee becoming deprecated
* Extract common code to an inline functionKarl Williamson2013-08-291-0/+1
| | | | | This fairly short paradigm is repeated in several places; a later commit will improve it.
* Only predeclare S_sv_or_pv_pos_u2b for -DPERL_CORE or -DPERL_EXTNicholas Clark2013-08-281-1/+3
| | | | | Otherwise when compiling XS code, there is a declaration for a function which is never used, which can cause some compilers to issue a warning.
* [perl #117265] safesyscalls: check embedded nul in syscall argsTony Cook2013-08-261-0/+1
| | | | | | | | | | | | | | | | Check for the nul char in pathnames and string arguments to syscalls, return undef and set errno to ENOENT. Added to the io warnings category syscalls. Strings with embedded \0 chars were prev. ignored in the syscall but kept in perl. The hidden payloads in these invalid string args may cause unnoticed security problems, as they are hard to detect, ignored by the syscalls but kept around in perl PVs. Allow an ending \0 though, as several modules add a \0 to such strings without adjusting the length. This is based on a change originally by Reini Urban, but pretty much all of the code has been replaced.