summaryrefslogtreecommitdiff
path: root/pp_hot.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove unnecessary code from pp_addFather Chrysostomos2011-04-081-13/+0
| | | | | This code, added recently in 4c3ac4b and amended in 837c879, has been unnecessary since commit 75ea7a1.
* Remove unnecessary code from pp_eqFather Chrysostomos2011-04-081-12/+0
| | | | | This code, added recently in 7d779b2, has been unnecessary since com- mit 75ea7a1.
* [perl #87708] $tied == $tiedFather Chrysostomos2011-04-071-0/+12
| | | | | | | | | | | | | | | | | | This is only part of #87708. This fixes the + operator outside of any ‘use integer’ scope when the same tied scalar is used for both operands and returns two different values. Before this commit, get-magic would be called only once and the same value used. In 5.12.x it just worked. I tried modifying pp_eq throughout to take this case into account, but it made the most common cases slightly slower, presumably because of the extra checks. So this follows the same temp sv method that I used for pp_add (in 4c3ac4b and 837c879), which, though slowing down this edge cases due to the extra allocation, leaves the most common cases just as fast. (And, in case my benchmarks were unreliably [not unlikely], this method is also safer, as it has less chance of getting different code paths wrong.)
* Correct stupidities in 4c3ac4bFather Chrysostomos2011-04-061-2/+5
| | | | | | | Allocating an extra SV for rare edge cases...er...only needs to be done in those rare edge cases. Uninitialized warnings are only supposed to be enabled when they are.
* [perl #87708] $tied + $tiedFather Chrysostomos2011-04-061-0/+10
| | | | | | | | | This is just part of #87708. This fixes the + operator outside of any ‘use integer’ when the same tied scalar is used for both operands and returns two different val- ues. Before this commit, get-magic would be called only once and the same value used. In 5.12.x it worked.
* [perl #82111] de-pessimise some my @array = ...David Mitchell2011-03-121-1/+12
| | | | | | | | | | | | | Due to obscure closure and goto tricks, it's sometimes possible for the array or hash in the LHS of 'my @a = ...' and 'my %h = ...' to be non-empty. At compile-time, these conditions are detected and the assign op is compiled with the OPpASSIGN_COMMON, making the assignment slower. This commit speeds it up again by adding a run-time check to pp_aassign to only do the OPpASSIGN_COMMON code-branch if the LHS isn't an empty array or hash. See also #70171.
* Stop aelemfast from crashing on GVs with null AVsFather Chrysostomos2011-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As reported at nntp://nntp.perl.org/1298599236.4753.72.camel@p100 (and respaced for readability): #!perl5.12.0 $r=q/ print __FILE__; local *dbline = $main::{"_<".__FILE__}; print $dbline[0] /; eval $r;' __END__ (eval 1) Bus error This only seems to happen in non-threaded perls. It can be reduced to this: *d = *a; print $d[0]; The $d[0] is optimised into an aelemfast op (instead of the usual aelem with an rv2av kid). pp_aelemfast is at fault, as evidenced by the fact that this does not crash (the ${\...} prevents the optimisation): *d = *a; print $d[${\0}]; pp_aelemfast uses GvAV instead of GvAVn. Usually $d[0] will autovivify @d, but the glob assignment leaves $d[0] pointing to a glob (*d) with no array. Then pp_alemfast passes a null pointer around.
* pp_subst: eliminate 'matched' local varDavid Mitchell2011-02-181-5/+3
|
* taint REGEX SVs as well as refs to themDavid Mitchell2011-02-181-1/+3
| | | | | | | | | | | Now that REGEX is actually a first-class SV type, we can taint the regex SV directly, as well as the RV pointing to it. This means that this now taints: $rr = qr/$tainted/; $r = $$r; /$r/;
* pp_subst: exit earlier after failed matchDavid Mitchell2011-02-181-9/+10
| | | | | | | | If the match fails, don't bother to execute some code that prepares the source and replacement strings for a substitution (e.g. matching UTF8-ness). (This is an enhancement to ff6e92e827a143094fdf3af374056b524759194b)
* tweak the new pattern taint descriptionDavid Mitchell2011-02-181-10/+11
|
* document how tainting works with pattern matchingDavid Mitchell2011-02-161-1/+70
|
* fix many s/// tainting bugsDavid Mitchell2011-02-161-18/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a re-implementation of the tainting code in pp_subst and pp_substcont. Although this fixes many bugs, because its a de-novo rewrite of the tainting parts of the code in those two functions, it's quite possible that it breaks some existing tainting behaviour. It doesn't break any existing tests, although it turns out that this area was severely under-tested anyway. The main bugs that this commit fixes are as follows, where: T = a tainted value L = pattern tainted by locale (e.g. use locale; s/\w//) Happens both with and without 'use re taint' unless specified. Happens with all modifiers (/g, /r etc) unless explicitly mentioned. $1 unexpectedly untainted: s/T// T =~ s/// under use re 'taint' original string unexpectedly untainted: s/L//, s/L//g return value unexpectedly untainted: T =~ s///g under no re 'taint' s/L//g, s/L//r return value unexpectedly tainted: s/T// s//T/r under no re 'taint' T =~ s/// under use re 'taint' s//T/ under use re 'taint' Also, with /ge, the original string becomes tainted as soon as possible (usually in the second entry to the /e code block) rather than only at the end, in code like $orig =~ s/T/...code.../ge The rationale behind the taintedness of the return value of s/// (in the non /r case), is that a boolean value shouldn't be tainted. This corresponds to the general perl tainting policy that boolean ops don't return tainted values. On the other hand, when it returns an integer (number of matches), that should be tainted. A couple of note about the old tainting code this replaces: firstly, several occurrences of the following were NOOPs, since rxtainted was U8 and the bit being ored was > 256: rxtainted |= RX_MATCH_TAINTED(rx) secondly, removing a whole bunch of the following didn't make any existing tests fail: TAINT_IF(rxtainted & 1);
* pp_match: indent label slightlyDavid Mitchell2011-02-161-1/+1
| | | | | 'play_it_again:' was on column 0, which meant that most diff utilities interpreted it as a function name.
* pp_subst: move a common block outside an if/thenDavid Mitchell2011-02-061-18/+8
| | | | | The last few commits have been working towards making two blocks of code identical. Now it's payback time!
* pp_subst: do SvUTF8_on next to the SvPOK_only_UTF8David Mitchell2011-02-061-2/+2
| | | | | | This should leave things functionally unchanged. This is another step in making two branches of code more identical
* fix a s/non-utf8/is-utf8/ bit of nastinessDavid Mitchell2011-02-061-2/+3
| | | | | | | | | | | | | Commit 3e462cdc2087ddf90984010fabd80c30db92bfa0 provided a fix for the s/non-utf8/is-utf8/ case by upgrading TARG to UTF8 after the match, but before the substitution. It used sv_utf8_upgrade() rather than sv_utf8_upgrade_nomg(), so for example, with a tied variable, FETCH would get called again, and all the char* pointers such as s would be left dangling. If the length of the string was unchanged, the code wouldn't notice this. Fix by using the _nomg() variant, and by checking whether the string has been reallocated
* pp_subst: remove a superflous PUTBACK/SPAGAINDavid Mitchell2011-02-061-5/+1
| | | | | | | These were added around a mg_set() call before the stack-of-stacks mechanism was introduced, which has made them redundant. This is another step in making two branches of code more identical
* pp_subtr: preserve UTF8 flag in rare casesDavid Mitchell2011-02-061-1/+1
| | | | | | | | | | | | There are two main branches in pp_subtr(): the 'in-place' and the other, depending on whether the replacement string is short enough to be inserted directly. Commit 80b498e0aacf413fb7460d6882a74c68c1f9df48 back in 2000 changed a SvPOK_only() to a SvPOK_only_UTF8() to preserve the UTF8 bit, but only on *one* branch. Add the change to the other branch too. This will only make a difference in rare cases involving 'use bytes' (where it's arguably broken and generating malformed utf8 anyway); but the main reason for doing it is to allow soon for some identical code in the two branches to be de-duplicated.
* pp_subst: move a bock of code to to decrease gotosDavid Mitchell2011-02-061-8/+7
|
* pp_subst: compact a couple of PUSHes using ?:David Mitchell2011-02-061-8/+2
|
* pp_subst: remove a duplicate labelDavid Mitchell2011-02-061-2/+1
| | | | (both nope: and ret_no: labelled the same chunk of exit code)
* pp_subst: exit as soon as !matchDavid Mitchell2011-02-061-6/+5
| | | | | ... rather than messing about first deciding whether to process a successful match inline or not
* pp_substr: combine two identical blocks of codeDavid Mitchell2011-02-061-9/+2
|
* fix a confusing open scope in pp_substDavid Mitchell2011-01-301-1/+2
| | | | just a white space change
* regen/opcode.pl should only generate prototypes for pp_* functions that exist.Nicholas Clark2011-01-091-1/+1
| | | | | | | It now generates prototypes for all functions that implement OPs. Hence Perl_unimplemented_op no longer needs a special-case prototype. As it is now generating a prototype for Perl_do_kv, no need for regen/embed.pl to duplicate this. Convert the last two users of the macro do_kv() to Perl_do_kv(aTHX).
* Generate pp_* prototypes in pp_proto.h, and remove pp.symNicholas Clark2011-01-091-1/+1
| | | | | | | | | | | Eliminate the #define pp_foo Perl_pp_foo(pTHX) macros, and update the 13 locations that relied on them. regen/opcode.pl now generates prototypes for the PP functions directly, into pp_proto.h. It no longer writes pp.sym, and regen/embed.pl no longer reads this, removing the only ordering dependency in the regen scripts. opcode.pl is now responsible for prototypes for pp_* functions. (embed.pl remains responsible for ck_* functions, reading from regen/opcodes)
* Fix typos (spelling errors) in Perl sources.Peter J. Acklam) (via RT2011-01-071-1/+1
| | | | | | | | | # New Ticket Created by (Peter J. Acklam) # Please include the string: [perl #81904] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81904 > Signed-off-by: Abigail <abigail@abigail.be>
* Convert tied READLINE to using Perl_tied_method()Nicholas Clark2011-01-051-12/+6
|
* Convert tied PRINT to using Perl_tied_method()Nicholas Clark2011-01-051-16/+5
| | | | | Add a flag TIED_METHOD_SAY to Perl_tied_method(), to allow tied PRINT to effect C<local $\ = "\n";> within the ENTER/LEAVE pair of Perl_tied_method().
* Reindent pp_rv2avVincent Pit2011-01-031-31/+31
|
* GvIO(gv) returns NULL for a NULL gv, so refactor to take advantage of this.Nicholas Clark2011-01-021-3/+3
| | | | | | Simplify tests of !gv || !io to just !io, avoid calling GvIO(gv) more than once, and where possible initialise io at declaration time, to allow it to be const.
* make <expr> always overload if expr is overloadedDavid Mitchell2011-01-021-1/+1
| | | | | | | | Due to the way that '<> as glob' was parsed differently from '<> as filehandle' from 5.6 onwards, something like <$foo[0]> didn't handle overloading, even where $foo[0] was an overloaded object. This was contrary to the docs for overload, and meant that <> couldn't be used as a general overloaded iterator operator.
* standardise amagic method namingDavid Mitchell2010-12-311-1/+1
| | | | | | | | | | | | | | Some amagic-related macros take the full method enumeration name, (e.g. "add_amg"); while others "helpfully" allow you to pass a shortened version, ("add"), and do a CAT2(meth,_amg) behind the scenes. Standardise on passing the full name; this makes it less confusing and allows you to grep for the enumeration name in the source. It updates two macros to accept full enumeration names: tryAMAGICunTARGET (which isn't used outside the core apparently), and AMG_CALLun, which is replaced by a new AMG_CALLunary (since AMG_CALLun is used outside the core).
* As report_evil_fh() checks WARN_{CLOSED,UNOPENED}, don't duplicate this.Nicholas Clark2010-12-281-3/+2
| | | | | | | | | | This trades reduced code size for an extra function call in the error path with warnings disabled. (And removes a duplicated check for the case of taking the error path *with* warnings enabled.) Removing the check from Perl_do_close() does not change behaviour, as io is NULL there, hence Perl_report_evil_fh() will always be checking WARN_UNOPENED and setting vile to "unopened".
* As report_wrongway_fh() checks ckWARN(WARN_IO) internally, don't duplicate this.Nicholas Clark2010-12-281-7/+5
| | | | | | This trades reduced code size for an extra function call in the error path with warnings disabled. (And removes a duplicated check for the case of taking the error path *with* warnings enabled.)
* Argument op to report_evil_fh() is always PL_op->op_type, so need not be passedNicholas Clark2010-12-281-3/+3
|
* The io argument to report_evil_fh() is always GvIO(gv), so need not be passed.Nicholas Clark2010-12-281-3/+3
|
* Extract the OP_phoney_* code from report_evil_fh() into report_wrongway_fh()Nicholas Clark2010-12-281-2/+2
| | | | | Previously Perl_report_evil_fh()'s body was just an if/else at the top level - a good sign that it is actually implementing two disjoint functions.
* only call amagic_deref_call() if we have toDavid Mitchell2010-12-161-5/+8
|
* don't upgrade overload IV return values to NVDavid Mitchell2010-12-151-1/+1
| | | | | | | | (if we can avoid it). Fix for RT #77456. Basically it extends the usage of the AMGf_numeric flag to the remaining overloadable numeric ops that behave differently with IV and NV.
* Another oops.Father Chrysostomos2010-11-291-3/+1
| | | | | Something else changed unnecessarily by 541ed3a9. I really oughtn’t do this when I’ve been awake for more than 18 hours....
* Oops.Father Chrysostomos2010-11-291-1/+0
| | | | | That was part of my first attempt to fix [perl #68560]. I forgot to delete it. (It’s harmless.)
* [perl #68560] calling closure prototype SEGVsFather Chrysostomos2010-11-291-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a closure is created, the original sub is cloned (except that the op tree is shared). That original sub (called the closure prototype) is not usually accessible to perl. An attribute handler (MODIFY_CODE_ATTRIBUTES) is passed a reference to it, however. If that code reference is called within the attribute handler, an ‘Undefined subroutine called’ error results, because the op tree has not been attached yet. If that code reference is stashed away and called after the attribute handler returns, it will most likely crash. This is because its pad is full of nulls. A regular $proto->() or &$proto() call that sets up @_ will crash in attempting to do so. A &$proto call will bypass that, but attempting to read any lexical variables from the containing scope will cause a crash. Any operator that uses TARG (i.e., most of them) will crash. So this commit puts a check for closure prototypes in pp_entersub. It produces a new error message, ‘Closure prototype called’. This does introduce a backward-incompatible change: code like this used to work: sub MODIFY_CODE_ATTRIBUTES { $'proto = $_[1] } { my $x; () = sub :attr { () = $x; print "hello\n" } } &$'proto; But writing a useful subroutine that tiptoes past the crashes is so difficult that I think this breakage is acceptable.
* fix for #23790.Marty Pauley2010-11-041-0/+23
| | | | | | | padav is leaving an arrayref on the stack when producing the return value for an lvalue sub. But when this is in an argument list it really should be a array, not a ref. So, in leavesublv I check for this case and expand the arrayref to an array.
* Inline tryAMAGICunDEREF_var() into its callers and eliminate it.Nicholas Clark2010-11-031-3/+4
| | | | Nothing outside the core was using this macro.
* s///r leaks like a sieveFather Chrysostomos2010-11-021-1/+1
|
* RT #63790: &{PL_sv_yes} corrupted mark stackDavid Mitchell2010-10-301-0/+2
| | | | | Calling a subref whose value was PL_sv_yes, and without args, failed to pop an entry off the mark stack
* [perl #78674] Fix stack pointer corruption in pp_concat() with 'use encoding'Niko Tyni2010-10-291-0/+3
| | | | | sv_utf8_upgrade_nomg() may reallocate the stack via sv_recode_to_utf8() if 'use encoding' is in effect, causing stack pointer corruption.
* Revert "Fix for RT#1804: Anonymous glob breaks when assigned through"Father Chrysostomos2010-10-251-8/+0
| | | | | | | | | This reverts commit 0fe688f528b0e1b5bef6fb30d5e45316430e8a41, except for the tests. It is no longer necessary, as of change 2acc3314e31a9. Another reason for this revert is that doing so fixes bug #77812, or at least it would if 2acc3314e31a9 had not fixed that, too.