When the rpeep is available (i.e. starting from perl 5.13.4), recursion in
the peephole optimizer replacement seemingly only happens for static
infinite loops (think for (;;) { }), even though the 'seen' pointer table
is checked for every op. This may cause slowdowns even outside of the scope
of the pragma. To mitigate this problem, only check for recursion on
nextstate, dbstate, and stub ops, since one of those three kind of ops must
occur in any loop/block (respectively for non-empty, non-empty debugging
and empty loops).
const a_op_info *oi = NULL;
UV flags = 0;
+#if !A_HAS_RPEEP
if (ptable_fetch(seen, o))
break;
ptable_seen_store(seen, o, o);
+#endif
switch (o->op_type) {
+#if A_HAS_RPEEP
+ case OP_NEXTSTATE:
+ case OP_DBSTATE:
+ case OP_STUB:
+ if (ptable_fetch(seen, o))
+ return;
+ ptable_seen_store(seen, o, o);
+ break;
+#endif
case OP_PADSV:
if (o->op_ppaddr != a_pp_deref) {
oi = a_map_fetch(o);