summaryrefslogtreecommitdiff
path: root/op.h
Commit message (Collapse)AuthorAgeFilesLines
* add Op(MORE|LAST|MAYBE)SIB_set; rm OpSIBLING_setDavid Mitchell2015-04-191-5/+28
| | | | | | | | | | | | | | | | | the OpSIBLING_set() macro just set the op_sibling/op_sibparent field, and didn't update op_moresib. Remove this macro, and replace it with the three macros OpMORESIB_set OpLASTSIB_set OpMAYBESIB_set which also set op_moresib appropriately. These were suggested by Zefram. Then in the remaining areas in op.c where low-level op_sibling/op_moresib tweaking is done, use the new macros instead (so if nothing else, they get used and tested.)
* rename op_lastsib to op_moresib, and invert logicDavid Mitchell2015-04-191-5/+5
| | | | | | | 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.
* op_sibling => op_sibparent under PERL_OP_PARENTDavid Mitchell2015-04-191-3/+12
| | | | | | | | | | | On perls built under -DPERL_OP_PARENT, rename the op_sibling OP field to op_sibparent, since it can now contain either a pointer to the next sibling if not the last sibling, or back to the parent if it is. Code written to work under PERL_OP_PARENT should be using macros like OpSIBLING() rather than accessing op_sibling directly, so this should be a transparent change. It will also make code naughtily accessing this field directly give a compile error.
* 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.
* Reserve a bit for 'the re strict subpragma.Karl Williamson2015-01-131-1/+1
| | | | This is another step in the process
* Fix apidocs for OP_TYPE_IS(_OR_WAS) - arguments separated by |, not ,.Matthew Horsfall (alh)2015-01-081-2/+2
| | | | This was causing Devel::PPPort's tooling some grief.
* Create bit for /n.Karl Williamson2014-12-281-1/+1
|
* op.h: Parenthesize macro args for cUNOPx etc.Father Chrysostomos2014-12-271-12/+12
| | | | | Without this, we cannot do cUNOPx(complex expression) without worrying about precedence issues.
* Disallow GIMME in ext/Father Chrysostomos2014-12-211-1/+1
| | | | | It’s an inefficient macro, so we don’t want it inadvertently used again.
* Use GIMME_V in preference to GIMMEFather Chrysostomos2014-12-191-1/+3
| | | | | | | | | GIMME_V is a simpler macro that results in smaller machine code. GIMME does not distinguish between scalar and void context. The two instances of GIMME == G_SCALAR that I changed (which used to match void context too, but no longer do) are in code paths unreachable in void context, so we don’t need to check for it.
* op.h: Note chdir’s use of OPf_SPECIALFather Chrysostomos2014-12-131-0/+1
|
* Change OP_SIBLING to OpSIBLINGFather Chrysostomos2014-12-071-9/+12
| | | | | | | | | 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-3/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 UNOP_AUX OP classDavid Mitchell2014-12-071-0/+19
| | | | | | | | | | | | | This is the same as a UNOP, but with the addition of an op_aux field, which points to an array of UNOP_AUX_item unions. It is intended as a general escape mechanism for adding per-op-type extra fields (or arrays of items) to UNOPs. Its class character (for regen/opcodes etc) is '+'. Currently there are no ops of this type; but shortly, OP_MULTIDEREF will be added, which is the original motivation for this new op type.
* Return fresh scalar from join(const,const)Father Chrysostomos2014-12-041-0/+4
| | | | | | | | | | | | | | | | | | | $ perl5.20.1 -Ilib -le 'for(1,2) { push @_, \join "x", 1 } print for @_' SCALAR(0x7fb131005438) SCALAR(0x7fb131005648) $ ./perl -Ilib -le 'for(1,2) { push @_, \join "x", 1 } print for @_' SCALAR(0x7fe612831b30) SCALAR(0x7fe612831b30) Notice how we now get two references to the same scalar. I broke this accidentally in 987c9691. If join has two arguments, it gets con- verted to a stringify op. The stringify op might get constant-folded, and folding of stringify is special, because the parser uses it itself to implement qq(). So I had ck_join set op_folded to flag the op as being a folded join. Only that came too late, because op_convert_list(OP_STRINGIFY,...) folds the op before it returns it. Hence, the folded constant was flagged the wrong way, and stopped being implicitly copied by refgen (\).
* Speed up method calls like $o->Other::method() and $o->Other::SUPER::method().syber2014-12-021-0/+7
| | | | | | | | | | | | | | | 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
* Correct OPf_SPECIAL/OP_UNSTACK commentFather Chrysostomos2014-11-251-1/+1
| | | | I misread the code when I added it.
* Remove op_const_class; just use the name on the stacksyber2014-11-241-8/+0
| | | | | | | Instead of storing the class name in the op_const_class field of the METHOP in addition to pushing it on to the stack, just use the item on the stack. This also makes $class->method faster if $class is already a shared hash string.
* op_class_sv removed for threaded perls op_class_targ removed for ↵syber2014-11-231-2/+5
| | | | non-threaded perls
* This commit speeds up class method calls when class name is constant.syber2014-11-231-0/+5
| | | | | | | | | | | | | | | | I.e. MyClass->method() and MyClass->$dynamic_method() By about 30%. It was done by saving class name (as shared COW string) in METHOP and later checking it in method_common(). If it was set, then it fetches stash via gv_stashsv using precomputed hash value instead of falling into a bunch of conditions and fetching stash without hash value.
* op.h: Note unstack use of OPf_SPECIALFather Chrysostomos2014-11-201-0/+1
|
* Don’t copy VMS hints to cop->op_privateFather Chrysostomos2014-11-081-3/+0
| | | | | | Commit d5ec29879 in 2006 started storing all the hints in COPs. Some VMS-specific hints have nonetheless still been copied from PL_hints to cop->op_private, though that is no longer necessary.
* Make OP_METHOD* to be of new class METHOPsyber2014-10-031-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* Update comments for OPf_SPECIAL/doFather Chrysostomos2014-10-021-1/+1
| | | | | ‘do subname’ has been removed, so OPf_SPECIAL no longer applies to OP_ENTERSUB.
* Suppress some Solaris warningsKarl Williamson2014-09-291-13/+13
| | | | | | | | We get an integer overflow message when we left shift a 1 into the highest bit of a word. This changes the 1's into 1U's to indicate unsigned. This is done for all the flag bits in the affected word, as they could get reorderd by someone in the future, unintentionally reintroducing this problem again.
* Make space for /xx flagKarl Williamson2014-09-291-1/+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
* op.h: Move flag bits; comment shared-bit schemeKarl Williamson2014-09-291-18/+50
| | | | | | | This changes op.h to correspond with regexp.h. It moves all the used bits up in the word so that if a new shared bit is added, the #error will be triggered, alerting the person doing it that things need adjusting so binary compatibility is preserved.
* Only #define IS_(PADGV|CONST) if !PERL_COREFather Chrysostomos2014-09-171-5/+8
| | | | | | | | | | | | and give IS_PADGV a simpler definition. These are not used in the perl core any more and shouldn’t be. The IS_PADGV definition checked for the IN_PAD flag, which flag never made much sense (see the prev. commit’s message). Since any GV could end up with that flag, and since any GV coming near a pad would get it, it might as well have been turned on for all GVs (except copies). So just check whether the thingy is a GV.
* op.c:ck_subr: reify GVs based on call checkerFather Chrysostomos2014-09-151-1/+4
| | | | | | | | | | | | | | | Instead of faking up a GV to pass to the call checker if we have a lexical sub, just get the GV from CvGV (since that will reify the GV, even for lexical subs), unless the call checker has not specifically requested GVs. For now, we assume the default call checker cannot handle non-GV sub names, as indeed it cannot. An imminent commit will rectify that. The code in scope.c was getting the name hek from the proto CV (stowed in magic on the pad name) if the CV in the pad had lost it. Now, the proto CV can lose it at compile time via CvGV, so that does not work anymore. Instead, just get it from the GV.
* mask VMS hints bits in COPsDavid Mitchell2014-09-101-1/+2
| | | | | | | | | | | | A couple of VMS-specific hints bits are stored in op_private on COPs. Currently these are added using NATIVE_HINTS, which is defined as PL_hints >> 24. Since other hints have started using the top byte of PL_hints, this has the possibility of inadvertently setting other bits in cop->op_private. So mask out the bits we don't want. We need this before the next commit, which will assert valid bits on debugging builds. (This is VMS-specific, and has been applied blind)
* Automate processing of op_private flagsDavid Mitchell2014-09-101-197/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new config file, regen/op_private, which contains all the information about the flags and descriptions for the OP op_private field. Previously, the flags themselves were defined in op.h, accompanied by textual descriptions (sometimes inaccurate or incomplete). For display purposes, there were short labels for each flag found in Concise.pm, and another set of labels for Perl_do_op_dump() in dump.c. These two sets of labels differed from each other in spelling (e.g. REFC verses REFCOUNT), and differed in completeness and accuracy. With this commit, all the data to generate the defines and the labels is derived from a single source, and are generated automatically by 'make regen'. It also contains complete data on which bits are used for what by each op. So any attempt to add a new flag for a particular op where that bit is already in use, will raise an error in make regen. This compares to the previous practice of reading the descriptions in op.h and hoping for the best. It also makes use of data in regen/opcodes: for example, regen/op_private specifies that all ops flagged as 'T' get the OPpTARGET_MY flag. Since the set of labels used by Concise and Perl_do_op_dump() differed, I've standardised on the Concise version. Thus this commit changes the output produced by Concise only marginally, while Perl_do_op_dump() is considerably different. As well as the change in labels (and missing labels), Perl_do_op_dump() formerly had a bug whereby any unrecognised bits would not be shown if there was at least one recognised bit. So while Concise displayed (and still does) "LVINTRO,2", Perl_do_op_dump() has changed: - PRIVATE = (INTRO) + PRIVATE = (LVINTRO,0x2) Concise has mainly changed in that a few op/bit combinations weren't being shown symbolically, and now are. I've avoiding fixing the ones that would break tests; they'll be fixed up in the next few commits. A few new OPp* flags have been added: OPpARG1_MASK OPpARG2_MASK OPpARG3_MASK OPpARG4_MASK OPpHINT_M_VMSISH_STATUS OPpHINT_M_VMSISH_TIME OPpHINT_STRICT_REFS The last three are analogues for existing HINT_* flags. The former four reflect that many ops some of the lower few bits of op_private to indicate how many args the op expects. While (for now) this is still displayed as, e.g. "LVINTRO,2", the definitions in regen/op_private now fully account for which ops use which bits for the arg count. There is a new module, B::Op_private, which allows this new data to be accessed from Perl. For example, use B::Op_private; my $name = $B::Op_private::bits{aelem}{7}; # OPpLVAL_INTRO my $value = $B::Op_private::defines{$name}; # 128 my $label = $B::Op_private::labels{$name}; # LVINTRO There are several new constant PL_* tables. PL_op_private_valid[] specifies for each op number, which bits are valid for that op. In a couple of commits' time, op_free() will use this on debugging builds to assert that no ops gained any private flags which we don't know about. In fact it was by using such a temporary assert repeatedly against the test suite, that I tracked down most of the inconsistencies and errors in the current flag data. The other PL_op_private_* tables contain a compact representation of all the ops/bits/labels in a format suitable for Perl_do_op_dump() to decode Op_private. Overall, the perl binary is about 500 bytes smaller on my system.
* better document OA_ flagsDavid Mitchell2014-09-101-2/+3
| | | | | Its a bit confusing which bits in PL_opargs are used for what, and which flags in regen/opcodes map to which OA_* value
* op.h: Correct PERL_LOADMOD_IMPORT_OPS commentFather Chrysostomos2014-09-061-1/+4
| | | | This description, added in ec6d81aba, is misleading.
* Avoid vivifying stuff when looking up barewordsFather Chrysostomos2014-08-291-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Till now, when a bareword was looked up to see whether it was a sub- routine, an rv2cv op was created (to allow PL_check hooks to override the process), which was then asked for its GV. Afterwards, the GV was downgraded back to nothing if possible. So a lot of the time a GV was autovivified and then discarded. This has been the case since f74617600 (5.12). If we know there is a good chance that the rv2cv op is about to be deleted, we can avoid that by passing a flag to the new op. Also f74617600 actually changed the behaviour by vivifying stashes that used not be vivified: sub foo { print shift, "\n" } SUPER::foo bar if 0; foo SUPER; Output in 5.10: SUPER Output as of this commit: SUPER Output in 5.12 to 5.21.3: Can't locate object method "foo" via package "SUPER" at - line 3.
* Remove flagging OP_READLINE with OPf_SPECIALRafael Garcia-Suarez2014-07-241-1/+0
| | | | | This was used to distinguish forms <FILE> from <$file>, but doesn't seem to be used anymore by anything.
* Fix typo in op.hAaron Crane2014-07-091-1/+1
| | | | | This caused all OP structures to be larger than intended; for example, it made `struct op` 48 bytes rather than 40 on Mac OS X x86-64.
* add op_lastsib and -DPERL_OP_PARENTDavid Mitchell2014-07-081-5/+13
| | | | | | | | | | | | | | | | | | | | Add the boolean field op_lastsib to OPs. Within the core, this is set on the last op in an op_sibling chain (so it is synonymous with op_sibling being null). By default, its value is set but not used. In addition, add a new build define (not yet enabled by default), -DPERL_OP_PARENT, that forces the core to use op_lastsib to detect the last op in a sibling chain, rather than op_sibling being NULL. This frees up the last op_sibling pointer in the chain, which rather than being set to NULL, is now set to point back to the parent of the sibling chain (if any). This commit also adds a C-level op_parent() function and B parent() method; under default builds they just return NULL, under PERL_OP_PARENT they return the parent of the current op. Collectively this provides a facility not previously available from B:: nor C, of being able to follow an op tree up as well as down.
* wrap op_sibling field access in OP_SIBLING* macrosDavid Mitchell2014-07-081-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | Remove (almost all) direct access to the op_sibling field of OP structs, and use these three new macros instead: OP_SIBLING(o); OP_HAS_SIBLING(o); OP_SIBLING_set(o, new_value); OP_HAS_SIBLING is intended to be a slightly more efficient version of OP_SIBLING when only boolean context is needed. For now these three macros are just defined in the obvious way: #define OP_SIBLING(o) (0 + (o)->op_sibling) #define OP_HAS_SIBLING(o) (cBOOL((o)->op_sibling)) #define OP_SIBLING_set(o, sib) ((o)->op_sibling = (sib)) but abstracting them out will allow us shortly to make the last pointer in an op_sibling chain point back to the parent rather than being null, with a new flag indicating whether this is the last op. Perl_ck_fun() still has a couple of direct uses of op_sibling, since it takes the field's address, which is not covered by these macros.
* Remove MAD.Jarkko Hietaniemi2014-06-131-104/+0
| | | | | | MAD = Misc Attribute Decoration; unmaintained attempt at preserving the Perl parse tree more faithfully so that automatic conversion to Perl 6 would have been easier.
* Trailing comma in enum is not C89.Jarkko Hietaniemi2014-05-281-1/+1
|
* Macro for common OP checks: "is this X or was it before NULLing?"Steffen Mueller2014-02-261-3/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | For example, if (OP_TYPE_IS_OR_WAS(o, OP_LIST)) ... is now available instead of either of the following: if ( o && ( o->op_type == OP_LIST || (o->op_type == OP_NULL && o->op_targ == OP_LIST) ) ) ... if ( o && (o->op_type == OP_NULL ? o->op_targ ? o->op_type) == OP_LIST ) ... In case the above logic is a bit unclear: It checks whether that OP is an OP_LIST or used to be one before being NULLed using op_null. (FTR, the resulting OP_NULLs have their op_targ set to the old OP type). This sort of check (and it's reverse "isn't and didn't use to be") are a relatively common pattern in the part of op.c that tries to intuit structures from optimization-mangled OP trees. Hopefully, using these macros will make some code a fair amount clearer.
* Change av_len calls to av_tindex for clarityKarl Williamson2014-02-201-1/+1
| | | | | | av_tindex is a more clearly named synonym for av_len, available starting in v5.18. This changes the core uses to it, including modules in /ext, which are not dual-lifed.
* subroutine signaturesZefram2014-02-011-1/+1
| | | | | | | | | | Declarative syntax to unwrap argument list into lexical variables. "sub foo ($a,$b) {...}" checks number of arguments and puts the arguments into lexical variables. Signatures are not equivalent to the existing idiom of "sub foo { my($a,$b) = @_; ... }". Signatures are only available by enabling a non-default feature, and generate warnings about being experimental. The syntactic clash with prototypes is managed by disabling the short prototype syntax when signatures are enabled.
* perlapi: Consistent spaces after dotsFather Chrysostomos2013-12-291-21/+23
| | | | plus some typo fixes. I probably changed some things in perlintern, too.
* [perl #115736] fix undocumented param from newATTRSUB_flagsDaniel Dragan2013-12-231-1/+2
| | | | | flags param was poorly designed and didn't have a formal api. Replace it with the bool it really is. See #115736 for details.
* Optimise out PUSHMARK/RETURN if return is the last statement in a sub.Matthew Horsfall2013-12-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes: sub baz { return $cat; } Behave like: sub baz { $cat; } Which is notably faster. Unpatched: ./perl -Ilib/ ~/stuff/bench.pl Benchmark: timing 40000000 iterations of normal, ret... normal: 3 wallclock secs ( 1.60 usr + 0.01 sys = 1.61 CPU) @ 24844720.50/s (n=40000000) ret: 3 wallclock secs ( 2.08 usr + 0.00 sys = 2.08 CPU) @ 19230769.23/s (n=40000000) Patched: ./perl -Ilib ~/stuff/bench.pl Benchmark: timing 40000000 iterations of aret, normal... normal: 2 wallclock secs ( 1.72 usr + 0.00 sys = 1.72 CPU) @ 23255813.95/s (n=40000000) ret: 2 wallclock secs ( 1.72 usr + 0.00 sys = 1.72 CPU) @ 23255813.95/s (n=40000000) The difference in OP trees can be seen here: Unpatched: $ perl -MO=Concise,baz -e 'sub baz { return $cat }' main::baz: 5 <1> leavesub[1 ref] K/REFC,1 ->(end) - <@> lineseq KP ->5 1 <;> nextstate(main 1 -e:1) v ->2 4 <@> return K ->5 2 <0> pushmark s ->3 - <1> ex-rv2sv sK/1 ->4 3 <#> gvsv[*cat] s ->4 -e syntax OK Patched: $ ./perl -Ilib -MO=Concise,baz -e 'sub baz { return $cat }' main::baz: 3 <1> leavesub[1 ref] K/REFC,1 ->(end) - <@> lineseq KP ->3 1 <;> nextstate(main 1 -e:1) v ->2 - <@> return K ->- - <0> pushmark s ->2 - <1> ex-rv2sv sK/1 ->- 2 <$> gvsv(*cat) s ->3 -e syntax OK (Includes some modifications from Steffen)
* fix multi-eval of Perl_custom_op_xop in XopENTRYDaniel Dragan2013-11-101-5/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 1830b3d9c8 introduced a flaw where XopENTRY calls Perl_custom_op_xop twice to retrieve the same XOP *. This is inefficient and causes extra machine code. Since I found no CPAN or upstream=blead usage of Perl_custom_op_xop, and its previous docs say it isn't 100% public, it is being converted to a macro. Most usage of Perl_custom_op_xop is to conditionally fetch a member of the XOP struct, which was previously implemented by XopENTRY. Move the XopENTRY logic and picking defaults to an expanded version of Perl_custom_op_xop. The union allows Perl_custom_op_get_field to return its result in 1 register, since the union is similar to a void * or IV, but with the machine code overhead of casting, if any, being done in the callee (Perl_custom_op_get_field), not the caller. Perl_custom_op_get_field can also return the XOP * without looking inside it to implement Perl_custom_op_xop. XopENTRYCUSTOM is a wrapper around Perl_custom_op_get_field with XopENTRY-like usage. XopENTRY is used by the OP_* macros, which are heavily used (but rarely called, since custom ops are rare) by Perl lang warnings system. The vararg warning arguments are usually evaluted no matter if the warning will be printed to STDERR or not. Since some people like to ignore warnings or run no strict; and warnings branches are frequent in pp_*, it is beneficial to make the OP_* macros smaller in machine code. The design of Perl_custom_op_get_field supports these goals. This commit does not pass judgement on Ben Morrow's unclear public or private API designation of Perl_custom_op_xop, and whether Perl_custom_op_xop should deprecated and removed from public API. It was trivial to leave a form of Perl_custom_op_xop in the new design. XOPe enums are identical to XOPf constants so no conversion has to be done between the field selector parameter and the field flag to test in machine code. ASSUME and NOT_REACHED are being introduced. The closest to the 2 previously was "assert(0)". Perl has not used ASSUME or CC specific versions of it before. Clang, GCC >= 4.5, and Visual C are supported. For completeness, ARMCC's __promise was added, but Perl is not known to have any support for ARMCC by this commiter. This patch is part of perl #115032.
* Make &CORE::exit respect vmsish exit hintFather Chrysostomos2013-11-081-3/+0
| | | | | | | | | by removing the hint from the exit op itself and just having pp_exit look in the cop hint hash, where it is already stored (as a result of having been in %^H at compile time). &CORE:: subs intentionally lack a nextstate op (cop) so they can see the hints in the caller’s nextstate op.
* Fix &CORE::exit/die under vmsish "hushed"Father Chrysostomos2013-11-081-2/+9
| | | | | | | This commit makes them behave like exit and die without the ampersand by moving the OPpHUSH_VMSISH hint from exit/die op to the current statement (nextstate/cop) instead. &CORE:: subs intentionally lack a nextstate op, so they can see the hints in the caller’s nextstate op.
* Warn for all uses of %hash{...} in scalar cxFather Chrysostomos2013-11-081-2/+2
| | | | | | | | | | | | | | and reword the warning slightly. See <20131027204944.20489.qmail@lists-nntp.develooper.com>. To avoid getting a warning about scalar context for ‘delete %a[1,2]’, which dies anyway, I stopped scalar context from being applied to delete’s argument. Scalar context is not meaningful here anyway, and the context is not really scalar. This also means that ‘delete sort’ no longer produces a warning about scalar context before dying, so I added a test for that.