summaryrefslogtreecommitdiff
path: root/regcomp_study.c
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2023-01-08 11:35:38 +0100
committerYves Orton <demerphq@gmail.com>2023-01-15 17:21:25 +0100
commit98ce67cb64ba29be3aa5fd5b81012a3aab873b8e (patch)
tree3d8cc0841fb8b36a3cf18da610cb033345b44814 /regcomp_study.c
parent0678333e684b55ba8877db1f865692713dacafc0 (diff)
downloadperl-98ce67cb64ba29be3aa5fd5b81012a3aab873b8e.tar.gz
regcomp_study.c - disable CURLYX optimizations when EVAL has been seen anywhere
Historically we disabled CURLYX optimizations when they *contained* an EVAL, on the assumption that the optimization might affect how many times, etc, the eval was called. However, this is also true for CURLYX with evals *afterwards*. If the CURLYN or CURLYM optimization can prune off the search space, then an eval afterwards will be affected. An when you take into account GOSUB, it means that an eval in front might be affected by an optimization after it. So for now we disable CURLYN and CURLYM in any pattern with an EVAL.
Diffstat (limited to 'regcomp_study.c')
-rw-r--r--regcomp_study.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/regcomp_study.c b/regcomp_study.c
index 296de3f7e4..88672077d7 100644
--- a/regcomp_study.c
+++ b/regcomp_study.c
@@ -2688,23 +2688,26 @@ Perl_study_chunk(pTHX_
stopmin = min;
DEBUG_STUDYDATA("after-whilem accept", data, depth, is_inf, min, stopmin, delta);
}
+ DEBUG_STUDYDATA("PRE CURLYX_TO_CURLYN", data, depth, is_inf, min, stopmin, delta);
/* Try powerful optimization CURLYX => CURLYN. */
if ( RE_OPTIMIZE_CURLYX_TO_CURLYN
&& OP(oscan) == CURLYX
&& data
- && data->flags & SF_IN_PAR
- && !(data->flags & SF_HAS_EVAL)
+ && !pRExC_state->code_blocks /* XXX: for now disable whenever eval
+ is seen anywhere. We need a better
+ way. */
+ && ( ( data->flags & (SF_IN_PAR|SF_HAS_EVAL) ) == SF_IN_PAR )
&& !deltanext
&& minnext == 1
&& mutate_ok
) {
+ DEBUG_STUDYDATA("CURLYX_TO_CURLYN", data, depth, is_inf, min, stopmin, delta);
/* Try to optimize to CURLYN. */
regnode *nxt = REGNODE_AFTER_type(oscan, tregnode_CURLYX);
regnode * const nxt1 = nxt;
#ifdef DEBUGGING
regnode *nxt2;
#endif
-
/* Skip open. */
nxt = regnext(nxt);
if (!REGNODE_SIMPLE(OP(nxt))
@@ -2741,10 +2744,15 @@ Perl_study_chunk(pTHX_
}
nogo:
+ DEBUG_STUDYDATA("PRE CURLYX_TO_CURLYM", data, depth, is_inf, min, stopmin, delta);
+
/* Try optimization CURLYX => CURLYM. */
if ( RE_OPTIMIZE_CURLYX_TO_CURLYM
&& OP(oscan) == CURLYX
&& data
+ && !pRExC_state->code_blocks /* XXX: for now disable whenever eval
+ is seen anywhere. We need a better
+ way. */
&& !(data->flags & (SF_HAS_PAR|SF_HAS_EVAL))
&& !deltanext /* atom is fixed width */
&& minnext != 0 /* CURLYM can't handle zero width */
@@ -2753,6 +2761,7 @@ Perl_study_chunk(pTHX_
&& !(RExC_seen & REG_UNFOLDED_MULTI_SEEN)
&& mutate_ok
) {
+ DEBUG_STUDYDATA("CURLYX_TO_CURLYM", data, depth, is_inf, min, stopmin, delta);
/* XXXX How to optimize if data == 0? */
/* Optimize to a simpler form. */
regnode *nxt = REGNODE_AFTER_type(oscan, tregnode_CURLYX); /* OPEN */