Skip to content

Commit d7fba44

Browse files
committed
ext/opcache/jit/zend_jit_trace: move redundant code to zend_jit_hot_counter_allocate()
1 parent a9c614d commit d7fba44

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8269,6 +8269,14 @@ static int zend_jit_restart_hot_trace_counters(zend_op_array *op_array)
82698269
return SUCCESS;
82708270
}
82718271

8272+
static int16_t *zend_jit_hot_counter_allocate(void)
8273+
{
8274+
int16_t *counter =
8275+
&zend_jit_hot_counters[ZEND_JIT_COUNTER_NUM];
8276+
ZEND_JIT_COUNTER_NUM = (ZEND_JIT_COUNTER_NUM + 1) % ZEND_HOT_COUNTERS_COUNT;
8277+
return counter;
8278+
}
8279+
82728280
static int zend_jit_setup_hot_trace_counters(zend_op_array *op_array)
82738281
{
82748282
zend_op *opline;
@@ -8313,8 +8321,7 @@ static int zend_jit_setup_hot_trace_counters(zend_op_array *op_array)
83138321
opline->handler = (const void*)zend_jit_loop_trace_counter_handler;
83148322
if (!trace_info->counter) {
83158323
trace_info->counter =
8316-
&zend_jit_hot_counters[ZEND_JIT_COUNTER_NUM];
8317-
ZEND_JIT_COUNTER_NUM = (ZEND_JIT_COUNTER_NUM + 1) % ZEND_HOT_COUNTERS_COUNT;
8324+
zend_jit_hot_counter_allocate();
83188325
}
83198326
trace_info->trace_flags |=
83208327
ZEND_JIT_TRACE_START_LOOP;
@@ -8338,8 +8345,7 @@ static int zend_jit_setup_hot_trace_counters(zend_op_array *op_array)
83388345
/* function entry */
83398346
opline->handler = (const void*)zend_jit_func_trace_counter_handler;
83408347
trace_info->counter =
8341-
&zend_jit_hot_counters[ZEND_JIT_COUNTER_NUM];
8342-
ZEND_JIT_COUNTER_NUM = (ZEND_JIT_COUNTER_NUM + 1) % ZEND_HOT_COUNTERS_COUNT;
8348+
zend_jit_hot_counter_allocate();
83438349
trace_info->trace_flags |=
83448350
ZEND_JIT_TRACE_START_ENTER;
83458351
}

0 commit comments

Comments
 (0)