From 93bad3fd55489cbd2d3157da1fcb3b524e960dd2 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Sun, 24 Apr 2011 16:37:17 +0100 Subject: Split OP_AELEMFAST_LEX out from OP_AELEMFAST. 6a077020aea1c5f0 extended the OP_AELEMFAST optimisation to lexical arrays. Previously OP_AELEMFAST was only used as an optimisation for OP_GV, which is a PADOP/SVOP. However, by reusing the same opcode, and signalling (pad) lexical vs package, it introduced a myriad of special cases, because OP_PADAV is a BASEOP (not a PADOP), whilst OP_AELEMFAST is a PADOP/SVOP (which is larger). Using two OP numbers allows each variant to have the correct OP flags in PL_opargs. Both can continue to share the same C code. --- op.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'op.c') diff --git a/op.c b/op.c index b91f32284e..bd403abca9 100644 --- a/op.c +++ b/op.c @@ -571,8 +571,7 @@ Perl_op_clear(pTHX_ OP *o) case OP_GVSV: case OP_GV: case OP_AELEMFAST: - if (! (o->op_type == OP_AELEMFAST && o->op_flags & OPf_SPECIAL)) { - /* not an OP_PADAV replacement */ + { GV *gv = (o->op_type == OP_GV || o->op_type == OP_GVSV) #ifdef USE_ITHREADS && PL_curpad @@ -1069,6 +1068,7 @@ Perl_scalarvoid(pTHX_ OP *o) case OP_SPRINTF: case OP_AELEM: case OP_AELEMFAST: + case OP_AELEMFAST_LEX: case OP_ASLICE: case OP_HELEM: case OP_HSLICE: @@ -1654,6 +1654,7 @@ Perl_op_lvalue(pTHX_ OP *o, I32 type) break; case OP_AELEMFAST: + case OP_AELEMFAST_LEX: localize = -1; PL_modcount++; break; @@ -9538,10 +9539,10 @@ Perl_rpeep(pTHX_ register OP *o) if (o->op_type == OP_GV) { gv = cGVOPo_gv; GvAVn(gv); + o->op_type = OP_AELEMFAST; } else - o->op_flags |= OPf_SPECIAL; - o->op_type = OP_AELEMFAST; + o->op_type = OP_AELEMFAST_LEX; } break; } -- cgit v1.2.1