Skip to content

Commit c790c98

Browse files
committed
ext/opcache/jit/zend_jit_internal: add ZEND_OP_TRACE_INFO_OFFSET()
Shortcut which allows eliminating several zend_jit_op_array_trace_extension* variables.
1 parent 08e8090 commit c790c98

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

ext/opcache/jit/zend_jit_internal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,14 @@ typedef struct _zend_jit_op_array_trace_extension {
498498
zend_op_trace_info trace_info[1];
499499
} zend_jit_op_array_trace_extension;
500500

501+
static zend_always_inline size_t ZEND_OP_TRACE_INFO_OFFSET(const zend_op_array *op_array)
502+
{
503+
const zend_jit_op_array_trace_extension *jit_extension =
504+
(const zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array);
505+
ZEND_ASSERT(jit_extension != NULL);
506+
return jit_extension->offset;
507+
}
508+
501509
static zend_always_inline zend_op_trace_info *ZEND_OP_TRACE_INFO(const zend_op *opline, size_t offset)
502510
{
503511
return (zend_op_trace_info*)((char*)opline + offset);

ext/opcache/jit/zend_jit_trace.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7579,8 +7579,6 @@ int ZEND_FASTCALL zend_jit_trace_hot_root(zend_execute_data *execute_data, const
75797579
zend_jit_trace_stop stop;
75807580
int ret = 0;
75817581
zend_op_array *op_array;
7582-
zend_jit_op_array_trace_extension *jit_extension;
7583-
size_t offset;
75847582
uint32_t trace_num;
75857583
zend_jit_trace_rec trace_buffer[ZEND_JIT_TRACE_MAX_LENGTH];
75867584

@@ -7592,8 +7590,7 @@ int ZEND_FASTCALL zend_jit_trace_hot_root(zend_execute_data *execute_data, const
75927590
trace_num = ZEND_JIT_TRACE_NUM;
75937591
orig_opline = opline;
75947592
op_array = &EX(func)->op_array;
7595-
jit_extension = (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array);
7596-
offset = jit_extension->offset;
7593+
const size_t offset = ZEND_OP_TRACE_INFO_OFFSET(op_array);
75977594

75987595
EX(opline) = opline;
75997596

@@ -7642,9 +7639,7 @@ int ZEND_FASTCALL zend_jit_trace_hot_root(zend_execute_data *execute_data, const
76427639
if (JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_START) {
76437640
const zend_op_array *op_array = trace_buffer[0].op_array;
76447641
const zend_op *opline = trace_buffer[1].opline;
7645-
zend_jit_op_array_trace_extension *jit_extension =
7646-
(zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array);
7647-
size_t offset = jit_extension->offset;
7642+
const size_t offset = ZEND_OP_TRACE_INFO_OFFSET(op_array);
76487643

76497644
fprintf(stderr, "---- TRACE %d start (%s) %s%s%s() %s:%d\n",
76507645
trace_num,

0 commit comments

Comments
 (0)