com php-src: Enable PCRE JIT compiler: ext/pcre/php_pcre.c ext/pcre/php_pcre.h ext/standard/tests/general_funct ions/ini_get_all.phpt
sapi/cli/tests/006.phpt
| From: | Dmitry Stogov | Date: | Fri, 25 Apr 2014 04:33:37 +0000 |
| Subject: | com php-src: Enable PCRE JIT compiler: ext/pcre/php_pcre.c ext/pcre/php_pcre.h ext/standard/tests/general_funct ions/ini_get_all.phpt sapi/cli/tests/006.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77279@lists.php.net to get a copy of this message | ||
Commit: d0ed1212a454dbbae7ec0327bc4f063e26037a0b
Author: Dmitry Stogov <dmitry@zend.com> Fri, 25 Apr 2014 08:33:37 +0400
Parents: 2178612186e030b344f05a85fda6e46851b5a598
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d0ed1212a454dbbae7ec0327bc4f063e26037a0b
Log:
Enable PCRE JIT compiler
Changed paths:
M ext/pcre/php_pcre.c
M ext/pcre/php_pcre.h
M ext/standard/tests/general_functions/ini_get_all.phpt
M sapi/cli/tests/006.phpt
Diff:
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 60769f1..983dd6d 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -117,7 +117,10 @@ static PHP_GSHUTDOWN_FUNCTION(pcre) /* {{{ */
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("pcre.backtrack_limit", "1000000", PHP_INI_ALL,
OnUpdateLong, backtrack_limit, zend_pcre_globals, pcre_globals)
- STD_PHP_INI_ENTRY("pcre.recursion_limit", "100000", PHP_INI_ALL, OnUpdateLong,
recursion_limit, zend_pcre_globals, pcre_globals)
+ STD_PHP_INI_ENTRY("pcre.recursion_limit", "100000", PHP_INI_ALL,
OnUpdateLong, recursion_limit, zend_pcre_globals, pcre_globals)
+#ifdef PCRE_STUDY_JIT_COMPILE
+ STD_PHP_INI_ENTRY("pcre.jit", "1", PHP_INI_ALL,
OnUpdateBool, jit, zend_pcre_globals, pcre_globals)
+#endif
PHP_INI_END()
@@ -412,12 +415,22 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex
TSRMLS
return NULL;
}
+#ifdef PCRE_STUDY_JIT_COMPILE
+ if (PCRE_G(jit)) {
+ /* Enable PCRE JIT compiler */
+ do_study = 1;
+ soptions |= PCRE_STUDY_JIT_COMPILE;
+ }
+#endif
+
/* If study option was specified, study the pattern and
store the result in extra for passing to pcre_exec. */
if (do_study) {
extra = pcre_study(re, soptions, &error);
if (extra) {
extra->flags |= PCRE_EXTRA_MATCH_LIMIT | PCRE_EXTRA_MATCH_LIMIT_RECURSION;
+ extra->match_limit = PCRE_G(backtrack_limit);
+ extra->match_limit_recursion = PCRE_G(recursion_limit);
}
if (error != NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while studying pattern");
diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h
index f352059..266f676 100644
--- a/ext/pcre/php_pcre.h
+++ b/ext/pcre/php_pcre.h
@@ -70,6 +70,9 @@ ZEND_BEGIN_MODULE_GLOBALS(pcre)
HashTable pcre_cache;
long backtrack_limit;
long recursion_limit;
+#ifdef PCRE_STUDY_JIT_COMPILE
+ zend_bool jit;
+#endif
int error_code;
ZEND_END_MODULE_GLOBALS(pcre)
diff --git a/ext/standard/tests/general_functions/ini_get_all.phpt
b/ext/standard/tests/general_functions/ini_get_all.phpt
index 60cd38a..806831e 100644
--- a/ext/standard/tests/general_functions/ini_get_all.phpt
+++ b/ext/standard/tests/general_functions/ini_get_all.phpt
@@ -30,7 +30,7 @@ Warning: ini_get_all(): Unable to find extension 'nosuchextension' in %s
on line
bool(false)
array(0) {
}
-array(2) {
+array(3) {
["pcre.backtrack_limit"]=>
array(3) {
["global_value"]=>
@@ -40,6 +40,15 @@ array(2) {
["access"]=>
int(7)
}
+ ["pcre.jit"]=>
+ array(3) {
+ ["global_value"]=>
+ string(1) "1"
+ ["local_value"]=>
+ string(1) "1"
+ ["access"]=>
+ int(7)
+ }
["pcre.recursion_limit"]=>
array(3) {
["global_value"]=>
@@ -50,9 +59,11 @@ array(2) {
int(7)
}
}
-array(2) {
+array(3) {
["pcre.backtrack_limit"]=>
string(7) "1000000"
+ ["pcre.jit"]=>
+ string(1) "1"
["pcre.recursion_limit"]=>
string(6) "100000"
}
diff --git a/sapi/cli/tests/006.phpt b/sapi/cli/tests/006.phpt
index 3d5c916..e9e8b7e 100644
--- a/sapi/cli/tests/006.phpt
+++ b/sapi/cli/tests/006.phpt
@@ -34,6 +34,9 @@ string(%d) "Extension [ <persistent> extension #%d pcre version
<no_version> ] {
Entry [ pcre.recursion_limit <ALL> ]
Current = '%d'
}
+ Entry [ pcre.jit <ALL> ]
+ Current = '%d'
+ }
}
- Constants [14] {