diff options
author | Dmitry Stogov <dmitry@zend.com> | 2020-07-08 18:14:11 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2020-07-08 18:14:11 +0300 |
commit | a75cf0c7e13232ec4bdf17a1cd78fcd8b4a3c81c (patch) | |
tree | fc92226c780c6c9669face5e4a7fffe5fe0f034d | |
parent | 06da048622c46b8322ef651c9dae2ffd68161842 (diff) | |
download | php-git-a75cf0c7e13232ec4bdf17a1cd78fcd8b4a3c81c.tar.gz |
JIT support for opcache restart
-rw-r--r-- | ext/opcache/ZendAccelerator.c | 5 | ||||
-rw-r--r-- | ext/opcache/jit/zend_jit.c | 21 | ||||
-rw-r--r-- | ext/opcache/jit/zend_jit.h | 1 | ||||
-rw-r--r-- | ext/opcache/jit/zend_jit_trace.c | 10 |
4 files changed, 36 insertions, 1 deletions
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 23889327a7..073b3c8b58 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2506,6 +2506,11 @@ int accel_activate(INIT_FUNC_ARGS) if (ZCSG(preload_script)) { preload_restart(); } + +#ifdef HAVE_JIT + zend_jit_restart(); +#endif + ZCSG(accelerator_enabled) = ZCSG(cache_status_before_restart); if (ZCSG(last_restart_time) < ZCG(request_time)) { ZCSG(last_restart_time) = ZCG(request_time); diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index debf4df866..478244b6d7 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -3798,7 +3798,7 @@ ZEND_EXT_API int zend_jit_startup(void *buf, size_t size, zend_bool reattached) } #endif - dasm_ptr = dasm_end = (void*)(((char*)dasm_buf) + size - sizeof(*dasm_ptr)); + dasm_ptr = dasm_end = (void*)(((char*)dasm_buf) + size - sizeof(*dasm_ptr) * 2); if (!reattached) { zend_jit_unprotect(); *dasm_ptr = dasm_buf; @@ -3847,6 +3847,11 @@ ZEND_EXT_API int zend_jit_startup(void *buf, size_t size, zend_bool reattached) return FAILURE; } + /* save JIT buffer pos */ + zend_jit_unprotect(); + dasm_ptr[1] = dasm_ptr[0]; + zend_jit_protect(); + return SUCCESS; } @@ -3926,4 +3931,18 @@ ZEND_EXT_API void zend_jit_deactivate(void) } } +ZEND_EXT_API void zend_jit_restart(void) +{ + if (dasm_buf) { + zend_jit_unprotect(); + + /* restore JIT buffer pos */ + dasm_ptr[0] = dasm_ptr[1]; + + zend_jit_trace_restart(); + + zend_jit_protect(); + } +} + #endif /* HAVE_JIT */ diff --git a/ext/opcache/jit/zend_jit.h b/ext/opcache/jit/zend_jit.h index 406e0edece..49150a62ae 100644 --- a/ext/opcache/jit/zend_jit.h +++ b/ext/opcache/jit/zend_jit.h @@ -140,6 +140,7 @@ ZEND_EXT_API void zend_jit_shutdown(void); ZEND_EXT_API void zend_jit_activate(void); ZEND_EXT_API void zend_jit_deactivate(void); ZEND_EXT_API void zend_jit_status(zval *ret); +ZEND_EXT_API void zend_jit_restart(void); typedef struct _zend_lifetime_interval zend_lifetime_interval; typedef struct _zend_life_range zend_life_range; diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 8516353902..7a0e6fbcc2 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -5606,3 +5606,13 @@ static void zend_jit_trace_init_caches(void) static void zend_jit_trace_reset_caches(void) { } + +static void zend_jit_trace_restart(void) +{ + ZEND_JIT_TRACE_NUM = 1; + ZEND_JIT_COUNTER_NUM = 0; + ZEND_JIT_EXIT_NUM = 0; + ZEND_JIT_EXIT_COUNTERS = 0; + + zend_jit_trace_init_caches(); +} |