summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2020-11-19 12:32:36 +0300
committerDmitry Stogov <dmitry@zend.com>2020-11-19 12:32:36 +0300
commit069f9cbaa55d0f3d5fdc12898f2197ce317bb555 (patch)
tree688c552032611bbe06b5b128ad1e1beb48bed110
parent46b9e0c874bedc90ea092099fa7d0be11395148c (diff)
downloadphp-git-069f9cbaa55d0f3d5fdc12898f2197ce317bb555.tar.gz
Added missing deoptimization code for trampoline handling
-rw-r--r--ext/opcache/jit/zend_jit_disasm_x86.c1
-rw-r--r--ext/opcache/jit/zend_jit_helpers.c9
-rw-r--r--ext/opcache/jit/zend_jit_trace.c6
-rw-r--r--ext/opcache/jit/zend_jit_x86.dasc11
4 files changed, 26 insertions, 1 deletions
diff --git a/ext/opcache/jit/zend_jit_disasm_x86.c b/ext/opcache/jit/zend_jit_disasm_x86.c
index afd830e89f..11335918cb 100644
--- a/ext/opcache/jit/zend_jit_disasm_x86.c
+++ b/ext/opcache/jit/zend_jit_disasm_x86.c
@@ -494,6 +494,7 @@ static int zend_jit_disasm_init(void)
#if (PHP_VERSION_ID <= 80000) && (SIZEOF_SIZE_T == 4)
REGISTER_HELPER(zval_jit_update_constant_ex);
#endif
+ REGISTER_HELPER(zend_jit_free_trampoline_helper);
#undef REGISTER_HELPER
#ifndef _WIN32
diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c
index 5d5a30541b..7c164cd23b 100644
--- a/ext/opcache/jit/zend_jit_helpers.c
+++ b/ext/opcache/jit/zend_jit_helpers.c
@@ -2666,4 +2666,11 @@ static zend_result ZEND_FASTCALL zval_jit_update_constant_ex(zval *p, zend_class
}
return SUCCESS;
}
-#endif \ No newline at end of file
+#endif
+
+static void ZEND_FASTCALL zend_jit_free_trampoline_helper(zend_function *func)
+{
+ ZEND_ASSERT(func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE);
+ zend_string_release_ex(func->common.function_name, 0);
+ zend_free_trampoline(func);
+}
diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c
index b74ccaad31..f08791a8d1 100644
--- a/ext/opcache/jit/zend_jit_trace.c
+++ b/ext/opcache/jit/zend_jit_trace.c
@@ -3289,6 +3289,12 @@ static int zend_jit_trace_deoptimization(dasm_State **Dst,
}
}
+ if ((flags & ZEND_JIT_EXIT_METHOD_CALL) && !polymorphic_side_trace) {
+ if (!zend_jit_free_trampoline(Dst)) {
+ return 0;
+ }
+ }
+
return 1;
}
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index 9187e3d7f0..1a590313c7 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -3930,6 +3930,17 @@ static int zend_jit_store_const(dasm_State **Dst, int var, zend_reg reg)
return 1;
}
+static int zend_jit_free_trampoline(dasm_State **Dst)
+{
+ | /// if (UNEXPECTED(func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE))
+ | test dword [r0 + offsetof(zend_function, common.fn_flags)], ZEND_ACC_CALL_VIA_TRAMPOLINE
+ | jz >1
+ | mov FCARG1a, r0
+ | EXT_CALL zend_jit_free_trampoline_helper, r0
+ |1:
+ return 1;
+}
+
static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op1_def_info, zend_jit_addr op1_def_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, int may_overflow, int may_throw)
{
if (op1_info & ((MAY_BE_UNDEF|MAY_BE_ANY)-MAY_BE_LONG)) {