summaryrefslogtreecommitdiff
path: root/ext/Opcode
Commit message (Collapse)AuthorAgeFilesLines
* Add string- and number-specific bitop typesFather Chrysostomos2015-01-311-2/+3
| | | | | and also implement the pp functions, though nothing compiles to these ops yet.
* bump $Opcode::VERSION to 1.32Tony Cook2015-01-291-1/+1
|
* comment out dead code in Opcode::Daniel Dragan2015-01-291-2/+9
| | | | | | | | opcode_debug has never had an API to turn it on/set it to non-0 since Opcode::'s initial commit 6badd1a5d1 in 5.003001. Making opcode_debug a constant allows the CC to constant fold away the code, the warn string literals, and makes the my_cxt_t struct slightly smaller. Dont remove the code entirely since someone might find it useful one day.
* Add :const anon sub attributeFather Chrysostomos2015-01-191-1/+1
|
* Increase $Opcode::VERSION to 1.31Father Chrysostomos2014-12-211-1/+1
|
* Use GIMME_V in OpcodeFather Chrysostomos2014-12-211-1/+1
| | | | GIMME_V is a simpler macro that results in smaller machine code.
* Propagate context properly in Safe->revalFather Chrysostomos2014-12-212-1/+19
| | | | | | | | (or, rather, in Opcode.xs). It was providing scalar context when invoked in void context. Test- ing Safe->reval itself is complicated, because Opcode.xs, which is an essential part of the fix, is not dual-life.
* Add OP_MULTIDEREFDavid Mitchell2014-12-071-1/+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-1/+1
| | | | | | | | | | | | | | | 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
* Opcode.pm: wrap long verbatim pod lineFather Chrysostomos2014-11-281-1/+2
|
* speedup for SUPER::method() calls.syber2014-11-281-2/+2
| | | | | | | | | | | | | | | 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/+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-1/+1
|
* Add lvref op typeFather Chrysostomos2014-10-101-1/+1
|
* Increase $Opcode::VERSION to 1.29Father Chrysostomos2014-10-101-1/+1
|
* Add refassign op typeFather Chrysostomos2014-10-101-1/+1
|
* Critical bugfix in module Safe (Opcode). Version increased, changelog and ↵syber2014-08-052-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | test added. This example hacks outside environment: package My::Controller; use strict; sub jopa { return "jopa\n"; } package main; use Safe; my $s = new Safe; my $ok = $s->reval(q{ package My::Controller; sub jopa { return "hacked\n"; } My::Controller->jopa(); }); print My::Controller->jopa();
* Opcode: fix 'null argument' warningDavid Mitchell2013-11-132-2/+4
| | | | | | | | | | | | | | | | HvNAME_get() can return NULL, and strNE() wants non-null args. [ As a side note: on debugging builds this line if (strNE(HvNAME_get(hv),"main")) { macro-expands into an 18,000 character line (!) due to the fact that HvNAME_get() is quite a big expansion under debugging, and strNE expands to strlen, which under gcc expands to a huge macro (which is mainly lots of different compile-time alternatives depending on which of its args are constants), that references its args several times. ]
* Increase $Opcode::VERSION to 1.26Father Chrysostomos2013-09-131-1/+1
|
* Add new opcodes to Opcode.pmFather Chrysostomos2013-09-131-3/+4
|
* add padrange opDavid Mitchell2012-11-101-2/+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/+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-1/+1
| | | | | This will be used for introducing ‘my’ subs on scope entry, by turning off the stale flag.
* Add padcv to Opcode.pmFather Chrysostomos2012-09-151-1/+1
|
* Opcode.pm: wrap long pod linesFather Chrysostomos2012-08-261-17/+24
|
* Increase $Opcode::VERSION to 1.24Father Chrysostomos2012-08-261-1/+1
|
* Remove boolkeys opFather Chrysostomos2012-08-261-1/+1
|
* Implement the fc keyword and the \F string escape.Brian Fraser2012-01-291-2/+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-2/+2
| | | | | After much alternation, altercation and alteration, __SUB__ is finally here.
* [perl #101486] Make PL_curstash refcountedFather Chrysostomos2011-10-222-3/+3
| | | | | | | | | | This stops PL_curstash from pointing to a freed-and-reused scalar in cases like ‘package Foo; BEGIN {*Foo:: = *Bar::}’. In such cases, another BEGIN block, or any subroutine definition, would cause a crash. Now it just happily proceeds. newATTRSUB and newXS have been modified not to call mro_method_changed_in in such cases, as it doesn’t make sense.
* Add coreargs opFather Chrysostomos2011-08-181-2/+2
| | | | &CORE::foo subs will use this operator for sorting out @_.
* Split OP_AELEMFAST_LEX out from OP_AELEMFAST.Nicholas Clark2011-06-121-2/+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.
* Fix typos (spelling errors) in ext/*.Peter J. Acklam) (via RT2011-01-071-1/+1
| | | | | | | | | # New Ticket Created by (Peter J. Acklam) # Please include the string: [perl #81882] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81882 > Signed-off-by: Abigail <abigail@abigail.be>
* bump version of many modulesZefram2010-12-191-1/+1
| | | | | Core-only modules that have changed from v5.13.7, and dual-life modules that have changed from v5.13.7 and didn't show up in earlier passes.
* Convert ext/Opcode/t/ops.t to Test::MoreNicholas Clark2010-12-171-7/+5
|
* fix various compiler warnings from XS codeZefram2010-12-111-2/+2
| | | | | | | | | | | Trivial changes to fix warnings of types * unclear precedence * assignment as conditional * signed/unsigned mixing * unused parameter/variable * value computed not used * wrong argument type for a printf format * variable may be used uninitialised (due to unhandled switch case)
* Test that Opcode loads without warnings.Nicholas Clark2010-11-091-3/+13
| | | | This will fail if there are untagged ops.
* Tidy up ext/Opcode/t/Opcode.t.Nicholas Clark2010-11-091-10/+10
| | | | | Convert a loop with a die into regular tests. Don't declare lexicals ahead of use. Don't even declare a lexical @o3, which isn't used.
* Convert ext/Opcode/t/Opcode.t to Test::More.Nicholas Clark2010-11-091-39/+39
| | | | The tests (including the still-TODO) mostly date from 1996.
* Add new ops in Opcode, so it does not warn at compilationRafael Garcia-Suarez2010-11-061-3/+3
| | | | The ops are the recently-introduced reach, rvalues, rkeys and transr.
* All callers of get_op_bitspec() in Opcode.xs pass len, so don't call strlen().Nicholas Clark2010-11-011-2/+0
| | | | This commit brought to you by the campaign for elimination of strlen().
* Small refactoring of op_names_init() and put_op_bitspec() in Opcode.xsNicholas Clark2010-11-011-7/+3
| | | | | | | | | Change op_names_init() to use memset() rather than a longhand loop, and to call put_op_bitspec() with an explicit length by using STR_WITH_LEN(). As all calls to put_op_bitspec() now pass in a length, remove the code to call strlen() if the passed-in length is zero. This commit brought to you by the campaign for elimination of strlen().
* Convert modules in ext/ to pass minimal arguments to XSLoader::load().Nicholas Clark2010-10-141-3/+3
|
* Replace sv_2mortal(newSVpvn(...)) with newSVpvn_flags(..., SVs_TEMP)Nicholas Clark2009-10-151-4/+8
|
* Use gv_stashsv() and gv_fetchpvs(), the later with proper arguments.Nicholas Clark2009-10-152-7/+7
| | | | | | | Brought to you by the Campaign for the Elimination of strlen(). (And the elimination of accidental bugs due to typos in lenghts of constants, and the elimination of abuse of boolean constants for parameters with more than 2 values.)
* 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.
* Make extensions in ext run their tests from the extension's own directory.Nicholas Clark2009-08-282-4/+0
| | | | | | | | | | | Inspired by, and in parts borrows from, Schwern's branch on github, but takes a slightly different approach in places. Not quite perfect yet - ext/File-Glob still runs from t, at least one FIXME needs fixing, and the changes to dual-life modules' tests need to be filtered back upstream, and possibly modified to suit their respective authors. But it works.
* Mark all .t and .pm files as non executableRafael Garcia-Suarez2009-06-062-0/+0
|
* make_ext.pl's automatic Makefile.PL generation can write these five for us.Nicholas Clark2009-03-261-6/+0
|
* Move Safe.pm into ext/Safe, and temporarily give it a Makfile.PLNicholas Clark2009-02-101-634/+0
|