Skip to content

Commit 0695048

Browse files
committed
JIT refactoring to allow run-time changes of JIT options (triggers, optimization_level, debug flags, etc)
1 parent 1179686 commit 0695048

14 files changed

+530
-470
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2854,6 +2854,10 @@ static int accel_startup(zend_extension *extension)
28542854
accel_globals_ctor(&accel_globals);
28552855
#endif
28562856

2857+
#ifdef HAVE_JIT
2858+
zend_jit_init();
2859+
#endif
2860+
28572861
#ifdef ZEND_WIN32
28582862
# if !defined(__has_feature) || !__has_feature(address_sanitizer)
28592863
_setmaxstdio(2048); /* The default configuration is limited to 512 stdio files */
@@ -2937,8 +2941,7 @@ static int accel_post_startup(void)
29372941
size_t jit_size = 0;
29382942
zend_bool reattached = 0;
29392943

2940-
if (ZCG(accel_directives).jit &&
2941-
ZCG(accel_directives).jit_buffer_size) {
2944+
if (JIT_G(enabled) && JIT_G(buffer_size)) {
29422945
size_t page_size;
29432946

29442947
# ifdef _WIN32
@@ -2952,12 +2955,9 @@ static int accel_post_startup(void)
29522955
zend_accel_error(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - can't get page size.");
29532956
abort();
29542957
}
2955-
jit_size = ZCG(accel_directives).jit_buffer_size;
2958+
jit_size = JIT_G(buffer_size);
29562959
jit_size = ZEND_MM_ALIGNED_SIZE_EX(jit_size, page_size);
29572960
shm_size += jit_size;
2958-
} else {
2959-
ZCG(accel_directives).jit = 0;
2960-
ZCG(accel_directives).jit_buffer_size = 0;
29612961
}
29622962

29632963
switch (zend_shared_alloc_startup(shm_size, jit_size)) {
@@ -3010,13 +3010,13 @@ static int accel_post_startup(void)
30103010

30113011
zend_shared_alloc_lock();
30123012
#ifdef HAVE_JIT
3013-
if (ZCG(accel_directives).jit &&
3014-
ZCG(accel_directives).jit_buffer_size &&
3015-
ZSMMG(reserved) &&
3016-
zend_jit_startup(ZCG(accel_directives).jit, ZSMMG(reserved), jit_size, reattached) == SUCCESS) {
3017-
ZCG(jit_enabled) = 1;
3018-
} else {
3019-
ZCG(jit_enabled) = 0;
3013+
if (JIT_G(enabled)) {
3014+
if (JIT_G(buffer_size) == 0
3015+
|| !ZSMMG(reserved)
3016+
|| zend_jit_startup(ZSMMG(reserved), jit_size, reattached) != SUCCESS) {
3017+
JIT_G(enabled) = 0;
3018+
JIT_G(on) = 0;
3019+
}
30203020
}
30213021
#endif
30223022
zend_shared_alloc_save_state();

ext/opcache/ZendAccelerator.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,6 @@ typedef struct _zend_accel_directives {
191191
#ifdef ZEND_WIN32
192192
char *cache_id;
193193
#endif
194-
#ifdef HAVE_JIT
195-
zend_long jit;
196-
zend_long jit_buffer_size;
197-
zend_long jit_debug;
198-
zend_long jit_bisect_limit;
199-
#endif
200194
} zend_accel_directives;
201195

202196
typedef struct _zend_accel_globals {
@@ -227,9 +221,6 @@ typedef struct _zend_accel_globals {
227221
void *arena_mem;
228222
zend_persistent_script *current_persistent_script;
229223
zend_bool is_immutable_class;
230-
#ifdef HAVE_JIT
231-
zend_bool jit_enabled;
232-
#endif
233224
/* cache to save hash lookup on the same INCLUDE opcode */
234225
const zend_op *cache_opline;
235226
zend_persistent_script *cache_persistent_script;

0 commit comments

Comments
 (0)