Skip to content

Commit d6eaab1

Browse files
committed
ext/opcache/jit/zend_jit: use modulo instead of bitwise and
This is clearer and more robust (just in case ZEND_HOT_COUNTERS_COUNT some days gets changed to not be a power of two), and results in the exact same machine code, thanks to compiler optimizations.
1 parent 2c22f5d commit d6eaab1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4459,7 +4459,7 @@ static int zend_jit_setup_hot_counters(zend_op_array *op_array)
44594459
}
44604460
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
44614461
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_HOT_COUNTERS;
4462-
jit_extension->counter = &zend_jit_hot_counters[zend_jit_op_array_hash(op_array) & (ZEND_HOT_COUNTERS_COUNT - 1)];
4462+
jit_extension->counter = &zend_jit_hot_counters[zend_jit_op_array_hash(op_array) % ZEND_HOT_COUNTERS_COUNT];
44634463
for (i = 0; i < op_array->last; i++) {
44644464
jit_extension->orig_handlers[i] = op_array->opcodes[i].handler;
44654465
}

0 commit comments

Comments
 (0)