com php-src: Don't JIT functions with many blocks: ext/opcache/ jit/zend_jit.c
| From: | Nikita Popov | Date: | Wed, 29 May 2019 09:49:44 +0000 |
| Subject: | com php-src: Don't JIT functions with many blocks: ext/opcache/ jit/zend_jit.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106436@lists.php.net to get a copy of this message | ||
Commit: b7a6430a52da182646844860a03fc6befbac8012
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 29 May 2019 11:48:40 +0200
Parents: 6d89553c481099d35a1001540bbdb32afd3281a2
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b7a6430a52da182646844860a03fc6befbac8012
Log:
Don't JIT functions with many blocks
Avoids a stack overflow in Zend/tests/runtime_compile_time_binary_operands.php
that happens in recursive RPO calculation. We could make that code
non-recursive, but I don't think it makes sense to JIT this kind of
function in the first place.
Changed paths:
M ext/opcache/jit/zend_jit.c
Diff:
diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c
index 0d43576..c6849cd 100644
--- a/ext/opcache/jit/zend_jit.c
+++ b/ext/opcache/jit/zend_jit.c
@@ -599,6 +599,13 @@ static int zend_jit_build_cfg(zend_op_array *op_array, zend_cfg *cfg)
return FAILURE;
}
+ /* Don't JIT huge functions. Apart from likely being detrimental due to the amount of
+ * generated code, some of our analysis is recursive and will stack overflow with many
+ * blocks. */
+ if (cfg->blocks_count > 100000) {
+ return FAILURE;
+ }
+
if (zend_cfg_build_predecessors(&CG(arena), cfg) != SUCCESS) {
return FAILURE;
}