Skip to content

Add configuration opcache.jit_max_trace_length #11173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2023
Merged
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
1 change: 1 addition & 0 deletions ext/opcache/jit/zend_jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ typedef struct _zend_jit_globals {
zend_long max_recursive_calls; /* max number of recursive inlined call unrolls */
zend_long max_recursive_returns; /* max number of recursive inlined return unrolls */
zend_long max_polymorphic_calls; /* max number of inlined polymorphic calls */
zend_long max_trace_length; /* max length of a single trace */

zend_sym_node *symbols; /* symbols for disassembler */

Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/jit/zend_jit_vm_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_loop_trace_helper(ZEND_OPCODE_HAN
trace_buffer[idx].info = _op | (_info); \
trace_buffer[idx].ptr = _ptr; \
idx++; \
if (idx >= ZEND_JIT_TRACE_MAX_LENGTH - 2) { \
if (idx >= JIT_G(max_trace_length) - 2) { \
stop = ZEND_JIT_TRACE_STOP_TOO_LONG; \
break; \
}
Expand All @@ -372,7 +372,7 @@ ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_loop_trace_helper(ZEND_OPCODE_HAN
trace_buffer[idx].op3_type = _op3_type; \
trace_buffer[idx].ptr = _ptr; \
idx++; \
if (idx >= ZEND_JIT_TRACE_MAX_LENGTH - 2) { \
if (idx >= JIT_G(max_trace_length) - 2) { \
stop = ZEND_JIT_TRACE_STOP_TOO_LONG; \
break; \
}
Expand Down
15 changes: 15 additions & 0 deletions ext/opcache/zend_accelerator_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,19 @@ static ZEND_INI_MH(OnUpdateUnrollL)
ZEND_JIT_TRACE_MAX_LOOPS_UNROLL);
return FAILURE;
}

static ZEND_INI_MH(OnUpdateMaxTraceLength)
{
zend_long val = zend_ini_parse_quantity_warn(new_value, entry->name);
if (val > 3 && val <= ZEND_JIT_TRACE_MAX_LENGTH) {
zend_long *p = (zend_long *) ZEND_INI_GET_ADDR();
*p = val;
return SUCCESS;
}
zend_error(E_WARNING, "Invalid \"%s\" setting. Should be between 4 and %d", ZSTR_VAL(entry->name),
ZEND_JIT_TRACE_MAX_LENGTH);
return FAILURE;
}
#endif

ZEND_INI_BEGIN()
Expand Down Expand Up @@ -336,6 +349,7 @@ ZEND_INI_BEGIN()
STD_PHP_INI_ENTRY("opcache.jit_max_recursive_calls" , "2", PHP_INI_ALL, OnUpdateUnrollC, max_recursive_calls, zend_jit_globals, jit_globals)
STD_PHP_INI_ENTRY("opcache.jit_max_recursive_returns" , "2", PHP_INI_ALL, OnUpdateUnrollR, max_recursive_returns, zend_jit_globals, jit_globals)
STD_PHP_INI_ENTRY("opcache.jit_max_polymorphic_calls" , "2", PHP_INI_ALL, OnUpdateLong, max_polymorphic_calls, zend_jit_globals, jit_globals)
STD_PHP_INI_ENTRY("opcache.jit_max_trace_length" , "1024", PHP_INI_ALL, OnUpdateMaxTraceLength, max_trace_length, zend_jit_globals, jit_globals)
#endif
ZEND_INI_END()

Expand Down Expand Up @@ -849,6 +863,7 @@ ZEND_FUNCTION(opcache_get_configuration)
add_assoc_long(&directives, "opcache.jit_max_root_traces", JIT_G(max_root_traces));
add_assoc_long(&directives, "opcache.jit_max_side_traces", JIT_G(max_side_traces));
add_assoc_long(&directives, "opcache.jit_prof_threshold", JIT_G(prof_threshold));
add_assoc_long(&directives, "opcache.jit_max_trace_length", JIT_G(max_trace_length));
#endif

add_assoc_zval(return_value, "directives", &directives);
Expand Down