This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Allow OPpTARGET_MY optimisation for vec
authorFather Chrysostomos <sprout@cpan.org>
Fri, 7 Nov 2014 22:43:39 +0000 (14:43 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 8 Nov 2014 04:14:36 +0000 (20:14 -0800)
commitdb098081e3682316e8cf22b9705c2563fc91eaec
treed6995b6da841611dcb53586165ced017401d05ce
parent93f5d0e84de625ae81930095bb540c0d9dbda3f2
Allow OPpTARGET_MY optimisation for vec

Many operators have a special SV allocated in the pad which is used
for return values (the target).  If we make that pad offset point to
a lexical variable, then we can optimise, say, $lexical = "$foo" into
just "$foo", where $lexical is stringify’s ‘target’.  And pp_stringify
doesn’t need to know any better.  We already do that for many ops.

This can be extended to vec().  Despite what the comment in op_pri-
vate says, lvalue usage does not matter here, because the OPpTARGET_MY
optimisation only happens when the operator is in rvalue context.  And
the rvalue code paths use TARG and push TARG on to the stack.
lib/B/Op_private.pm
opcode.h
regen/op_private
regen/opcodes