]> granicus.if.org Git - php/commitdiff
Add jit_bisect_limit
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 30 Aug 2019 10:47:49 +0000 (12:47 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 30 Aug 2019 12:50:22 +0000 (14:50 +0200)
To help identify which function is being miscompiled.

ext/opcache/ZendAccelerator.h
ext/opcache/jit/zend_jit.c
ext/opcache/zend_accelerator_module.c

index 0f31c65182852deb8c49d1e74fdfa6ed5ac6bc86..8a49c8e94bad1e11eb02e24ba045b50aabb39f74 100644 (file)
@@ -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;
 
index 6f537da44ba4aa0357573a601e4a2b615daf517a..bba076cac7f1f99591c82639ae0b4a39be09a7c2 100644 (file)
@@ -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);
index 4e8c8c7f5bcb335a19bef52b9bef1067786f6548..9f4dc2e841ace5161feb3993995df4189d0b0e24 100644 (file)
@@ -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);