diff options
author | Florian Ragwitz <rafl@debian.org> | 2010-08-16 00:16:00 +0200 |
---|---|---|
committer | Florian Ragwitz <rafl@debian.org> | 2010-08-16 00:18:20 +0200 |
commit | 666e7765a1af9c81577039073e9ff43b19d9110f (patch) | |
tree | ff72f5d3cf5cbe011e1115e67bbe74dfd153b114 /pod | |
parent | 874cd4e1c18d04983efb99e1366ac237240dcd07 (diff) | |
download | perl-666e7765a1af9c81577039073e9ff43b19d9110f.tar.gz |
Revert "Make the peep recurse via PL_peepp"
This reverts commit 65bfe90c4b4ea5706a50067179e60d4e8de6807a.
While it made a few of the things I wanted possible, a couple of other things
one might need to do and I thought this change would enable don't actually
work. Thanks Zefram for pointing out my mistake.
Conflicts:
ext/XS-APItest/APItest.xs
op.c
Diffstat (limited to 'pod')
-rw-r--r-- | pod/perl5134delta.pod | 8 | ||||
-rw-r--r-- | pod/perlguts.pod | 60 |
2 files changed, 3 insertions, 65 deletions
diff --git a/pod/perl5134delta.pod b/pod/perl5134delta.pod index b7398e33d7..dfd73c1b49 100644 --- a/pod/perl5134delta.pod +++ b/pod/perl5134delta.pod @@ -532,14 +532,6 @@ contains a more specific escape hatch: This can be used for modules that have not been upgraded to 5.6 naming conventions (and really should be completely obsolete by now). -=item Make extending the peephole optimizer easier - -As of version 5.8, extension authors were allowed to replace perl's peephole -optimizer function. However, this was B<very> hard to do, as there was no way to -add new optimizations without having to copy large parts of perl's original -optimizer. This problem is now solved by a rework of the optimizer extension -API. See L<perlguts/"Compile pass 3: peephole optimization"> for details. - =item C<Perl_grok_bslash_o> and C<Perl_grok_bslash_c> may change in future The functions C<Perl_grok_bslash_o> and C<Perl_grok_bslash_c>, which are public diff --git a/pod/perlguts.pod b/pod/perlguts.pod index 6a244b7d79..62e99bd386 100644 --- a/pod/perlguts.pod +++ b/pod/perlguts.pod @@ -1821,63 +1821,9 @@ of free()ing (i.e. their type is changed to OP_NULL). After the compile tree for a subroutine (or for an C<eval> or a file) is created, an additional pass over the code is performed. This pass is neither top-down or bottom-up, but in the execution order (with -additional complications for conditionals). Optimizations performed -at this stage are subject to the same restrictions as in the pass 2. - -Peephole optimizations are done by calling the function pointed to by -the global variable C<PL_peepp>. By default, C<PL_peepp> points to the -function C<Perl_peep>. However, extensions may provide their own -peephole optimizers, like this: - - peep_t original_peep; - - void my_peep (pTHX_ OP *o, peep_next_t *next_peep) - { - /* Delegate perl's original optimizer. The function pointer - * in next_peep->fn will point to the optimizer function - * initially invoked, so when perl's peep recurses into some - * branch of the optree, it'll call back to my_peep. - */ - CALL_FPTR(original_peep)(aTHX_ o, next_peep); - - if (!o) - return; - - for (; o; o = o->op_next) { - /* custom optimisations */ - } - } - - /* later, for example in a BOOT section */ - original_peep = PL_peepp; - PL_peepp = my_peep; - -Do note that the peephole optimizer is called for each root of an -optree. It has to traverse that optree itself, if necessary. - -However, it is not normally necessary for peep extensions to walk into -branches of conditions. Perl's original optimizer, which extensions should -always delegate to, already implements that and will call the optimizer -pointed to by C<next_peep> for each root OP of branches. By default, -C<next_peep> points to whatever is in C<PL_peepp>, but it is also possible -to make the default optimizer call back to different optimizers: - - void my_peep (pTHX_ OP *o, peep_next_t *next_peep) - { - peep_next_t other_peep = { my_other_peep, NULL }; - - /* call the original peep, and have it call my_other_peep when - * recursing into branches */ - CALL_FPTR(original_peep)(aTHX_ o, &other_peep); - } - -The second member of C<peep_next_t>, C<user_data>, which is just set to -C<NULL> in the above example, may be used to pass along arbitrary data to -later invocations of peep functions. - -Also note that, under some conditions, the peephole optimizer will be -called with a C<NULL> opcode. That is perfectly normal and optimizer -functions need to accomodate for that. +additional complications for conditionals). These optimizations are +done in the subroutine peep(). Optimizations performed at this stage +are subject to the same restrictions as in the pass 2. =head2 Pluggable runops |