summaryrefslogtreecommitdiff
path: root/regen/opcodes
Commit message (Collapse)AuthorAgeFilesLines
* add padrange opDavid Mitchell2012-11-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This single op can, in some circumstances, replace the sequence of a pushmark followed by one or more padsv/padav/padhv ops, and possibly a trailing 'list' op, but only where the targs of the pad ops form a continuous range. This is generally more efficient, but is particularly so in the case of void-context my declarations, such as: my ($a,@b); Formerly this would be executed as the following set of ops: pushmark pushes a new mark padsv[$a] pushes $a, does a SAVEt_CLEARSV padav[@b] pushes all the flattened elements (i.e. none) of @a, does a SAVEt_CLEARSV list pops the mark, and pops all stack elements except the last nextstate pops the remaining stack element It's now: padrange[$a..@b] does two SAVEt_CLEARSV's nextstate nothing needing doing to the stack Note that in the case above, this commit changes user-visible behaviour in pathological cases; in particular, it has always been possible to modify a lexical var *before* the my is executed, using goto or closure tricks. So in principle someone could tie an array, then could notice that FETCH is no longer being called, e.g. f(); my ($s, @a); # this no longer triggers two FETCHES sub f { tie @a, ...; push @a, 1,2; } But I think we can live with that. Note also that having a padrange operator will allow us shortly to have a corresponding SAVEt_CLEARPADRANGE save type, that will replace multiple individual SAVEt_CLEARSV's.
* Add clonecv op typeFather Chrysostomos2012-09-151-0/+1
| | | | | | This will be used for cloning a ‘my’ sub on scope entry. I was going to use pp_padcv for this, but it would end up having a top-level if/else.
* Add introcv op typeFather Chrysostomos2012-09-151-0/+1
| | | | | This will be used for introducing ‘my’ subs on scope entry, by turning off the stale flag.
* padcv op typeFather Chrysostomos2012-09-151-0/+2
|
* Remove boolkeys opFather Chrysostomos2012-08-261-1/+0
|
* Merge ck_trunc and ck_chdirFather Chrysostomos2012-07-251-1/+1
| | | | | | ck_chdir, added in 2006 (d4ac975e) duplicates ck_trunc, added in 1993 (79072805), except for a null op check which is harmless when applied to chdir.
* [perl #113470] Constant folding for packFather Chrysostomos2012-07-131-1/+1
| | | | | | | | | | | | | This takes the pessimistic approach of skipping it for any first argu- ment that is not a plain non-magical PV, just in case there is a 'p' or 'P' in the stringified form. Otherwise it scans the PV for 'p' or 'P' and skips the folding if either is present. Then it falls through to the usual op-filtering logic. I nearly made ‘pack;’ crash, so I added a test to bproto.t.
* Constant folding for xFather Chrysostomos2012-06-081-1/+1
|
* Make pos use ck_fun and OA_SCALARREFFather Chrysostomos2012-05-291-1/+1
| | | | | | See the previous commit. The same applies here. In short, this allows core_prototype and pp_coreargs to be simpler.
* Make undef use ck_fun and OA_SCALARREFFather Chrysostomos2012-05-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | In regen/opcodes, we have some operators that use ck_fun and have R for the argument. And there are some that use ck_lfun and have S for the argument. These both amount to more or less the same thing. ck_fun/R goes through the OA_SCALARREF case in ck_fun, which calls op_lvalue(scalar()) on the child op. ck_lfun/S goes through the OA_SCALAR case in ck_fun, which calls scalar(), and then ck_lfun sees to it that op_lvalue is called. The only real difference is that the OA_SCALAR case makes sure there are not too many arguments. Since both core_prototype and pp_coreargs need special cases to deal with OA_SCALAR that is really ‘supposed’ to be OA_SCALARREF, it becomes simpler to add &CORE::undef if undef uses R. In that case, we also have to put the argument-checking in the OA_SCALARREF, but we make it conditional on the op being an undef op, for the sake of doing one thing at a time. (This is a bit of a mess; see ticket #96006.)
* regen/opcodes: Rmv evalonce commentFather Chrysostomos2012-05-211-1/+0
| | | | | | | | | | | | | This goes all the way back to when perl 5.0 was being polished up. The idea behind evalonce is that eval "constant string" should be optimisable by being compiled ahead of time, just like eval { ... }. But this could never work properly, because BEGIN blocks would only fire once. Also, eval '$x .. $y' is an easy way to create two separ- ate flip-flops. There are undoubtedly many other reasons why this could never work. So there is no reason to keep this comment any longer, as it is not (or should not be) a to-do item.
* Implement the fc keyword and the \F string escape.Brian Fraser2012-01-291-0/+3
| | | | | | | | | | | | | | | | | | | | | | Along with the simple_casefolding and full_casefolding features. fc() stands for foldcase, a sort of pseudo case (like lowercase), which is used to implement Unicode casefolding. It maps a string to a form where all case differences are erased, so it's a locale-independent way of checking if two strings are the same, regardless of case. This functionality was, and still is, available through the regular expression engine -- /i matches would use casefolding internally. The fc keyword merely exposes this for easier access. Previously, one could attempt to case-insensitively test two strings for equality by doing lc($a) eq lc($b) But that might get you wrong results, for example in the case of \x{DF}, LATIN SMALL LETTER SHARP S.
* [perl #103492] Give lvalue cx to (s)printf argsFather Chrysostomos2011-12-311-1/+1
| | | | | | | | | Or potential lvalue context, like function calls. The %n format code’s existence renders these two very much like func- tion calls, as they can modify their arguments. This allows sprintf("...%n", substr ...) to work.
* Stop seek($glob_copy...) from clearing PL_last_in_gvFather Chrysostomos2011-12-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | seek had the same bug as tell. Here is the commit message from 8dc99089, which fixed tell: ---------------------------------------------------------------------- Stop tell($glob_copy) from clearing PL_last_in_gv This bug is a side effect of rv2gv’s starting to return an incoercible mortal copy of a coercible glob in 5.14: $ perl5.12.4 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' 0 $ perl5.14.0 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' -1 In the first case, tell without arguments is returning the position of the filehandle. In the second case, tell with an explicit argument that happens to be a coercible glob (tell has an implicit rv2gv, so tell $fh is actu- ally tell *$fh) sets PL_last_in_gv to a mortal copy thereof, which is freed at the end of the statement, setting PL_last_in_gv to null. So there is no ‘last used’ handle by the time we get to the tell without arguments. This commit adds a new rv2gv flag that tells it not to copy the glob. By doing it unconditionally on the kidop, this allows tell(*$fh) to work the same way. Let’s hope nobody does tell(*{*$fh}), which will unset PL_last_in_gv because the inner * returns a mortal copy. This whole area is really icky. PL_last_in_gv should be refcounted, but that would cause handles to leak out of scope, breaking programs that rely on the auto-closing ‘feature’.
* Stop tell($glob_copy) from clearing PL_last_in_gvFather Chrysostomos2011-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug is a side effect of rv2gv’s starting to return an incoercible mortal copy of a coercible glob in 5.14: $ perl5.12.4 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' 0 $ perl5.14.0 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' -1 In the first case, tell without arguments is returning the position of the filehandle. In the second case, tell with an explicit argument that happens to be a coercible glob (tell has an implicit rv2gv, so tell $fh is actu- ally tell *$fh) sets PL_last_in_gv to a mortal copy thereof, which is freed at the end of the statement, setting PL_last_in_gv to null. So there is no ‘last used’ handle by the time we get to the tell without arguments. This commit adds a new rv2gv flag that tells it not to copy the glob. By doing it unconditionally on the kidop, this allows tell(*$fh) to work the same way. Let’s hope nobody does tell(*{*$fh}), which will unset PL_last_in_gv because the inner * returns a mortal copy. This whole area is really icky. PL_last_in_gv should be refcounted, but that would cause handles to leak out of scope, breaking programs that rely on the auto-closing ‘feature’.
* [perl #80628] __SUB__Father Chrysostomos2011-11-221-0/+2
| | | | | After much alternation, altercation and alteration, __SUB__ is finally here.
* Throw a helpful warning when someone tries length(@array) or length(%hash)Matthew Horsfall (alh)2011-11-181-1/+1
|
* Add evalbytes functionFather Chrysostomos2011-11-061-1/+1
| | | | | | | | | | | This function evaluates its argument as a byte string, regardless of the internal encoding. It croaks if the string contains characters outside the byte range. Hence evalbytes(" use utf8; '\xc4\x80' ") will return "\x{100}", even if the original string had the UTF8 flag on, and evalbytes(" '\xc4\x80' ") will return "\xc4\x80". This has the side effect of fixing the deparsing of CORE::break under ‘use feature’ when there is an override.
* Warn for $[ ‘version’ checksFather Chrysostomos2011-11-011-8/+8
| | | | | | | Following Michael Schwern’s suggestion, here is a warning for those hapless folks who use $[ for version checks. It applies whenever $[ is used in one of: < > <= >=
* regen/opcode.pl: generate OP_IS_DIRHOP, use in gv.cJim Cromie2011-09-091-6/+6
| | | | | | | Generate OP_IS_DIRHOP like other OP_IS_* macros, use in gv.c:Perl_gv_add_by_type(). Modifies 'F' operand type to 'DF'. This yields a micro-optimization.
* implement OP_IS_NUMCOMPARE like other OP_IS macrosJim Cromie2011-09-091-14/+15
| | | | | | | other macros are written by regen/opcode.pl into opnames.h Generate OP_IS_NUMCOMPARE the same way, and get a micro-optimization. Adds a new 'S<' operand type for the numeric comparison ops. Needs make regen.
* Refactor unpack’s newDEFSVOP logic; correct prototypeFather Chrysostomos2011-08-211-1/+1
| | | | | | | | | | | | | | | | | 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.
* Add coreargs opFather Chrysostomos2011-08-181-0/+3
| | | | &CORE::foo subs will use this operator for sorting out @_.
* Change (l)stat’s prototype from * to ;*Father Chrysostomos2011-08-121-2/+2
| | | | | | | | | | | | | | Since the argument is optional, we need a semicolon. This commit accomplishes that by setting the OA_OPTIONAL flag for the appropriate entries in PL_opargs. This should not affect anything else, as ck_ftst (the check routine for [l]stat) doesn’t even look at PL_opargs. It also has to tweak the prototype-generation logic slightly, because PL_opargs also has OA_DEFGV set. I think this is insignificant enough not to warrant a delta entry.
* Reorder ops so that trans{,r} and aelemfast{,_lex} are adjacent.Nicholas Clark2011-06-121-6/+3
|
* Split OP_AELEMFAST_LEX out from OP_AELEMFAST.Nicholas Clark2011-06-121-0/+2
| | | | | | | | | | | | | 6a077020aea1c5f0 extended the OP_AELEMFAST optimisation to lexical arrays. Previously OP_AELEMFAST was only used as an optimisation for OP_GV, which is a PADOP/SVOP. However, by reusing the same opcode, and signalling (pad) lexical vs package, it introduced a myriad of special cases, because OP_PADAV is a BASEOP (not a PADOP), whilst OP_AELEMFAST is a PADOP/SVOP (which is larger). Using two OP numbers allows each variant to have the correct OP flags in PL_opargs. Both can continue to share the same C code.
* Make push/shift $scalar accept only unblessed aryrefsFather Chrysostomos2011-04-181-3/+3
| | | | See ticket #80626.
* Remove references to Mac OS classic from comments the opcode descriptions.Nicholas Clark2011-01-191-4/+0
|
* Extract the opcode data from regen/opcode.pl into regen/opcodesNicholas Clark2011-01-091-0/+546
Whilst it is possible to open regen/opcode.pl and parse it to find the __END__ token, it's not the cleanest approach.