]> granicus.if.org Git - php/commitdiff
Don't JIT functions with many blocks
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 29 May 2019 09:48:40 +0000 (11:48 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 29 May 2019 09:49:44 +0000 (11:49 +0200)
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.

ext/opcache/jit/zend_jit.c

index 0d43576ed333665920570e1477ad08d66f0fa79d..c6849cd3aca2cc2212b697f0212104237ffc150d 100644 (file)
@@ -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;
        }