summaryrefslogtreecommitdiff
path: root/pp_proto.h
Commit message (Collapse)AuthorAgeFilesLines
* Add avhvswitch opFather Chrysostomos2016-05-201-0/+1
| | | | | &CORE::keys() et al. will use this to switch between keys and akeys depending on the argument type.
* better glibc i_modulo bug handlingjimc2016-05-171-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pp-i-modulo code currently detects a glibc bug at runtime, at the 1st exec of each I_MODULO op. This is suboptimal; the bug should be detectable early, and PL_ppaddr[I_MODULO] updated just once, before any optrees are built. Then, because we avoid the need to fixup I_MODULO ops in already built optrees, we can drop the !PERL_DEBUG_READONLY_OPS limitation on the alternative/workaround I_MODULO implementation that avoids the bug. perl.c: bug detection code is copied from PP(i_modulo), into S_fixup_platform_bugs(), and called from perl_construct(). It patches Perl_pp_i_modulo_1() into PL_ppaddr[I_MODULO] when needed. pp.c: PP(i_modulo_0), the original implementation, is renamed to PP(i_modulo) PP(i_modulo_1), the bug-fix workaround, is renamed _glibc_bugfix it is #ifdefd as before, but dropping !PERL_DEBUG_READONLY_OPS PP(i_modulo) - the 1st-exec switcher code, is dropped ocode.pl: Two i_modulo entries are added to @raw_alias. - 1st alias: Perl_pp_i_modulo => 'i_modulo' - 2nd alt: Perl_pp_i_modulo_glibc_bugfix => 'i_modulo' 1st is a restatement of the default alias/mapping that would be created without the line. 2nd line is then seen as alternative to the explicit mapping set by 1st. Alternative functions are written to pp_proto.h after the standard Perl_pp_* list, and include #if-cond, #endif wrappings, as was specified by 2nd @raw_alias addition. Changes tested by inserting '1 ||' into the 3 ifdefs and bug-detection code. TODO: In pp_proto.h generation, the #ifdef wrapping code which handles the alternative functions looks like it should also be used for the non-alternate functions. In particular, there are a handful of pp-function prototypes that should be wrapped with #ifdef HAS_SOCKET. That said, there have been no problem reports, so I left it alone. TonyC: make S_fixup_platform_bugs static, porting/libperl.t was failing.
* split pp_postdec() from pp_postinc() and improveDavid Mitchell2015-11-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pp_postinc() handles both $x++ and $x-- (and the integer variants pp_i_postinc/dec). Split it into two separate functions, as handling both inc and dec in the same function requires 3 extra conditionals. At the same time make the code more efficient. As currently written it: 1) checked for "bad" SVs (such as read-only) and croaked; 2) did a sv_setsv(TARG, TOPs) to return a copy of the original value; 2) checked for a IOK-only SV and if so, directly incremented the IVX slot; 3) else called out to sv_inc/dec() to handle the more complex cases. This commit combines the checks in (1) and (3) into one single big check of flags, and for the simple integer case, skips 2) and does a more efficient SETi() instead. For the non-simple case, both pp_postinc() and pp_postdec() now call a common static function to handle everything else. Porting/bench.pl shows the following raw numbers for '$y = $x++' ($x and $y lexical and holding integers): before after ------ ----- Ir 306.0 223.0 Dr 106.0 82.0 Dw 51.0 44.0 COND 48.0 33.0 IND 8.0 6.0 COND_m 1.9 0.0 IND_m 4.0 4.0
* split pp_predec() from pp_preinc() and improveDavid Mitchell2015-11-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pp_preinc() handles both ++$x and --$x (and the integer variants pp_i_preinc/dec). Split it into two separate functions, as handling both inc and dec in the same function requires 3 extra conditionals. At the same time make the code more efficient. As currently written it: 1) checked for "bad" SVs (such as read-only) and croaked; 2) checked for a IOK-only SV and directly incremented the IVX slot; 3) else called out to sv_inc() to handle the more complex cases. This commit combines the checks in (1) and (2) into one single big check of flags, and anything "bad" simply skips the IOK-only code and calls sv_dec(), which can do its own checking of read-only etc and croak if necessary. Porting/bench.pl shows the following raw numbers for ++$x ($x lexical and holding an integer): before after -------- -------- Ir 77.0 56.0 Dr 30.0 24.0 Dw 10.0 10.0 COND 12.0 9.0 IND 2.0 2.0 COND_m -0.1 0.0 IND_m 2.0 2.0 Even having split the function into two, the combined size of the two new functions is smaller than the single previous function.
* Delete experimental autoderef featureAaron Crane2015-07-131-1/+0
|
* Add string- and number-specific bitop typesFather Chrysostomos2015-01-311-0/+6
| | | | | and also implement the pp functions, though nothing compiles to these ops yet.
* Add :const anon sub attributeFather Chrysostomos2015-01-191-0/+1
|
* Add OP_MULTIDEREFDavid Mitchell2014-12-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+2
| | | | | | | | | | | | | | | 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-0/+1
| | | | | | | | | | | | | | | 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-0/+1
| | | | | 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-0/+1
|
* Add lvref op typeFather Chrysostomos2014-10-101-0/+1
|
* Add refassign op typeFather Chrysostomos2014-10-101-0/+1
|
* index/value array slice operationRuslan Zakirov2013-09-131-0/+1
| | | | | | 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-0/+1
| | | | | | 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-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/+1
|
* Banish boolkeysFather Chrysostomos2012-08-251-1/+0
| | | | | | | | | | | | | | Since 6ea72b3a1, rv2hv and padhv have had the ability to return boo- leans in scalar context, instead of bucket stats, if flagged the right way. sub { %hash || ... } is optimised to take advantage of this. If the || is in unknown context at compile time, the %hash is flagged as being maybe a true boolean. When flagged that way, it returns a bool- ean if block_gimme() returns G_VOID. If rv2hv and padhv can already do this, then we don’t need the boolkeys op any more. We can just flag the rv2hv to return a boolean. In all the cases where boolkeys was used, we know at compile time that it is true boolean context, so we add a new flag for that.
* Implement the fc keyword and the \F string escape.Brian Fraser2012-01-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | 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-0/+1
| | | | | After much alternation, altercation and alteration, __SUB__ is finally here.
* Merge postinc and postdecFather Chrysostomos2011-09-161-1/+0
| | | | They were nearly identical.
* Merge preinc and postincFather Chrysostomos2011-09-161-1/+0
| | | | | They are almost identical. This gives the compiler less code to digest.
* Add coreargs opFather Chrysostomos2011-08-181-0/+1
| | | | &CORE::foo subs will use this operator for sorting out @_.
* Move all the generated file header printing into read_only_top()Nicholas Clark2011-01-231-3/+3
| | | | | | | | | 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".
* Merge the implementations of {end,set}{gr,pw}ent with endhostent.Nicholas Clark2011-01-101-4/+0
| | | | | Unlike set{host,net,proto,serv}ent, set{gr,pw}ent don't have stayopen parameter, hence their "signature" is the same as the ent*ent functions.
* Merge the implementations of pp_s{host,net,proto,serv}ent.Nicholas Clark2011-01-101-3/+0
|
* Merge the implementations of pp_e{host,net,proto,serv}ent.Nicholas Clark2011-01-101-3/+0
| | | | | | | PL_op_desc[] rather than PL_op_name(), as the OPs are internally named e*ent, but implement the ent*ent functions, and when unimplemented report themselves using the function name. No need for OP_DESC(), as the switch statement means that we can't encounter OP_CUSTOM.
* Rename pp_send to pp_syswrite, making send an alias for syswrite.Nicholas Clark2011-01-091-1/+1
| | | | | Previously syswrite was an alias for send. However, syswrite is always available, whereas send is not implemented if HAS_SOCKET is not defined.
* regen/opcode.pl should only generate prototypes for pp_* functions that exist.Nicholas Clark2011-01-091-91/+2
| | | | | | | 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-2/+373
| | | | | | | | | | | 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)
* Move OP prototypes from pp_proto.h to proto.hNicholas Clark2010-09-271-414/+2
| | | | | | | | | | | | Make embed.pl fully responsible for generating prototypes and embedding macros for pp_* and ck_* functions, placing them in embed.h and proto.h opcode.pl no longer generates pp_proto.h Remove the (effectively) duplicate explicit entries for (all but 2) ck_* functions from embed.fnc We can't actually remove pp_proto.h from the distribution *yet*, as ExtUtils::MM_Unix and ExtUtils::MM_VMS have hardcoded lists of the installed headers. Once this is resolved, we can.
* Move the boolkeys op to the group of hash ops.Nicholas Clark2009-10-151-1/+1
| | | | This breaks binary compatibility.
* Optimise if (%foo) to be faster than if(keys %foo)demerphq2009-10-151-0/+1
| | | | | | | | | | | 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.
* Re: [PATCH] Splitting OP_CONST (Was: pp_const, not, that, hot?)Vincent Pit2008-02-231-0/+1
| | | | | | Message-ID: <47B60D72.50708@profvince.com> Date: Fri, 15 Feb 2008 23:08:50 +0100 p4raw-id: //depot/perl@33356
* Eliminate ck_lengthconst.Nicholas Clark2008-02-201-1/+0
| | | p4raw-id: //depot/perl@33338
* [patch] optimize OP_IS_(FILETEST|SOCKET) macrosJim Cromie2008-02-101-2/+2
| | | | | | 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-1/+0
| | | p4raw-id: //depot/perl@33072
* Implement each @array.Nicholas Clark2007-12-201-0/+4
| | | | | | 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-0/+1
| | | | | | | | | | | | | | | 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-12/+12
| | | | | logical groups. p4raw-id: //depot/perl@30784
* Make readline() default to *ARGV.Rafael Garcia-Suarez2007-03-241-0/+1
| | | | | Plus MAD fixes. p4raw-id: //depot/perl@30750
* Eliminate pp_threadsv, as it was only ever used by 5005 threads.Nicholas Clark2007-01-081-1/+0
| | | p4raw-id: //depot/perl@29727
* Patch by Yves Orton to fix the regression reported in :Andreas König2006-11-201-5/+5
| | | | | | Subject: 28325/6 break DateTime::Format::Strptime Message-ID: <877ixs6oa6.fsf@k75.linux.bogus> p4raw-id: //depot/perl@29324
* Re: $, and sayGisle Aas2006-11-021-1/+0
| | | | | | | | Message-ID: <lrek2t1e8n.fsf@caliper.activestate.com> with tweaks so "say;" continues to default to $_ plus a regression test p4raw-id: //depot/perl@29187
* Allow bareword file handle as argument to chdir().Gisle Aas2006-02-071-0/+1
| | | | | | This copies the mechanism used by truncate(). Fixes bug #38457. p4raw-id: //depot/perl@27125
* latest switch/say/~~Robin Houston2005-12-191-0/+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/+4
| | | | | | in read-only mode. Make vi modelines compatible with non-vim vi versions. p4raw-id: //depot/perl@24445