diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-11-25 13:36:29 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-11-26 14:33:46 -0800 |
commit | 1a35f9ffbd3ab4c89b6f5cad456b2b317c85e96e (patch) | |
tree | 66bf2690a6e643970b445f2109d5227f8035caed /toke.c | |
parent | 65ae8d9907f85f9548082307d1fa0010e9fb4d41 (diff) | |
download | perl-1a35f9ffbd3ab4c89b6f5cad456b2b317c85e96e.tar.gz |
Optimise __SUB__ to a constant
If __SUB__ is not inside a closure, it can be optimised to a constant.
We can only do this in the peephole optimiser, as we cannot tell
whether PL_compcv will become a closure until we reach the end
of the sub.
The __SUB__ op cannot simply be replaced with a const op, as the par-
ent op is not readily available in the peephole optimiser and, hence,
we cannot change its pointer.
So we have to convert the runcv op itself into a const op. So it
has to be the same size. This commit makes it a PVOP, since newPVOP,
unlike newSVOP, allows a null pv. To avoid adding workarounds to B
modules, I put an exception in newPVOP’s assertion, instead of chang-
ing the type in regen/opcodes.
But B::Deparse still had to be updated to avoid infinite recursion.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -7128,7 +7128,7 @@ Perl_yylex(pTHX) } case KEY___SUB__: - FUN0(OP_RUNCV); + FUN0OP(newPVOP(OP_RUNCV,0,NULL)); case KEY_AUTOLOAD: case KEY_DESTROY: |