Skip to content

Commit 383053c

Browse files
committed
Merge branch 'PHP-8.2'
2 parents ca5f668 + 07bf42d commit 383053c

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8203,22 +8203,34 @@ int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf
82038203
t = &zend_jit_traces[num];
82048204
}
82058205

8206-
SHM_UNPROTECT();
8207-
zend_jit_unprotect();
8206+
zend_shared_alloc_lock();
82088207

82098208
jit_extension = (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(t->op_array);
8210-
if (ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & ZEND_JIT_TRACE_START_LOOP) {
8211-
((zend_op*)(t->opline))->handler = (const void*)zend_jit_loop_trace_counter_handler;
8212-
} else if (ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & ZEND_JIT_TRACE_START_ENTER) {
8213-
((zend_op*)(t->opline))->handler = (const void*)zend_jit_func_trace_counter_handler;
8214-
} else if (ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & ZEND_JIT_TRACE_START_RETURN) {
8215-
((zend_op*)(t->opline))->handler = (const void*)zend_jit_ret_trace_counter_handler;
8209+
8210+
/* Checks under lock, just in case something has changed while we were waiting for the lock */
8211+
if (!(ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & (ZEND_JIT_TRACE_JITED|ZEND_JIT_TRACE_BLACKLISTED))) {
8212+
/* skip: not JIT-ed nor blacklisted */
8213+
} else if (ZEND_JIT_TRACE_NUM >= JIT_G(max_root_traces)) {
8214+
/* skip: too many root traces */
8215+
} else {
8216+
SHM_UNPROTECT();
8217+
zend_jit_unprotect();
8218+
8219+
if (ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & ZEND_JIT_TRACE_START_LOOP) {
8220+
((zend_op*)(t->opline))->handler = (const void*)zend_jit_loop_trace_counter_handler;
8221+
} else if (ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & ZEND_JIT_TRACE_START_ENTER) {
8222+
((zend_op*)(t->opline))->handler = (const void*)zend_jit_func_trace_counter_handler;
8223+
} else if (ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & ZEND_JIT_TRACE_START_RETURN) {
8224+
((zend_op*)(t->opline))->handler = (const void*)zend_jit_ret_trace_counter_handler;
8225+
}
8226+
ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags &=
8227+
ZEND_JIT_TRACE_START_LOOP|ZEND_JIT_TRACE_START_ENTER|ZEND_JIT_TRACE_START_RETURN;
8228+
8229+
zend_jit_protect();
8230+
SHM_PROTECT();
82168231
}
8217-
ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags &=
8218-
ZEND_JIT_TRACE_START_LOOP|ZEND_JIT_TRACE_START_ENTER|ZEND_JIT_TRACE_START_RETURN;
82198232

8220-
zend_jit_protect();
8221-
SHM_PROTECT();
8233+
zend_shared_alloc_unlock();
82228234

82238235
return 0;
82248236
}

0 commit comments

Comments
 (0)