summaryrefslogtreecommitdiff
path: root/opcode.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2012-09-24 13:50:22 +0100
committerDavid Mitchell <davem@iabyn.com>2012-11-10 13:39:31 +0000
commita7fd8ef68b459a13ba95615ec125e2e7ba656b47 (patch)
tree874247cb2e03f98ee1de71d4a7eb29d3e84a7611 /opcode.h
parentad9e6ae10fb581c6c053b862286f8e187063c3ab (diff)
downloadperl-a7fd8ef68b459a13ba95615ec125e2e7ba656b47.tar.gz
add padrange op
This single op can, in some circumstances, replace the sequence of a pushmark followed by one or more padsv/padav/padhv ops, and possibly a trailing 'list' op, but only where the targs of the pad ops form a continuous range. This is generally more efficient, but is particularly so in the case of void-context my declarations, such as: my ($a,@b); Formerly this would be executed as the following set of ops: pushmark pushes a new mark padsv[$a] pushes $a, does a SAVEt_CLEARSV padav[@b] pushes all the flattened elements (i.e. none) of @a, does a SAVEt_CLEARSV list pops the mark, and pops all stack elements except the last nextstate pops the remaining stack element It's now: padrange[$a..@b] does two SAVEt_CLEARSV's nextstate nothing needing doing to the stack Note that in the case above, this commit changes user-visible behaviour in pathological cases; in particular, it has always been possible to modify a lexical var *before* the my is executed, using goto or closure tricks. So in principle someone could tie an array, then could notice that FETCH is no longer being called, e.g. f(); my ($s, @a); # this no longer triggers two FETCHES sub f { tie @a, ...; push @a, 1,2; } But I think we can live with that. Note also that having a padrange operator will allow us shortly to have a corresponding SAVEt_CLEARPADRANGE save type, that will replace multiple individual SAVEt_CLEARSV's.
Diffstat (limited to 'opcode.h')
-rw-r--r--opcode.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/opcode.h b/opcode.h
index 02769ba347..540dc0ba97 100644
--- a/opcode.h
+++ b/opcode.h
@@ -524,6 +524,7 @@ EXTCONST char* const PL_op_name[] = {
"padcv",
"introcv",
"clonecv",
+ "padrange",
"freed",
};
#endif
@@ -908,6 +909,7 @@ EXTCONST char* const PL_op_desc[] = {
"private subroutine",
"private subroutine",
"private subroutine",
+ "list of private variables",
"freed op",
};
#endif
@@ -1306,6 +1308,7 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
Perl_pp_padcv,
Perl_pp_introcv,
Perl_pp_clonecv,
+ Perl_pp_padrange,
}
#endif
#ifdef PERL_PPADDR_INITED
@@ -1700,6 +1703,7 @@ EXT Perl_check_t PL_check[] /* or perlvars.h */
Perl_ck_null, /* padcv */
Perl_ck_null, /* introcv */
Perl_ck_null, /* clonecv */
+ Perl_ck_null, /* padrange */
}
#endif
#ifdef PERL_CHECK_INITED
@@ -2088,6 +2092,7 @@ EXTCONST U32 PL_opargs[] = {
0x00000040, /* padcv */
0x00000040, /* introcv */
0x00000040, /* clonecv */
+ 0x00000040, /* padrange */
};
#endif