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:
@@ -9720,7 +9720,11 @@ ZEND_VM_HANDLER(202, ZEND_CALLABLE_CONVERT, UNUSED, UNUSED, NUM|CACHE_SLOT)
|
|||||||
if (closure) {
|
if (closure) {
|
||||||
ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure);
|
ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure);
|
||||||
} else {
|
} 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) {
|
if (Z_TYPE_P(closure_zv) == IS_NULL) {
|
||||||
zend_closure_from_frame(closure_zv, call);
|
zend_closure_from_frame(closure_zv, call);
|
||||||
}
|
}
|
||||||
|
|||||||
12
Zend/zend_vm_execute.h
generated
12
Zend/zend_vm_execute.h
generated
@@ -39093,7 +39093,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_CALLABLE_CONV
|
|||||||
if (closure) {
|
if (closure) {
|
||||||
ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure);
|
ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure);
|
||||||
} else {
|
} 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) {
|
if (Z_TYPE_P(closure_zv) == IS_NULL) {
|
||||||
zend_closure_from_frame(closure_zv, call);
|
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) {
|
if (closure) {
|
||||||
ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure);
|
ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure);
|
||||||
} else {
|
} 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) {
|
if (Z_TYPE_P(closure_zv) == IS_NULL) {
|
||||||
zend_closure_from_frame(closure_zv, call);
|
zend_closure_from_frame(closure_zv, call);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user