Skip to content

Commit b7a6430

Browse files
committed
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.
1 parent 6d89553 commit b7a6430

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,13 @@ static int zend_jit_build_cfg(zend_op_array *op_array, zend_cfg *cfg)
599599
return FAILURE;
600600
}
601601

602+
/* Don't JIT huge functions. Apart from likely being detrimental due to the amount of
603+
* generated code, some of our analysis is recursive and will stack overflow with many
604+
* blocks. */
605+
if (cfg->blocks_count > 100000) {
606+
return FAILURE;
607+
}
608+
602609
if (zend_cfg_build_predecessors(&CG(arena), cfg) != SUCCESS) {
603610
return FAILURE;
604611
}

0 commit comments

Comments
 (0)