Skip to content

Commit bbe2191

Browse files
authored
ROR the callable_convert_cache key for better hash distribution (#20052)
1 parent f9678e7 commit bbe2191

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Zend/zend_vm_def.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9720,7 +9720,11 @@ ZEND_VM_HANDLER(202, ZEND_CALLABLE_CONVERT, UNUSED, UNUSED, NUM|CACHE_SLOT)
97209720
if (closure) {
97219721
ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure);
97229722
} else {
9723-
zval *closure_zv = zend_hash_index_lookup(&EG(callable_convert_cache), (zend_ulong)(uintptr_t)call->func);
9723+
/* Rotate the key for better hash distribution. */
9724+
const int shift = sizeof(size_t) == 4 ? 6 : 7;
9725+
zend_ulong key = (zend_ulong)(uintptr_t)call->func;
9726+
key = (key >> shift) | (key << ((sizeof(key) * 8) - shift));
9727+
zval *closure_zv = zend_hash_index_lookup(&EG(callable_convert_cache), key);
97249728
if (Z_TYPE_P(closure_zv) == IS_NULL) {
97259729
zend_closure_from_frame(closure_zv, call);
97269730
}

Zend/zend_vm_execute.h

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)