Skip to content

JIT refactoring to allow run-time changes of JIT options #5580

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 3 commits 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
26 changes: 13 additions & 13 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -2854,6 +2854,10 @@ static int accel_startup(zend_extension *extension)
accel_globals_ctor(&accel_globals);
#endif

#ifdef HAVE_JIT
zend_jit_init();
#endif

#ifdef ZEND_WIN32
# if !defined(__has_feature) || !__has_feature(address_sanitizer)
_setmaxstdio(2048); /* The default configuration is limited to 512 stdio files */
Expand Down Expand Up @@ -2937,8 +2941,7 @@ static int accel_post_startup(void)
size_t jit_size = 0;
zend_bool reattached = 0;

if (ZCG(accel_directives).jit &&
ZCG(accel_directives).jit_buffer_size) {
if (JIT_G(enabled) && JIT_G(buffer_size)) {
size_t page_size;

# ifdef _WIN32
Expand All @@ -2952,12 +2955,9 @@ static int accel_post_startup(void)
zend_accel_error(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - can't get page size.");
abort();
}
jit_size = ZCG(accel_directives).jit_buffer_size;
jit_size = JIT_G(buffer_size);
jit_size = ZEND_MM_ALIGNED_SIZE_EX(jit_size, page_size);
shm_size += jit_size;
} else {
ZCG(accel_directives).jit = 0;
ZCG(accel_directives).jit_buffer_size = 0;
}

switch (zend_shared_alloc_startup(shm_size, jit_size)) {
Expand Down Expand Up @@ -3010,13 +3010,13 @@ static int accel_post_startup(void)

zend_shared_alloc_lock();
#ifdef HAVE_JIT
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) {
ZCG(jit_enabled) = 1;
} else {
ZCG(jit_enabled) = 0;
if (JIT_G(enabled)) {
if (JIT_G(buffer_size) == 0
|| !ZSMMG(reserved)
|| zend_jit_startup(ZSMMG(reserved), jit_size, reattached) != SUCCESS) {
JIT_G(enabled) = 0;
JIT_G(on) = 0;
}
}
#endif
zend_shared_alloc_save_state();
Expand Down
9 changes: 0 additions & 9 deletions ext/opcache/ZendAccelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,6 @@ typedef struct _zend_accel_directives {
#ifdef ZEND_WIN32
char *cache_id;
#endif
#ifdef HAVE_JIT
zend_long jit;
zend_long jit_buffer_size;
zend_long jit_debug;
zend_long jit_bisect_limit;
#endif
} zend_accel_directives;

typedef struct _zend_accel_globals {
Expand Down Expand Up @@ -227,9 +221,6 @@ typedef struct _zend_accel_globals {
void *arena_mem;
zend_persistent_script *current_persistent_script;
zend_bool is_immutable_class;
#ifdef HAVE_JIT
zend_bool jit_enabled;
#endif
/* cache to save hash lookup on the same INCLUDE opcode */
const zend_op *cache_opline;
zend_persistent_script *cache_persistent_script;
Expand Down
Loading