summaryrefslogtreecommitdiff
path: root/ext/B
Commit message (Collapse)AuthorAgeFilesLines
* Revert "[perl #118525] Return B::HEK for B::CV::GV of lexical subs"Father Chrysostomos2013-07-122-66/+1
| | | | | | | This reverts commit 8748370e90a24f3901d476f43ed77f1ac3d861f4. There appears to be a typemap problem. I accidentally pushed the patch too soon. Sorry for the noise.
* [perl #118525] Return B::HEK for B::CV::GV of lexical subsReini Urban2013-07-122-1/+66
| | | | | | A lexsub has a hek instead of a gv. Provide a ref to a PV for the name in the new B::HEK class. This crashed previously accessing the not existing SvFLAGS of the hek.
* [perl #117727] Document B::PADLISTFather Chrysostomos2013-07-051-1/+30
| | | | I neglected this when I added that class in perl 5.17.4
* Revert "Create SVt_INVLIST"Karl Williamson2013-07-041-1/+1
| | | | | | | | This reverts commit e045dbedc7da04e20cc8cfccec8a2e3ccc62cc8b. Blead won't compile with address sanitizer; commit 7cb47964955167736b2923b008cc8023a9b035e8 reverting an earlier commit failed to fix that. I'm trying two more reversions to get it back working. This is one of those
* Create SVt_INVLISTKarl Williamson2013-07-031-1/+1
| | | | | | | | | | This reshuffles the svtype enum to remove the dummy slot created in a previous commit, and add the new SVt_INVLIST type in its proper order. It still is unused, but since it is an extension of SVt_PV, it must be greater than that type's enum value. Since it can't be upgraded to any other PV type, it comes right after SVt_PV. Affected tables in the core are updated.
* Fix up f_sort.t for changes in the prev commitFather Chrysostomos2013-06-261-20/+40
|
* Update B's size/offset for CvFLAGS to U32, following commit 51c78f1b91bbcd7a.Nicholas Clark2013-06-251-1/+1
| | | | | | | | | B.xs contains a table of offsets and sizes for members of the various SV structures. This needs updating as 51c78f1b91bbcd7a changed CvFLAGS from U16 to U32. This ommision won't be noticed on little endian platforms, but on big endian platforms B::CV::CvFLAGS will return 0 instead of the true value. For: RT #118603
* Quote and indent %B::Concise::priv initialisation consistentlyDagfinn Ilmari Mannsåker2013-06-241-68/+60
| | | | | | | | | | | | | | | | - use qw() for all word lists - use double quotes for single strings (only) where necessary - hanging indent after opening operator/paren No difference in the resulting data structure, as verified with: ./perl -Ilib -MData::Dumper -MB::Concise -e 'package Data::Dumper { $Sortkeys = $Terse = $Useqq = $Deepcopy = 1; $Quotekeys = 0 } print Dumper(\%B::Concise::priv)' Bump B::Concise $VERSION. For: RT #118609.
* Stop split from mangling constantsFather Chrysostomos2013-06-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | At compile time, if split occurs on the right-hand side of an assign- ment to a list of scalars, if the limit argument is a constant con- taining the number 0 then it is modified in place to hold one more than the number of scalars. This means ‘constants’ can change their values, if they happen to be in the wrong place at the wrong time: $ ./perl -Ilib -le 'use constant NULL => 0; ($a,$b,$c) = split //, $foo, NULL; print NULL' 4 I considered checking the reference count on the SV, but since XS code could create its own const ops with weak references to the same cons- tants elsewhere, the safest way to avoid modifying someone else’s SV is to mark the split op in ck_split so we know the SV belongs to that split op alone. Also, to be on the safe side, turn off the read-only flag before modi- fying the SV, instead of relying on the special case for compile time in sv_force_normal.
* Increase $B::Concise::VERSION to 0.97Father Chrysostomos2013-06-221-1/+1
|
* Fixed verbatim lines in POD over 79 charactersBrian Gottreu2013-06-221-7/+7
|
* Increase $B::VERSION to 1.44Father Chrysostomos2013-06-211-1/+1
|
* Remove BmRARE and BmPREVIOUSFather Chrysostomos2013-06-211-7/+13
| | | | | These were only used by the study code, which was disabled in 5.16.0 and removed shortly thereafter.
* optree_constants.t: Correct line number in commentFather Chrysostomos2013-06-211-1/+1
| | | | | | | Why we need a reference like this is beyond me, but it is extremely fragile, because even cosmetic changes to gv.t will throw it off. That said, at least the next person looking at it won’t be as puzzled as I was (until the next gv.t change).
* Fix ext\B\t\concise.t when building with ALL_STATIC=define on WindowsSteve Hay2013-06-181-2/+6
| | | | | Skip testing that Data::Dumper is loaded as needed when it is statically linked.
* Typo fixes for B modules.David Steinbrunner2013-05-253-6/+6
| | | | | | | Uses of 'optimise' change to 'optimize' to be consistent with other uses of 'optimize'. Bump $VERSION.
* Tweak the test from 2721a2ca2e5e889d to work with PERL_UNICODE set.Nicholas Clark2013-01-111-2/+2
|
* stop -MO=Concise -e'm?x?' segfaultingDavid Mitchell2013-01-094-21/+49
| | | | | | | | | | | | | | | The op_pmreplstart field in a PMOP is actually a union, containing op_pmreplstart for OP_SUBST, and op_pmstash/op_pmstashoff for OP_MATCH with PMf_ONCE set. The B pmreplstart method just blindly treated the value of this field as an op pointer, even when it wasn't an OP_SUBST. Hence the segfault. Make it instead return a null pointer when not OP_SUBST. At the same time I improved the PMOP handling code in Concise.xs so that it expects particular types for that and the op_pmreplrootu union based on the op type (OP_SUBST or OP_PUSHRE) rather than trying to handle any field value regardless of op type.
* B.xs: silence clang warningDavid Mitchell2012-12-131-1/+1
| | | | PADOFFSET is unsigned, so checking that it's >= 0 is pointless.
* Remove improper use of each() in B::walksymtable and fix ext/B/t/xref.tYves Orton2012-11-222-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improper use of each() in walksymtable() makes behavior undefined. As of the hash randomization patch ext/B/t/xref.t would occasionally fail. A closer inspection revealed that the output that is parsed in t/xref.t would vary greatly from run to run, with bizarre double entries and sometimes missing packages, etc. So in 100 runs we would see something like 25 of one variant, and then 25 of another, and then about 50 singletons. The notable difference between the two large groups is that one was missing entire modules worth of output, the other appeared to be correct. The singletons tended to differ from one of the other two by a line or two. Changing the each() to a keys() appears to fix this bug, making the output consistent every time. My theory is that it is possible for the symbol table logic to recurse and enter the same package twice, which would result in its each iterator changing state but I have not verfied this. In order to make sure that the traversal order is deterministic I decided to use sort(keys()) (In other words the sort() is there to guarantee a given output in the future, not to fix this bug). Annoyingly many times the test would pass even though the output it was parsing was grossly wrong. I think we need to figure out a better way to test this module. We should probably check for the presence of various packages, like the B package itsef, Errno.pm etc. I cannot explain yet why this bug was sensitive to build options. My normal build options seemed to not have any issue, wheras others did. Apparently ok (with or without -Dusethreads): git clean -dfX; ./Configure -Doptimize=-g -d -Dusedevel -Dusethreads -Dprefix=~/bleadperl -Dcc=ccache\ gcc -Dld=gcc -DDEBUGGING Regular fails: git clean -dfx; ./Configure -des -Dusedevel -Dprefix=~/bleadperl -Dcc=ccache\ gcc -Dld=gcc My tests used the following one liners: for file in test{1..100}; do ./perl -Ilib ext/B/t/xref.t > $file 2>&1; done; md5sum test* | sort | uniq -c -w32 | sort -n
* ext/B/t/OptreeCheck.pm: fix hint strippingDavid Mitchell2012-11-101-1/+1
| | | | | The code that strips hints from a nextstate couldn't handle the 'next' pointer being '-', e.g. v:>,<,% ->-
* fix optree_misc.t test after smokeDavid Mitchell2012-11-101-34/+34
| | | | | Some of the unicode setting in a smoke environment sets the open hints output on nextstate lines.
* Consolidate any single pad ops after a padrangeDavid Mitchell2012-11-101-1/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Given something like my ($a,$b); my $c; my $d; then after having detected that we can create a padrange op for $a,$b, extend it to include $c,$d too. Together with the previous commit that consolidates adjacent padrange ops, this means that any contiguous sequence of void 'my' declarations that starts with a list (i.e. my ($x,..) rather than my $x) will all be compressed into a single padrange op. For example my ($a,$b); my @c; my %d; my ($e,@f); becomes the two ops padrange[$a;$b;@c;%d;$e;@f] nextstate The restriction on the first 'my' being a list is that we only ever convert pushmarks into padranges, to keep things manageable (both for compiling and for Deparse). This simply means that my $x; my ($a,$b); my @c; my %d; my ($e,@f) becomes padsv[$x] nextstate padrange[$a;$b;@c;%d;$e;@f] nextstate
* Consolidate adjacent padrange opsDavid Mitchell2012-11-101-1/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In something like my ($a,$b); my ($c,$d); when converting $c,$d into a padrange op, check first whether we're immediately preceded by a similar padrange (and nextstate) op, and if so re-use the existing padrange op (by increasing the count). Also, skip the first nextstate and only use the second nextstate. So pushmark; padsv[$a]; padsv[$b]; list; nextstate 1; pushmark; padsv[$c]; padsv[$c]; list; nextstate 2; becomes padrange[$a,$b] nextstate 1; pushmark; padsv[$c]; padsv[$c]; list; nextstate 2; which then becomes padrange[$a,$b,$c,$d]; nextstate 2;
* padrange: handle @_ directlyDavid Mitchell2012-11-102-3/+141
| | | | | | | | | | | | | | | | | | | | | | | | | In a construct like my ($x,$y) = @_ the pushmark/padsv/padsv is already optimised into a single padrange op. This commit makes the OPf_SPECIAL flag on the padrange op indicate that in addition, @_ should be pushed onto the stack, skipping an additional pushmark/gv[*_]/rv2sv combination. So in total (including the earlier padrange work), the above construct goes from being 3 <0> pushmark s 4 <$> gv(*_) s 5 <1> rv2av[t3] lK/1 6 <0> pushmark sRM*/128 7 <0> padsv[$x:1,2] lRM*/LVINTRO 8 <0> padsv[$y:1,2] lRM*/LVINTRO 9 <2> aassign[t4] vKS to 3 <0> padrange[$x:1,2; $y:1,2] l*/LVINTRO,2 ->4 4 <2> aassign[t4] vKS
* add padrange opDavid Mitchell2012-11-104-80/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 $B::overlay featureDavid Mitchell2012-11-103-1/+118
| | | | | | | This allows you to alter the read-only "view" of an optree, by making particular B::*OP methods on particular op nodes return customised values. Intended to be used by B::Deparse to "undo" optimisations, thus making it easier to add new optree optimisations without breaking Deparse.
* Allow regexp-to-pvlv assignmentFather Chrysostomos2012-10-302-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since the xpvlv and regexp structs conflict, we have to find somewhere else to put the regexp struct. I was going to sneak it in SvPVX, allocating a buffer large enough to fit the regexp struct followed by the string, and have SvPVX - sizeof(regexp) point to the struct. But that would make all regexp flag-checking macros fatter, and those are used in hot code. So I came up with another method. Regexp stringification is not speed-critical. So we can move the regexp stringification out of re->sv_u and put it in the regexp struct. Then the regexp struct itself can be pointed to by re->sv_u. So SVt_REGEXPs will have re->sv_any and re->sv_u pointing to the same spot. PVLVs can then have sv->sv_any point to the xpvlv body as usual, but have sv->sv_u point to a regexp struct. All regexp member access can go through sv_u instead of sv_any, which will be no slower than before. Regular expressions will no longer be SvPOK, so we give sv_2pv spec- ial logic for regexps. We don’t need to make the regexp struct larger, as SvLEN is currently always 0 iff mother_re is set. So we can replace the SvLEN field with the pv. SvFAKE is never used without SvPOK or SvSCREAM also set. So we can use that to identify regexps.
* start to make ext/B work with 5.14.xDavid Mitchell2012-10-262-12/+19
| | | | | | This fixes up a couple of test files to work under 5.14.x. Lots more needs fixing up to make the whole distribution work under 5.14.x, but I've lost the will for now.,
* B.xs: move all B::*OP methods to B::OP::nextDavid Mitchell2012-10-261-221/+175
| | | | | | | | | | The previous commit moved all B::*OP methods capable of using direct field offsets into next(). This commit moves the remaining B::*OP methods onto it too (apart from oplist(), which returns a list rather than a single item). This simplifies the code, reduces the object size, and will also make it easier to add an overlay facility, which will be coming soon.
* B.xs: rationalise all methods aliased to next()David Mitchell2012-10-261-149/+145
| | | | | | | | | | | | | | | | | | | | | | The code for B::OP::next() actually implements all B::*OP::* methods that work by directly returning a field at a known offset in the OP structure. Methods that can't do direct access usually have their own body, rather than sharing with next(). However, whether a method can do direct field access is often dependent on threading and/or perl version; so the same method is sometimes implemented by next(), and sometimes by one or more individual method bodies. This is all very confusing. This commit takes all methods that *may* be implemented within next(), and makes them always implemented by next(), using a table of data that describes each method's offset, or -1 if it needs special handling. This makes it a lot easier to see what's going on, and will also make it easier to add an overlay facility, which will be coming soon. The following commit will consolidate the remaining B::*OP methods within next().
* ext/B: remove pre-5.10 supportDavid Mitchell2012-10-2611-351/+53
| | | | | | | | | Expunge all conditional code that supports 5.6.x through 5.9.x, making 5.10.0 the oldest release notionally supported. This simplifies things considerably. See p5p thread starting at Message-ID: <20121018122941.GE1908@iabyn.com>
* make ext/B work with 5.16.xDavid Mitchell2012-10-2612-61/+196
| | | | | | | | | | | | | | | | | | | | | | | | | | The modules and tests under ext/B are notionally supposed to be portable to older perl versions; in practice, extensive bit-rot has occurred; often attempts have been made to add version-specific code, which haven't actually been tested against older perl versions. This commit does the minimum necessary to get the tests under ext/B working with 5.16.0 and 5.16.1, threaded and unthreaded. It makes no assertions as to whether it will work with the rest of the 5.16.x test suite. The side effects of this fix-up are: * a facility has been added to OptreeCheck.pm (the test module that checks the Concise output of various constructs) that allows version-specific matching, e.g.: # 4 <$> const(PV "junk") s* < 5.017002 # 4 <$> const(PV "junk") s*/FOLD >=5.017002 * OptreeCheck.pm's skip mechanism was found to be broken: checkOptree() allows you to specify skipping, but only skipped one test, even though a single call to checkOptree() could generate multiple lines of test output.
* fix hash order dependency in ext/B/t/b.tYves Orton2012-10-261-2/+6
| | | | Hash seed randomization causes these tests to fail occasionally.
* [perl #49190] Don’t prematurely optimise s/foo/bar$baz/Father Chrysostomos2012-10-112-13/+11
| | | | | | | | | | | | | | | | | | | | | | | $baz could be aliased to a package variable, so we do need to recon- catenate for every iteration of s///g. For s/// without /g, only one more op will be executed, so the speed difference is negligible. The only cases we can optimise in terms of skipping the evaluation of the ops on the rhs (by eliminating the substconst op) are s//constant/ and s//$single_variable/. Anything more complicated causes bugs. A recent commit made s/foo/$bar/g re-stringify $bar for each iteration (though without having to reevaluate the ops that return $bar). So we no longer have to special-case match vars at compile time. This means that s/foo/bar$baz/g will be slower (and less buggy), but s/foo/$1/g will be faster. This also caused an existing taint but in pp_subst to surface. If get-magic turns off taint on a replacement string, it should not be considered tainted. So the taint check on the replacement should come *after* the stringification. This applies to the constant replacement optimisation. pp_substcont was already doing this correctly.
* For backcompat, B::formfeed can use gv_fetchpvs() if there is no PL_formfeed.Nicholas Clark2012-09-202-1/+12
|
* Allow CVs to point to HEKs rather than GVsFather Chrysostomos2012-09-151-1/+5
| | | | This will allow named lexical subs to exist independent of GVs.
* ext/B/B.xs: Remove EBCDIC dependencyKarl Williamson2012-09-131-8/+0
| | | | | | These are unnecessary EBCDIC dependencies: It uses isPRINT() on EBCDIC, and an expression on ASCII, but isPRINT() is defined to be precisely that expression on ASCII platforms.
* Banish boolkeysFather Chrysostomos2012-08-251-1/+1
| | | | | | | | | | | | | | 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.
* Increase $B::Concise::VERSION to 0.93Father Chrysostomos2012-08-251-1/+1
|
* Optimise %hash in sub { %hash || ... }Father Chrysostomos2012-08-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In %hash || $foo, the %hash is in scalar context, so it has to iterate through the buckets to produce statistics on bucket usage. If the || is in void context, the value returned by hash is only ever used as a boolean (as || doesn’t have to return it). We already opti- mise it by adding a boolkeys op when it is known at compile time that || will be in void context. In sub { %hash || $foo } it is not known at compile time that it will be in void context, so it wasn’t optimised. This commit optimises it by flagging the %hash at compile time as being possibly in ‘true boolean’ context. When that flag is set, the rv2hv and padhv ops call block_gimme() to see whether || is in void context. This speeds things up signficantly. Here is what I got after optimis- ing rv2hv but before doing padhv: $ time ./miniperl -e '%hash = 1..10000; sub { %hash || 1 }->() for 1..100000' real 0m0.179s user 0m0.101s sys 0m0.005s $ time ./miniperl -e 'my %hash = 1..10000; sub { %hash || 1 }->() for 1..100000' real 0m5.446s user 0m2.419s sys 0m0.015s (That example is slightly misleading because of the closure, but the closure version takes 1 sec. when optimised.)
* Use FooBAR convention for new pad macrosFather Chrysostomos2012-08-221-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After a while, I realised that it can be confusing for PAD_ARRAY and PAD_MAX to take a pad argument, but for PAD_SV to take a number and PAD_SET_CUR a padlist. I was copying the HEK_KEY convention, which was probably a bad idea. This is what we use elsewhere: TypeMACRO ----===== AvMAX CopFILE PmopSTASH StashHANDLER OpslabREFCNT_dec Furthermore, heks are not part of the API, so what convention they use is not so important. So these: PADNAMELIST_* PADLIST_* PADNAME_* PAD_* are now: Padnamelist* Padlist* Padname* Pad*
* Increase $B::VERSION to 1.38Father Chrysostomos2012-08-211-1/+1
|
* Increase $B::Xref::VERSION from 1.03 to 1.04Father Chrysostomos2012-08-211-1/+1
|
* Stop padlists from being AVsFather Chrysostomos2012-08-213-5/+88
| | | | | | | | | | | | | | | | | | | | | In order to fix a bug, I need to add new fields to padlists. But I cannot easily do that as long as they are AVs. So I have created a new padlist struct. This not only allows me to extend the padlist struct with new members as necessary, but also saves memory, as we now have a three-pointer struct where before we had a whole SV head (3-4 pointers) + XPVAV (5 pointers). This will unfortunately break half of CPAN, but the pad API docs clearly say this: NOTE: this function is experimental and may change or be removed without notice. This would have broken B::Debug, but a patch sent upstream has already been integrated into blead with commit 9d2d23d981.
* Tweak the test from 35f7559499c4a614 to work with PERL_UNICODE set.Nicholas Clark2012-08-151-4/+4
|
* OptreeCheck.pm: typoFather Chrysostomos2012-08-101-1/+1
|
* B::Concise: Two unused varsFather Chrysostomos2012-08-101-2/+0
| | | | | | One was made unnecessary by 35f7559499. The other was added by 35f7559499 and never used. I forgot to clean up once I had things working.
* Newlines in a runperl() prog cause trouble so use progfile insteadSteve Hay2012-08-102-13/+29
| | | | | This fixes "Format not terminated at -e line 2, at end of line" errors on Windows (at least) coming from the new tests added by commit 35f7559499.
* B::Concise: Document formatsFather Chrysostomos2012-08-081-1/+2
|