summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-11-25 13:36:29 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-11-26 14:33:46 -0800
commit1a35f9ffbd3ab4c89b6f5cad456b2b317c85e96e (patch)
tree66bf2690a6e643970b445f2109d5227f8035caed /toke.c
parent65ae8d9907f85f9548082307d1fa0010e9fb4d41 (diff)
downloadperl-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.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/toke.c b/toke.c
index a9b5e498e9..e5da941510 100644
--- a/toke.c
+++ b/toke.c
@@ -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: