Skip to content

Commit e86011c

Browse files
committed
Store JIT/non-JIT regex in a different PCRE cache slot
1 parent 5604f7a commit e86011c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

ext/pcre/php_pcre.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,24 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
627627
pcre_cache_entry *ret;
628628

629629
if (locale_aware && BG(ctype_string)) {
630-
key = zend_string_concat2(
630+
key = zend_string_concat3(
631631
ZSTR_VAL(BG(ctype_string)), ZSTR_LEN(BG(ctype_string)),
632-
ZSTR_VAL(regex), ZSTR_LEN(regex));
632+
ZSTR_VAL(regex), ZSTR_LEN(regex),
633+
#ifdef HAVE_PCRE_JIT_SUPPORT
634+
PCRE_G(jit) ? "1" : "0", 1
635+
#else
636+
"", 0
637+
#endif
638+
);
633639
} else {
640+
#ifdef HAVE_PCRE_JIT_SUPPORT
641+
key = zend_string_concat2(
642+
ZSTR_VAL(regex), ZSTR_LEN(regex),
643+
PCRE_G(jit) ? "1" : "0", 1
644+
);
645+
#else
634646
key = regex;
647+
#endif
635648
}
636649

637650
/* Try to lookup the cached regex entry, and if successful, just pass
@@ -786,7 +799,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
786799
return NULL;
787800
}
788801

789-
if (key != regex) {
802+
if (locale_aware && BG(ctype_string)) {
790803
tables = (uint8_t *)zend_hash_find_ptr(&char_tables, BG(ctype_string));
791804
if (!tables) {
792805
zend_string *_k;

0 commit comments

Comments
 (0)