41
41
42
42
#define PREG_JIT (1<<3)
43
43
44
+ #define PREG_JIT_ATTEMPTED (1<<4)
45
+
44
46
#define PCRE_CACHE_SIZE 4096
45
47
46
48
struct _pcre_cache_entry {
@@ -618,7 +620,12 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
618
620
char * p , * pp ;
619
621
char * pattern ;
620
622
size_t pattern_len ;
623
+ #ifdef HAVE_PCRE_JIT_SUPPORT
624
+ bool jit_enabled = PCRE_G (jit );
625
+ uint32_t poptions = jit_enabled ? PREG_JIT_ATTEMPTED : 0 ;
626
+ #else
621
627
uint32_t poptions = 0 ;
628
+ #endif
622
629
const uint8_t * tables = NULL ;
623
630
zval * zv ;
624
631
pcre_cache_entry new_entry ;
@@ -639,14 +646,18 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
639
646
zv = zend_hash_find (& PCRE_G (pcre_cache ), key );
640
647
if (zv ) {
641
648
pcre_cache_entry * pce = (pcre_cache_entry * )Z_PTR_P (zv );
642
- if (!(pce -> preg_options & PREG_JIT ) == !PCRE_G (jit )) {
649
+ #ifdef HAVE_PCRE_JIT_SUPPORT
650
+ if (!!(pce -> preg_options & PREG_JIT_ATTEMPTED ) == jit_enabled ) {
651
+ #endif
643
652
if (key != regex ) {
644
653
zend_string_release_ex (key , 0 );
645
654
}
646
655
return pce ;
656
+ #ifdef HAVE_PCRE_JIT_SUPPORT
647
657
} else {
648
658
zend_hash_del (& PCRE_G (pcre_cache ), key );
649
659
}
660
+ #endif
650
661
}
651
662
652
663
p = ZSTR_VAL (regex );
@@ -826,7 +837,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
826
837
}
827
838
828
839
#ifdef HAVE_PCRE_JIT_SUPPORT
829
- if (PCRE_G ( jit ) ) {
840
+ if (jit_enabled ) {
830
841
/* Enable PCRE JIT compiler */
831
842
rc = pcre2_jit_compile (re , PCRE2_JIT_COMPLETE );
832
843
if (EXPECTED (rc >= 0 )) {
0 commit comments