Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions ext/opcache/jit/zend_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ ZEND_EXT_API void zend_jit_status(zval *ret)
add_assoc_long(&stats, "buffer_size", 0);
add_assoc_long(&stats, "buffer_free", 0);
}
add_assoc_long(&stats, "function_compilation_successes", JIT_G(function_compilation_successes));
add_assoc_long(&stats, "function_compilation_failures", JIT_G(function_compilation_failures));
add_assoc_zval(ret, "jit", &stats);
}

Expand Down Expand Up @@ -1981,6 +1983,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
op_array->function_name ? ZSTR_VAL(op_array->function_name) : "{main}",
ZSTR_VAL(op_array->filename), op_array->line_start);
}
JIT_G(function_compilation_failures)++;
return FAILURE;
}
}
Expand Down Expand Up @@ -2089,7 +2092,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
if (JIT_G(opt_flags) & (ZEND_JIT_REG_ALLOC_LOCAL|ZEND_JIT_REG_ALLOC_GLOBAL)) {
zend_arena_release(&CG(arena), checkpoint);
}
return SUCCESS;
goto jit_success;
}
zend_jit_label(&dasm_state, ssa->cfg.blocks_count + b);
zend_jit_prologue(&dasm_state);
Expand All @@ -2104,7 +2107,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
if (JIT_G(opt_flags) & (ZEND_JIT_REG_ALLOC_LOCAL|ZEND_JIT_REG_ALLOC_GLOBAL)) {
zend_arena_release(&CG(arena), checkpoint);
}
return SUCCESS;
goto jit_success;
} else {
zend_jit_label(&dasm_state, ssa->cfg.blocks_count + b);
zend_jit_prologue(&dasm_state);
Expand Down Expand Up @@ -2974,7 +2977,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
break;
case ZEND_NEW:
if (!zend_jit_handler(&dasm_state, opline, 1)) {
return 0;
goto jit_success;
}
if (opline->extended_value == 0 && (opline+1)->opcode == ZEND_DO_FCALL) {
zend_class_entry *ce = NULL;
Expand Down Expand Up @@ -3037,6 +3040,9 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
if (JIT_G(opt_flags) & (ZEND_JIT_REG_ALLOC_LOCAL|ZEND_JIT_REG_ALLOC_GLOBAL)) {
zend_arena_release(&CG(arena), checkpoint);
}

jit_success:
JIT_G(function_compilation_successes)++;
return SUCCESS;

jit_failure:
Expand All @@ -3046,6 +3052,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
if (JIT_G(opt_flags) & (ZEND_JIT_REG_ALLOC_LOCAL|ZEND_JIT_REG_ALLOC_GLOBAL)) {
zend_arena_release(&CG(arena), checkpoint);
}

JIT_G(function_compilation_failures)++;
return FAILURE;
}

Expand Down
3 changes: 3 additions & 0 deletions ext/opcache/jit/zend_jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ typedef struct _zend_jit_globals {
uint8_t bad_root_cache_stop[ZEND_JIT_TRACE_BAD_ROOT_SLOTS];
uint32_t bad_root_slot;

uint32_t function_compilation_successes;
uint32_t function_compilation_failures;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jit_globals structure is not shared across processes, so each process is going to keep (and show) only it's own number of compiled and failed functions.

uint8_t exit_counters[ZEND_JIT_TRACE_MAX_EXIT_COUNTERS];
} zend_jit_globals;

Expand Down
2 changes: 2 additions & 0 deletions ext/opcache/jit/zend_jit_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -5595,6 +5595,8 @@ static void zend_jit_trace_init_caches(void)
memset(JIT_G(bad_root_cache_count), 0, sizeof(JIT_G(bad_root_cache_count)));
memset(JIT_G(bad_root_cache_stop), 0, sizeof(JIT_G(bad_root_cache_count)));
JIT_G(bad_root_slot) = 0;
JIT_G(function_compilation_successes) = 0;
JIT_G(function_compilation_failures) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not specific to tracing JIT. It would be better to move this assignments to zend_jit.c


memset(JIT_G(exit_counters), 0, sizeof(JIT_G(exit_counters)));
}
Expand Down
37 changes: 37 additions & 0 deletions ext/opcache/tests/jit/opcache_get_status.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--TEST--
Test JIT information in opcache_get_status
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
opcache.protect_memory=1
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php

var_dump(opcache_get_status()['jit'])

?>
--EXPECTF--
array(9) {
["enabled"]=>
bool(true)
["on"]=>
bool(true)
["kind"]=>
int(0)
["opt_level"]=>
int(5)
["opt_flags"]=>
int(6)
["buffer_size"]=>
int(%d)
["buffer_free"]=>
int(%d)
["function_compilation_successes"]=>
int(1)
["function_compilation_failures"]=>
int(0)
}