Skip to content

Commit 0a59bdc

Browse files
committed
ext/opcache/jit/zend_jit_trace: copy offset to local variable
Don't remember the zend_jit_op_array_trace_extension pointer unless we need more than the offset. This eliminates a few memory reads.
1 parent e96f55f commit 0a59bdc

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6906,23 +6906,20 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
69066906
const zend_op_array *rec_op_array;
69076907

69086908
rec_op_array = op_array = trace_buffer->op_array;
6909-
jit_extension =
6910-
(zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array);
6909+
size_t offset = ZEND_OP_TRACE_INFO_OFFSET(op_array);
69116910
p = trace_buffer + ZEND_JIT_TRACE_START_REC_SIZE;
69126911
for (;;p++) {
69136912
if (p->op == ZEND_JIT_TRACE_VM) {
69146913
opline = p->opline;
69156914
} else if (p->op == ZEND_JIT_TRACE_ENTER) {
69166915
if (p->op_array == rec_op_array) {
6917-
zend_jit_trace_setup_ret_counter(opline, jit_extension->offset);
6916+
zend_jit_trace_setup_ret_counter(opline, offset);
69186917
}
69196918
op_array = p->op_array;
6920-
jit_extension =
6921-
(zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array);
6919+
offset = ZEND_OP_TRACE_INFO_OFFSET(op_array);
69226920
} else if (p->op == ZEND_JIT_TRACE_BACK) {
69236921
op_array = p->op_array;
6924-
jit_extension =
6925-
(zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array);
6922+
offset = ZEND_OP_TRACE_INFO_OFFSET(op_array);
69266923
} else if (p->op == ZEND_JIT_TRACE_END) {
69276924
break;
69286925
}
@@ -6944,9 +6941,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
69446941
do {
69456942
if (frame->call_opline) {
69466943
op_array = &frame->func->op_array;
6944+
const size_t offset = ZEND_OP_TRACE_INFO_OFFSET(op_array);
69476945
jit_extension =
69486946
(zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array);
6949-
zend_jit_trace_setup_ret_counter(frame->call_opline, jit_extension->offset);
6947+
zend_jit_trace_setup_ret_counter(frame->call_opline, offset);
69506948
}
69516949
frame = frame->prev;
69526950
} while (frame);

0 commit comments

Comments
 (0)