Skip to content

Commit d2f8114

Browse files
committed
Set proper jit_extension for inherited methods
1 parent 0de3ca4 commit d2f8114

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,6 +3286,8 @@ static int zend_jit_setup_hot_counters(zend_op_array *op_array)
32863286
}
32873287
}
32883288

3289+
zend_shared_alloc_register_xlat_entry(op_array->opcodes, jit_extension);
3290+
32893291
return SUCCESS;
32903292
}
32913293

@@ -3333,6 +3335,7 @@ ZEND_EXT_API int zend_jit_op_array(zend_op_array *op_array, zend_script *script)
33333335
jit_extension->orig_handler = (void*)opline->handler;
33343336
ZEND_SET_FUNC_INFO(op_array, (void*)jit_extension);
33353337
opline->handler = (const void*)zend_jit_runtime_jit_handler;
3338+
zend_shared_alloc_register_xlat_entry(op_array->opcodes, jit_extension);
33363339

33373340
return SUCCESS;
33383341
} else if (JIT_G(trigger) == ZEND_JIT_ON_PROF_REQUEST) {
@@ -3353,6 +3356,7 @@ ZEND_EXT_API int zend_jit_op_array(zend_op_array *op_array, zend_script *script)
33533356
jit_extension->orig_handler = (void*)opline->handler;
33543357
ZEND_SET_FUNC_INFO(op_array, (void*)jit_extension);
33553358
opline->handler = (const void*)zend_jit_profile_jit_handler;
3359+
zend_shared_alloc_register_xlat_entry(op_array->opcodes, jit_extension);
33563360
}
33573361

33583362
return SUCCESS;
@@ -3485,6 +3489,27 @@ ZEND_EXT_API int zend_jit_script(zend_script *script)
34853489
}
34863490

34873491
zend_arena_release(&CG(arena), checkpoint);
3492+
3493+
if (JIT_G(trigger) == ZEND_JIT_ON_FIRST_EXEC
3494+
|| JIT_G(trigger) == ZEND_JIT_ON_PROF_REQUEST
3495+
|| JIT_G(trigger) == ZEND_JIT_ON_HOT_COUNTERS
3496+
|| JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
3497+
zend_class_entry *ce;
3498+
zend_op_array *op_array;
3499+
3500+
ZEND_HASH_FOREACH_PTR(&script->class_table, ce) {
3501+
ZEND_HASH_FOREACH_PTR(&ce->function_table, op_array) {
3502+
if (!ZEND_FUNC_INFO(op_array)) {
3503+
void *jit_extension = zend_shared_alloc_get_xlat_entry(op_array->opcodes);
3504+
3505+
if (jit_extension) {
3506+
ZEND_SET_FUNC_INFO(op_array, jit_extension);
3507+
}
3508+
}
3509+
} ZEND_HASH_FOREACH_END();
3510+
} ZEND_HASH_FOREACH_END();
3511+
}
3512+
34883513
return SUCCESS;
34893514

34903515
jit_failure:

ext/opcache/jit/zend_jit_trace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5205,6 +5205,8 @@ static int zend_jit_setup_hot_trace_counters(zend_op_array *op_array)
52055205
}
52065206
}
52075207

5208+
zend_shared_alloc_register_xlat_entry(op_array->opcodes, jit_extension);
5209+
52085210
return SUCCESS;
52095211
}
52105212

ext/opcache/zend_persist.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "zend_interfaces.h"
3131

3232
#ifdef HAVE_JIT
33+
# include "Optimizer/zend_func_info.h"
3334
# include "jit/zend_jit.h"
3435
#endif
3536

@@ -384,6 +385,21 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc
384385
ZEND_ASSERT(op_array->vars != NULL);
385386
}
386387
ZCG(mem) = (void*)((char*)ZCG(mem) + ZEND_ALIGNED_SIZE(zend_extensions_op_array_persist(op_array, ZCG(mem))));
388+
#ifdef HAVE_JIT
389+
if (JIT_G(on) && JIT_G(opt_level) <= ZEND_JIT_LEVEL_OPT_FUNCS &&
390+
!ZCG(current_persistent_script)->corrupted) {
391+
if (JIT_G(trigger) == ZEND_JIT_ON_FIRST_EXEC
392+
|| JIT_G(trigger) == ZEND_JIT_ON_PROF_REQUEST
393+
|| JIT_G(trigger) == ZEND_JIT_ON_HOT_COUNTERS
394+
|| JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
395+
void *jit_extension = zend_shared_alloc_get_xlat_entry(op_array->opcodes);
396+
397+
if (jit_extension) {
398+
ZEND_SET_FUNC_INFO(op_array, jit_extension);
399+
}
400+
}
401+
}
402+
#endif
387403
return;
388404
}
389405
} else {

0 commit comments

Comments
 (0)