1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ROR the callable_convert_cache key for better hash distribution (#20052)

This commit is contained in:
Niels Dossche
2025-10-15 21:58:23 +02:00
committed by GitHub
parent f9678e7b90
commit bbe2191002
2 changed files with 15 additions and 3 deletions

View File

@@ -9720,7 +9720,11 @@ ZEND_VM_HANDLER(202, ZEND_CALLABLE_CONVERT, UNUSED, UNUSED, NUM|CACHE_SLOT)
if (closure) {
ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure);
} else {
zval *closure_zv = zend_hash_index_lookup(&EG(callable_convert_cache), (zend_ulong)(uintptr_t)call->func);
/* Rotate the key for better hash distribution. */
const int shift = sizeof(size_t) == 4 ? 6 : 7;
zend_ulong key = (zend_ulong)(uintptr_t)call->func;
key = (key >> shift) | (key << ((sizeof(key) * 8) - shift));
zval *closure_zv = zend_hash_index_lookup(&EG(callable_convert_cache), key);
if (Z_TYPE_P(closure_zv) == IS_NULL) {
zend_closure_from_frame(closure_zv, call);
}

12
Zend/zend_vm_execute.h generated
View File

@@ -39093,7 +39093,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_CALLABLE_CONV
if (closure) {
ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure);
} else {
zval *closure_zv = zend_hash_index_lookup(&EG(callable_convert_cache), (zend_ulong)(uintptr_t)call->func);
/* Rotate the key for better hash distribution. */
const int shift = sizeof(size_t) == 4 ? 6 : 7;
zend_ulong key = (zend_ulong)(uintptr_t)call->func;
key = (key >> shift) | (key << ((sizeof(key) * 8) - shift));
zval *closure_zv = zend_hash_index_lookup(&EG(callable_convert_cache), key);
if (Z_TYPE_P(closure_zv) == IS_NULL) {
zend_closure_from_frame(closure_zv, call);
}
@@ -94331,7 +94335,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_CALLABLE_CONVERT_S
if (closure) {
ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure);
} else {
zval *closure_zv = zend_hash_index_lookup(&EG(callable_convert_cache), (zend_ulong)(uintptr_t)call->func);
/* Rotate the key for better hash distribution. */
const int shift = sizeof(size_t) == 4 ? 6 : 7;
zend_ulong key = (zend_ulong)(uintptr_t)call->func;
key = (key >> shift) | (key << ((sizeof(key) * 8) - shift));
zval *closure_zv = zend_hash_index_lookup(&EG(callable_convert_cache), key);
if (Z_TYPE_P(closure_zv) == IS_NULL) {
zend_closure_from_frame(closure_zv, call);
}