Skip to content

[jit] Split up opcache.jit bitmask into four distinct INI settings. #5510

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

Closed
wants to merge 1 commit into from
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
7 changes: 6 additions & 1 deletion ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -3010,10 +3010,15 @@ static int accel_post_startup(void)

zend_shared_alloc_lock();
#ifdef HAVE_JIT
zend_long jit_flags = ZCG(accel_directives).jit_optimization_level * 1 +
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should emit a notice or startup error if any of the individual flags is out of range. This is somewhat of a pre-existing issue, the jit didn't warn before.

For example, ZCG(accel_directives).jit_optimization_level < 0 || ZCG(accel_directives).jit_optimization_level > 5 should emit a notice along the lines of opcache.jit_optimization should be an integer between 0 and 5, but got %d

(I'd agree that the opcache.jit bitmask would be better off as individual settings and this is an improvement, especially since there was previously no way to change just one of these)

ZCG(accel_directives).jit_trigger * 10 +
ZCG(accel_directives).jit_register_allocation * 100 +
ZCG(accel_directives).jit_cpu_flags * 1000;

if (ZCG(accel_directives).jit &&
ZCG(accel_directives).jit_buffer_size &&
ZSMMG(reserved) &&
zend_jit_startup(ZCG(accel_directives).jit, ZSMMG(reserved), jit_size, reattached) == SUCCESS) {
zend_jit_startup(jit_flags, ZSMMG(reserved), jit_size, reattached) == SUCCESS) {
ZCG(jit_enabled) = 1;
} else {
ZCG(jit_enabled) = 0;
Expand Down
6 changes: 5 additions & 1 deletion ext/opcache/ZendAccelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ typedef struct _zend_accel_directives {
char *cache_id;
#endif
#ifdef HAVE_JIT
zend_long jit;
zend_bool jit;
zend_long jit_optimization_level;
zend_long jit_trigger;
zend_long jit_register_allocation;
zend_long jit_cpu_flags;
zend_long jit_buffer_size;
zend_long jit_debug;
zend_long jit_bisect_limit;
Expand Down
3 changes: 0 additions & 3 deletions ext/opcache/jit/zend_jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
#define ZEND_JIT_CPU_FLAGS(n) (((n) / 1000) % 10)


#define ZEND_JIT_DEFAULT "1205"


/* Makes profile based JIT (opcache.jit=2*) to generate code only for most
* often called functions (above the threshold).
* TODO: this setting should be configurable
Expand Down
3 changes: 2 additions & 1 deletion ext/opcache/tests/jit/defined_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
opcache.jit=1235
opcache.jit=1
opcache.jit_trigger=3
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
Expand Down
12 changes: 10 additions & 2 deletions ext/opcache/zend_accelerator_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ ZEND_INI_BEGIN()
STD_PHP_INI_ENTRY("opcache.cache_id" , "" , PHP_INI_SYSTEM, OnUpdateString, accel_directives.cache_id, zend_accel_globals, accel_globals)
#endif
#ifdef HAVE_JIT
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" , "1" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.jit, zend_accel_globals, accel_globals)
STD_PHP_INI_ENTRY("opcache.jit_optimization_level" , "5" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.jit_optimization_level, zend_accel_globals, accel_globals)
STD_PHP_INI_ENTRY("opcache.jit_trigger" , "0" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.jit_trigger, zend_accel_globals, accel_globals)
STD_PHP_INI_ENTRY("opcache.jit_register_allocation" , "2" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.jit_register_allocation, zend_accel_globals, accel_globals)
STD_PHP_INI_ENTRY("opcache.jit_cpu_flags" , "1" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.jit_cpu_flags, 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)
Expand Down Expand Up @@ -722,7 +726,11 @@ ZEND_FUNCTION(opcache_get_configuration)
add_assoc_string(&directives, "opcache.cache_id", STRING_NOT_NULL(ZCG(accel_directives).cache_id));
#endif
#ifdef HAVE_JIT
add_assoc_long(&directives, "opcache.jit", ZCG(accel_directives).jit);
add_assoc_bool(&directives, "opcache.jit", ZCG(accel_directives).jit);
add_assoc_long(&directives, "opcache.jit_optimization_level", ZCG(accel_directives).jit_optimization_level);
add_assoc_long(&directives, "opcache.jit_trigger", ZCG(accel_directives).jit_trigger);
add_assoc_long(&directives, "opcache.jit_register_allocation", ZCG(accel_directives).jit_register_allocation);
add_assoc_long(&directives, "opcache.jit_cpu_flags", ZCG(accel_directives).jit_cpu_flags);
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);
Expand Down