From: Nikita Popov Date: Fri, 30 Aug 2019 10:47:49 +0000 (+0200) Subject: Add jit_bisect_limit X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65fa6dac195a859f6b96bdbf06f69645215df9c6;p=php Add jit_bisect_limit To help identify which function is being miscompiled. --- diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index 0f31c65182..8a49c8e94b 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -192,6 +192,7 @@ typedef struct _zend_accel_directives { zend_long jit; zend_long jit_buffer_size; zend_long jit_debug; + zend_long jit_bisect_limit; #endif } zend_accel_directives; diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 6f537da44b..bba076cac7 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -92,6 +92,8 @@ static void **dasm_ptr = NULL; static size_t dasm_size = 0; +static zend_long jit_bisect_pos = 0; + static const void *zend_jit_runtime_jit_handler = NULL; static const void *zend_jit_profile_jit_handler = NULL; static const void *zend_jit_func_counter_handler = NULL; @@ -1972,6 +1974,20 @@ static int zend_jit(zend_op_array *op_array, zend_ssa *ssa, const zend_op *rt_op zend_bool is_terminated = 1; /* previous basic block is terminated by jump */ zend_bool recv_emitted = 0; /* emitted at least one RECV opcode */ + if (ZCG(accel_directives).jit_bisect_limit) { + jit_bisect_pos++; + if (jit_bisect_pos >= ZCG(accel_directives).jit_bisect_limit) { + if (jit_bisect_pos == ZCG(accel_directives).jit_bisect_limit) { + fprintf(stderr, "Not JITing %s%s%s in %s:%d and after due to jit_bisect_limit\n", + op_array->scope ? ZSTR_VAL(op_array->scope->name) : "", + op_array->scope ? "::" : "", + op_array->function_name ? ZSTR_VAL(op_array->function_name) : "{main}", + ZSTR_VAL(op_array->filename), op_array->line_start); + } + return FAILURE; + } + } + if (zend_jit_reg_alloc) { checkpoint = zend_arena_checkpoint(CG(arena)); ra = zend_jit_allocate_registers(op_array, ssa); diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 4e8c8c7f5b..9f4dc2e841 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -313,6 +313,7 @@ ZEND_INI_BEGIN() STD_PHP_INI_ENTRY("opcache.jit" , ZEND_JIT_DEFAULT, PHP_INI_SYSTEM, OnUpdateLong, accel_directives.jit, zend_accel_globals, accel_globals) STD_PHP_INI_ENTRY("opcache.jit_buffer_size" , "0" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.jit_buffer_size, zend_accel_globals, accel_globals) STD_PHP_INI_ENTRY("opcache.jit_debug" , "0" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.jit_debug, zend_accel_globals, accel_globals) + STD_PHP_INI_ENTRY("opcache.jit_bisect_limit" , "0" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.jit_bisect_limit, zend_accel_globals, accel_globals) #endif ZEND_INI_END() @@ -780,6 +781,7 @@ static ZEND_FUNCTION(opcache_get_configuration) add_assoc_long(&directives, "opcache.jit", ZCG(accel_directives).jit); add_assoc_long(&directives, "opcache.jit_buffer_size", ZCG(accel_directives).jit_buffer_size); add_assoc_long(&directives, "opcache.jit_debug", ZCG(accel_directives).jit_debug); + add_assoc_long(&directives, "opcache.jit_bisect_limit", ZCG(accel_directives).jit_bisect_limit); #endif add_assoc_zval(return_value, "directives", &directives);