From: Dmitry Stogov Date: Tue, 29 Sep 2020 10:05:24 +0000 (+0300) Subject: Keep track information about used JIT trigger in ZEND_FUNC_INFO(op_array)->func_info... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dddb40313bf8acdf0294deb3b41fbe94de2806e6;p=php Keep track information about used JIT trigger in ZEND_FUNC_INFO(op_array)->func_info.flags --- diff --git a/ext/opcache/Optimizer/zend_func_info.h b/ext/opcache/Optimizer/zend_func_info.h index 97f60ad37e..13dd2e3127 100644 --- a/ext/opcache/Optimizer/zend_func_info.h +++ b/ext/opcache/Optimizer/zend_func_info.h @@ -35,6 +35,12 @@ #define ZEND_FUNC_HAS_EXTENDED_STMT (1<<11) #define ZEND_SSA_TSSA (1<<12) /* used by tracing JIT */ +#define ZEND_FUNC_JIT_ON_FIRST_EXEC (1<<13) /* used by JIT */ +#define ZEND_FUNC_JIT_ON_PROF_REQUEST (1<<14) /* used by JIT */ +#define ZEND_FUNC_JIT_ON_HOT_COUNTERS (1<<15) /* used by JIT */ +#define ZEND_FUNC_JIT_ON_HOT_TRACE (1<<16) /* used by JIT */ + + typedef struct _zend_func_info zend_func_info; typedef struct _zend_call_info zend_call_info; diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 348f15c4fc..3d46fcc8b5 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -3452,7 +3452,12 @@ static void zend_jit_cleanup_func_info(zend_op_array *op_array) if (JIT_G(trigger) == ZEND_JIT_ON_FIRST_EXEC || JIT_G(trigger) == ZEND_JIT_ON_PROF_REQUEST || JIT_G(trigger) == ZEND_JIT_ON_HOT_COUNTERS) { - memset(func_info, 0, sizeof(zend_func_info)); + func_info->num = 0; + func_info->flags &= ZEND_FUNC_JIT_ON_FIRST_EXEC + | ZEND_FUNC_JIT_ON_PROF_REQUEST + | ZEND_FUNC_JIT_ON_HOT_COUNTERS + | ZEND_FUNC_JIT_ON_HOT_TRACE; + memset(&func_info->ssa, 0, sizeof(zend_func_info) - offsetof(zend_func_info, ssa)); } else { ZEND_SET_FUNC_INFO(op_array, NULL); } @@ -3637,6 +3642,7 @@ static int zend_jit_setup_hot_counters(zend_op_array *op_array) jit_extension = (zend_jit_op_array_hot_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_hot_extension) + (op_array->last - 1) * sizeof(void*)); memset(&jit_extension->func_info, 0, sizeof(zend_func_info)); + jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_HOT_COUNTERS; jit_extension->counter = &zend_jit_hot_counters[zend_jit_op_array_hash(op_array) & (ZEND_HOT_COUNTERS_COUNT - 1)]; for (i = 0; i < op_array->last; i++) { jit_extension->orig_handlers[i] = op_array->opcodes[i].handler; @@ -3689,6 +3695,7 @@ ZEND_EXT_API int zend_jit_op_array(zend_op_array *op_array, zend_script *script) } jit_extension = (zend_jit_op_array_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_extension)); memset(&jit_extension->func_info, 0, sizeof(zend_func_info)); + jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_FIRST_EXEC; jit_extension->orig_handler = (void*)opline->handler; ZEND_SET_FUNC_INFO(op_array, (void*)jit_extension); opline->handler = (const void*)zend_jit_runtime_jit_handler; @@ -3708,6 +3715,7 @@ ZEND_EXT_API int zend_jit_op_array(zend_op_array *op_array, zend_script *script) } jit_extension = (zend_jit_op_array_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_extension)); memset(&jit_extension->func_info, 0, sizeof(zend_func_info)); + jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_PROF_REQUEST; jit_extension->orig_handler = (void*)opline->handler; ZEND_SET_FUNC_INFO(op_array, (void*)jit_extension); opline->handler = (const void*)zend_jit_profile_jit_handler; diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 8057e8131b..cc42fcb51b 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -486,7 +486,12 @@ static zend_ssa *zend_jit_trace_build_ssa(const zend_op_array *op_array, zend_sc jit_extension = (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array); - memset(&jit_extension->func_info, 0, sizeof(jit_extension->func_info)); + jit_extension->func_info.num = 0; + jit_extension->func_info.flags &= ZEND_FUNC_JIT_ON_FIRST_EXEC + | ZEND_FUNC_JIT_ON_PROF_REQUEST + | ZEND_FUNC_JIT_ON_HOT_COUNTERS + | ZEND_FUNC_JIT_ON_HOT_TRACE; + memset(&jit_extension->func_info.ssa, 0, sizeof(zend_func_info) - offsetof(zend_func_info, ssa)); ssa = &jit_extension->func_info.ssa; if (JIT_G(opt_level) >= ZEND_JIT_LEVEL_OPT_FUNC) { @@ -5708,7 +5713,12 @@ jit_cleanup: jit_extension = (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array); - memset(&jit_extension->func_info, 0, sizeof(jit_extension->func_info)); + jit_extension->func_info.num = 0; + jit_extension->func_info.flags &= ZEND_FUNC_JIT_ON_FIRST_EXEC + | ZEND_FUNC_JIT_ON_PROF_REQUEST + | ZEND_FUNC_JIT_ON_HOT_COUNTERS + | ZEND_FUNC_JIT_ON_HOT_TRACE; + memset(&jit_extension->func_info.ssa, 0, sizeof(zend_func_info) - offsetof(zend_func_info, ssa)); } zend_arena_release(&CG(arena), checkpoint); @@ -6833,6 +6843,7 @@ static int zend_jit_setup_hot_trace_counters(zend_op_array *op_array) jit_extension = (zend_jit_op_array_trace_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_trace_extension) + (op_array->last - 1) * sizeof(zend_op_trace_info)); memset(&jit_extension->func_info, 0, sizeof(zend_func_info)); + jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_HOT_TRACE; jit_extension->op_array = op_array; jit_extension->offset = (char*)jit_extension->trace_info - (char*)op_array->opcodes; for (i = 0; i < op_array->last; i++) {