Skip to content

Commit 3db2dd5

Browse files
committed
another test
1 parent b5f4f40 commit 3db2dd5

File tree

4 files changed

+48
-21
lines changed

4 files changed

+48
-21
lines changed

Zend/zend_API.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,26 +1608,30 @@ static zend_always_inline void _object_properties_init(zend_object *object, zend
16081608
zval *src = CE_DEFAULT_PROPERTIES_TABLE(class_type);
16091609
zval *dst = object->properties_table;
16101610

1611-
if (!(class_type->ce_flags & ZEND_ACC_HAS_RC_PROPS)) {
1611+
if (false && !(class_type->ce_flags & ZEND_ACC_HAS_RC_PROPS)) {//TODO: disabled; also actually this may replace the internal class thing?
16121612
// printf("fast path %s\n", class_type->name->val);
1613-
// memcpy(dst, src, sizeof(zval) * class_type->default_properties_count);
1614-
zval *end = src + class_type->default_properties_count;
1615-
do {
1616-
ZVAL_COPY_VALUE_PROP(dst, src);
1617-
src++;
1618-
dst++;
1619-
} while (src != end);
1613+
memcpy(dst, src, sizeof(zval) * class_type->default_properties_count);
1614+
// zval *end = src + class_type->default_properties_count;
1615+
// do {
1616+
// ZVAL_COPY_VALUE_PROP(dst, src);
1617+
// src++;
1618+
// dst++;
1619+
// } while (src != end);
16201620
} else {
16211621
// printf("slow path %s\n", class_type->name->val);
1622-
zval *end = src + class_type->default_properties_count;
1622+
// zval *end = src + class_type->default_properties_count;
16231623

16241624
if (UNEXPECTED(class_type->type == ZEND_INTERNAL_CLASS)) {
1625-
do {
1626-
ZVAL_COPY_OR_DUP_PROP(dst, src);
1627-
src++;
1628-
dst++;
1629-
} while (src != end);
1625+
// do {
1626+
// ZVAL_COPY_OR_DUP_PROP(dst, src);
1627+
// src++;
1628+
// dst++;
1629+
// } while (src != end);
1630+
// TODO: assertion?
1631+
/* zend_declare_typed_property() disallows refcounted default property values in internal classes */
1632+
memcpy(dst, src, sizeof(zval) * class_type->default_properties_count);
16301633
} else {
1634+
zval *end = src + class_type->default_properties_count;
16311635
do {
16321636
ZVAL_COPY_PROP(dst, src);
16331637
src++;

Zend/zend_operators.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,6 +2372,28 @@ static int hash_zval_identical_function(zval *z1, zval *z2) /* {{{ */
23722372
}
23732373
/* }}} */
23742374

2375+
ZEND_API bool ZEND_FASTCALL zend_is_identical2(const zval *op1, const zval *op2)
2376+
{
2377+
switch (Z_TYPE_P(op1)) {
2378+
case IS_LONG:
2379+
return (Z_LVAL_P(op1) == Z_LVAL_P(op2));
2380+
case IS_RESOURCE:
2381+
return (Z_RES_P(op1) == Z_RES_P(op2));
2382+
case IS_DOUBLE:
2383+
return (Z_DVAL_P(op1) == Z_DVAL_P(op2));
2384+
case IS_STRING:
2385+
return zend_string_equals(Z_STR_P(op1), Z_STR_P(op2));
2386+
case IS_ARRAY:
2387+
return (Z_ARRVAL_P(op1) == Z_ARRVAL_P(op2) ||
2388+
zend_hash_compare(Z_ARRVAL_P(op1), Z_ARRVAL_P(op2), (compare_func_t) hash_zval_identical_function, 1) == 0);
2389+
case IS_OBJECT:
2390+
return (Z_OBJ_P(op1) == Z_OBJ_P(op2));
2391+
default:
2392+
return 0;
2393+
}
2394+
}
2395+
2396+
// TODO: use zend_is_identical2 ?
23752397
ZEND_API bool ZEND_FASTCALL zend_is_identical(const zval *op1, const zval *op2) /* {{{ */
23762398
{
23772399
if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) {

Zend/zend_operators.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ ZEND_API zend_result ZEND_FASTCALL shift_right_function(zval *result, zval *op1,
5656
ZEND_API zend_result ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2);
5757

5858
ZEND_API bool ZEND_FASTCALL zend_is_identical(const zval *op1, const zval *op2);
59+
ZEND_API bool ZEND_FASTCALL zend_is_identical2(const zval *op1, const zval *op2);
5960

6061
ZEND_API zend_result ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2);
6162
ZEND_API zend_result ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2);
@@ -856,7 +857,7 @@ static zend_always_inline bool fast_is_identical_function(zval *op1, zval *op2)
856857
} else if (Z_TYPE_P(op1) <= IS_TRUE) {
857858
return 1;
858859
}
859-
return zend_is_identical(op1, op2);
860+
return zend_is_identical2(op1, op2);
860861
}
861862

862863
static zend_always_inline bool fast_is_not_identical_function(zval *op1, zval *op2)
@@ -866,7 +867,7 @@ static zend_always_inline bool fast_is_not_identical_function(zval *op1, zval *o
866867
} else if (Z_TYPE_P(op1) <= IS_TRUE) {
867868
return 0;
868869
}
869-
return !zend_is_identical(op1, op2);
870+
return !zend_is_identical2(op1, op2);
870871
}
871872

872873
/* buf points to the END of the buffer */

ext/standard/array.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6470,14 +6470,14 @@ PHP_FUNCTION(array_map)
64706470
array_init_size(return_value, maxlen);
64716471
zend_hash_real_init(Z_ARRVAL_P(return_value), HT_IS_PACKED(Z_ARRVAL(arrays[0])));
64726472

6473-
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL(arrays[0]), num_key, str_key, zv) {
6474-
fci.retval = &result;
6475-
fci.param_count = 1;
6476-
fci.params = &arg;
6473+
fci.retval = &result;
6474+
fci.param_count = 1;
6475+
fci.params = &arg;
64776476

6477+
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL(arrays[0]), num_key, str_key, zv) {
64786478
ZVAL_COPY(&arg, zv);
64796479
ret = zend_call_function(&fci, &fci_cache);
6480-
i_zval_ptr_dtor(&arg);
6480+
Z_TRY_DELREF(arg); /* hash table still holds a reference, no dtor check is necessary */
64816481
if (ret != SUCCESS || Z_TYPE(result) == IS_UNDEF) {
64826482
zend_array_destroy(Z_ARR_P(return_value));
64836483
RETURN_NULL();

0 commit comments

Comments
 (0)