Commit c167fab61d for perl
commit c167fab61dd90cacd1e8155107dea86337f927de
Author: David Mitchell <davem@iabyn.nospamdeletethisbit.com>
Date: Wed Oct 14 20:11:13 2026 +0100
regmatch: refactor: use MULTICALL_FLAGS_PREFIX_ etc
Make use of the FOO_MULTICALL_FLAGS_PREFIX_ macros (which were added by
the previous commit) in the regex engine's runtime when executing EVAL
nodes (i.e. (?{...}) etc). This moves the MULTICALL's state away from
hidden local variables and into the reginfo structure, which will allow
the state to be accessed from multiple functions, and so shortly allow
the EVAL code to be moved into its own function.
diff --git a/perl.h b/perl.h
index b03c991078..4e072898ff 100644
--- a/perl.h
+++ b/perl.h
@@ -4862,7 +4862,6 @@ struct Perl_OpDumpContext;
#endif
#include "sv.h"
-#include "regexp.h"
#include "util.h"
#include "form.h"
#include "gv.h"
@@ -4872,6 +4871,7 @@ struct Perl_OpDumpContext;
#include "op.h"
#include "hv.h"
#include "cop.h"
+#include "regexp.h"
#include "av.h"
#include "mg.h"
#include "scope.h"
diff --git a/regexec.c b/regexec.c
index c7a1677dd8..a0e020d28f 100644
--- a/regexec.c
+++ b/regexec.c
@@ -7234,7 +7234,6 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
type such as \1 or (??{...}. For more
details, see
L<perlreguts/The super-linear cache> */
- dMULTICALL;
U8 gimme = G_SCALAR;
U32 maxopenparen = 0; /* max '(' index seen so far */
int to_complement; /* Invert the result? */
@@ -7263,10 +7262,6 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
reginfo->caller_cv = NULL;
reginfo->last_pad = NULL;
- /* shut up 'may be used uninitialized' compiler warnings for dMULTICALL */
- multicall_oldcatch = 0;
- PERL_UNUSED_VAR(multicall_cop);
-
st = PL_regmatch_state;
/* Note that nextbyte is a byte even in UTF */
@@ -9092,10 +9087,10 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
? CXp_SUB_RE_FAKE : 0));
SAVECOMPPAD();
if (reginfo->last_pushed_cv) {
- CHANGE_MULTICALL_FLAGS(newcv, flags);
+ CHANGE_MULTICALL_FLAGS_PREFIX_(newcv, flags, reginfo->);
}
else {
- PUSH_MULTICALL_FLAGS(newcv, flags);
+ PUSH_MULTICALL_FLAGS_PREFIX_(newcv, flags, reginfo->);
}
/* see notes above */
CX_CUR()->blk_oldsaveix = orig_savestack_ix;
@@ -9105,7 +9100,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
else {
/* these assignments are just to silence compiler
* warnings */
- multicall_cop = NULL;
+ reginfo->multicall_cop = NULL;
}
reginfo->last_pad = PL_comppad;
@@ -11073,7 +11068,7 @@ NULL
/* see "Some notes about MULTICALL" above, especially how
* the POP_MULTICALL does the equivalent of the LEAVE_SCOPE
* for us, so no need to do it explicitly. */
- POP_MULTICALL;
+ POP_MULTICALL_PREFIX_(reginfo->);
PERL_UNUSED_VAR(SP);
}
else {
diff --git a/regexp.h b/regexp.h
index e0f620169d..9123c01bd3 100644
--- a/regexp.h
+++ b/regexp.h
@@ -851,6 +851,8 @@ typedef struct {
CV *caller_cv; /* who called us: a cached find_runcv(NULL) */
CV *last_pushed_cv; /* most recently called (?{...}) CV */
PAD* last_pad; /* pad used for last (?{...}) execution */
+ /* vars holding private state between MULTICALLs */
+ dMULTICALL;
} regmatch_info;