Commit cc611faf1b for perl

commit cc611faf1bcc0680d5420f29d90ae73df6c8c15e
Author: David Mitchell <davem@iabyn.nospamdeletethisbit.com>
Date:   Sun Sep 20 14:41:40 2026 +0100

    regex: increase 15->30 max super-linear cache node

    There is currently a limit of 15 on the number of WHILEM nodes which can
    participate in the super-linear cache. This used to be a hard limit, as
    the node index was stored in the upper 4-bits of the 8-bit FLAGS()
    field of the node.

    Now the index uses all 8 bits, so there is a theoretical hard upper
    limit of 255. This commit increases the actual limit from 15 to 30.

    A higher limit means that more quantifiers in very complex patterns can
    make use of the cache, so less backtracking might ensue. The downside is
    that more cache memory may be allocated, although the cache is now
    allocated per-node, so it won't necessarily use more memory.

    By not going immediately to 255, this commit is a cautious first step.

diff --git a/pod/perlreguts.pod b/pod/perlreguts.pod
index 1b25df91ca..e1fddbda3b 100644
--- a/pod/perlreguts.pod
+++ b/pod/perlreguts.pod
@@ -1376,14 +1376,15 @@ point. ]

 =item *

-There is currently a hard limit of 15 cache-participating C<WHILEM> nodes
-per regex.
+There is currently a limit of 30 cache-participating C<WHILEM> nodes per
+regex. In theory this could in future be changed up a hard limit of 255.
+This is set by the C<SLC_MAX_WHILEM_NODES> define in F<regcomp_study.c>.

 =back

 =head4 The super-linear cache at run-time

-In a compiled regex, a node id in the range 1-15 is stored in the
+In a compiled regex, a node id in the range 1-30 is stored in the
 C<FLAGS()> field of each participating C<WHILEM> node (a value of 0
 indicates that the node isn't suitable for the SLC). The field
 C<slc_whilem_seen> in the C<regexp_internal> structure indicates the total
diff --git a/regcomp_study.c b/regcomp_study.c
index 77ff2d4a1e..99e3e2874d 100644
--- a/regcomp_study.c
+++ b/regcomp_study.c
@@ -31,6 +31,9 @@
     Newx(and_withp, 1, regnode_ssc); \
     SAVEFREEPV(and_withp)

+/* Max number of WHILEM nodes which can participate in the super-linear
+ * cache. */
+#define SLC_MAX_WHILEM_NODES 30

 static void
 S_unwind_scan_frames(pTHX_ void *p)
@@ -2789,7 +2792,7 @@ Perl_study_chunk(pTHX_
                         !FLAGS(nxt)
                         /* max supported number of WHILEM nodes that can
                          * participate in super-linear cache */
-                      && RExC_rxi->slc_whilem_seen < 15)
+                      && RExC_rxi->slc_whilem_seen < SLC_MAX_WHILEM_NODES)
                     {
                         ++RExC_rxi->slc_whilem_seen;
                         FLAGS(nxt) = RExC_rxi->slc_whilem_seen; /* On WHILEM */