Skip to content

Commit 65fa6da

Browse files
committed
Add jit_bisect_limit
To help identify which function is being miscompiled.
1 parent 39ab410 commit 65fa6da

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

ext/opcache/ZendAccelerator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ typedef struct _zend_accel_directives {
192192
zend_long jit;
193193
zend_long jit_buffer_size;
194194
zend_long jit_debug;
195+
zend_long jit_bisect_limit;
195196
#endif
196197
} zend_accel_directives;
197198

ext/opcache/jit/zend_jit.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ static void **dasm_ptr = NULL;
9292

9393
static size_t dasm_size = 0;
9494

95+
static zend_long jit_bisect_pos = 0;
96+
9597
static const void *zend_jit_runtime_jit_handler = NULL;
9698
static const void *zend_jit_profile_jit_handler = NULL;
9799
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
19721974
zend_bool is_terminated = 1; /* previous basic block is terminated by jump */
19731975
zend_bool recv_emitted = 0; /* emitted at least one RECV opcode */
19741976

1977+
if (ZCG(accel_directives).jit_bisect_limit) {
1978+
jit_bisect_pos++;
1979+
if (jit_bisect_pos >= ZCG(accel_directives).jit_bisect_limit) {
1980+
if (jit_bisect_pos == ZCG(accel_directives).jit_bisect_limit) {
1981+
fprintf(stderr, "Not JITing %s%s%s in %s:%d and after due to jit_bisect_limit\n",
1982+
op_array->scope ? ZSTR_VAL(op_array->scope->name) : "",
1983+
op_array->scope ? "::" : "",
1984+
op_array->function_name ? ZSTR_VAL(op_array->function_name) : "{main}",
1985+
ZSTR_VAL(op_array->filename), op_array->line_start);
1986+
}
1987+
return FAILURE;
1988+
}
1989+
}
1990+
19751991
if (zend_jit_reg_alloc) {
19761992
checkpoint = zend_arena_checkpoint(CG(arena));
19771993
ra = zend_jit_allocate_registers(op_array, ssa);

ext/opcache/zend_accelerator_module.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ ZEND_INI_BEGIN()
313313
STD_PHP_INI_ENTRY("opcache.jit" , ZEND_JIT_DEFAULT, PHP_INI_SYSTEM, OnUpdateLong, accel_directives.jit, zend_accel_globals, accel_globals)
314314
STD_PHP_INI_ENTRY("opcache.jit_buffer_size" , "0" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.jit_buffer_size, zend_accel_globals, accel_globals)
315315
STD_PHP_INI_ENTRY("opcache.jit_debug" , "0" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.jit_debug, zend_accel_globals, accel_globals)
316+
STD_PHP_INI_ENTRY("opcache.jit_bisect_limit" , "0" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.jit_bisect_limit, zend_accel_globals, accel_globals)
316317
#endif
317318
ZEND_INI_END()
318319

@@ -780,6 +781,7 @@ static ZEND_FUNCTION(opcache_get_configuration)
780781
add_assoc_long(&directives, "opcache.jit", ZCG(accel_directives).jit);
781782
add_assoc_long(&directives, "opcache.jit_buffer_size", ZCG(accel_directives).jit_buffer_size);
782783
add_assoc_long(&directives, "opcache.jit_debug", ZCG(accel_directives).jit_debug);
784+
add_assoc_long(&directives, "opcache.jit_bisect_limit", ZCG(accel_directives).jit_bisect_limit);
783785
#endif
784786

785787
add_assoc_zval(return_value, "directives", &directives);

0 commit comments

Comments
 (0)