This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
OP_EMPTYAVHV: create ops in newANONHASH/newANONLIST rather than rpeep
authorRichard Leach <richardleach@users.noreply.github.com>
Sat, 19 Aug 2023 00:27:18 +0000 (00:27 +0000)
committerRichard Leach <richardleach@users.noreply.github.com>
Tue, 29 Aug 2023 10:49:41 +0000 (11:49 +0100)
commit5fa726eb82cb1530d131c957769b0e3d0ff4fe42
treed8e73152cb8060fa1279e07d494ce6ac65541450
parenteb6516ffa3ddb0059def2a460fc63023888bbba7
OP_EMPTYAVHV: create ops in newANONHASH/newANONLIST rather than rpeep

The current implementation of the OP_EMPTYAVHV optimization does not
optimize instances of empty anonymous hashes/lists on the RHS of LOGOP
conditions, such as in `my $x = $y || {}`.

This commit addresses this by removing the peephole optimization in
favour of having EMPTYAVHV OPs produced directly whenever a call is
made to `newANONHASH` or `newANONLIST` with an empty child OP `o`.
The standard TARGMY optimization in `S_maybe_targlex` has been
slightly adapted to also optimize the `LVINTRO` case for this OP.

This commit also addresses some feedback nits from the last dev
cycle: EMPTYAVHV is no longer a LISTOP, now just a BASEOP, and it
does not use the OPf_SPECIAL flag. (Both were unnecessary carryovers
from the ANONHASH and ANONLIST OPs.)
op.c
opcode.h
peep.c
regen/opcodes