Optimize zend_hash_real_init()

This commit is contained in:
Dmitry Stogov 2018-03-23 00:13:45 +03:00
parent 8598240c69
commit a795bd8265
13 changed files with 102 additions and 84 deletions

View File

@ -475,7 +475,7 @@ ZEND_FUNCTION(func_get_args)
if (arg_count) {
array_init_size(return_value, arg_count);
first_extra_arg = ex->func->op_array.num_args;
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
i = 0;
p = ZEND_CALL_ARG(ex, 1);
@ -644,7 +644,7 @@ ZEND_FUNCTION(each)
break;
}
array_init_size(return_value, 4);
zend_hash_real_init(Z_ARRVAL_P(return_value), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(return_value));
/* add value elements */
ZVAL_DEREF(entry);
@ -2121,7 +2121,7 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) /
zval *p = ZEND_CALL_ARG(call, 1);
array_init_size(arg_array, num_args);
zend_hash_real_init(Z_ARRVAL_P(arg_array), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(arg_array));
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(arg_array)) {
if (call->func->type == ZEND_USER_FUNCTION) {
uint32_t first_extra_arg = MIN(num_args, call->func->op_array.num_args);

View File

@ -1505,7 +1505,7 @@ ZEND_API zend_array *zend_rebuild_symbol_table(void) /* {{{ */
if (!ex->func->op_array.last_var) {
return symbol_table;
}
zend_hash_real_init(symbol_table, 0);
zend_hash_real_init_mixed(symbol_table);
/*printf("Cache miss! Initialized %x\n", EG(active_symbol_table));*/
}
if (EXPECTED(ex->func->op_array.last_var)) {

View File

@ -114,46 +114,45 @@ static zend_always_inline uint32_t zend_hash_check_size(uint32_t nSize)
#endif
}
static zend_always_inline void zend_hash_real_init_packed_ex(HashTable *ht)
{
HT_SET_DATA_ADDR(ht, pemalloc(HT_SIZE(ht), GC_FLAGS(ht) & IS_ARRAY_PERSISTENT));
HT_FLAGS(ht) |= HASH_FLAG_INITIALIZED | HASH_FLAG_PACKED;
HT_HASH_RESET_PACKED(ht);
}
static zend_always_inline void zend_hash_real_init_mixed_ex(HashTable *ht)
{
(ht)->nTableMask = -(ht)->nTableSize;
HT_SET_DATA_ADDR(ht, pemalloc(HT_SIZE(ht), GC_FLAGS(ht) & IS_ARRAY_PERSISTENT));
HT_FLAGS(ht) |= HASH_FLAG_INITIALIZED;
if (EXPECTED(ht->nTableMask == (uint32_t)-8)) {
Bucket *arData = ht->arData;
HT_HASH_EX(arData, -8) = -1;
HT_HASH_EX(arData, -7) = -1;
HT_HASH_EX(arData, -6) = -1;
HT_HASH_EX(arData, -5) = -1;
HT_HASH_EX(arData, -4) = -1;
HT_HASH_EX(arData, -3) = -1;
HT_HASH_EX(arData, -2) = -1;
HT_HASH_EX(arData, -1) = -1;
} else {
HT_HASH_RESET(ht);
}
}
static zend_always_inline void zend_hash_real_init_ex(HashTable *ht, int packed)
{
HT_ASSERT_RC1(ht);
ZEND_ASSERT(!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED));
if (packed) {
HT_SET_DATA_ADDR(ht, pemalloc(HT_SIZE(ht), GC_FLAGS(ht) & IS_ARRAY_PERSISTENT));
HT_FLAGS(ht) |= HASH_FLAG_INITIALIZED | HASH_FLAG_PACKED;
HT_HASH_RESET_PACKED(ht);
zend_hash_real_init_packed_ex(ht);
} else {
(ht)->nTableMask = -(ht)->nTableSize;
HT_SET_DATA_ADDR(ht, pemalloc(HT_SIZE(ht), GC_FLAGS(ht) & IS_ARRAY_PERSISTENT));
HT_FLAGS(ht) |= HASH_FLAG_INITIALIZED;
if (EXPECTED(ht->nTableMask == (uint32_t)-8)) {
Bucket *arData = ht->arData;
HT_HASH_EX(arData, -8) = -1;
HT_HASH_EX(arData, -7) = -1;
HT_HASH_EX(arData, -6) = -1;
HT_HASH_EX(arData, -5) = -1;
HT_HASH_EX(arData, -4) = -1;
HT_HASH_EX(arData, -3) = -1;
HT_HASH_EX(arData, -2) = -1;
HT_HASH_EX(arData, -1) = -1;
} else {
HT_HASH_RESET(ht);
}
zend_hash_real_init_mixed_ex(ht);
}
}
static zend_always_inline void zend_hash_check_init(HashTable *ht, int packed)
{
HT_ASSERT_RC1(ht);
if (UNEXPECTED(!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED))) {
zend_hash_real_init_ex(ht, packed);
}
}
#define CHECK_INIT(ht, packed) \
zend_hash_check_init(ht, packed)
static const uint32_t uninitialized_bucket[-HT_MIN_MASK] =
{HT_INVALID_IDX, HT_INVALID_IDX};
@ -216,6 +215,22 @@ ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, zend_bool packed)
zend_hash_real_init_ex(ht, packed);
}
ZEND_API void ZEND_FASTCALL zend_hash_real_init_packed(HashTable *ht)
{
IS_CONSISTENT(ht);
HT_ASSERT_RC1(ht);
zend_hash_real_init_packed_ex(ht);
}
ZEND_API void ZEND_FASTCALL zend_hash_real_init_mixed(HashTable *ht)
{
IS_CONSISTENT(ht);
HT_ASSERT_RC1(ht);
zend_hash_real_init_mixed_ex(ht);
}
ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht)
{
void *new_data, *old_data = HT_GET_DATA_ADDR(ht);
@ -254,7 +269,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, zend
if (nSize > ht->nTableSize) {
ht->nTableSize = zend_hash_check_size(nSize);
}
zend_hash_check_init(ht, packed);
zend_hash_real_init(ht, packed);
} else {
if (packed) {
ZEND_ASSERT(HT_FLAGS(ht) & HASH_FLAG_PACKED);
@ -582,7 +597,7 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s
HT_ASSERT_RC1(ht);
if (UNEXPECTED(!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED))) {
CHECK_INIT(ht, 0);
zend_hash_real_init_mixed(ht);
if (!ZSTR_IS_INTERNED(key)) {
zend_string_addref(key);
HT_FLAGS(ht) &= ~HASH_FLAG_STATIC_KEYS;
@ -667,7 +682,7 @@ static zend_always_inline zval *_zend_hash_str_add_or_update_i(HashTable *ht, co
HT_ASSERT_RC1(ht);
if (UNEXPECTED(!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED))) {
CHECK_INIT(ht, 0);
zend_hash_real_init_mixed(ht);
goto add_to_hash;
} else if (HT_FLAGS(ht) & HASH_FLAG_PACKED) {
zend_hash_packed_to_hash(ht);
@ -817,11 +832,12 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht,
HT_ASSERT_RC1(ht);
if (UNEXPECTED(!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED))) {
CHECK_INIT(ht, h < ht->nTableSize);
if (h < ht->nTableSize) {
zend_hash_real_init_packed_ex(ht);
p = ht->arData + h;
goto add_to_packed;
}
zend_hash_real_init_mixed(ht);
goto add_to_hash;
} else if (HT_FLAGS(ht) & HASH_FLAG_PACKED) {
if (h < ht->nNumUsed) {

View File

@ -99,6 +99,8 @@ ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht);
_zend_hash_init((ht), (nSize), (pDestructor), (persistent))
ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, zend_bool packed);
ZEND_API void ZEND_FASTCALL zend_hash_real_init_packed(HashTable *ht);
ZEND_API void ZEND_FASTCALL zend_hash_real_init_mixed(HashTable *ht);
ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht);
ZEND_API void ZEND_FASTCALL zend_hash_to_packed(HashTable *ht);
ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, zend_bool packed);

View File

@ -68,7 +68,7 @@ ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */
zobj->properties = zend_new_array(ce->default_properties_count);
if (ce->default_properties_count) {
zend_hash_real_init(zobj->properties, 0);
zend_hash_real_init_mixed(zobj->properties);
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) {
if (/*prop_info->ce == ce &&*/
(prop_info->flags & ZEND_ACC_STATIC) == 0) {

View File

@ -196,7 +196,7 @@ ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object,
if (!new_object->properties) {
new_object->properties = zend_new_array(zend_hash_num_elements(old_object->properties));
zend_hash_real_init(new_object->properties, 0);
zend_hash_real_init_mixed(new_object->properties);
} else {
zend_hash_extend(new_object->properties, new_object->properties->nNumUsed + zend_hash_num_elements(old_object->properties), 0);
}

View File

@ -69,7 +69,7 @@ ZEND_KNOWN_STRINGS(_ZEND_STR_DSC)
static void zend_init_interned_strings_ht(HashTable *interned_strings, int permanent)
{
zend_hash_init(interned_strings, 1024, NULL, _str_dtor, permanent);
zend_hash_real_init(interned_strings, 0);
zend_hash_real_init_mixed(interned_strings);
}
ZEND_API void zend_interned_strings_init(void)

View File

@ -4763,7 +4763,7 @@ ZEND_VM_HANDLER(164, ZEND_RECV_VARIADIC, NUM, UNUSED|CACHE_SLOT)
zval *param;
array_init_size(params, arg_count - arg_num + 1);
zend_hash_real_init(Z_ARRVAL_P(params), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(params));
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(params)) {
param = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T);
if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
@ -5233,7 +5233,7 @@ ZEND_VM_HANDLER(71, ZEND_INIT_ARRAY, CONST|TMP|VAR|CV, CONST|TMPVAR|UNUSED|NEXT|
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_DISPATCH_TO_HANDLER(ZEND_ADD_ARRAY_ELEMENT);
} else {
@ -7730,7 +7730,7 @@ ZEND_VM_HANDLER(158, ZEND_CALL_TRAMPOLINE, ANY, ANY)
zval *end = p + num_args;
args = zend_new_array(num_args);
zend_hash_real_init(args, 1);
zend_hash_real_init_packed(args);
ZEND_HASH_FILL_PACKED(args) {
do {
ZEND_HASH_FILL_ADD(p);
@ -8247,7 +8247,7 @@ ZEND_VM_HANDLER(195, ZEND_FUNC_GET_ARGS, UNUSED|CONST, UNUSED)
ht = zend_new_array(result_size);
ZVAL_ARR(EX_VAR(opline->result.var), ht);
zend_hash_real_init(ht, 1);
zend_hash_real_init_packed(ht);
ZEND_HASH_FILL_PACKED(ht) {
zval *p, *q;
uint32_t i = skip;

View File

@ -1946,7 +1946,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CALL_TRAMPOLINE_SPEC_HANDLER(Z
zval *end = p + num_args;
args = zend_new_array(num_args);
zend_hash_real_init(args, 1);
zend_hash_real_init_packed(args);
ZEND_HASH_FILL_PACKED(args) {
do {
ZEND_HASH_FILL_ADD(p);
@ -2423,7 +2423,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RECV_VARIADIC_SPEC_UNUSED_HAND
zval *param;
array_init_size(params, arg_count - arg_num + 1);
zend_hash_real_init(Z_ARRVAL_P(params), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(params));
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(params)) {
param = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T);
if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
@ -5645,7 +5645,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_CONST_HA
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -7663,7 +7663,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_TMPVAR_H
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_TMPVAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -8991,7 +8991,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_UNUSED_H
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -9486,7 +9486,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FUNC_GET_ARGS_SPEC_CONST_UNUSE
ht = zend_new_array(result_size);
ZVAL_ARR(EX_VAR(opline->result.var), ht);
zend_hash_real_init(ht, 1);
zend_hash_real_init_packed(ht);
ZEND_HASH_FILL_PACKED(ht) {
zval *p, *q;
uint32_t i = skip;
@ -10771,7 +10771,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_CV_HANDL
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -18947,7 +18947,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_CONST_HAND
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -19361,7 +19361,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_TMPVAR_HAN
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMPVAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -19851,7 +19851,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_UNUSED_HAN
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -20321,7 +20321,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_CV_HANDLER
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -24203,7 +24203,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_CONST_HAND
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -26348,7 +26348,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_TMPVAR_HAN
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMPVAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -27934,7 +27934,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_UNUSED_HAN
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -30158,7 +30158,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_CV_HANDLER
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -34781,7 +34781,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FUNC_GET_ARGS_SPEC_UNUSED_UNUS
ht = zend_new_array(result_size);
ZVAL_ARR(EX_VAR(opline->result.var), ht);
zend_hash_real_init(ht, 1);
zend_hash_real_init_packed(ht);
ZEND_HASH_FILL_PACKED(ht) {
zval *p, *q;
uint32_t i = skip;
@ -41225,7 +41225,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_CONST_HANDL
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -44843,7 +44843,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_TMPVAR_HAND
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMPVAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -46927,7 +46927,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_UNUSED_HAND
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {
@ -50500,7 +50500,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_CV_HANDLER(
ZVAL_ARR(array, zend_new_array(size));
/* Explicitly initialize array as not-packed if flag is set */
if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(array), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(array));
}
ZEND_VM_TAIL_CALL(ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
} else {

View File

@ -2681,7 +2681,7 @@ PHP_FUNCTION(array_fill)
zend_long n;
array_init_size(return_value, (uint32_t)(start_key + num));
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
Z_ARRVAL_P(return_value)->nNumUsed = (uint32_t)(start_key + num);
Z_ARRVAL_P(return_value)->nNumOfElements = (uint32_t)num;
Z_ARRVAL_P(return_value)->nNextFreeElement = (zend_long)(start_key + num);
@ -2706,7 +2706,7 @@ PHP_FUNCTION(array_fill)
} else {
/* create hash */
array_init_size(return_value, (uint32_t)num);
zend_hash_real_init(Z_ARRVAL_P(return_value), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(return_value));
if (Z_REFCOUNTED_P(val)) {
GC_ADDREF_EX(Z_COUNTED_P(val), (uint32_t)num);
}
@ -2763,7 +2763,7 @@ PHP_FUNCTION(array_fill_keys)
} \
size = (uint32_t)_php_math_round(__calc_size, 0, PHP_ROUND_HALF_UP); \
array_init_size(return_value, size); \
zend_hash_real_init(Z_ARRVAL_P(return_value), 1); \
zend_hash_real_init_packed(Z_ARRVAL_P(return_value)); \
} while (0)
#define RANGE_CHECK_LONG_INIT_ARRAY(start, end) do { \
@ -2774,7 +2774,7 @@ PHP_FUNCTION(array_fill_keys)
} \
size = (uint32_t)(__calc_size + 1); \
array_init_size(return_value, size); \
zend_hash_real_init(Z_ARRVAL_P(return_value), 1); \
zend_hash_real_init_packed(Z_ARRVAL_P(return_value)); \
} while (0)
/* {{{ proto array range(mixed low, mixed high[, int step])
@ -2832,7 +2832,7 @@ PHP_FUNCTION(range)
}
/* Initialize the return_value as an array. */
array_init_size(return_value, (uint32_t)(((low - high) / lstep) + 1));
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
for (; low >= high; low -= (unsigned int)lstep) {
ZVAL_INTERNED_STR(&tmp, ZSTR_CHAR(low));
@ -2848,7 +2848,7 @@ PHP_FUNCTION(range)
goto err;
}
array_init_size(return_value, (uint32_t)(((high - low) / lstep) + 1));
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
for (; low <= high; low += (unsigned int)lstep) {
ZVAL_INTERNED_STR(&tmp, ZSTR_CHAR(low));
@ -3582,7 +3582,7 @@ PHP_FUNCTION(array_slice)
if (HT_IS_PACKED(Z_ARRVAL_P(input)) &&
(!preserve_keys ||
(offset == 0 && HT_IS_WITHOUT_HOLES(Z_ARRVAL_P(input))))) {
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(input), entry) {
pos++;
@ -3860,7 +3860,7 @@ static inline void php_array_merge_or_replace_wrapper(INTERNAL_FUNCTION_PARAMETE
array_init_size(return_value, count);
dest = Z_ARRVAL_P(return_value);
if (HT_FLAGS(src) & HASH_FLAG_PACKED) {
zend_hash_real_init(dest, 1);
zend_hash_real_init_packed(dest);
ZEND_HASH_FILL_PACKED(dest) {
ZEND_HASH_FOREACH_VAL(src, src_entry) {
if (UNEXPECTED(Z_ISREF_P(src_entry) &&
@ -3873,7 +3873,7 @@ static inline void php_array_merge_or_replace_wrapper(INTERNAL_FUNCTION_PARAMETE
} ZEND_HASH_FILL_END();
} else {
zend_string *string_key;
zend_hash_real_init(dest, 0);
zend_hash_real_init_mixed(dest);
ZEND_HASH_FOREACH_STR_KEY_VAL(src, string_key, src_entry) {
if (UNEXPECTED(Z_ISREF_P(src_entry) &&
Z_REFCOUNT_P(src_entry) == 1)) {
@ -3992,7 +3992,7 @@ PHP_FUNCTION(array_keys)
}
} else {
array_init_size(return_value, elem_count);
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
if (HT_IS_PACKED(arrval) && HT_IS_WITHOUT_HOLES(arrval)) {
/* Optimistic case: range(0..n-1) for vector-like packed array */
@ -4046,7 +4046,7 @@ PHP_FUNCTION(array_values)
/* Initialize return array */
array_init_size(return_value, zend_hash_num_elements(arrval));
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
/* Go through input array and add values to the return array */
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
@ -4185,7 +4185,7 @@ PHP_FUNCTION(array_column)
array_init_size(return_value, zend_hash_num_elements(arr_hash));
if (!zkey) {
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
ZEND_HASH_FOREACH_VAL(arr_hash, data) {
ZVAL_DEREF(data);
@ -4262,7 +4262,7 @@ PHP_FUNCTION(array_reverse)
/* Initialize return array */
array_init_size(return_value, zend_hash_num_elements(Z_ARRVAL_P(input)));
if ((HT_FLAGS(Z_ARRVAL_P(input)) & HASH_FLAG_PACKED) && !preserve_keys) {
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
ZEND_HASH_REVERSE_FOREACH_VAL(Z_ARRVAL_P(input), entry) {
if (UNEXPECTED(Z_ISREF_P(entry) &&
@ -4331,7 +4331,7 @@ PHP_FUNCTION(array_pad)
array_init_size(return_value, pad_size_abs);
if (HT_FLAGS(Z_ARRVAL_P(input)) & HASH_FLAG_PACKED) {
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
if (pad_size < 0) {
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
@ -5859,7 +5859,7 @@ PHP_FUNCTION(array_rand)
}
/* i = 0; */
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
zval zv;
/* We can't use zend_hash_index_find()

View File

@ -180,7 +180,7 @@ PHP_FUNCTION(hrtime)
PHP_RETURN_HRTIME(t);
} else {
array_init_size(return_value, 2);
zend_hash_real_init(Z_ARRVAL_P(return_value), 1);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
add_next_index_long(return_value, (zend_long)(t / (php_hrtime_t)NANO_IN_SEC));
add_next_index_long(return_value, (zend_long)(t % (php_hrtime_t)NANO_IN_SEC));
}

View File

@ -1376,7 +1376,7 @@ yy82:
array_init_size(rval, elements);
/* we can't convert from packed to hash during unserialization, because
reference to some zvals might be keept in var_hash (to support references) */
zend_hash_real_init(Z_ARRVAL_P(rval), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(rval));
} else {
ZVAL_EMPTY_ARRAY(rval);
return finish_nested_data(UNSERIALIZE_PASSTHRU);

View File

@ -880,7 +880,7 @@ use_double:
array_init_size(rval, elements);
/* we can't convert from packed to hash during unserialization, because
reference to some zvals might be keept in var_hash (to support references) */
zend_hash_real_init(Z_ARRVAL_P(rval), 0);
zend_hash_real_init_mixed(Z_ARRVAL_P(rval));
} else {
ZVAL_EMPTY_ARRAY(rval);
return finish_nested_data(UNSERIALIZE_PASSTHRU);