summaryrefslogtreecommitdiff
path: root/embed.h
diff options
context:
space:
mode:
authorSteffen Mueller <smueller@cpan.org>2014-02-22 10:08:25 +0100
committerSteffen Mueller <smueller@cpan.org>2014-02-26 21:27:57 +0100
commit7d3c8a6837b55fff0e6294ebf8c94a1601367c76 (patch)
treea73bc7c98cf940228a9be15c13c3521a13b865c9 /embed.h
parent11ee9dd668c24ff655cfec47610c8939e74a8506 (diff)
downloadperl-7d3c8a6837b55fff0e6294ebf8c94a1601367c76.tar.gz
Optimization: Remove needless list/pushmark pairs from the OP execution
This is an optimization for OP trees that involve list OPs in list context. In list context, the list OP's first child, a pushmark, will do what its name claims and push a mark to the mark stack, indicating the start of a list of parameters to another OP. Then the list's other child OPs will do their stack pushing. Finally, the list OP will be executed and do nothing but undo what the pushmark has done. This is because the main effect of the list OP only really kicks in if it's not in array context (actually, it should probably only kick in if it's in scalar context, but I don't know of any valid examples of list OPs in void contexts). This optimization is quite a measurable speed-up for array or hash slicing and some other situations. Another (contrived) example is that (1,2,(3,4)) now actually is the same, performance-wise as (1,2,3,4), albeit that's rarely relevant. The price to pay for this is a slightly convoluted (by standards other than the perl core) bit of optimization logic that has to do minor look-ahead on certain OPs in the peephole optimizer. A number of tests failed after the first attack on this problem. The failures were in two categories: a) Tests that are sensitive to details of the OP tree structure and did verbatim text comparisons of B::Concise output (ouch). These are just patched according to the new red in this commit. b) Test that validly failed because certain conditions in op.c were expecting OP_LISTs where there are now OP_NULLs (with op_targ=OP_LIST). For these, the respective conditions in op.c were adjusted. The change includes modifying B::Deparse to handle the new OP tree structure in the face of nulled OP_LISTs.
Diffstat (limited to 'embed.h')
-rw-r--r--embed.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/embed.h b/embed.h
index 16ebd328c4..facb415fc6 100644
--- a/embed.h
+++ b/embed.h
@@ -1478,6 +1478,7 @@
#define new_logop(a,b,c,d) S_new_logop(aTHX_ a,b,c,d)
#define no_bareword_allowed(a) S_no_bareword_allowed(aTHX_ a)
#define no_fh_allowed(a) S_no_fh_allowed(aTHX_ a)
+#define null_listop_in_list_context(a) S_null_listop_in_list_context(aTHX_ a)
#define op_integerize(a) S_op_integerize(aTHX_ a)
#define op_std_init(a) S_op_std_init(aTHX_ a)
#define pmtrans(a,b,c) S_pmtrans(aTHX_ a,b,c)