Safefree(PL_origfilename);
PL_origfilename = NULL;
Safefree(PL_reg_curpm);
- Safefree(PL_reg_poscache);
free_tied_hv_pool();
Safefree(PL_op_mask);
Safefree(PL_psig_name);
/* As these are inside a structure, PERLVARI isn't capable of initialising
them */
PL_reg_curpm = NULL;
- PL_reg_poscache = PL_reg_starttry = NULL;
}
STATIC void
Copy(&PL_reg_state, state, 1, struct re_save_state);
- PL_reg_poscache = NULL;
- PL_reg_poscache_size = 0;
-
/* Save $1..$n (#18107: UTF-8 s/(\w+)/uc($1)/e); AMS 20021106. */
if (PL_curpm) {
const REGEXP * const rx = PM_GETRE(PL_curpm);
reginfo->info_aux->old_regmatch_state = old_regmatch_state;
reginfo->info_aux->old_regmatch_slab = old_regmatch_slab;
+ reginfo->info_aux->poscache = NULL;
SAVEDESTRUCTOR_X(S_cleanup_regmatch_info_aux, reginfo->info_aux);
"unreachable code" warnings, which are bogus, but distracting. */
#define CACHEsayNO \
if (ST.cache_mask) \
- PL_reg_poscache[ST.cache_offset] |= ST.cache_mask; \
+ reginfo->info_aux->poscache[ST.cache_offset] |= ST.cache_mask; \
sayNO
/* this is used to determine how far from the left messages like
if (reginfo->poscache_iter-- == 0) {
/* initialise cache */
const I32 size = (reginfo->poscache_maxiter + 7)/8;
- if (PL_reg_poscache) {
- if ((I32)PL_reg_poscache_size < size) {
- Renew(PL_reg_poscache, size, char);
- PL_reg_poscache_size = size;
+ regmatch_info_aux *const aux = reginfo->info_aux;
+ if (aux->poscache) {
+ if ((I32)reginfo->poscache_size < size) {
+ Renew(aux->poscache, size, char);
+ reginfo->poscache_size = size;
}
- Zero(PL_reg_poscache, size, char);
+ Zero(aux->poscache, size, char);
}
else {
- PL_reg_poscache_size = size;
- Newxz(PL_reg_poscache, size, char);
+ reginfo->poscache_size = size;
+ Newxz(aux->poscache, size, char);
}
DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log,
"%swhilem: Detected a super-linear match, switching on caching%s...\n",
* (scan->flags>>4);
mask = 1 << (offset % 8);
offset /= 8;
- if (PL_reg_poscache[offset] & mask) {
+ if (reginfo->info_aux->poscache[offset] & mask) {
DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log,
"%*s whilem: (cache) already tried at this position...\n",
REPORT_CODE_OFF+depth*2, "")
regmatch_info_aux_eval *eval_state = aux->info_aux_eval;
regmatch_slab *s;
+ Safefree(aux->poscache);
+
if (eval_state) {
/* undo the effects of S_setup_eval_state() */
regmatch_info_aux_eval *info_aux_eval;
struct regmatch_state *old_regmatch_state; /* saved PL_regmatch_state */
struct regmatch_slab *old_regmatch_slab; /* saved PL_regmatch_slab */
+ char *poscache; /* S-L cache of fail positions of WHILEMs */
} regmatch_info_aux;
regmatch_info_aux_eval *info_aux_eval; /* extra saved state for (?{}) */
I32 poscache_maxiter; /* how many whilems todo before S-L cache kicks in */
I32 poscache_iter; /* current countdown from _maxiter to zero */
+ STRLEN poscache_size; /* size of regmatch_info_aux.poscache */
bool intuit; /* re_intuit_start() is the top-level caller */
bool is_utf8_pat; /* regex is utf8 */
bool is_utf8_target; /* string being matched is utf8 */
} regmatch_slab;
#define PL_reg_curpm PL_reg_state.re_state_reg_curpm
-#define PL_reg_poscache PL_reg_state.re_state_reg_poscache
-#define PL_reg_poscache_size PL_reg_state.re_state_reg_poscache_size
#define PL_reg_starttry PL_reg_state.re_state_reg_starttry
struct re_save_state {
PMOP *re_state_reg_curpm; /* from regexec.c */
- STRLEN re_state_reg_poscache_size; /* size of pos cache of WHILEM */
- char *re_state_reg_poscache; /* cache of pos of WHILEM */
char *re_state_reg_starttry; /* from regexec.c */
};
- SAVESTACK_ALLOC_FOR_RE_SAVE_STATE);
PL_savestack_ix -= SAVESTACK_ALLOC_FOR_RE_SAVE_STATE;
- if (PL_reg_poscache != state->re_state_reg_poscache) {
- Safefree(PL_reg_poscache);
- }
Copy(state, &PL_reg_state, 1, struct re_save_state);
}
break;
new_state->re_state_reg_curpm
= (PMOP*) any_dup(old_state->re_state_reg_curpm,
proto_perl);
- new_state->re_state_reg_poscache
- = pv_dup(old_state->re_state_reg_poscache);
- new_state->re_state_reg_starttry
- = pv_dup(old_state->re_state_reg_starttry);
break;
}
case SAVEt_COMPILE_WARNINGS: