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

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 x.  Despite what the comment in op_private
says, list return values do not matter here, because the OPpTARGET_MY
optimisation only happens when the operator is in scalar context.  And
the scalar code paths use TARG and push TARG on to the stack.
lib/B/Op_private.pm
opcode.h
regen/op_private
regen/opcodes