summaryrefslogtreecommitdiff
path: root/dump.c
Commit message (Collapse)AuthorAgeFilesLines
* Eliminate PL_sawalias, GPf_ALIASED_SVDavid Mitchell2015-08-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | These two commits: v5.21.3-759-gff2a62e "Skip no-common-vars optimisation for aliases" v5.21.4-210-gc997e36 "Make list assignment respect foreach aliasing" added a run-time mechanism to detect aliased package variables, by either "*pkg = ...," or "for $pkg (...)", and used that information to enable the OPpASSIGN_COMMON mechanism at runtime for detecting common elements in a list assign, e.g. for $alias ($a, ...) { ($a,$b) = (1,$alias); } The previous commit but one changed the OPpASSIGN_COMMON mechanism such that it no longer uses PL_sawalias. So this var and the mechanism for setting it can now be removed. This commit removes: * the PL_sawalias variable * the GPf_ALIASED_SV GP flag * the SAVEt_GP_ALIASED_SV and save_aliased_sv() save type.
* mg_names.c -> mg_names.incJarkko Hietaniemi2015-07-221-1/+1
|
* Remove NEW_ from PERL_NEW_COPY_ON_WRITEFather Chrysostomos2015-06-291-1/+1
|
* Remove PERL_OLD_COPY_ON_WRITEFather Chrysostomos2015-06-291-9/+0
|
* Cannot do much if putc fails in debug output.Jarkko Hietaniemi2015-06-261-11/+11
| | | | Coverity CID 104782 (only flagged the deb.c spot)
* silence some gcc -pendantic warningsDavid Mitchell2015-06-191-3/+3
|
* remove deprecated /\C/ RE character classDavid Mitchell2015-06-191-1/+0
| | | | | | This horrible thing broke encapsulation and was as buggy as a very buggy thing. It's been officially deprecated since 5.20.0 and now it can finally die die die!!!!
* rename op_lastsib to op_moresib, and invert logicDavid Mitchell2015-04-191-1/+1
| | | | | | | Rather than having a flag which indicates that there are no more siblings, have a flag which indicates that there are more siblings. This flag was only introduced during the current blead cycle, so no production releases know about it.
* Replace common Emacs file-local variables with dir-localsDagfinn Ilmari Mannsåker2015-03-221-6/+0
| | | | | | | | | | | | | | | | An empty cpan/.dir-locals.el stops Emacs using the core defaults for code imported from CPAN. Committer's work: To keep t/porting/cmp_version.t and t/porting/utils.t happy, $VERSION needed to be incremented in many files, including throughout dist/PathTools. perldelta entry for module updates. Add two Emacs control files to MANIFEST; re-sort MANIFEST. For: RT #124119.
* Change some locale manipulation macros in prep for APIKarl Williamson2015-03-191-4/+4
| | | | | | | | | | This changes the way some of the current internal-only macros are named and used in order to simplify things and minimize what gets exposed as part of the API. Although these have not been listed as publicly available, it costs essentially nothing to keep the old names around in case someone was illegally using them.
* make perl -Dt display padnames with sort blocksDavid Mitchell2015-03-131-12/+20
| | | | | | | | | | | | | | | | | | | | When a sort block (as opposed to sort sub) is executed, a new stackinfo is pushed with a single CXt_NULL on top. Since S_deb_curcv() only examines the *current* CX stack looking for the current running CV, it fails to find it in this case and returns null. This means that on threaded builds you get things like: $ perl -Dt -e'my $x; @a=sort { $x } 1,2' ... (-e:1) padsv([1]) where it can't find a pad to look up the name of the lexical at targ 1. This commit makes S_deb_curcv() continue to the previous CX stack when it finds it's on a PERLSI_SORT stackinfo. The output from the above is now: (-e:1) padsv($x)
* Perl_multideref_stringify: don't SEGV on null cvDavid Mitchell2015-03-131-15/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | This function is called by e.g. "perl -Dt" to display the multideref op: $ perl -Dt -e'$a->{foo}[1]' ... (-e:1) multideref($a->{"foo"}[1]) On threaded builds, it needs to know the correct pad (and so the correct cv too) so that it can access GVs and const SVs that have been moved to the pad. However with a sort code block (rather than a sort sub), S_deb_curcv() returns null, so multideref_stringify() is called with a null CV. This then SEGVs. Although ideally S_deb_curcv() should be fixed, a function like multideref_stringify(), which can be used for debugging, should be robust in unexpected circumstances. So this commit makes it safe (although not particularly useful) with a null CV: $ perl -Dt -e'@a = sort { $a->[$i] <=> $b->[$i] } [0], [1]' ... (-e:1) sort (-e:1) multideref(<NULLGV>->[<NULLGV>]) (-e:1) multideref(<NULLGV>->[<NULLGV>])
* don't test non-null argsDavid Mitchell2015-03-111-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For lots of core functions: if a function parameter has been declared NN in embed.fnc, don't test for nullness at the start of the function, i.e. eliminate code like if (!foo) ... On debugging builds the test is redundant, as the PERL_ARGS_ASSERT_FOO at the start of the function will already have croaked. On optimised builds, it will skip the check (and so be slightly faster), but if actually passed a null arg, will now crash with a null-deref SEGV rather than doing whatever the check used to do (e.g. croak, or silently return and let the caller's code logic to go awry). But hopefully this should never happen as such instances will already have been detected on debugging builds. It also has the advantage of shutting up recent clangs which spew forth lots of stuff like: sv.c:6308:10: warning: nonnull parameter 'bigstr' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion] if (!bigstr) The only exception was in dump.c, where rather than skipping the null test, I instead changed the function def in embed.fnc to allow a null arg, on the basis that dump functions are often used for debugging (where pointers may unexpectedly become NULL) and it's better there to display that this item is null than to SEGV. See the p5p thread starting at 20150224112829.GG28599@iabyn.com.
* sprinkle NOTREACHED and FALLTHROUGHDavid Mitchell2015-03-051-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | Coverity complains bitterly about many switch statements in lots of files. Many of these are of the form: case FOO: ... goto baz; case BAR: .... and something as smart as Coverity shouldn't really be complaining about a missing 'break' when the last statement of the previous branch is an unconditional goto/return/continue. But I've shoved in a bunch of 'NOTREACHED' to hopefully shut it up. Missing 'FALLTHROUGH' comments were more reasonable, and I've added them where appropriate. The only confusing one was cx_dup(), where the various CXt_LOOP_ branches all fell through to the next one, and it took a while to figure out that those weren't bugs.
* do_op_dump(): handle unknown op_private enumsDavid Mitchell2015-02-261-1/+4
| | | | | | | | | | | | | Where a bitfield value in op_private doesn't correspond to any enums, do_op_dump() is supposed to display the value as an integer (with optional LABEL= prefix). Concise does this, do_op_dump was failing to do this, and instead trying to display the value symbolically as string at offset -1 in PL_op_private_labels. This wasn't important yet as no ops currently have an unspecified enum value. Spotted by Coverity.
* restate -Dx dumping top-level subsDavid Mitchell2015-02-261-1/+4
| | | | | | | | | | Commit v5.21.3-638-g2eaf799 made compiled subs that don't have :: in their name be stored in stashes as refs to CVs rather than as GVs. This indirectly stopped perl -Dx from dumping such subs. This commit reinstates the old behaviour by making Perl_dump_packsubs_perl() upgrade the stash entry to a GV when it finds an RV->CV.
* rename unop_aux_stringify to multideref_stringifyDavid Mitchell2015-01-271-4/+4
| | | | | | | | | | | | This function returns a string representation of the OP_MULTIDEREF op (as used by the output of perl -Dt). However, the stringification of a UNOP_AUX op is op-specific, and hypothetical future UNOP_AUX-class ops will need their own functions. So the current function name is misleading. It should be safe to rename it, as it only been in since 5.21.7, and isn't public.
* Support for nocapture regexp flag /nMatthew Horsfall (alh)2014-12-281-0/+1
| | | | | | | | | | | | | | | | | | | | This flag will prevent () from capturing and filling in $1, $2, etc... Named captures will still work though, and if used will cause $1, $2, etc... to be filled in *only* within named groups. The motivation behind this is to allow the common construct of: /(?:b|c)a(?:t|n)/ To be rewritten more cleanly as: /(b|c)a(t|n)/n When you want grouping but no memory penalty on captures. You can also use ?n inside of a () directly to avoid capturing, and ?-n inside of a () to negate its effects if you want to capture.
* dump.c: Suppress extra sigils in multideref dumpFather Chrysostomos2014-12-201-1/+3
| | | | | | | | | | | | This: my $z; my @y; $y[$z] included <+> multideref($@y[$$z]) sK ->6 in its -MO=Concise output.
* dump.c:unop_aux_stringify: Use newSVpvn_flagsFather Chrysostomos2014-12-201-1/+1
| | | | | newSVpvn_flags with SVs_TEMP takes less machine code than sv_2mortal(newSVpv()).
* dump.c: Make static functions staticFather Chrysostomos2014-12-131-2/+2
|
* rename S_print_gv_name() to S_append_gv_name()David Mitchell2014-12-131-5/+5
| | | | | | | and remove its sigil arg. During development of OP_MULTIDEREF this function evolved; the new name reflects its usage more accurately, and sigil is always '$'.
* unop_aux_stringify(): remove redundant assignmentDavid Mitchell2014-12-101-1/+1
| | | | | | | | my recent OP_MULTIDEREF patch included this bizarre thinko: PAD *comppad = comppad = ....; Spotted by Jarkko.
* Change OP_SIBLING to OpSIBLINGFather Chrysostomos2014-12-071-1/+1
| | | | | | | | | to match the existing convention (OpREFCNT, OpSLAB). Dave Mitchell asked me to wait until after his multideref work was merged. Unfortunately, there are now CPAN modules using OP_SIBLING.
* Add OP_MULTIDEREFDavid Mitchell2014-12-071-0/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* add S_deb_padvar() to dump.cDavid Mitchell2014-12-071-30/+35
| | | | factor out the code that prints a pad var name in -Dt output
* printf type-matching continues. again.Jarkko Hietaniemi2014-12-051-1/+1
|
* dump.c: Don’t dump CvOUTSIDE SV when there is noneFather Chrysostomos2014-12-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | $ ./perl -Ilib -MDevel::Peek -Mfeature=:all -Xle 'my sub f; Dump \&f' SV = IV(0x7fd7138312b0) at 0x7fd7138312c0 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x7fd713831b90 SV = PVCV(0x7fd7138303d0) at 0x7fd713831b90 REFCNT = 2 FLAGS = (CLONED,DYNFILE,NAMED,LEXICAL) COMP_STASH = 0x7fd713807ce8 "main" ROOT = 0x0 NAME = "f" FILE = "-e" DEPTH = 0 FLAGS = 0x19040 OUTSIDE_SEQ = 187 PADLIST = 0x7fd7134067e8 PADNAME = 0x7fd713411f88(0x7fd713406d48) PAD = 0x7fd713807e68(0x7fd71340d2f8) OUTSIDE = 0x0 (null) SV = 0 That final ‘SV = 0’ is very confusing!
* dump.c: Clarify podKarl Williamson2014-12-031-3/+3
|
* 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
* [perl #123223] Make PADNAME a separate typeFather Chrysostomos2014-11-301-25/+4
| | | | | | | | | | | distinct from SV. This should fix the CPAN modules that were failing when the PadnameLVALUE flag was added, because it shared the same bit as SVs_OBJECT and pad names were going through code paths not designed to handle pad names. Unfortunately, it will probably break other CPAN modules, but I think this change is for the better, as it makes both pad names and SVs sim- pler and makes pad names take less memory.
* Use PADNAME rather than SV in dump.c:debopFather Chrysostomos2014-11-301-2/+2
|
* Make PADNAMELIST a separate typeFather Chrysostomos2014-11-301-11/+4
| | | | This is in preparation for making PADNAME a separate type.
* 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%.
* printf type-matching.Jarkko Hietaniemi2014-11-271-1/+1
|
* add xs_handshake APIDaniel Dragan2014-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This API elevates the amount of ABI compatibility protection between XS modules and the interp. It also makes each boot XSUB smaller in machine code by removing function calls and factoring out code into the new Perl_xs_handshake and Perl_xs_epilog functions. sv.c : - revise padlist duping code to reduce code bloat/asserts on DEBUGGING ext/DynaLoader/dlutils.c : - disable version checking so interp startup is faster, ABI mismatches are impossible because DynaLoader is never available as a shared library ext/XS-APItest/XSUB-redefined-macros.xs : - "" means dont check the version, so switch to " " to make the test in xsub_h.t pass, see ML thread "XS_APIVERSION_BOOTCHECK and XS_VERSION is CPP defined but "", mow what?" ext/re/re.xs : - disable API version checking until #123007 is resolved ParseXS/Utilities.pm : 109-standard_XS_defs.t : - remove context from S_croak_xs_usage similar to core commit cb077ed296 . CvGV doesn't need a context until 5.21.4 and commit ae77754ae2 and by then core's croak_xs_uage API has been long available and this backport doesn't need to account for newer perls - fix test where lack of having PERL_IMPLICIT_CONTEXT caused it to fail
* dump.c: Use same code for cops and ex-copsFather Chrysostomos2014-11-061-24/+4
| | | | | This also allows ex-dbstate ops to have their cop fields dumped, which was not the case before.
* dump.c: Dump seq field of nextstate opsFather Chrysostomos2014-11-061-0/+2
| | | | This is very useful for debugging.
* free up CvPADLIST slot for XSUBs for future useDaniel Dragan2014-10-311-3/+7
| | | | | | | | | | | | | | | | | | | CvRESERVED is a placeholder, it will be replaced with a sentinal value from future revised BOOTCHECK API. CvPADLIST_set was helpful during development of this patch, so keep it around for now. PoisonPADLIST's magic value is from PERL_POISON 0xEF pattern. Some PoisonPADLIST locations will get code from future BOOTCHECK API. Make padlist_dup a NN function to avoid overhead of calling it for XSUBs during closing. Perl_cv_undef_flags's else if (CvISXSUB(&cvbody)) is to avoid whitespace changes. Filed as perl [#123059].
* Consistent spaces after dots in perlapi.podFather Chrysostomos2014-10-281-1/+1
|
* dump.c: Fix C++ buildFather Chrysostomos2014-10-191-2/+2
|
* dump.c: Add PERL_PV_PRETTY_EXACTSIZE optionYves Orton2014-10-201-19/+39
| | | | | | Sometimes we want things to fit exactly into a specific number of chars, elipses, quotes and all. Includes make regen update to make dsv argument nullok.
* dump.c: Dump pmop patterns without trailing )Father Chrysostomos2014-10-121-2/+2
|
* Make OP_METHOD* to be of new class METHOPsyber2014-10-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a new opcode class, METHOP, which will hold class/method related info needed at runtime to improve performance of class/object method calls, then change OP_METHOD and OP_METHOD_NAMED from being UNOP/SVOP to being METHOP. Note that because OP_METHOD is a UNOP with an op_first, while OP_METHOD_NAMED is an SVOP, the first field of the METHOP structure is a union holding either op_first or op_sv. This was seen as less messy than having to introduce two new op classes. The new op class's character is '.' Nothing has changed in functionality and/or performance by this commit. It just introduces new structure which will be extended with extra fields and used in later commits. Added METHOP constructors: - newMETHOP() for method ops with dynamic method names. The only optype for this op is OP_METHOD. - newMETHOP_named() for method ops with constant method names. Optypes for this op are: OP_METHOD_NAMED (currently) and (later) OP_METHOD_SUPER, OP_METHOD_REDIR, OP_METHOD_NEXT, OP_METHOD_NEXTCAN, OP_METHOD_MAYBENEXT (This commit includes fixups by davem)
* Make space for /xx flagKarl Williamson2014-09-291-0/+1
| | | | | | This doesn't actually use the flag yet. We no longer have to make version-dependent changes to ext/Devel-Peek/t/Peek.t, (it being in /ext) so this doesn't
* Remove most uses of PADMYFather Chrysostomos2014-09-241-3/+2
| | | | SVs_PADMY is now 0, and SvPADMY means !SvPADTMP.
* Add flags to cv_name; allow unqualified retvalFather Chrysostomos2014-09-241-1/+1
| | | | | | | | | | One of the main purposes of cv_name was to provide a way for CPAN mod- ules easily to obtain the name of a sub. As written, it was not actually sufficient, as some modules, such as Devel::Declare, need an unqualified name. So I am breaking compatibility with 5.21.4 (which introduced cv_name, but is only a dev release) by adding a flags parameter.
* Add SVf_PROTECTFather Chrysostomos2014-09-201-0/+1
|
* Renumber SVf_IsCOWFather Chrysostomos2014-09-201-2/+2
| | | | and free up a bit.
* Dump GPFLAGSFather Chrysostomos2014-09-181-0/+4
|