summaryrefslogtreecommitdiff
path: root/opnames.h
Commit message (Collapse)AuthorAgeFilesLines
* Delete experimental autoderef featureAaron Crane2015-07-131-16/+13
|
* Add OP_IS_INFIX_BITFather Chrysostomos2015-01-311-0/+3
| | | | A convenience macro that a forthcoming commit will use.
* Add string- and number-specific bitop typesFather Chrysostomos2015-01-311-294/+302
| | | | | and also implement the pp functions, though nothing compiles to these ops yet.
* Add :const anon sub attributeFather Chrysostomos2015-01-191-1/+2
|
* Add OP_MULTIDEREFDavid Mitchell2014-12-071-242/+243
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This op is an optimisation for any series of one or more array or hash lookups and dereferences, where the key/index is a simple constant or package/lexical variable. If the first-level lookup is of a simple array/hash variable or scalar ref, then that is included in the op too. So all of the following are replaced with a single op: $h{foo} $a[$i] $a[5][$k][$i] $r->{$k} local $a[0][$i] exists $a[$i]{$k} delete $h{foo} while these aren't: $a[0] already handled by OP_AELEMFAST $a[$x+1] not a simple index and these are partially replaced: (expr)->[0]{$k} the bit following (expr) is replaced $h{foo}[$x+1][0] the first and third lookups are each done with a multideref op, while the $x+1 expression and middle lookup are done by existing add, aelem etc ops. Up until now, aggregate dereferencing has been very heavyweight in ops; for example, $r->[0]{$x} is compiled as: gv[*r] s rv2sv sKM/DREFAV,1 rv2av[t2] sKR/1 const[IV 0] s aelem sKM/DREFHV,2 rv2hv sKR/1 gvsv[*x] s helem vK/2 When executing this, in addition to the actual calls to av_fetch() and hv_fetch(), there is a lot of overhead of pushing SVs on and off the stack, and calling lots of little pp() functions from the runops loop (each with its potential indirect branch miss). The multideref op avoids that by running all the code in a loop in a switch statement. It makes use of the new UNOP_AUX type to hold an array of typedef union { PADOFFSET pad_offset; SV *sv; IV iv; UV uv; } UNOP_AUX_item; In something like $a[7][$i]{foo}, the GVs or pad offsets for @a and $i are stored as items in the array, along with a pointer to a const SV holding 'foo', and the UV 7 is stored directly. Along with this, some UVs are used to store a sequence of actions (several actions are squeezed into a single UV). Then the main body of pp_multideref is a big while loop round a switch, which reads actions and values from the AUX array. The two big branches in the switch are ones that are affectively unrolled (/DREFAV, rv2av, aelem) and (/DREFHV, rv2hv, helem) triplets. The other branches are various entry points that handle retrieving the different types of initial value; for example 'my %h; $h{foo}' needs to get %h from the pad, while '(expr)->{foo}' needs to pop expr off the stack. Note that there is a slight complication with /DEREF; in the example above of $r->[0]{$x}, the aelem op is actually aelem sKM/DREFHV,2 which means that the aelem, after having retrieved a (possibly undef) value from the array, is responsible for autovivifying it into a hash, ready for the next op. Similarly, the rv2sv that retrieves $r from the typeglob is responsible for autovivifying it into an AV. This action of doing the next op's work for it complicates matters somewhat. Within pp_multideref, the autovivification action is instead included as the first step of the current action. In terms of benchmarking with Porting/bench.pl, a simple lexical $a[$i][$j] shows a reduction of approx 40% in numbers of instructions executed, while $r->[0][0][0] uses 54% fewer. The speed-up for hash accesses is relatively more modest, since the actual hash lookup (i.e. hv_fetch()) is more expensive than an array lookup. A lexical $h{foo} uses 10% fewer, while $r->{foo}{bar}{baz} uses 34% fewer instructions. Overall, bench.pl --tests='/expr::(array|hash)/' ... gives: PRE POST ------ ------ Ir 100.00 145.00 Dr 100.00 165.30 Dw 100.00 175.74 COND 100.00 132.02 IND 100.00 171.11 COND_m 100.00 127.65 IND_m 100.00 203.90 with cache misses unchanged at 100%. In general, the more lookups done, the bigger the proportionate saving.
* Speed up method calls like $o->Other::method() and $o->Other::SUPER::method().syber2014-12-021-182/+184
| | | | | | | | | | | | | | | It was done by adding new OP_METHOD_REDIR and OP_METHOD_REDIR_SUPER optypes. Class name to redirect is saved into METHOP as a shared hash string. Method name is changed (class name removed) an saved into op_meth_sv as a shared string hash. So there is no need now to scan for '::' and calculate class and method names at runtime (in gv_fetchmethod_*) and searching cache HV without precomputed hash. B::* modules are changed to support new op types. method_redir is now printed by Concise like (for threaded perl) $obj->AAA::meth 5 <.> method_redir[PACKAGE "AAA", PV "meth"] ->6
* speedup for SUPER::method() calls.syber2014-11-281-182/+183
| | | | | | | | | | | | | | | In ck_method: Scan for '/::. If found SUPER::, create OP_METHOD_SUPER op with precomputed hash value for method name. In B::*, added support for method_super In pp_hot.c, pp_method_*: S_method_common removed, code related to getting stash is moved to S_opmethod_stash, other code is moved to pp_method_* functions. As a result, SUPER::func() calls speeded up by 50%.
* Add lvavref op typeFather Chrysostomos2014-10-111-1/+2
| | | | | This will be used for slurpy array ref assignments. \(@a) = \(@b) will make @a share the same elements as @b.
* Add lvrefslice op typeFather Chrysostomos2014-10-101-1/+2
|
* Add lvref op typeFather Chrysostomos2014-10-101-1/+2
|
* Add refassign op typeFather Chrysostomos2014-10-101-1/+2
|
* index/value array slice operationRuslan Zakirov2013-09-131-247/+248
| | | | | | kvaslice operator that imlements %a[0,2,4] syntax which result in list of index/value pairs. Implemented in consistency with "key/value hash slice" operator.
* key/value hash slice operationRuslan Zakirov2013-09-131-235/+236
| | | | | | kvhslice operator that implements %h{1,2,3,4} syntax which returns list of key value pairs rather than just values (regular slices).
* add padrange opDavid Mitchell2012-11-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+2
| | | | | | 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-1/+2
| | | | | This will be used for introducing ‘my’ subs on scope entry, by turning off the stale flag.
* padcv op typeFather Chrysostomos2012-09-151-1/+2
|
* Remove boolkeys opFather Chrysostomos2012-08-261-232/+231
|
* Add OP_FREED op typeFather Chrysostomos2012-06-291-0/+1
| | | | | | | | This is a dummy op type that should never be seen by any code except op allocation code (to come). So it is not in the usual list of opcodes, but is #defined outside the range valid of opcodes.
* Implement the fc keyword and the \F string escape.Brian Fraser2012-01-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | 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 #80628] __SUB__Father Chrysostomos2011-11-221-1/+2
| | | | | After much alternation, altercation and alteration, __SUB__ is finally here.
* regen/opcode.pl: generate OP_IS_DIRHOP, use in gv.cJim Cromie2011-09-091-3/+7
| | | | | | | 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-0/+3
| | | | | | | 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.
* Add coreargs opFather Chrysostomos2011-08-181-1/+2
| | | | &CORE::foo subs will use this operator for sorting out @_.
* Reorder ops so that trans{,r} and aelemfast{,_lex} are adjacent.Nicholas Clark2011-06-121-335/+335
|
* Split OP_AELEMFAST_LEX out from OP_AELEMFAST.Nicholas Clark2011-06-121-1/+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.
* Move all the generated file header printing into read_only_top()Nicholas Clark2011-01-231-5/+4
| | | | | | | | | Previously all the scripts in regen/ had code to generate header comments (buffer-read-only, "do not edit this file", and optionally regeneration script, regeneration data, copyright years and filename). This change results in some minor reformatting of header blocks, and standardises the copyright line as "Larry Wall and others".
* Extract the opcode data from regen/opcode.pl into regen/opcodesNicholas Clark2011-01-091-1/+1
| | | | | Whilst it is possible to open regen/opcode.pl and parse it to find the __END__ token, it's not the cleanest approach.
* Remove OP_phoney_{IN,OUT}PUT_ONLY, as they are no longer used or supported.Nicholas Clark2010-12-281-3/+0
|
* Add transr op typeFather Chrysostomos2010-11-021-1/+2
| | | | | for the upcoming y///r feature. There are not enough flag bits, hence the extra type.
* Allow push/pop/keys/etc to act on referencesDavid Golden2010-10-311-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All built-in functions that operate directly on array or hash containers now also accept hard references to arrays or hashes: |----------------------------+---------------------------| | Traditional syntax | Terse syntax | |----------------------------+---------------------------| | push @$arrayref, @stuff | push $arrayref, @stuff | | unshift @$arrayref, @stuff | unshift $arrayref, @stuff | | pop @$arrayref | pop $arrayref | | shift @$arrayref | shift $arrayref | | splice @$arrayref, 0, 2 | splice $arrayref, 0, 2 | | keys %$hashref | keys $hashref | | keys @$arrayref | keys $arrayref | | values %$hashref | values $hashref | | values @$arrayref | values $arrayref | | ($k,$v) = each %$hashref | ($k,$v) = each $hashref | | ($k,$v) = each @$arrayref | ($k,$v) = each $arrayref | |----------------------------+---------------------------| This allows these built-in functions to act on long dereferencing chains or on the return value of subroutines without needing to wrap them in C<@{}> or C<%{}>: push @{$obj->tags}, $new_tag; # old way push $obj->tags, $new_tag; # new way for ( keys %{$hoh->{genres}{artists}} ) {...} # old way for ( keys $hoh->{genres}{artists} ) {...} # new way For C<push>, C<unshift> and C<splice>, the reference will auto-vivify if it is not defined, just as if it were wrapped with C<@{}>. Calling C<keys> or C<values> directly on a reference gives a substantial performance improvement over explicit dereferencing. For C<keys>, C<values>, C<each>, when overloaded dereferencing is present, the overloaded dereference is used instead of dereferencing the underlying reftype. Warnings are issued about assumptions made in the following three ambiguous cases: (a) If both %{} and @{} overloading exists, %{} is used (b) If %{} overloading exists on a blessed arrayref, %{} is used (c) If @{} overloading exists on a blessed hashref, @{} is used
* opcode.pl -> regen/opcode.plFather Chrysostomos2010-10-131-2/+2
|
* Move the boolkeys op to the group of hash ops.Nicholas Clark2009-10-151-225/+225
| | | | This breaks binary compatibility.
* Optimise if (%foo) to be faster than if(keys %foo)demerphq2009-10-151-1/+2
| | | | | | | | | | | Thread was "[PATCH] Make if (%hash) {} act the same as if (keys %hash) {}" http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2006-11/msg00432.html but the implementation evolved from the approach described in the subject, to instead add a new opcode pp_boolkeys, to exactly preserve the existing behaviour. Various conflicts with the passage of time resolved, 'register' removed, and a $VERSION bump.
* Update copyright year in opcode.pl to reflect change 33364.Nicholas Clark2008-10-251-1/+1
| | | p4raw-id: //depot/perl@34587
* Re: [patch] optimize OP_IS_(FILETEST|SOCKET) macrosJim Cromie2008-02-251-0/+3
| | | | | | From: "Jim Cromie" <jim.cromie@gmail.com> Message-ID: <cfe85dfa0802101152n4e1b9e07pc7fb7ad9241a9794@mail.gmail.com> p4raw-id: //depot/perl@33364
* Re: [PATCH] Splitting OP_CONST (Was: pp_const, not, that, hot?)Vincent Pit2008-02-231-40/+41
| | | | | | Message-ID: <47B60D72.50708@profvince.com> Date: Fri, 15 Feb 2008 23:08:50 +0100 p4raw-id: //depot/perl@33356
* [patch] optimize OP_IS_(FILETEST|SOCKET) macrosJim Cromie2008-02-101-405/+370
| | | | | | Message-ID: <47ADBF3B.2050108@gmail.com> Date: Sat, 09 Feb 2008 07:56:59 -0700 p4raw-id: //depot/perl@33267
* Eliminate the OP_SETSTATE, which had been disabled by change 4309.Nicholas Clark2008-01-261-169/+168
| | | p4raw-id: //depot/perl@33072
* Implement each @array.Nicholas Clark2007-12-201-233/+236
| | | | | | Documentation needed, FIXME for proper 64 bit support of arrays longer than 2**32, re-order the new ops at the end if merging to 5.10.x. p4raw-id: //depot/perl@32680
* Make state $zok = slosh(); behave as the Perl 6 design with an implicitNicholas Clark2007-09-061-2/+3
| | | | | | | | | | | | | | | START block. First time through, call slosh() and assign to $zok. Subsequently neither call slosh() nor assign to $zok. Adds a new op ONCE to control the conditonal call and assign. No change to list context, so state ($zok) = slosh() and (state $zok) = ... etc will still repeatedly evaluate and assign. [Can't fix that before 5.10] Use as an RVALUE is as Larry's design - my $boff = state $zok = ...; will evaluate, assign and return first time, and subsequently act as if it were written my $boff = $zok; FIXME - state $zok = ...; won't deparse - I believe op->op_last isn't being correctly set on the sassign, but I don't know how to fix this. This change may be backed out before 5.10. p4raw-id: //depot/perl@31798
* A logical rearrangement of ops, to get the post 5.005 ops to theirNicholas Clark2007-03-301-262/+262
| | | | | logical groups. p4raw-id: //depot/perl@30784
* Eliminate pp_threadsv, as it was only ever used by 5005 threads.Nicholas Clark2007-01-081-16/+15
| | | p4raw-id: //depot/perl@29727
* Re-order ops to the implementation order in pp_sys.c - this makes aNicholas Clark2006-11-121-14/+14
| | | | | branch table corresponding to a switch statement slightly smaller. p4raw-id: //depot/perl@29251
* Update the copyright years in the generated files, and nostdio.hNicholas Clark2006-01-081-1/+2
| | | p4raw-id: //depot/perl@26736
* latest switch/say/~~Robin Houston2005-12-191-2/+10
| | | | | Message-Id: <20051217204431.GB28940@rpc142.cs.man.ac.uk> p4raw-id: //depot/perl@26400
* Include vim/emacs modelines in generated files to open themRafael Garcia-Suarez2005-05-111-1/+3
| | | | | | in read-only mode. Make vi modelines compatible with non-vim vi versions. p4raw-id: //depot/perl@24445
* Update copyright noticesRafael Garcia-Suarez2004-03-161-1/+1
| | | p4raw-id: //depot/perl@22509
* Fix up Larry's copyright statements to my best knowledge.Jarkko Hietaniemi2003-04-161-1/+1
| | | | | | | (Lots of Perl 5 source code archaeology was involved.) Larry didn't make strangled noises when I showed him the patch, either :-) p4raw-id: //depot/perl@19242
* Update all copyrights to 2003, from JarkkoHugo van der Sanden2003-03-021-1/+1
| | | p4raw-id: //depot/perl@18801