summaryrefslogtreecommitdiff
path: root/embed.h
Commit message (Collapse)AuthorAgeFilesLines
...
* utf8.c: Add function to retrieve new _Perl_IDStart propKarl Williamson2011-10-011-0/+1
|
* regcomp.c: Add invlist_invert_prop()Karl Williamson2011-10-011-0/+1
| | | | | | | | | This new function inverts a Unicode property. A regular inversion doesn't work because it operates on the whole of the code space, and Unicode property inversions don't invert above-Unicode code points. This does for inversion lists, what an earlier commit did for swashes. This function is currently not called by anyone.
* [perl #93590] $tainted ~~ [...] failingFather Chrysostomos2011-09-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When smartmatch is about to start, to avoid calling get-magic (e.g., FETCH methods) more than once, it copies any argument that has get-magic. Tainting uses get-magic to taint the expression. Calling mg_get(sv) on a tainted scalar causes PL_tainted to be set, causing any scalars modified by sv_setsv_flags to be tainted. That means that tainting magic gets copied from one scalar to another. So when smartmatch tries to copy the variable to avoid repeated calls to magic, it still copies taint magic to the new variable. For $scalar ~~ @array (or ~~ [...]), S_do_smartmatch calls itself recursively for each element of @array, with $scalar (on the suppos- edly non-magical copy of $scalar) on the left and the element on the right. In that recursive call, it again does the get-magic check and copies the argument. Since the copied of a tainted variable on the LHS is magical, it gets copied again. Since the first copy is a mortal (marked TEMP) with a refcount of one, the second copy steal its string buffer. The outer call to S_do_smartmatch then proceeds with the second ele- ment of @array, without realising that its copy of $scalar has lost its string buffer and is now undefined. So these produce incorrect results under -T (where $^X is ‘perl’): $^X =~ ["whatever", undef] # matches $^X =~ ["whatever", "perl"] # fails This problem did not start occurring until this commit: commit 8985fe98dcc5c0af2fadeac15dfbc13f553ee7fc Author: David Mitchell <davem@iabyn.com> Date: Thu Dec 30 10:32:44 2010 +0000 Better handling of magic methods freeing the SV mg_get used to increase the refcount unconditionally, pushing it on to the mortals stack. So the magical copy would have had a refcount of 2, preventing its string buffer from being stolen. Now it has a ref- erence count of 1. This commit solves it by adding a new parameter to S_do_smartmatch telling it that the variable has already been copied and does not even need to be checked. The $scalar~~@array case sets that parameter for the recursive calls. That avoids the whole string-stealing problem *and* avoids extra unnecessary SVs.
* Move non-constant folding parts of fold_constants into a separate functions.Gerard Goossen2011-09-051-0/+2
| | | | | | | | | | The non-constant folding parts of fold_constants are moved into separate functions. op_integerize handles converting ops to integer (and special case of OP_NEGATE), op_std_init handling some standard functionality (forced scalar context and allocating the TARGET). Both functions are called where fold_constants is called (but we might want to make that a bit some selective and use op_std_init in other places).
* Eliminate is_gv_magical_svFather Chrysostomos2011-08-301-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This resolves perl bug #97978. Many built-in variables, like $], are actually created on the fly when first accessed. Perl likes to pretend that these variables have always existed, so it autovivifies the *] glob even in rvalue context (e.g., defined *{"]"}, close "]"). The list of variables that were autovivified was maintained separ- ately (in is_gv_magical_sv) from the code that actually creates them (gv_fetchpvn_flags). ‘Maintained’ is not actually precise: it *wasn’t* being maintained, and there were new variables that never got added to is_gv_magical_sv and one deleted variable that was never removed. There are only two pieces of code that call is_gv_magical_sv, both in pp.c: S_rv2gv (called by *{} and also the implicit *{} that functions like close() provide) and Perl_softrefxv (called by ${}, @{}, %{}). In both cases, the glob is immediately autovivified if is_gv_magical_sv returns true. So this commit eliminates the extra maintenance burden by extirpat- ing is_gv_magical_sv altogether, and replacing it with a new flag to gv_fetchpvn_flags, GvADDMG, which will autovivify a glob *if* it’s a magical one. It does make defined(*{"frobbly"}) slightly slower, in that it creates a temporary glob and then frees it when it sees nothing magical has been done with it. But this case is rare enough it should not matter. At least I got rid of the bugginess.
* Move coresub op-creation from gv.c to op.cFather Chrysostomos2011-08-241-0/+1
| | | | | | | | | | | | For functions that take handles as arguments, this code will need to call static functions in op.c, like is_handle_constructor. While we could make is_handle_constructor into a non-static function and call it from gv.c, that seems backwards, as it would result in a lot of op-manipulation code in the middle of gv.c. So this commit creates a new function in op.c, called coresub_op, which is only called from gv.c, from the &CORE::sub code.
* Add find_rundefsv2 functionFather Chrysostomos2011-08-241-0/+1
| | | | | | | | | | Subs in the CORE package with a (_) prototype will use this. This accepts a CV and a sequence number, so that one can use it to find the $_ in the caller’s scope. It only uses the topmost call of a subroutine that is being called recur- sively, so it’s not really a general-purpose function. But it suffices for &CORE::abs and friends.
* Move making inplace sort and reverse away from the peephole optimiser to ↵Gerard Goossen2011-08-241-1/+1
| | | | | | | | scalarvoid. Why: The in place assignment is not just an optimisation but has significant different behaviour and thus doesn't belong in the peephole optimiser. Also the optree changes are unified and simpler.
* Revert "Test CORE::break’s prototype"Father Chrysostomos2011-08-241-1/+1
| | | | | | | | | This reverts commit e52d58aa5bea245b66786b4c9029e849a2be69d3. I don’t quite know how I managed it, but I really screw up this time! Two completely unrelated commits ended up getting merged into one, so, to avoid confusion down the road, I’m reverting it, only to reapply it shortly....
* Test CORE::break’s prototypeFather Chrysostomos2011-08-241-1/+1
|
* Refactor unpack’s newDEFSVOP logic; correct prototypeFather Chrysostomos2011-08-211-1/+0
| | | | | | | | | | | | | | | | | unpack is the only op that takes an implicit $_ for its second argu- ment. (For others it’s the first.) Instead of special-casing unpack with its own ck_ routine, we can sim- ply modify the logic in ck_fun to apply OA_DEFGV to the first optional argument, not just the first argument. Currently OA_DEFGV is not set in PL_opargs[OP_UNPACK], which means the automatically-generated prototype is ($;$), instead of ($_). This commit sets the flag on the op, changes it to use ck_fun directly, and updates ck_fun and the prototype-generation code accord- ingly. I couldn’t put this in multiple commits, as the changes are interdependent.
* Move pp_-specific code out of core_prototypeFather Chrysostomos2011-08-141-1/+1
| | | | | | | | | | | | | | Commit b8c38f0a2a65 refactored pp_prototype by moving much of its code to a new function in op.c, called core_prototype. This served two purposes: (1) to allow the code to be simplified, which required the use of static functions in op.c, and (2) to allow the &CORE::subs feature to share the same code. But some code was moved to core_prototype which, in hindsight, did not need to be moved, such as the ‘Can’t find an opnumber’ message. This commit moves that code back to pp_prototype, resulting in a sim- pler (and possibly faster, at least for &CORE::subs) core_prototype.
* Make core_prototype provide the op number as wellFather Chrysostomos2011-08-141-1/+1
| | | | | | | Since it has to calculate it, it might as well provide it, so callers do not have to go through that while(i < MAXO) loop yet again. (The &CORE::foo feature will use this.)
* Move aassign common var detection to a separate function.Gerard Goossen2011-08-081-0/+1
|
* Remove Perl_modFather Chrysostomos2011-08-021-1/+0
| | | | | | | After mod was renamed to op_lvalue, this stub was added temporarily to provide a smoother transition for the compilers. The compiler maintainer is happy with its extirpation at this stage. See ticket #78908.
* Add finalize_optree function which can take over all the compile time ↵Gerard Goossen2011-07-281-0/+2
| | | | | | | | | | | | checking/finalization now being done by the peephole optimizer. This function takes the optree after it is finished building. It takes over some of the checking and final conversions which are currently being done by the peephole optimizer. Add the moment this is an unnecessary extra step after the peephole optimizer, but with a separate code generation step, the current peephole optimizer can't exists and this function will take over all its essential compile time functions.
* Add core_prototype; make pp_prototype use itFather Chrysostomos2011-07-261-0/+1
| | | | | | | | | | | | | | | | This commit moves the code for generating core prototypes into a sepa- rate function, core_prototype, in op.c. This serves two porpoises: • It allows the lock and tie exceptional cases to be incorporated into the main prototype=generation code, which requires the use of a static function in op.c. • It allows other parts of the core (e.g., the upcoming \&CORE::foo feature) to use the same code. The docs for it are in a section boringly entitled ‘Functions in op.c’, for lack of a better name. This, I believe, is the only op.c function that is in perlintern currently, so it’s hard to see what to name a section that will, at least for now, contain nothing else.
* Perl_my_p{open,close} do not exist under PERL_IMPLICIT_SYS.Nicholas Clark2011-07-241-2/+4
| | | | | PERL_IMPLICIT_SYS only builds on Win32. Correct embed.fnc to reflect the reality.
* Change was_lvalue_sub back to X; spell out the only use of itFather Chrysostomos2011-07-141-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | OK, now I understand what’s happening. If there is a public macro (PUSHSUB) that contains a call to a pri- vate function (was_lvalue_sub), that function has to be exported, so that non-core code can call it. But if it is marked X, there is no was_lvalue_sub shorthand macro visible to non-core code, so when the PUSHSUB macro is expanded in such code, the was_lvalue_sub(...) bit becomes a call to the function literally named was_lvalue_sub, as opposed to Perl_lvalue_sub (and is compiled that way on forgiving platforms). Making it A makes that macro available to non-core code, but also implies that it is available for direct use by extensions, which is not the case with was_lvalue_sub. So, this commit makes it X again, but spells it out in PUSHSUB, so there is no need for the function’s macro to be available when PUSHSUB is expanded. Hence, there is no need for the was_lvalue_sub macro to exist, so this commit also removes it. See also these three commits: c73b0699db 7b70e81778 777d901444
* Added a flags parameter to pad_findlex.Brian Fraser2011-07-121-1/+1
|
* APIify pad functionsZefram2011-07-121-11/+15
| | | | | | | Move several pad functions into the core API. Document the pad functions more consistently for perlapi. Fix the interface issues around delimitation of lexical variable names, providing _pvn, _pvs, _pv, and _sv forms of pad_add_name and pad_findmy.
* A not X for was_lvalue_sub in embed.fnc.Craig A. Berry2011-07-111-1/+1
| | | | | | 7b70e8177801df4e142684870ce037d584f72e7b was my (wrong) suggestion, and it made the symbol only visible when PERL_CORE was defined, which it isn't in List::Util.
* Propagate (non-)lvalue context through nested callsFather Chrysostomos2011-07-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, this code would fail: $foo = "foo"; sub foo :lvalue{ return index "foo","o" } sub bar :lvalue { foo } $x = bar; (It would fail for ‘return $]’ as well. Whether it’s a PADTMP or a read-only scalar makes no difference.) foo would think it was being called in true lvalue context, because the entersub op that called it (in bar) was marked that way, bar being an lvalue sub as well. The PUSHSUB macro in cop.h needed to be modified to account for dynamic, or indetermine, context (i.e., indeterminable at compile time). This happens when an entersub op is an argument to return or the last statement in a subroutine. In those cases it has to propa- gate the context from the caller. So what we now do is this: Both lvalue and in-args flags are turned on for an entersub op when op_lvalue is called with OP_LEAVESUBLV as the type. Then PUSHSUB copies into the context stack only those flags that are set both on the current entersub op and in the context stack for the previous sub call.
* Restrict some inversion list functionsKarl Williamson2011-07-031-4/+4
| | | | | These functions are internal only with names beginning with underscore. I hadn't realized that their definitions could be restricted.
* Allow utf8.c to access 4 inversion list functionsKarl Williamson2011-07-031-4/+6
|
* Change 4 inversion list functions from S_ to Perl_Karl Williamson2011-07-031-4/+4
| | | | | This is in preparation for them to be called from another file. Note that they are still protected by an #ifdef in embed.fnc.
* Change names of some inversion list functionsKarl Williamson2011-07-031-4/+4
| | | | | | The names now begin with an underscore to emphasize that they are for internal use only. This is in preparation for making them accessible beyond regcomp.c.
* Add 3 methods for inversion listsKarl Williamson2011-07-031-0/+3
| | | | This adds inversion, cloning, and set subtraction
* Add an element to inversion list data structureKarl Williamson2011-07-031-0/+2
| | | | | This element is restricted to either 0 or 1. The comments detail how its use enables an inversion list to be efficiently inverted.
* Add length element to inversion listsKarl Williamson2011-07-031-0/+1
| | | | | Future changes will make the length no longer the same as SvCUR, so create an element to hold the correct length
* Add iterator for inversion listsKarl Williamson2011-07-031-0/+3
|
* regcomp.c: Rmv no longer called functionKarl Williamson2011-07-031-1/+0
| | | | | | | | | | | | | | This hasn't been used since 626725768b7b17463e9ec7b92e2da37105036252 Author: Nicholas Clark <nick@ccl4.org> Date: Thu May 26 22:29:40 2011 -0600 regcomp.c: Fix memory leak regression here was a remaining memory leak in the new inversion lists data structure under threading. This solves it by changing the implementation to use a SVpPV instead of doing our own memory management. Then the already existing code for handling SVs returns the memory when done.
* regcomp.c: Remove no longer called functionKarl Williamson2011-07-031-1/+0
| | | | | | The invlist_destroy function was misleading, as it has changed to just decrement the reference count, which may or may not lead to immediate destruction
* regcomp.c: Revise inversion list APIKarl Williamson2011-07-031-2/+2
| | | | | | | These are static functions so no external effect. Revise the calling sequence of two functions so that they can know enough to free memory if appropriate of the other parameters. This hides from the callers the need for tracking when to free memory.
* Factor stack adjustments on leave in a new static functionVincent Pit2011-06-261-0/+1
| | | | This is just a refactoring. There should be no functional changes.
* add do_ncmp fn and make pp_ncmp, pp_eq etc use itDavid Mitchell2011-06-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | Extract most of the body of pp_ncmp() (numeric compare) into a separate function, do_ncmp(), then make the following ops use it: pp_ncmp pp_lt pp_le pp_eq pp_ne pp_ge pp_gt This removes a lot of similar or duplicated code, most of which is dedicated to handling the various combinations of IV verses UV verses NV verses NaN. The various ops first check for, and directly process, the simple and common case of both args being SvIOK_notUV(), and pass the processing on to do_ncmp() otherwise. Benchmarking seems to indicate (but with a lot of noise) that the SvIOK_notUV case is slightly faster than before, and the do_ncmp() branch slightly slower.
* op_lvalue .= _flagsFather Chrysostomos2011-06-241-1/+0
| | | | | | | | | | Add flags param to op_lvalue, so that the caller can ask it not to croak when encountering an unmodifiable op (upcoming). This is in preparation for making the \$ prototype accept any lvalue. There is no mathom, as the changes that this will support are by no means suitable for maint.
* regcomp.c: Fix memory leak regressionNicholas Clark2011-05-261-1/+0
| | | | | | | | There was a remaining memory leak in the new inversion lists data structure under threading. This solves it by changing the implementation to use a SVpPV instead of doing our own memory management. Then the already existing code for handling SVs returns the memory when done.
* add hfree_next_entry(), hv_free_ent_ret()David Mitchell2011-05-191-0/+1
| | | | | | | | | | | | | Move body of hfreeentries()' central loop into a new function, hfree_next_entry(); leaving hfreeentries() as a simple loop that calls hfree_next_entry() until there are no entries left. This will in future allow sv_clear() to free a hash iteratively rather than recursively. Similarly, turn hv_free_ent() into a thin wrapper around a new function, hv_free_ent_ret(), which doesn't free HeVAL(), but rather just returns the SV instead.
* utf8.c: Add _flags version of to_utf8_fold()Karl Williamson2011-05-031-2/+2
| | | | | | | | | | And also to_uni_fold(). The flag allows retrieving either simple or full folds. The interface is subject to change, so these are marked experimental and their names begin with underscore. The old versions are turned into macros calling the new versions with the correct extra parameter.
* Make push/shift $scalar accept only unblessed aryrefsFather Chrysostomos2011-04-181-1/+0
| | | | See ticket #80626.
* Add depth parameter to reg_namedseqKarl Williamson2011-03-201-1/+1
|
* regcomp.c: Merge identical functionsKarl Williamson2011-03-081-1/+0
| | | | | These two functions now have identical code, so merge them, but use a macro in case they ever need to diverge again.
* Avoid miniperl SEGVing when processing -I on the #! lineNicholas Clark2011-03-051-1/+5
| | | | | | | | | | | | | | | | | | A side-effect of change 3185893b8dec1062 was to force av in S_incpush() to be NULL, whilst other flag variables were still set as if it were non-NULL, for certain cases, only when compiled with -DPERL_IS_MINIPERL The "obvious" fix is to also set all the flag variables to 0 under -DPERL_IS_MINIPERL, to make everything consistent. However, this confuses (at least) the local version of gcc, which issues warnings about passing a NULL value (av, known always to be NULL) as a not-NULL parameter, despite the fact that all the relevant calls are inside blocks which are actually dead code, due to the if() conditions being const variables set to 0 under -DPERL_IS_MINIPERL. So to avoid future bug reports about compiler warnings, the least worst thing to do seems to be to use #ifndef to use the pre-processor to eliminate the dead code, and related variables.
* regcomp.c: Add parameters to fcnsKarl Williamson2011-02-271-2/+2
| | | | | | A pointer to the list of multi-char folds in an ANYOF node is now passed to the routines that set the bit map. This is in preparation for those routines to add to the list
* regcomp.c: Add fcn add_cp_to_invlist()Karl Williamson2011-02-271-0/+1
| | | | | This is just an inline shorthand when a single code point is all that is needed. A macro could have been used instead, but this just seemed nicer.
* regcomp.c: Factor code into a function.Karl Williamson2011-02-271-0/+1
| | | | A future commit uses this same code, so put it into a common place.
* handy.h: isIDFIRST_utf8() changed to use XIDStartKarl Williamson2011-02-171-0/+2
| | | | | | | | | | Previously this used a home-grown definition of an identifier start, stemming from a bug in some early Unicode versions. This led to some problems, fixed by #74022. But the home-grown solution did not track Unicode, and allowed for characters, like marks, to begin words when they shouldn't. This change brings this macro into compliance with Unicode going-forward.
* foldEQ_utf8: Add version with flags parameterKarl Williamson2011-02-141-1/+1
| | | | | The parameter doesn't do anything yet. The old version becomes a macro calling the new version with 0 as the flags.
* regcomp.c: Put two static functions in embed.fncKarl Williamson2011-02-141-0/+2
|