diff options
author | Dmitry Stogov <dmitry@zend.com> | 2019-01-31 18:47:58 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2019-02-04 13:20:25 +0300 |
commit | 91ef4124e56a8ec52078bdcb5547ea5dbf654566 (patch) | |
tree | 14285f0ab29d8274b8aeb7003ca7d0c77bbd604f | |
parent | 0476d558272c18778f95c0368e18108771a63d99 (diff) | |
download | php-git-91ef4124e56a8ec52078bdcb5547ea5dbf654566.tar.gz |
Refactor zend_object_handlers API to pass zend_object* and zend_string* insted of zval(s).
67 files changed, 2686 insertions, 1614 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index ac8e7db31c..b51d6bd408 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -504,20 +504,22 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest convert_to_string(arg); *dest = Z_STR_P(arg); } else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) { + zend_object *zobj = Z_OBJ_P(arg); + if (Z_OBJ_HANDLER_P(arg, cast_object)) { zval obj; - if (Z_OBJ_HANDLER_P(arg, cast_object)(arg, &obj, IS_STRING) == SUCCESS) { - zval_ptr_dtor(arg); + if (zobj->handlers->cast_object(zobj, &obj, IS_STRING) == SUCCESS) { + OBJ_RELEASE(zobj); ZVAL_COPY_VALUE(arg, &obj); *dest = Z_STR_P(arg); return 1; } - } else if (Z_OBJ_HANDLER_P(arg, get)) { + } else if (zobj->handlers->get) { zval rv; - zval *z = Z_OBJ_HANDLER_P(arg, get)(arg, &rv); + zval *z = zobj->handlers->get(zobj, &rv); if (Z_TYPE_P(z) != IS_OBJECT) { - zval_ptr_dtor(arg); + OBJ_RELEASE(zobj); if (Z_TYPE_P(z) == IS_STRING) { ZVAL_COPY_VALUE(arg, z); } else { @@ -1101,7 +1103,8 @@ ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args, zval *this * because it may call __set from the uninitialized object otherwise. */ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */ { - const zend_object_handlers *obj_ht = Z_OBJ_HT_P(obj); + zend_object *zobj = Z_OBJ_P(obj); + zend_object_write_property_t write_property = zobj->handlers->write_property; zend_class_entry *old_scope = EG(fake_scope); zend_string *key; zval *value; @@ -1109,10 +1112,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */ EG(fake_scope) = Z_OBJCE_P(obj); ZEND_HASH_FOREACH_STR_KEY_VAL(properties, key, value) { if (key) { - zval member; - - ZVAL_STR(&member, key); - obj_ht->write_property(obj, &member, value, NULL); + write_property(zobj, key, value, NULL); } } ZEND_HASH_FOREACH_END(); EG(fake_scope) = old_scope; @@ -1728,11 +1728,11 @@ ZEND_API int add_property_stringl_ex(zval *arg, const char *key, size_t key_len, ZEND_API int add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value) /* {{{ */ { - zval z_key; + zend_string *str; - ZVAL_STRINGL(&z_key, key, key_len); - Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, value, NULL); - zval_ptr_dtor(&z_key); + str = zend_string_init(key, key_len, 0); + Z_OBJ_HANDLER_P(arg, write_property)(Z_OBJ_P(arg), str, value, NULL); + zend_string_release_ex(str, 0); return SUCCESS; } /* }}} */ @@ -3143,16 +3143,18 @@ try_again: zend_class_entry *calling_scope; zend_function *fptr; zend_object *object; - if (Z_OBJ_HANDLER_P(callable, get_closure) - && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &calling_scope, &fptr, &object) == SUCCESS) { - zend_class_entry *ce = Z_OBJCE_P(callable); + zend_object *zobj = Z_OBJ_P(callable); + + if (zobj->handlers->get_closure + && zobj->handlers->get_closure(zobj, &calling_scope, &fptr, &object) == SUCCESS) { + zend_class_entry *ce = zobj->ce; zend_string *callable_name = zend_string_alloc( ZSTR_LEN(ce->name) + sizeof("::__invoke") - 1, 0); memcpy(ZSTR_VAL(callable_name), ZSTR_VAL(ce->name), ZSTR_LEN(ce->name)); memcpy(ZSTR_VAL(callable_name) + ZSTR_LEN(ce->name), "::__invoke", sizeof("::__invoke")); return callable_name; } - return zval_get_string(callable); + return zval_get_string_func(callable); } case IS_REFERENCE: callable = Z_REFVAL_P(callable); @@ -3277,7 +3279,7 @@ check_func: } return 0; case IS_OBJECT: - if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &fcc->calling_scope, &fcc->function_handler, &fcc->object) == SUCCESS) { + if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(Z_OBJ_P(callable), &fcc->calling_scope, &fcc->function_handler, &fcc->object) == SUCCESS) { fcc->called_scope = fcc->calling_scope; return 1; } @@ -3944,13 +3946,11 @@ ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, const char ZEND_API void zend_update_property_ex(zend_class_entry *scope, zval *object, zend_string *name, zval *value) /* {{{ */ { - zval property; zend_class_entry *old_scope = EG(fake_scope); EG(fake_scope) = scope; - ZVAL_STR(&property, name); - Z_OBJ_HT_P(object)->write_property(object, &property, value, NULL); + Z_OBJ_HT_P(object)->write_property(Z_OBJ_P(object), name, value, NULL); EG(fake_scope) = old_scope; } @@ -3958,14 +3958,14 @@ ZEND_API void zend_update_property_ex(zend_class_entry *scope, zval *object, zen ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zval *value) /* {{{ */ { - zval property; + zend_string *property; zend_class_entry *old_scope = EG(fake_scope); EG(fake_scope) = scope; - ZVAL_STRINGL(&property, name, name_length); - Z_OBJ_HT_P(object)->write_property(object, &property, value, NULL); - zval_ptr_dtor(&property); + property = zend_string_init(name, name_length, 0); + Z_OBJ_HT_P(object)->write_property(Z_OBJ_P(object), property, value, NULL); + zend_string_release_ex(property, 0); EG(fake_scope) = old_scope; } @@ -3982,14 +3982,14 @@ ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, c ZEND_API void zend_unset_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length) /* {{{ */ { - zval property; + zend_string *property; zend_class_entry *old_scope = EG(fake_scope); EG(fake_scope) = scope; - ZVAL_STRINGL(&property, name, name_length); - Z_OBJ_HT_P(object)->unset_property(object, &property, 0); - zval_ptr_dtor(&property); + property = zend_string_init(name, name_length, 0); + Z_OBJ_HT_P(object)->unset_property(Z_OBJ_P(object), property, 0); + zend_string_release_ex(property, 0); EG(fake_scope) = old_scope; } @@ -4148,13 +4148,12 @@ ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zval *object, zend_string *name, zend_bool silent, zval *rv) /* {{{ */ { - zval property, *value; + zval *value; zend_class_entry *old_scope = EG(fake_scope); EG(fake_scope) = scope; - ZVAL_STR(&property, name); - value = Z_OBJ_HT_P(object)->read_property(object, &property, silent?BP_VAR_IS:BP_VAR_R, NULL, rv); + value = Z_OBJ_HT_P(object)->read_property(Z_OBJ_P(object), name, silent?BP_VAR_IS:BP_VAR_R, NULL, rv); EG(fake_scope) = old_scope; return value; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 83afe6e640..08e2228200 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -632,7 +632,7 @@ END_EXTERN_C() #define RETURN_FALSE { RETVAL_FALSE; return; } #define RETURN_TRUE { RETVAL_TRUE; return; } -#define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p)) : NULL))) +#define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties(Z_OBJ_P(p)) : NULL))) #define ZVAL_IS_NULL(z) (Z_TYPE_P(z) == IS_NULL) /* For compatibility */ @@ -1501,15 +1501,16 @@ static zend_always_inline int zend_parse_arg_array_ht(zval *arg, HashTable **des if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY)) { *dest = Z_ARRVAL_P(arg); } else if (or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) { + zend_object *zobj = Z_OBJ_P(arg); if (separate - && Z_OBJ_P(arg)->properties - && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(arg)->properties) > 1)) { - if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(arg)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_DELREF(Z_OBJ_P(arg)->properties); + && zobj->properties + && UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { + if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { + GC_DELREF(zobj->properties); } - Z_OBJ_P(arg)->properties = zend_array_dup(Z_OBJ_P(arg)->properties); + zobj->properties = zend_array_dup(zobj->properties); } - *dest = Z_OBJ_HT_P(arg)->get_properties(arg); + *dest = zobj->handlers->get_properties(zobj); } else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) { *dest = NULL; } else { diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 984522cd52..e9252a484f 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -811,11 +811,11 @@ repeat: if (Z_TYPE(val_free) == IS_UNDEF) { if (Z_OBJ_HT_P(val)->get) { zval rv; - val = Z_OBJ_HT_P(val)->get(val, &rv); + val = Z_OBJ_HT_P(val)->get(Z_OBJ_P(val), &rv); ZVAL_COPY_VALUE(&val_free, val); goto repeat; } else if (Z_OBJ_HT_P(val)->cast_object) { - if (Z_OBJ_HT_P(val)->cast_object(val, &val_free, IS_STRING) == SUCCESS) { + if (Z_OBJ_HT_P(val)->cast_object(Z_OBJ_P(val), &val_free, IS_STRING) == SUCCESS) { val = &val_free; break; } @@ -1097,13 +1097,12 @@ ZEND_FUNCTION(get_object_vars) Z_PARAM_OBJECT(obj) ZEND_PARSE_PARAMETERS_END(); - properties = Z_OBJ_HT_P(obj)->get_properties(obj); + zobj = Z_OBJ_P(obj); + properties = zobj->handlers->get_properties(zobj); if (properties == NULL) { RETURN_FALSE; } - zobj = Z_OBJ_P(obj); - if (!zobj->ce->default_properties_count && properties == zobj->properties && !GC_IS_RECURSIVE(properties)) { /* fast copy */ if (EXPECTED(zobj->handlers == &std_object_handlers)) { @@ -1292,7 +1291,6 @@ ZEND_FUNCTION(property_exists) zend_string *property; zend_class_entry *ce; zend_property_info *property_info; - zval property_z; if (zend_parse_parameters(ZEND_NUM_ARGS(), "zS", &object, &property) == FAILURE) { return; @@ -1321,10 +1319,8 @@ ZEND_FUNCTION(property_exists) RETURN_TRUE; } - ZVAL_STR(&property_z, property); - if (Z_TYPE_P(object) == IS_OBJECT && - Z_OBJ_HANDLER_P(object, has_property)(object, &property_z, 2, NULL)) { + Z_OBJ_HANDLER_P(object, has_property)(Z_OBJ_P(object), property, 2, NULL)) { RETURN_TRUE; } RETURN_FALSE; diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index c5d35db790..d5f29c0069 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -395,28 +395,28 @@ static zend_function *zend_closure_get_method(zend_object **object, zend_string } /* }}} */ -static zval *zend_closure_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */ +static zval *zend_closure_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv) /* {{{ */ { ZEND_CLOSURE_PROPERTY_ERROR(); return &EG(uninitialized_zval); } /* }}} */ -static zval *zend_closure_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */ +static zval *zend_closure_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot) /* {{{ */ { ZEND_CLOSURE_PROPERTY_ERROR(); return value; } /* }}} */ -static zval *zend_closure_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */ +static zval *zend_closure_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot) /* {{{ */ { ZEND_CLOSURE_PROPERTY_ERROR(); return NULL; } /* }}} */ -static int zend_closure_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) /* {{{ */ +static int zend_closure_has_property(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot) /* {{{ */ { if (has_set_exists != ZEND_PROPERTY_EXISTS) { ZEND_CLOSURE_PROPERTY_ERROR(); @@ -425,7 +425,7 @@ static int zend_closure_has_property(zval *object, zval *member, int has_set_exi } /* }}} */ -static void zend_closure_unset_property(zval *object, zval *member, void **cache_slot) /* {{{ */ +static void zend_closure_unset_property(zend_object *object, zend_string *member, void **cache_slot) /* {{{ */ { ZEND_CLOSURE_PROPERTY_ERROR(); } @@ -461,9 +461,9 @@ static zend_object *zend_closure_new(zend_class_entry *class_type) /* {{{ */ } /* }}} */ -static zend_object *zend_closure_clone(zval *zobject) /* {{{ */ +static zend_object *zend_closure_clone(zend_object *zobject) /* {{{ */ { - zend_closure *closure = (zend_closure *)Z_OBJ_P(zobject); + zend_closure *closure = (zend_closure *)zobject; zval result; zend_create_closure(&result, &closure->func, @@ -472,9 +472,9 @@ static zend_object *zend_closure_clone(zval *zobject) /* {{{ */ } /* }}} */ -int zend_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr) /* {{{ */ +int zend_closure_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr) /* {{{ */ { - zend_closure *closure = (zend_closure *)Z_OBJ_P(obj); + zend_closure *closure = (zend_closure *)obj; *fptr_ptr = &closure->func; *ce_ptr = closure->called_scope; @@ -488,9 +488,9 @@ int zend_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function } /* }}} */ -static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{ */ +static HashTable *zend_closure_get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { - zend_closure *closure = (zend_closure *)Z_OBJ_P(object); + zend_closure *closure = (zend_closure *)object; zval val; struct _zend_arg_info *arg_info = closure->func.common.arg_info; HashTable *debug_info; @@ -553,9 +553,9 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{ } /* }}} */ -static HashTable *zend_closure_get_gc(zval *obj, zval **table, int *n) /* {{{ */ +static HashTable *zend_closure_get_gc(zend_object *obj, zval **table, int *n) /* {{{ */ { - zend_closure *closure = (zend_closure *)Z_OBJ_P(obj); + zend_closure *closure = (zend_closure *)obj; *table = Z_TYPE(closure->this_ptr) != IS_NULL ? &closure->this_ptr : NULL; *n = Z_TYPE(closure->this_ptr) != IS_NULL ? 1 : 0; diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 8352348a53..2f59d91953 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -982,7 +982,7 @@ ZEND_API ZEND_COLD void zend_exception_error(zend_object *ex, int severity) /* { zend_string *str, *file = NULL; zend_long line = 0; - zend_call_method_with_0_params(&exception, ce_exception, &ex->ce->__tostring, "__tostring", &tmp); + zend_call_method_with_0_params(Z_OBJ(exception), ce_exception, &ex->ce->__tostring, "__tostring", &tmp); if (!EG(exception)) { if (Z_TYPE(tmp) != IS_STRING) { zend_error(E_WARNING, "%s::__toString() must return a string", ZSTR_VAL(ce_exception->name)); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index f828157d4b..edaed2c63f 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -726,8 +726,8 @@ static zend_never_inline ZEND_COLD zval* ZEND_FASTCALL make_real_object(zval *ob zval_ptr_dtor_nogc(object); object_init(object); - Z_ADDREF_P(object); obj = Z_OBJ_P(object); + GC_ADDREF(obj); zend_error(E_WARNING, "Creating default object from empty value"); if (GC_REFCOUNT(obj) == 1) { /* the enclosing container was deleted, obj is unreferenced */ @@ -737,7 +737,7 @@ static zend_never_inline ZEND_COLD zval* ZEND_FASTCALL make_real_object(zval *ob } return NULL; } - Z_DELREF_P(object); + GC_DELREF(obj); return object; } @@ -1308,7 +1308,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_offset(void) static zend_never_inline void zend_assign_to_object_dim(zval *object, zval *dim, zval *value OPLINE_DC EXECUTE_DATA_DC) { - Z_OBJ_HT_P(object)->write_dimension(object, dim, value); + Z_OBJ_HT_P(object)->write_dimension(Z_OBJ_P(object), dim, value); if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), value); @@ -1320,11 +1320,11 @@ static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval * zval *z; zval rv, res; - if ((z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_R, &rv)) != NULL) { + if ((z = Z_OBJ_HT_P(object)->read_dimension(Z_OBJ_P(object), property, BP_VAR_R, &rv)) != NULL) { if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval rv2; - zval *value = Z_OBJ_HT_P(z)->get(z, &rv2); + zval *value = Z_OBJ_HT_P(z)->get(Z_OBJ_P(z), &rv2); if (z == &rv) { zval_ptr_dtor(&rv); @@ -1332,7 +1332,7 @@ static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval * ZVAL_COPY_VALUE(z, value); } if (binary_op(&res, z, value) == SUCCESS) { - Z_OBJ_HT_P(object)->write_dimension(object, property, &res); + Z_OBJ_HT_P(object)->write_dimension(Z_OBJ_P(object), property, &res); } if (z == &rv) { zval_ptr_dtor(&rv); @@ -1793,24 +1793,23 @@ static void zend_post_incdec_property_zval(zval *prop, zend_property_info *prop_ } } -static zend_never_inline void zend_post_incdec_overloaded_property(zval *object, zval *property, void **cache_slot, int inc OPLINE_DC EXECUTE_DATA_DC) +static zend_never_inline void zend_post_incdec_overloaded_property(zend_object *object, zend_string *name, void **cache_slot, int inc OPLINE_DC EXECUTE_DATA_DC) { - zval rv, obj; + zval rv; zval *z; zval z_copy; - ZVAL_OBJ(&obj, Z_OBJ_P(object)); - Z_ADDREF(obj); - z = Z_OBJ_HT(obj)->read_property(&obj, property, BP_VAR_R, cache_slot, &rv); + GC_ADDREF(object); + z =object->handlers->read_property(object, name, BP_VAR_R, cache_slot, &rv); if (UNEXPECTED(EG(exception))) { - OBJ_RELEASE(Z_OBJ(obj)); + OBJ_RELEASE(object); ZVAL_UNDEF(EX_VAR(opline->result.var)); return; } if (UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) && Z_OBJ_HT_P(z)->get) { zval rv2; - zval *value = Z_OBJ_HT_P(z)->get(z, &rv2); + zval *value = Z_OBJ_HT_P(z)->get(Z_OBJ_P(z), &rv2); if (z == &rv) { zval_ptr_dtor(&rv); } @@ -1824,23 +1823,22 @@ static zend_never_inline void zend_post_incdec_overloaded_property(zval *object, } else { decrement_function(&z_copy); } - Z_OBJ_HT(obj)->write_property(&obj, property, &z_copy, cache_slot); - OBJ_RELEASE(Z_OBJ(obj)); + object->handlers->write_property(object, name, &z_copy, cache_slot); + OBJ_RELEASE(object); zval_ptr_dtor(&z_copy); zval_ptr_dtor(z); } -static zend_never_inline void zend_pre_incdec_overloaded_property(zval *object, zval *property, void **cache_slot, int inc OPLINE_DC EXECUTE_DATA_DC) +static zend_never_inline void zend_pre_incdec_overloaded_property(zend_object *object, zend_string *name, void **cache_slot, int inc OPLINE_DC EXECUTE_DATA_DC) { zval rv; - zval *z, obj; + zval *z; zval z_copy; - ZVAL_OBJ(&obj, Z_OBJ_P(object)); - Z_ADDREF(obj); - z = Z_OBJ_HT(obj)->read_property(&obj, property, BP_VAR_R, cache_slot, &rv); + GC_ADDREF(object); + z = object->handlers->read_property(object, name, BP_VAR_R, cache_slot, &rv); if (UNEXPECTED(EG(exception))) { - OBJ_RELEASE(Z_OBJ(obj)); + OBJ_RELEASE(object); if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); } @@ -1849,7 +1847,7 @@ static zend_never_inline void zend_pre_incdec_overloaded_property(zval *object, if (UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) && Z_OBJ_HT_P(z)->get) { zval rv2; - zval *value = Z_OBJ_HT_P(z)->get(z, &rv2); + zval *value = Z_OBJ_HT_P(z)->get(Z_OBJ_P(z), &rv2); if (z == &rv) { zval_ptr_dtor(&rv); @@ -1865,22 +1863,21 @@ static zend_never_inline void zend_pre_incdec_overloaded_property(zval *object, if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), &z_copy); } - Z_OBJ_HT(obj)->write_property(&obj, property, &z_copy, cache_slot); - OBJ_RELEASE(Z_OBJ(obj)); + object->handlers->write_property(object, name, &z_copy, cache_slot); + OBJ_RELEASE(object); zval_ptr_dtor(&z_copy); zval_ptr_dtor(z); } -static zend_never_inline void zend_assign_op_overloaded_property(zval *object, zval *property, void **cache_slot, zval *value, binary_op_type binary_op OPLINE_DC EXECUTE_DATA_DC) +static zend_never_inline void zend_assign_op_overloaded_property(zend_object *object, zend_string *name, void **cache_slot, zval *value, binary_op_type binary_op OPLINE_DC EXECUTE_DATA_DC) { zval *z; - zval rv, obj, res; + zval rv, res; - ZVAL_OBJ(&obj, Z_OBJ_P(object)); - Z_ADDREF(obj); - z = Z_OBJ_HT(obj)->read_property(&obj, property, BP_VAR_R, cache_slot, &rv); + GC_ADDREF(object); + z = object->handlers->read_property(object, name, BP_VAR_R, cache_slot, &rv); if (UNEXPECTED(EG(exception))) { - OBJ_RELEASE(Z_OBJ(obj)); + OBJ_RELEASE(object); if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_UNDEF(EX_VAR(opline->result.var)); } @@ -1888,7 +1885,7 @@ static zend_never_inline void zend_assign_op_overloaded_property(zval *object, z } if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval rv2; - zval *value = Z_OBJ_HT_P(z)->get(z, &rv2); + zval *value = Z_OBJ_HT_P(z)->get(Z_OBJ_P(z), &rv2); if (z == &rv) { zval_ptr_dtor(&rv); @@ -1896,14 +1893,14 @@ static zend_never_inline void zend_assign_op_overloaded_property(zval *object, z ZVAL_COPY_VALUE(z, value); } if (binary_op(&res, z, value) == SUCCESS) { - Z_OBJ_HT(obj)->write_property(&obj, property, &res, cache_slot); + object->handlers->write_property(object, name, &res, cache_slot); } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), &res); } zval_ptr_dtor(z); zval_ptr_dtor(&res); - OBJ_RELEASE(Z_OBJ(obj)); + OBJ_RELEASE(object); } /* Utility Functions for Extensions */ @@ -2196,7 +2193,7 @@ fetch_from_array: if (dim_type == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) { dim++; } - retval = Z_OBJ_HT_P(container)->read_dimension(container, dim, type, result); + retval = Z_OBJ_HT_P(container)->read_dimension(Z_OBJ_P(container), dim, type, result); if (UNEXPECTED(retval == &EG(uninitialized_zval))) { zend_class_entry *ce = Z_OBJCE_P(container); @@ -2351,7 +2348,7 @@ try_string_offset: if (dim_type == IS_CONST && Z_EXTRA_P(dim) == ZEND_EXTRA_VALUE) { dim++; } - retval = Z_OBJ_HT_P(container)->read_dimension(container, dim, type, result); + retval = Z_OBJ_HT_P(container)->read_dimension(Z_OBJ_P(container), dim, type, result); ZEND_ASSERT(result != NULL); if (retval) { @@ -2439,7 +2436,7 @@ static zend_never_inline int ZEND_FASTCALL zend_isset_dim_slow(zval *container, } if (/*OP1_TYPE != IS_CONST &&*/ EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { - return Z_OBJ_HT_P(container)->has_dimension(container, offset, 0); + return Z_OBJ_HT_P(container)->has_dimension(Z_OBJ_P(container), offset, 0); } else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) { /* string offsets */ zend_long lval; @@ -2478,7 +2475,7 @@ static zend_never_inline int ZEND_FASTCALL zend_isempty_dim_slow(zval *container } if (/*OP1_TYPE != IS_CONST &&*/ EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { - return !Z_OBJ_HT_P(container)->has_dimension(container, offset, 1); + return !Z_OBJ_HT_P(container)->has_dimension(Z_OBJ_P(container), offset, 1); } else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) { /* string offsets */ zend_long lval; @@ -2708,8 +2705,10 @@ static zend_never_inline zend_bool zend_handle_fetch_obj_flags( static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, uint32_t prop_op_type, void **cache_slot, int type, uint32_t flags, zend_bool init_undef OPLINE_DC) { zval *ptr; + zend_object *zobj; + zend_string *name, *tmp_name; - if (container_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) { + if (container_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) { do { if (Z_ISREF_P(container) && Z_TYPE_P(Z_REFVAL_P(container)) == IS_OBJECT) { container = Z_REFVAL_P(container); @@ -2728,10 +2727,11 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c } } while (0); } + + zobj = Z_OBJ_P(container); if (prop_op_type == IS_CONST && - EXPECTED(Z_OBJCE_P(container) == CACHED_PTR_EX(cache_slot))) { + EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); - zend_object *zobj = Z_OBJ_P(container); if (EXPECTED(IS_VALID_PROPERTY_OFFSET(prop_offset))) { ptr = OBJ_PROP(zobj, prop_offset); @@ -2759,9 +2759,15 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c } } } - ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr, type, cache_slot); + + if (prop_op_type == IS_CONST) { + name = Z_STR_P(prop_ptr); + } else { + name = zval_get_tmp_string(prop_ptr, &tmp_name); + } + ptr = zobj->handlers->get_property_ptr_ptr(zobj, name, type, cache_slot); if (NULL == ptr) { - ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result); + ptr = zobj->handlers->read_property(zobj, name, type, cache_slot, result); if (ptr == result) { if (UNEXPECTED(Z_ISREF_P(ptr) && Z_REFCOUNT_P(ptr) == 1)) { ZVAL_UNREF(ptr); @@ -3854,15 +3860,15 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_string(zend_s } /* }}} */ -static zend_never_inline zend_execute_data *zend_init_dynamic_call_object(zval *function, uint32_t num_args) /* {{{ */ +static zend_never_inline zend_execute_data *zend_init_dynamic_call_object(zend_object *function, uint32_t num_args) /* {{{ */ { zend_function *fbc; zend_class_entry *called_scope; zend_object *object; uint32_t call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_DYNAMIC; - if (EXPECTED(Z_OBJ_HANDLER_P(function, get_closure)) && - EXPECTED(Z_OBJ_HANDLER_P(function, get_closure)(function, &called_scope, &fbc, &object) == SUCCESS)) { + if (EXPECTED(function->handlers->get_closure) && + EXPECTED(function->handlers->get_closure(function, &called_scope, &fbc, &object) == SUCCESS)) { if (fbc->common.fn_flags & ZEND_ACC_CLOSURE) { /* Delay closure destruction until its invocation */ diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index f58b9d7c95..a73982ab91 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -119,7 +119,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval } if (Z_TYPE_P(variable_ptr) == IS_OBJECT && UNEXPECTED(Z_OBJ_HANDLER_P(variable_ptr, set) != NULL)) { - Z_OBJ_HANDLER_P(variable_ptr, set)(variable_ptr, value); + Z_OBJ_HANDLER_P(variable_ptr, set)(Z_OBJ_P(variable_ptr), value); return variable_ptr; } if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && variable_ptr == value) { diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c index 4d3f829412..cebb7b9fb9 100644 --- a/Zend/zend_gc.c +++ b/Zend/zend_gc.c @@ -622,10 +622,8 @@ tail_call: if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED))) { int n; zval *zv, *end; - zval tmp; - ZVAL_OBJ(&tmp, obj); - ht = obj->handlers->get_gc(&tmp, &zv, &n); + ht = obj->handlers->get_gc(obj, &zv, &n); end = zv + n; if (EXPECTED(!ht)) { if (!n) return; @@ -730,10 +728,8 @@ tail_call: if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED))) { int n; zval *zv, *end; - zval tmp; - ZVAL_OBJ(&tmp, obj); - ht = obj->handlers->get_gc(&tmp, &zv, &n); + ht = obj->handlers->get_gc(obj, &zv, &n); end = zv + n; if (EXPECTED(!ht)) { if (!n) return; @@ -884,10 +880,8 @@ tail_call: if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED))) { int n; zval *zv, *end; - zval tmp; - ZVAL_OBJ(&tmp, obj); - ht = obj->handlers->get_gc(&tmp, &zv, &n); + ht = obj->handlers->get_gc(obj, &zv, &n); end = zv + n; if (EXPECTED(!ht)) { if (!n) return; @@ -1022,7 +1016,6 @@ tail_call: if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED))) { int n; zval *zv, *end; - zval tmp; /* optimization: color is GC_BLACK (0) */ if (!GC_INFO(ref)) { @@ -1032,8 +1025,7 @@ tail_call: obj->ce->destructor != NULL) { *flags |= GC_HAS_DESTRUCTORS; } - ZVAL_OBJ(&tmp, obj); - ht = obj->handlers->get_gc(&tmp, &zv, &n); + ht = obj->handlers->get_gc(obj, &zv, &n); end = zv + n; if (EXPECTED(!ht)) { if (!n) return count; @@ -1189,10 +1181,8 @@ tail_call: if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED))) { int n; zval *zv, *end; - zval tmp; - ZVAL_OBJ(&tmp, obj); - ht = obj->handlers->get_gc(&tmp, &zv, &n); + ht = obj->handlers->get_gc(obj, &zv, &n); end = zv + n; if (EXPECTED(!ht)) { if (!n) return; diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 9e7e5fe28f..827495c842 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -308,9 +308,9 @@ static uint32_t calc_gc_buffer_size(zend_generator *generator) /* {{{ */ } /* }}} */ -static HashTable *zend_generator_get_gc(zval *object, zval **table, int *n) /* {{{ */ +static HashTable *zend_generator_get_gc(zend_object *object, zval **table, int *n) /* {{{ */ { - zend_generator *generator = (zend_generator*) Z_OBJ_P(object); + zend_generator *generator = (zend_generator*)object; zend_execute_data *execute_data = generator->execute_data; zend_op_array *op_array; zval *gc_buffer; diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index e5b6251d17..e2138e0ce3 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -30,7 +30,7 @@ ZEND_API zend_class_entry *zend_ce_countable; /* {{{ zend_call_method Only returns the returned zval if retval_ptr != NULL */ -ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval_ptr, int param_count, zval* arg1, zval* arg2) +ZEND_API zval* zend_call_method(zend_object *object, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval_ptr, int param_count, zval* arg1, zval* arg2) { int result; zend_fcall_info fci; @@ -45,7 +45,7 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun } fci.size = sizeof(fci); - fci.object = object ? Z_OBJ_P(object) : NULL; + fci.object = object; fci.retval = retval_ptr ? retval_ptr : &retval; fci.param_count = param_count; fci.params = params; @@ -62,7 +62,7 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun ZVAL_UNDEF(&fci.function_name); /* Unused */ if (!obj_ce) { - obj_ce = object ? Z_OBJCE_P(object) : NULL; + obj_ce = object ? object->ce : NULL; } if (!fn_proxy || !*fn_proxy) { if (EXPECTED(obj_ce)) { @@ -87,7 +87,7 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun } if (object) { - fcic.called_scope = Z_OBJCE_P(object); + fcic.called_scope = object->ce; } else { zend_class_entry *called_scope = zend_get_called_scope(EG(current_execute_data)); @@ -99,13 +99,13 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun fcic.called_scope = called_scope; } } - fcic.object = object ? Z_OBJ_P(object) : NULL; + fcic.object = object; result = zend_call_function(&fci, &fcic); } if (result == FAILURE) { /* error at c-level */ if (!obj_ce) { - obj_ce = object ? Z_OBJCE_P(object) : NULL; + obj_ce = object ? object->ce : NULL; } if (!EG(exception)) { zend_error_noreturn(E_CORE_ERROR, "Couldn't execute method %s%s%s", obj_ce ? ZSTR_VAL(obj_ce->name) : "", obj_ce ? "::" : "", function_name); @@ -124,7 +124,7 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun /* {{{ zend_user_it_new_iterator */ ZEND_API void zend_user_it_new_iterator(zend_class_entry *ce, zval *object, zval *retval) { - zend_call_method_with_0_params(object, ce, &ce->iterator_funcs_ptr->zf_new_iterator, "getiterator", retval); + zend_call_method_with_0_params(Z_OBJ_P(object), ce, &ce->iterator_funcs_ptr->zf_new_iterator, "getiterator", retval); } /* }}} */ @@ -160,7 +160,7 @@ ZEND_API int zend_user_it_valid(zend_object_iterator *_iter) zval more; int result; - zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs_ptr->zf_valid, "valid", &more); + zend_call_method_with_0_params(Z_OBJ_P(object), iter->ce, &iter->ce->iterator_funcs_ptr->zf_valid, "valid", &more); result = i_zend_is_true(&more); zval_ptr_dtor(&more); return result ? SUCCESS : FAILURE; @@ -176,7 +176,7 @@ ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter) zval *object = &iter->it.data; if (Z_ISUNDEF(iter->value)) { - zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs_ptr->zf_current, "current", &iter->value); + zend_call_method_with_0_params(Z_OBJ_P(object), iter->ce, &iter->ce->iterator_funcs_ptr->zf_current, "current", &iter->value); } return &iter->value; } @@ -189,7 +189,7 @@ ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *ke zval *object = &iter->it.data; zval retval; - zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs_ptr->zf_key, "key", &retval); + zend_call_method_with_0_params(Z_OBJ_P(object), iter->ce, &iter->ce->iterator_funcs_ptr->zf_key, "key", &retval); if (Z_TYPE(retval) != IS_UNDEF) { ZVAL_ZVAL(key, &retval, 1, 1); @@ -210,7 +210,7 @@ ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter) zval *object = &iter->it.data; zend_user_it_invalidate_current(_iter); - zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs_ptr->zf_next, "next", NULL); + zend_call_method_with_0_params(Z_OBJ_P(object), iter->ce, &iter->ce->iterator_funcs_ptr->zf_next, "next", NULL); } /* }}} */ @@ -221,7 +221,7 @@ ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter) zval *object = &iter->it.data; zend_user_it_invalidate_current(_iter); - zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs_ptr->zf_rewind, "rewind", NULL); + zend_call_method_with_0_params(Z_OBJ_P(object), iter->ce, &iter->ce->iterator_funcs_ptr->zf_rewind, "rewind", NULL); } /* }}} */ @@ -425,7 +425,7 @@ ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *b zval retval; int result; - zend_call_method_with_0_params(object, ce, &ce->serialize_func, "serialize", &retval); + zend_call_method_with_0_params(Z_OBJ_P(object), ce, &ce->serialize_func, "serialize", &retval); if (Z_TYPE(retval) == IS_UNDEF || EG(exception)) { @@ -466,7 +466,7 @@ ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const uns ZVAL_STRINGL(&zdata, (char*)buf, buf_len); - zend_call_method_with_1_params(object, ce, &ce->unserialize_func, "unserialize", NULL, &zdata); + zend_call_method_with_1_params(Z_OBJ_P(object), ce, &ce->unserialize_func, "unserialize", NULL, &zdata); zval_ptr_dtor(&zdata); diff --git a/Zend/zend_interfaces.h b/Zend/zend_interfaces.h index 44770a1813..e7d0315ac5 100644 --- a/Zend/zend_interfaces.h +++ b/Zend/zend_interfaces.h @@ -37,7 +37,7 @@ typedef struct _zend_user_iterator { zval value; } zend_user_iterator; -ZEND_API zval* zend_call_method(zval *object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval, int param_count, zval* arg1, zval* arg2); +ZEND_API zval* zend_call_method(zend_object *object, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval, int param_count, zval* arg1, zval* arg2); #define zend_call_method_with_0_params(obj, obj_ce, fn_proxy, function_name, retval) \ zend_call_method(obj, obj_ce, fn_proxy, function_name, sizeof(function_name)-1, retval, 0, NULL, NULL) diff --git a/Zend/zend_iterators.c b/Zend/zend_iterators.c index 379a316c38..bb3cf1b6a2 100644 --- a/Zend/zend_iterators.c +++ b/Zend/zend_iterators.c @@ -24,7 +24,7 @@ static zend_class_entry zend_iterator_class_entry; static void iter_wrapper_free(zend_object *object); static void iter_wrapper_dtor(zend_object *object); -static HashTable *iter_wrapper_get_gc(zval *object, zval **table, int *n); +static HashTable *iter_wrapper_get_gc(zend_object *object, zval **table, int *n); static const zend_object_handlers iterator_object_handlers = { 0, @@ -72,7 +72,7 @@ static void iter_wrapper_dtor(zend_object *object) { } -static HashTable *iter_wrapper_get_gc(zval *object, zval **table, int *n) { +static HashTable *iter_wrapper_get_gc(zend_object *object, zval **table, int *n) { /* TODO: We need a get_gc iterator handler */ *table = NULL; *n = 0; diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index b252c4e4bd..e86a0bbf69 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -104,10 +104,8 @@ ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */ } /* }}} */ -ZEND_API HashTable *zend_std_get_properties(zval *object) /* {{{ */ +ZEND_API HashTable *zend_std_get_properties(zend_object *zobj) /* {{{ */ { - zend_object *zobj; - zobj = Z_OBJ_P(object); if (!zobj->properties) { rebuild_object_properties(zobj); } @@ -115,15 +113,13 @@ ZEND_API HashTable *zend_std_get_properties(zval *object) /* {{{ */ } /* }}} */ -ZEND_API HashTable *zend_std_get_gc(zval *object, zval **table, int *n) /* {{{ */ +ZEND_API HashTable *zend_std_get_gc(zend_object *zobj, zval **table, int *n) /* {{{ */ { - if (Z_OBJ_HANDLER_P(object, get_properties) != zend_std_get_properties) { + if (zobj->handlers->get_properties != zend_std_get_properties) { *table = NULL; *n = 0; - return Z_OBJ_HANDLER_P(object, get_properties)(object); + return zobj->handlers->get_properties(zobj); } else { - zend_object *zobj = Z_OBJ_P(object); - if (zobj->properties) { *table = NULL; *n = 0; @@ -137,15 +133,15 @@ ZEND_API HashTable *zend_std_get_gc(zval *object, zval **table, int *n) /* {{{ * } /* }}} */ -ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp) /* {{{ */ +ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); + zend_class_entry *ce = object->ce; zval retval; HashTable *ht; if (!ce->__debugInfo) { *is_temp = 0; - return Z_OBJ_HANDLER_P(object, get_properties)(object); + return object->handlers->get_properties(object); } zend_call_method_with_0_params(object, ce, &ce->__debugInfo, ZEND_DEBUGINFO_FUNC_NAME, &retval); @@ -647,20 +643,16 @@ ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *membe } /* }}} */ -ZEND_API zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */ +ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int type, void **cache_slot, zval *rv) /* {{{ */ { - zend_object *zobj; - zend_string *name, *tmp_name; zval *retval; uintptr_t property_offset; zend_property_info *prop_info = NULL; uint32_t *guard = NULL; - - zobj = Z_OBJ_P(object); - name = zval_get_tmp_string(member, &tmp_name); + zend_string *tmp_name = NULL; #if DEBUG_OBJECT_HANDLERS - fprintf(stderr, "Read object #%d property: %s\n", Z_OBJ_HANDLE_P(object), ZSTR_VAL(name)); + fprintf(stderr, "Read object #%d property: %s\n", zobj->handle, ZSTR_VAL(name)); #endif /* make zend_get_property_info silent if we have getter - we may want to use it */ @@ -792,18 +784,13 @@ exit: } /* }}} */ -ZEND_API zval *zend_std_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */ +ZEND_API zval *zend_std_write_property(zend_object *zobj, zend_string *name, zval *value, void **cache_slot) /* {{{ */ { - zend_object *zobj; - zend_string *name, *tmp_name; zval *variable_ptr, tmp; uintptr_t property_offset; zend_property_info *prop_info = NULL; ZEND_ASSERT(!Z_ISREF_P(value)); - zobj = Z_OBJ_P(object); - name = zval_get_tmp_string(member, &tmp_name); - property_offset = zend_get_property_offset(zobj->ce, name, (zobj->ce->__set != NULL), cache_slot, &prop_info); if (EXPECTED(IS_VALID_PROPERTY_OFFSET(property_offset))) { @@ -891,7 +878,6 @@ write_std_property: } exit: - zend_tmp_string_release(tmp_name); return variable_ptr; } /* }}} */ @@ -902,10 +888,10 @@ static ZEND_COLD zend_never_inline void zend_bad_array_access(zend_class_entry * } /* }}} */ -ZEND_API zval *zend_std_read_dimension(zval *object, zval *offset, int type, zval *rv) /* {{{ */ +ZEND_API zval *zend_std_read_dimension(zend_object *object, zval *offset, int type, zval *rv) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); - zval tmp_offset, tmp_object; + zend_class_entry *ce = object->ce; + zval tmp_offset; if (EXPECTED(instanceof_function_ex(ce, zend_ce_arrayaccess, 1) != 0)) { if (offset == NULL) { @@ -915,16 +901,16 @@ ZEND_API zval *zend_std_read_dimension(zval *object, zval *offset, int type, zva ZVAL_COPY_DEREF(&tmp_offset, offset); } - ZVAL_COPY(&tmp_object, object); + GC_ADDREF(object); if (type == BP_VAR_IS) { - zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetexists", rv, &tmp_offset); + zend_call_method_with_1_params(object, ce, NULL, "offsetexists", rv, &tmp_offset); if (UNEXPECTED(Z_ISUNDEF_P(rv))) { - zval_ptr_dtor(&tmp_object); + OBJ_RELEASE(object); zval_ptr_dtor(&tmp_offset); return NULL; } if (!i_zend_is_true(rv)) { - zval_ptr_dtor(&tmp_object); + OBJ_RELEASE(object); zval_ptr_dtor(&tmp_offset); zval_ptr_dtor(rv); return &EG(uninitialized_zval); @@ -932,9 +918,9 @@ ZEND_API zval *zend_std_read_dimension(zval *object, zval *offset, int type, zva zval_ptr_dtor(rv); } - zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetget", rv, &tmp_offset); + zend_call_method_with_1_params(object, ce, NULL, "offsetget", rv, &tmp_offset); - zval_ptr_dtor(&tmp_object); + OBJ_RELEASE(object); zval_ptr_dtor(&tmp_offset); if (UNEXPECTED(Z_TYPE_P(rv) == IS_UNDEF)) { @@ -951,10 +937,10 @@ ZEND_API zval *zend_std_read_dimension(zval *object, zval *offset, int type, zva } /* }}} */ -ZEND_API void zend_std_write_dimension(zval *object, zval *offset, zval *value) /* {{{ */ +ZEND_API void zend_std_write_dimension(zend_object *object, zval *offset, zval *value) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); - zval tmp_offset, tmp_object; + zend_class_entry *ce = object->ce; + zval tmp_offset; if (EXPECTED(instanceof_function_ex(ce, zend_ce_arrayaccess, 1) != 0)) { if (!offset) { @@ -962,9 +948,9 @@ ZEND_API void zend_std_write_dimension(zval *object, zval *offset, zval *value) } else { ZVAL_COPY_DEREF(&tmp_offset, offset); } - ZVAL_COPY(&tmp_object, object); - zend_call_method_with_2_params(&tmp_object, ce, NULL, "offsetset", NULL, &tmp_offset, value); - zval_ptr_dtor(&tmp_object); + GC_ADDREF(object); + zend_call_method_with_2_params(object, ce, NULL, "offsetset", NULL, &tmp_offset, value); + OBJ_RELEASE(object); zval_ptr_dtor(&tmp_offset); } else { zend_bad_array_access(ce); @@ -972,24 +958,24 @@ ZEND_API void zend_std_write_dimension(zval *object, zval *offset, zval *value) } /* }}} */ -ZEND_API int zend_std_has_dimension(zval *object, zval *offset, int check_empty) /* {{{ */ +ZEND_API int zend_std_has_dimension(zend_object *object, zval *offset, int check_empty) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); - zval retval, tmp_offset, tmp_object; + zend_class_entry *ce = object->ce; + zval retval, tmp_offset; int result; if (EXPECTED(instanceof_function_ex(ce, zend_ce_arrayaccess, 1) != 0)) { ZVAL_COPY_DEREF(&tmp_offset, offset); - ZVAL_COPY(&tmp_object, object); - zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetexists", &retval, &tmp_offset); + GC_ADDREF(object); + zend_call_method_with_1_params(object, ce, NULL, "offsetexists", &retval, &tmp_offset); result = i_zend_is_true(&retval); zval_ptr_dtor(&retval); if (check_empty && result && EXPECTED(!EG(exception))) { - zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetget", &retval, &tmp_offset); + zend_call_method_with_1_params(object, ce, NULL, "offsetget", &retval, &tmp_offset); result = i_zend_is_true(&retval); zval_ptr_dtor(&retval); } - zval_ptr_dtor(&tmp_object); + OBJ_RELEASE(object); zval_ptr_dtor(&tmp_offset); } else { zend_bad_array_access(ce); @@ -999,19 +985,14 @@ ZEND_API int zend_std_has_dimension(zval *object, zval *offset, int check_empty) } /* }}} */ -ZEND_API zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */ +ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *name, int type, void **cache_slot) /* {{{ */ { - zend_object *zobj; - zend_string *name, *tmp_name; zval *retval = NULL; uintptr_t property_offset; zend_property_info *prop_info = NULL; - zobj = Z_OBJ_P(object); - name = zval_get_tmp_string(member, &tmp_name); - #if DEBUG_OBJECT_HANDLERS - fprintf(stderr, "Ptr object #%d property: %s\n", Z_OBJ_HANDLE_P(object), ZSTR_VAL(name)); + fprintf(stderr, "Ptr object #%d property: %s\n", object->handle, ZSTR_VAL(name)); #endif property_offset = zend_get_property_offset(zobj->ce, name, (zobj->ce->__get != NULL), cache_slot, &prop_info); @@ -1039,7 +1020,6 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int typ zobj->properties = zend_array_dup(zobj->properties); } if (EXPECTED((retval = zend_hash_find(zobj->properties, name)) != NULL)) { - zend_tmp_string_release(tmp_name); return retval; } } @@ -1057,21 +1037,15 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int typ } } - zend_tmp_string_release(tmp_name); return retval; } /* }}} */ -ZEND_API void zend_std_unset_property(zval *object, zval *member, void **cache_slot) /* {{{ */ +ZEND_API void zend_std_unset_property(zend_object *zobj, zend_string *name, void **cache_slot) /* {{{ */ { - zend_object *zobj; - zend_string *name, *tmp_name; uintptr_t property_offset; zend_property_info *prop_info = NULL; - zobj = Z_OBJ_P(object); - name = zval_get_tmp_string(member, &tmp_name); - property_offset = zend_get_property_offset(zobj->ce, name, (zobj->ce->__unset != NULL), cache_slot, &prop_info); if (EXPECTED(IS_VALID_PROPERTY_OFFSET(property_offset))) { @@ -1089,7 +1063,7 @@ ZEND_API void zend_std_unset_property(zval *object, zval *member, void **cache_s if (zobj->properties) { HT_FLAGS(zobj->properties) |= HASH_FLAG_HAS_EMPTY_IND; } - goto exit; + return; } } else if (EXPECTED(IS_DYNAMIC_PROPERTY_OFFSET(property_offset)) && EXPECTED(zobj->properties != NULL)) { @@ -1100,10 +1074,10 @@ ZEND_API void zend_std_unset_property(zval *object, zval *member, void **cache_s zobj->properties = zend_array_dup(zobj->properties); } if (EXPECTED(zend_hash_del(zobj->properties, name) != FAILURE)) { - goto exit; + return; } } else if (UNEXPECTED(EG(exception))) { - goto exit; + return; } /* magic unset */ @@ -1118,27 +1092,24 @@ ZEND_API void zend_std_unset_property(zval *object, zval *member, void **cache_s /* Trigger the correct error */ zend_wrong_offset(zobj->ce, name); ZEND_ASSERT(EG(exception)); - goto exit; + return; } else { /* Nothing to do: The property already does not exist. */ } } - -exit: - zend_tmp_string_release(tmp_name); } /* }}} */ -ZEND_API void zend_std_unset_dimension(zval *object, zval *offset) /* {{{ */ +ZEND_API void zend_std_unset_dimension(zend_object *object, zval *offset) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); - zval tmp_offset, tmp_object; + zend_class_entry *ce = object->ce; + zval tmp_offset; if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1)) { ZVAL_COPY_DEREF(&tmp_offset, offset); - ZVAL_COPY(&tmp_object, object); - zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetunset", NULL, &tmp_offset); - zval_ptr_dtor(&tmp_object); + GC_ADDREF(object); + zend_call_method_with_1_params(object, ce, NULL, "offsetunset", NULL, &tmp_offset); + OBJ_RELEASE(object); zval_ptr_dtor(&tmp_offset); } else { zend_bad_array_access(ce); @@ -1621,17 +1592,13 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */ } /* }}} */ -ZEND_API int zend_std_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) /* {{{ */ +ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has_set_exists, void **cache_slot) /* {{{ */ { - zend_object *zobj; int result; zval *value = NULL; - zend_string *name, *tmp_name; uintptr_t property_offset; zend_property_info *prop_info = NULL; - - zobj = Z_OBJ_P(object); - name = zval_get_tmp_string(member, &tmp_name); + zend_string *tmp_name = NULL; property_offset = zend_get_property_offset(zobj->ce, name, 1, cache_slot, &prop_info); @@ -1728,14 +1695,14 @@ ZEND_API zend_string *zend_std_get_class_name(const zend_object *zobj) /* {{{ */ } /* }}} */ -ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type) /* {{{ */ +ZEND_API int zend_std_cast_object_tostring(zend_object *readobj, zval *writeobj, int type) /* {{{ */ { zval retval; zend_class_entry *ce; switch (type) { case IS_STRING: - ce = Z_OBJCE_P(readobj); + ce = readobj->ce; if (ce->__tostring && (zend_call_method_with_0_params(readobj, ce, &ce->__tostring, "__tostring", &retval) || EG(exception))) { if (UNEXPECTED(EG(exception) != NULL)) { @@ -1768,17 +1735,17 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty ZVAL_TRUE(writeobj); return SUCCESS; case IS_LONG: - ce = Z_OBJCE_P(readobj); + ce = readobj->ce; zend_error(E_NOTICE, "Object of class %s could not be converted to int", ZSTR_VAL(ce->name)); ZVAL_LONG(writeobj, 1); return SUCCESS; case IS_DOUBLE: - ce = Z_OBJCE_P(readobj); + ce = readobj->ce; zend_error(E_NOTICE, "Object of class %s could not be converted to float", ZSTR_VAL(ce->name)); ZVAL_DOUBLE(writeobj, 1); return SUCCESS; case _IS_NUMBER: - ce = Z_OBJCE_P(readobj); + ce = readobj->ce; zend_error(E_NOTICE, "Object of class %s could not be converted to number", ZSTR_VAL(ce->name)); ZVAL_LONG(writeobj, 1); return SUCCESS; @@ -1790,10 +1757,10 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty } /* }}} */ -ZEND_API int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr) /* {{{ */ +ZEND_API int zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr) /* {{{ */ { zval *func; - zend_class_entry *ce = Z_OBJCE_P(obj); + zend_class_entry *ce = obj->ce; if ((func = zend_hash_find_ex(&ce->function_table, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE), 1)) == NULL) { return FAILURE; @@ -1807,20 +1774,20 @@ ZEND_API int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_fun } } else { if (obj_ptr) { - *obj_ptr = Z_OBJ_P(obj); + *obj_ptr = obj; } } return SUCCESS; } /* }}} */ -ZEND_API HashTable *zend_std_get_properties_for(zval *obj, zend_prop_purpose purpose) { +ZEND_API HashTable *zend_std_get_properties_for(zend_object *obj, zend_prop_purpose purpose) { HashTable *ht; switch (purpose) { case ZEND_PROP_PURPOSE_DEBUG: - if (Z_OBJ_HT_P(obj)->get_debug_info) { + if (obj->handlers->get_debug_info) { int is_temp; - ht = Z_OBJ_HT_P(obj)->get_debug_info(obj, &is_temp); + ht = obj->handlers->get_debug_info(obj, &is_temp); if (ht && !is_temp && !(GC_FLAGS(ht) & GC_IMMUTABLE)) { GC_ADDREF(ht); } @@ -1832,7 +1799,7 @@ ZEND_API HashTable *zend_std_get_properties_for(zval *obj, zend_prop_purpose pur case ZEND_PROP_PURPOSE_VAR_EXPORT: case ZEND_PROP_PURPOSE_JSON: case _ZEND_PROP_PURPOSE_ARRAY_KEY_EXISTS: - ht = Z_OBJ_HT_P(obj)->get_properties(obj); + ht = obj->handlers->get_properties(obj); if (ht && !(GC_FLAGS(ht) & GC_IMMUTABLE)) { GC_ADDREF(ht); } @@ -1844,11 +1811,13 @@ ZEND_API HashTable *zend_std_get_properties_for(zval *obj, zend_prop_purpose pur } ZEND_API HashTable *zend_get_properties_for(zval *obj, zend_prop_purpose purpose) { - if (Z_OBJ_HT_P(obj)->get_properties_for) { - return Z_OBJ_HT_P(obj)->get_properties_for(obj, purpose); + zend_object *zobj = Z_OBJ_P(obj); + + if (zobj->handlers->get_properties_for) { + return zobj->handlers->get_properties_for(zobj, purpose); } - return zend_std_get_properties_for(obj, purpose); + return zend_std_get_properties_for(zobj, purpose); } ZEND_API const zend_object_handlers std_object_handlers = { diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index b65e53d7c5..64356bcb04 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -41,10 +41,10 @@ struct _zend_property_info; symbol table, its reference count should be 0. */ /* Used to fetch property from the object, read-only */ -typedef zval *(*zend_object_read_property_t)(zval *object, zval *member, int type, void **cache_slot, zval *rv); +typedef zval *(*zend_object_read_property_t)(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv); /* Used to fetch dimension from the object, read-only */ -typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int type, zval *rv); +typedef zval *(*zend_object_read_dimension_t)(zend_object *object, zval *offset, int type, zval *rv); /* The following rule applies to write_property() and write_dimension() implementations: @@ -54,23 +54,23 @@ typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int ty You must return the final value of the assigned property. */ /* Used to set property of the object */ -typedef zval *(*zend_object_write_property_t)(zval *object, zval *member, zval *value, void **cache_slot); +typedef zval *(*zend_object_write_property_t)(zend_object *object, zend_string *member, zval *value, void **cache_slot); /* Used to set dimension of the object */ -typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value); +typedef void (*zend_object_write_dimension_t)(zend_object *object, zval *offset, zval *value); /* Used to create pointer to the property of the object, for future direct r/w access */ -typedef zval *(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member, int type, void **cache_slot); +typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_string *member, int type, void **cache_slot); /* Used to set object value. Can be used to override assignments and scalar write ops (like ++, +=) on the object */ -typedef void (*zend_object_set_t)(zval *object, zval *value); +typedef void (*zend_object_set_t)(zend_object *object, zval *value); /* Used to get object value. Can be used when converting object value to * one of the basic types and when using scalar ops (like ++, +=) on the object */ -typedef zval* (*zend_object_get_t)(zval *object, zval *rv); +typedef zval* (*zend_object_get_t)(zend_object *object, zval *rv); /* Used to check if a property of the object exists */ /* param has_set_exists: @@ -78,21 +78,21 @@ typedef zval* (*zend_object_get_t)(zval *object, zval *rv); * 1 (set) whether property exists and is true * 2 (exists) whether property exists */ -typedef int (*zend_object_has_property_t)(zval *object, zval *member, int has_set_exists, void **cache_slot); +typedef int (*zend_object_has_property_t)(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot); /* Used to check if a dimension of the object exists */ -typedef int (*zend_object_has_dimension_t)(zval *object, zval *member, int check_empty); +typedef int (*zend_object_has_dimension_t)(zend_object *object, zval *member, int check_empty); /* Used to remove a property of the object */ -typedef void (*zend_object_unset_property_t)(zval *object, zval *member, void **cache_slot); +typedef void (*zend_object_unset_property_t)(zend_object *object, zend_string *member, void **cache_slot); /* Used to remove a dimension of the object */ -typedef void (*zend_object_unset_dimension_t)(zval *object, zval *offset); +typedef void (*zend_object_unset_dimension_t)(zend_object *object, zval *offset); /* Used to get hash of the properties of the object, as hash of zval's */ -typedef HashTable *(*zend_object_get_properties_t)(zval *object); +typedef HashTable *(*zend_object_get_properties_t)(zend_object *object); -typedef HashTable *(*zend_object_get_debug_info_t)(zval *object, int *is_temp); +typedef HashTable *(*zend_object_get_debug_info_t)(zend_object *object, int *is_temp); typedef enum _zend_prop_purpose { /* Used for debugging. Supersedes get_debug_info handler. */ @@ -114,7 +114,7 @@ typedef enum _zend_prop_purpose { } zend_prop_purpose; /* The return value must be released using zend_release_properties(). */ -typedef zend_array *(*zend_object_get_properties_for_t)(zval *object, zend_prop_purpose purpose); +typedef zend_array *(*zend_object_get_properties_for_t)(zend_object *object, zend_prop_purpose purpose); /* Used to call methods */ /* args on stack! */ @@ -127,7 +127,7 @@ typedef zend_function *(*zend_object_get_constructor_t)(zend_object *object); /* Object maintenance/destruction */ typedef void (*zend_object_dtor_obj_t)(zend_object *object); typedef void (*zend_object_free_obj_t)(zend_object *object); -typedef zend_object* (*zend_object_clone_obj_t)(zval *object); +typedef zend_object* (*zend_object_clone_obj_t)(zend_object *object); /* Get class name for display in var_dump and other debugging functions. * Must be defined and must return a non-NULL value. */ @@ -139,15 +139,15 @@ typedef int (*zend_object_compare_zvals_t)(zval *resul, zval *op1, zval *op2); /* Cast an object to some other type. * readobj and retval must point to distinct zvals. */ -typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type); +typedef int (*zend_object_cast_t)(zend_object *readobj, zval *retval, int type); /* updates *count to hold the number of elements present and returns SUCCESS. * Returns FAILURE if the object does not have any sense of overloaded dimensions */ -typedef int (*zend_object_count_elements_t)(zval *object, zend_long *count); +typedef int (*zend_object_count_elements_t)(zend_object *object, zend_long *count); -typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr); +typedef int (*zend_object_get_closure_t)(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr); -typedef HashTable *(*zend_object_get_gc_t)(zval *object, zval **table, int *n); +typedef HashTable *(*zend_object_get_gc_t)(zend_object *object, zval **table, int *n); typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2); @@ -205,23 +205,23 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p ZEND_API ZEND_COLD zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name); ZEND_API zend_function *zend_std_get_constructor(zend_object *object); ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent); -ZEND_API HashTable *zend_std_get_properties(zval *object); -ZEND_API HashTable *zend_std_get_gc(zval *object, zval **table, int *n); -ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp); -ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type); -ZEND_API zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot); -ZEND_API zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv); -ZEND_API zval *zend_std_write_property(zval *object, zval *member, zval *value, void **cache_slot); -ZEND_API int zend_std_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot); -ZEND_API void zend_std_unset_property(zval *object, zval *member, void **cache_slot); -ZEND_API zval *zend_std_read_dimension(zval *object, zval *offset, int type, zval *rv); -ZEND_API void zend_std_write_dimension(zval *object, zval *offset, zval *value); -ZEND_API int zend_std_has_dimension(zval *object, zval *offset, int check_empty); -ZEND_API void zend_std_unset_dimension(zval *object, zval *offset); +ZEND_API HashTable *zend_std_get_properties(zend_object *object); +ZEND_API HashTable *zend_std_get_gc(zend_object *object, zval **table, int *n); +ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp); +ZEND_API int zend_std_cast_object_tostring(zend_object *object, zval *writeobj, int type); +ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot); +ZEND_API zval *zend_std_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv); +ZEND_API zval *zend_std_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot); +ZEND_API int zend_std_has_property(zend_object *object, zend_string *member, int has_set_exists, void **cache_slot); +ZEND_API void zend_std_unset_property(zend_object *object, zend_string *member, void **cache_slot); +ZEND_API zval *zend_std_read_dimension(zend_object *object, zval *offset, int type, zval *rv); +ZEND_API void zend_std_write_dimension(zend_object *object, zval *offset, zval *value); +ZEND_API int zend_std_has_dimension(zend_object *object, zval *offset, int check_empty); +ZEND_API void zend_std_unset_dimension(zend_object *object, zval *offset); ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *method_name, const zval *key); ZEND_API zend_string *zend_std_get_class_name(const zend_object *zobj); ZEND_API int zend_std_compare_objects(zval *o1, zval *o2); -ZEND_API int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr); +ZEND_API int zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr); ZEND_API void rebuild_object_properties(zend_object *zobj); ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope); @@ -234,7 +234,7 @@ ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *membe /* Default behavior for get_properties_for. For use as a fallback in custom * get_properties_for implementations. */ -ZEND_API HashTable *zend_std_get_properties_for(zval *obj, zend_prop_purpose purpose); +ZEND_API HashTable *zend_std_get_properties_for(zend_object *obj, zend_prop_purpose purpose); /* Will call get_properties_for handler or use default behavior. For use by * consumers of the get_properties_for API. */ diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index 80efb8c895..f73ef91178 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -283,14 +283,12 @@ ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object, } } -ZEND_API zend_object *zend_objects_clone_obj(zval *zobject) +ZEND_API zend_object *zend_objects_clone_obj(zend_object *old_object) { - zend_object *old_object; zend_object *new_object; /* assume that create isn't overwritten, so when clone depends on the * overwritten one then it must itself be overwritten */ - old_object = Z_OBJ_P(zobject); new_object = zend_objects_new(old_object->ce); /* zend_objects_clone_members() expect the properties to be initialized. */ diff --git a/Zend/zend_objects.h b/Zend/zend_objects.h index cb0015599b..91d388154d 100644 --- a/Zend/zend_objects.h +++ b/Zend/zend_objects.h @@ -29,7 +29,7 @@ ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object, ZEND_API void zend_object_std_dtor(zend_object *object); ZEND_API void zend_objects_destroy_object(zend_object *object); -ZEND_API zend_object *zend_objects_clone_obj(zval *object); +ZEND_API zend_object *zend_objects_clone_obj(zend_object *object); END_EXTERN_C() #endif /* ZEND_OBJECTS_H */ diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index bf2f5771fb..832e715da1 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -138,13 +138,13 @@ ZEND_API zend_long ZEND_FASTCALL zend_atol(const char *str, size_t str_len) /* { #define convert_object_to_type(op, dst, ctype, conv_func) \ ZVAL_UNDEF(dst); \ if (Z_OBJ_HT_P(op)->cast_object) { \ - if (Z_OBJ_HT_P(op)->cast_object(op, dst, ctype) == FAILURE) { \ + if (Z_OBJ_HT_P(op)->cast_object(Z_OBJ_P(op), dst, ctype) == FAILURE) { \ zend_error(E_RECOVERABLE_ERROR, \ "Object of class %s could not be converted to %s", ZSTR_VAL(Z_OBJCE_P(op)->name),\ zend_get_type_by_const(ctype)); \ } \ } else if (Z_OBJ_HT_P(op)->get) { \ - zval *newop = Z_OBJ_HT_P(op)->get(op, dst); \ + zval *newop = Z_OBJ_HT_P(op)->get(Z_OBJ_P(op), dst); \ if (Z_TYPE_P(newop) != IS_OBJECT) { \ /* for safety - avoid loop */ \ ZVAL_COPY_VALUE(dst, newop); \ @@ -863,11 +863,11 @@ try_again: case IS_OBJECT: { zval tmp; if (Z_OBJ_HT_P(op)->cast_object) { - if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, IS_STRING) == SUCCESS) { + if (Z_OBJ_HT_P(op)->cast_object(Z_OBJ_P(op), &tmp, IS_STRING) == SUCCESS) { return Z_STR(tmp); } } else if (Z_OBJ_HT_P(op)->get) { - zval *z = Z_OBJ_HT_P(op)->get(op, &tmp); + zval *z = Z_OBJ_HT_P(op)->get(Z_OBJ_P(op), &tmp); if (Z_TYPE_P(z) != IS_OBJECT) { zend_string *str = zval_get_string(z); zval_ptr_dtor(z); @@ -2078,13 +2078,13 @@ ZEND_API int ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2) if (Z_TYPE_P(op1) == IS_OBJECT) { if (Z_OBJ_HT_P(op1)->get) { zval rv; - op_free = Z_OBJ_HT_P(op1)->get(op1, &rv); + op_free = Z_OBJ_HT_P(op1)->get(Z_OBJ_P(op1), &rv); ret = compare_function(result, op_free, op2); zend_free_obj_get_result(op_free); return ret; } else if (Z_TYPE_P(op2) != IS_OBJECT && Z_OBJ_HT_P(op1)->cast_object) { ZVAL_UNDEF(&tmp_free); - if (Z_OBJ_HT_P(op1)->cast_object(op1, &tmp_free, ((Z_TYPE_P(op2) == IS_FALSE || Z_TYPE_P(op2) == IS_TRUE) ? _IS_BOOL : Z_TYPE_P(op2))) == FAILURE) { + if (Z_OBJ_HT_P(op1)->cast_object(Z_OBJ_P(op1), &tmp_free, ((Z_TYPE_P(op2) == IS_FALSE || Z_TYPE_P(op2) == IS_TRUE) ? _IS_BOOL : Z_TYPE_P(op2))) == FAILURE) { ZVAL_LONG(result, 1); zend_free_obj_get_result(&tmp_free); return SUCCESS; @@ -2097,13 +2097,13 @@ ZEND_API int ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2) if (Z_TYPE_P(op2) == IS_OBJECT) { if (Z_OBJ_HT_P(op2)->get) { zval rv; - op_free = Z_OBJ_HT_P(op2)->get(op2, &rv); + op_free = Z_OBJ_HT_P(op2)->get(Z_OBJ_P(op2), &rv); ret = compare_function(result, op1, op_free); zend_free_obj_get_result(op_free); return ret; } else if (Z_TYPE_P(op1) != IS_OBJECT && Z_OBJ_HT_P(op2)->cast_object) { ZVAL_UNDEF(&tmp_free); - if (Z_OBJ_HT_P(op2)->cast_object(op2, &tmp_free, ((Z_TYPE_P(op1) == IS_FALSE || Z_TYPE_P(op1) == IS_TRUE) ? _IS_BOOL : Z_TYPE_P(op1))) == FAILURE) { + if (Z_OBJ_HT_P(op2)->cast_object(Z_OBJ_P(op2), &tmp_free, ((Z_TYPE_P(op1) == IS_FALSE || Z_TYPE_P(op1) == IS_TRUE) ? _IS_BOOL : Z_TYPE_P(op1))) == FAILURE) { ZVAL_LONG(result, -1); zend_free_obj_get_result(&tmp_free); return SUCCESS; @@ -2467,10 +2467,10 @@ try_again: zval rv; zval *val; - val = Z_OBJ_HANDLER_P(op1, get)(op1, &rv); + val = Z_OBJ_HANDLER_P(op1, get)(Z_OBJ_P(op1), &rv); Z_TRY_ADDREF_P(val); increment_function(val); - Z_OBJ_HANDLER_P(op1, set)(op1, val); + Z_OBJ_HANDLER_P(op1, set)(Z_OBJ_P(op1), val); zval_ptr_dtor(val); } else if (Z_OBJ_HANDLER_P(op1, do_operation)) { zval op2; @@ -2534,10 +2534,10 @@ try_again: zval rv; zval *val; - val = Z_OBJ_HANDLER_P(op1, get)(op1, &rv); + val = Z_OBJ_HANDLER_P(op1, get)(Z_OBJ_P(op1), &rv); Z_TRY_ADDREF_P(val); decrement_function(val); - Z_OBJ_HANDLER_P(op1, set)(op1, val); + Z_OBJ_HANDLER_P(op1, set)(Z_OBJ_P(op1), val); zval_ptr_dtor(val); } else if (Z_OBJ_HANDLER_P(op1, do_operation)) { zval op2; @@ -2568,16 +2568,18 @@ ZEND_API int ZEND_FASTCALL zend_is_true(zval *op) /* {{{ */ ZEND_API int ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */ { - if (Z_OBJ_HT_P(op)->cast_object) { + zend_object *zobj = Z_OBJ_P(op); + + if (zobj->handlers->cast_object) { zval tmp; - if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, _IS_BOOL) == SUCCESS) { + if (zobj->handlers->cast_object(zobj, &tmp, _IS_BOOL) == SUCCESS) { return Z_TYPE(tmp) == IS_TRUE; } - zend_error(E_RECOVERABLE_ERROR, "Object of class %s could not be converted to bool", ZSTR_VAL(Z_OBJ_P(op)->ce->name)); - } else if (Z_OBJ_HT_P(op)->get) { + zend_error(E_RECOVERABLE_ERROR, "Object of class %s could not be converted to bool", ZSTR_VAL(zobj->ce->name)); + } else if (zobj->handlers->get) { int result; zval rv; - zval *tmp = Z_OBJ_HT_P(op)->get(op, &rv); + zval *tmp = zobj->handlers->get(zobj, &rv); if (Z_TYPE_P(tmp) != IS_OBJECT) { /* for safety - avoid loop */ diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 11e9c3f413..1a2d1cf81c 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -801,14 +801,14 @@ static zend_always_inline int fast_is_not_identical_function(zval *op1, zval *op #define ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(opcode, binary_op) \ if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \ && op1 == result \ - && UNEXPECTED(Z_OBJ_HANDLER_P(op1, get)) \ - && EXPECTED(Z_OBJ_HANDLER_P(op1, set))) { \ + && UNEXPECTED(Z_OBJ_HANDLER_P(op1, get)) \ + && EXPECTED(Z_OBJ_HANDLER_P(op1, set))) { \ int ret; \ zval rv; \ - zval *objval = Z_OBJ_HANDLER_P(op1, get)(op1, &rv); \ - Z_TRY_ADDREF_P(objval); \ - ret = binary_op(objval, objval, op2); \ - Z_OBJ_HANDLER_P(op1, set)(op1, objval); \ + zval *objval = Z_OBJ_HANDLER_P(op1, get)(Z_OBJ_P(op1), &rv); \ + Z_TRY_ADDREF_P(objval); \ + ret = binary_op(objval, objval, op2); \ + Z_OBJ_HANDLER_P(op1, set)(Z_OBJ_P(op1), objval); \ zval_ptr_dtor(objval); \ return ret; \ } else if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \ diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 4d33e3ae9d..b1a3215894 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -707,7 +707,7 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) { #define Z_OBJCE(zval) (Z_OBJ(zval)->ce) #define Z_OBJCE_P(zval_p) Z_OBJCE(*(zval_p)) -#define Z_OBJPROP(zval) Z_OBJ_HT((zval))->get_properties(&(zval)) +#define Z_OBJPROP(zval) Z_OBJ_HT((zval))->get_properties(Z_OBJ(zval)) #define Z_OBJPROP_P(zval_p) Z_OBJPROP(*(zval_p)) #define Z_RES(zval) (zval).value.res diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 745d4a5a64..0079ddce29 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -801,6 +801,8 @@ ZEND_VM_HELPER(zend_binary_assign_op_obj_helper, VAR|UNUSED|CV, CONST|TMPVAR|CV, zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW); @@ -827,8 +829,14 @@ ZEND_VM_HELPER(zend_binary_assign_op_obj_helper, VAR|UNUSED|CV, CONST|TMPVAR|CV, ZEND_VM_C_LABEL(assign_op_object): /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (OP2_TYPE == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (OP2_TYPE == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -865,7 +873,10 @@ ZEND_VM_C_LABEL(assign_op_object): } } } else { - zend_assign_op_overloaded_property(object, property, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + zend_assign_op_overloaded_property(zobj, name, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + } + if (OP2_TYPE != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -1165,6 +1176,8 @@ ZEND_VM_HELPER(zend_pre_incdec_property_helper, VAR|UNUSED|CV, CONST|TMPVAR|CV, zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW); @@ -1189,8 +1202,14 @@ ZEND_VM_HELPER(zend_pre_incdec_property_helper, VAR|UNUSED|CV, CONST|TMPVAR|CV, ZEND_VM_C_LABEL(pre_incdec_object): /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (OP2_TYPE == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (OP2_TYPE == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -1204,7 +1223,10 @@ ZEND_VM_C_LABEL(pre_incdec_object): zend_pre_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_pre_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_pre_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (OP2_TYPE != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -1232,6 +1254,8 @@ ZEND_VM_HELPER(zend_post_incdec_property_helper, VAR|UNUSED|CV, CONST|TMPVAR|CV, zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW); @@ -1256,8 +1280,14 @@ ZEND_VM_HELPER(zend_post_incdec_property_helper, VAR|UNUSED|CV, CONST|TMPVAR|CV, ZEND_VM_C_LABEL(post_incdec_object): /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (OP2_TYPE == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (OP2_TYPE == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, cache_slot)) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { ZVAL_NULL(EX_VAR(opline->result.var)); } else { @@ -1270,7 +1300,10 @@ ZEND_VM_C_LABEL(post_incdec_object): zend_post_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_post_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_post_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (OP2_TYPE != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -1921,9 +1954,11 @@ ZEND_VM_HOT_OBJ_HANDLER(82, ZEND_FETCH_OBJ_R, CONST|TMPVAR|UNUSED|THIS|CV, CONST /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (OP2_TYPE == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -1942,17 +1977,17 @@ ZEND_VM_HOT_OBJ_HANDLER(82, ZEND_FETCH_OBJ_R, CONST|TMPVAR|UNUSED|THIS|CV, CONST Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; ZEND_VM_C_GOTO(fetch_obj_r_copy); } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -1960,11 +1995,18 @@ ZEND_VM_HOT_OBJ_HANDLER(82, ZEND_FETCH_OBJ_R, CONST|TMPVAR|UNUSED|THIS|CV, CONST } } } - } else if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if (OP2_TYPE != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { ZEND_VM_C_LABEL(fetch_obj_r_copy): @@ -2063,9 +2105,11 @@ ZEND_VM_COLD_CONST_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMPVAR|UNUSED|THIS|CV, C /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (OP2_TYPE == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -2084,17 +2128,17 @@ ZEND_VM_COLD_CONST_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMPVAR|UNUSED|THIS|CV, C Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; ZEND_VM_C_GOTO(fetch_obj_is_copy); } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -2102,9 +2146,15 @@ ZEND_VM_COLD_CONST_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMPVAR|UNUSED|THIS|CV, C } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if (OP2_TYPE != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { ZEND_VM_C_LABEL(fetch_obj_is_copy): @@ -2196,6 +2246,8 @@ ZEND_VM_HANDLER(136, ZEND_ASSIGN_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV, CACHE USE_OPLINE zend_free_op free_op1, free_op2, free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = GET_OP1_OBJ_ZVAL_PTR_PTR_UNDEF(BP_VAR_W); @@ -2220,8 +2272,9 @@ ZEND_VM_HANDLER(136, ZEND_ASSIGN_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV, CACHE } ZEND_VM_C_LABEL(assign_object): + zobj = Z_OBJ_P(object); if (OP2_TYPE == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -2311,7 +2364,17 @@ ZEND_VM_C_LABEL(fast_assign_obj): ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (OP2_TYPE == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (OP2_TYPE == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (OP2_TYPE == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (OP2_TYPE != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -3595,7 +3658,7 @@ ZEND_VM_C_LABEL(try_function_name): if (OP2_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { call = zend_init_dynamic_call_string(Z_STR_P(function_name), opline->extended_value); } else if (OP2_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT)) { - call = zend_init_dynamic_call_object(function_name, opline->extended_value); + call = zend_init_dynamic_call_object(Z_OBJ_P(function_name), opline->extended_value); } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY)) { call = zend_init_dynamic_call_array(Z_ARRVAL_P(function_name), opline->extended_value); } else if ((OP2_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(function_name) == IS_REFERENCE)) { @@ -5258,6 +5321,7 @@ ZEND_VM_COLD_CONST_HANDLER(110, ZEND_CLONE, CONST|TMPVAR|UNUSED|THIS|CV, ANY) USE_OPLINE zend_free_op free_op1; zval *obj; + zend_object *zobj; zend_class_entry *ce, *scope; zend_function *clone; zend_object_clone_obj_t clone_call; @@ -5291,9 +5355,10 @@ ZEND_VM_COLD_CONST_HANDLER(110, ZEND_CLONE, CONST|TMPVAR|UNUSED|THIS|CV, ANY) } } while (0); - ce = Z_OBJCE_P(obj); + zobj = Z_OBJ_P(obj); + ce = zobj->ce; clone = ce->clone; - clone_call = Z_OBJ_HT_P(obj)->clone_obj; + clone_call = zobj->handlers->clone_obj; if (UNEXPECTED(clone_call == NULL)) { zend_throw_error(NULL, "Trying to clone an uncloneable object of class %s", ZSTR_VAL(ce->name)); FREE_OP1(); @@ -5314,7 +5379,7 @@ ZEND_VM_COLD_CONST_HANDLER(110, ZEND_CLONE, CONST|TMPVAR|UNUSED|THIS|CV, ANY) } } - ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(obj)); + ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(zobj)); FREE_OP1(); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -5874,7 +5939,7 @@ ZEND_VM_C_LABEL(num_index_dim): if (OP2_TYPE == IS_CONST && Z_EXTRA_P(offset) == ZEND_EXTRA_VALUE) { offset++; } - Z_OBJ_HT_P(container)->unset_dimension(container, offset); + Z_OBJ_HT_P(container)->unset_dimension(Z_OBJ_P(container), offset); } else if (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) { zend_throw_error(NULL, "Cannot unset string offsets"); } @@ -5891,6 +5956,7 @@ ZEND_VM_HANDLER(76, ZEND_UNSET_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV, CACHE_S zend_free_op free_op1, free_op2; zval *container; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET); @@ -5910,7 +5976,15 @@ ZEND_VM_HANDLER(76, ZEND_UNSET_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV, CACHE_S break; } } - Z_OBJ_HT_P(container)->unset_property(container, offset, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (OP2_TYPE == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + Z_OBJ_HT_P(container)->unset_property(Z_OBJ_P(container), name, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (OP2_TYPE != IS_CONST) { + zend_tmp_string_release(tmp_name); + } } while (0); FREE_OP2(); @@ -5938,20 +6012,24 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET_R, CONST|TMP|VAR|CV, JMP_ADDR) FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } else if (OP1_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(array_ptr) == IS_OBJECT)) { - if (!Z_OBJCE_P(array_ptr)->get_iterator) { + zend_object *zobj = Z_OBJ_P(array_ptr); + if (!zobj->ce->get_iterator) { result = EX_VAR(opline->result.var); - ZVAL_COPY_VALUE(result, array_ptr); + ZVAL_OBJ(result, zobj); if (OP1_TYPE != IS_TMP_VAR) { - Z_ADDREF_P(array_ptr); + GC_ADDREF(zobj); } - if (Z_OBJ_P(array_ptr)->properties - && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { - if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_DELREF(Z_OBJ_P(array_ptr)->properties); + if (zobj->properties) { + if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { + if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { + GC_DELREF(zobj->properties); + } + zobj->properties = zend_array_dup(zobj->properties); } - Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); + } else { + zobj->properties = zobj->handlers->get_properties(zobj); } - Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(Z_OBJPROP_P(array_ptr), 0); + Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(zobj->properties, 0); FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -6574,6 +6652,7 @@ ZEND_VM_COLD_CONST_HANDLER(148, ZEND_ISSET_ISEMPTY_PROP_OBJ, CONST|TMPVAR|UNUSED zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_IS); @@ -6598,9 +6677,19 @@ ZEND_VM_COLD_CONST_HANDLER(148, ZEND_ISSET_ISEMPTY_PROP_OBJ, CONST|TMPVAR|UNUSED } } + if (OP2_TYPE == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if (OP2_TYPE != IS_CONST) { + zend_tmp_string_release(tmp_name); + } ZEND_VM_C_LABEL(isset_object_finish): FREE_OP2(); @@ -8257,18 +8346,20 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMP|VAR|CV, UNUSED) count = zend_array_count(Z_ARRVAL_P(op1)); break; } else if (Z_TYPE_P(op1) == IS_OBJECT) { + zend_object *zobj = Z_OBJ_P(op1); + /* first, we check if the handler is defined */ - if (Z_OBJ_HT_P(op1)->count_elements) { - if (SUCCESS == Z_OBJ_HT_P(op1)->count_elements(op1, &count)) { + if (zobj->handlers->count_elements) { + if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) { break; } } /* if not and the object implements Countable we call its count() method */ - if (instanceof_function(Z_OBJCE_P(op1), zend_ce_countable)) { + if (instanceof_function(zobj->ce, zend_ce_countable)) { zval retval; - zend_call_method_with_0_params(op1, NULL, NULL, "count", &retval); + zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 0ed4d27203..97dbc48b1c 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -2055,7 +2055,7 @@ try_function_name: if (IS_CONST != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { call = zend_init_dynamic_call_string(Z_STR_P(function_name), opline->extended_value); } else if (IS_CONST != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT)) { - call = zend_init_dynamic_call_object(function_name, opline->extended_value); + call = zend_init_dynamic_call_object(Z_OBJ_P(function_name), opline->extended_value); } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY)) { call = zend_init_dynamic_call_array(Z_ARRVAL_P(function_name), opline->extended_value); } else if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(function_name) == IS_REFERENCE)) { @@ -2224,7 +2224,7 @@ try_function_name: if ((IS_TMP_VAR|IS_VAR) != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { call = zend_init_dynamic_call_string(Z_STR_P(function_name), opline->extended_value); } else if ((IS_TMP_VAR|IS_VAR) != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT)) { - call = zend_init_dynamic_call_object(function_name, opline->extended_value); + call = zend_init_dynamic_call_object(Z_OBJ_P(function_name), opline->extended_value); } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY)) { call = zend_init_dynamic_call_array(Z_ARRVAL_P(function_name), opline->extended_value); } else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(function_name) == IS_REFERENCE)) { @@ -2342,7 +2342,7 @@ try_function_name: if (IS_CV != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) { call = zend_init_dynamic_call_string(Z_STR_P(function_name), opline->extended_value); } else if (IS_CV != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT)) { - call = zend_init_dynamic_call_object(function_name, opline->extended_value); + call = zend_init_dynamic_call_object(Z_OBJ_P(function_name), opline->extended_value); } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY)) { call = zend_init_dynamic_call_array(Z_ARRVAL_P(function_name), opline->extended_value); } else if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(function_name) == IS_REFERENCE)) { @@ -3008,6 +3008,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CONST_ USE_OPLINE zval *obj; + zend_object *zobj; zend_class_entry *ce, *scope; zend_function *clone; zend_object_clone_obj_t clone_call; @@ -3041,9 +3042,10 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CONST_ } } while (0); - ce = Z_OBJCE_P(obj); + zobj = Z_OBJ_P(obj); + ce = zobj->ce; clone = ce->clone; - clone_call = Z_OBJ_HT_P(obj)->clone_obj; + clone_call = zobj->handlers->clone_obj; if (UNEXPECTED(clone_call == NULL)) { zend_throw_error(NULL, "Trying to clone an uncloneable object of class %s", ZSTR_VAL(ce->name)); @@ -3064,7 +3066,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CONST_ } } - ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(obj)); + ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(zobj)); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -3248,20 +3250,24 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_CONST_HANDLER( ZEND_VM_NEXT_OPCODE(); } else if (IS_CONST != IS_CONST && EXPECTED(Z_TYPE_P(array_ptr) == IS_OBJECT)) { - if (!Z_OBJCE_P(array_ptr)->get_iterator) { + zend_object *zobj = Z_OBJ_P(array_ptr); + if (!zobj->ce->get_iterator) { result = EX_VAR(opline->result.var); - ZVAL_COPY_VALUE(result, array_ptr); + ZVAL_OBJ(result, zobj); if (IS_CONST != IS_TMP_VAR) { - Z_ADDREF_P(array_ptr); + GC_ADDREF(zobj); } - if (Z_OBJ_P(array_ptr)->properties - && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { - if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_DELREF(Z_OBJ_P(array_ptr)->properties); + if (zobj->properties) { + if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { + if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { + GC_DELREF(zobj->properties); + } + zobj->properties = zend_array_dup(zobj->properties); } - Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); + } else { + zobj->properties = zobj->handlers->get_properties(zobj); } - Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(Z_OBJPROP_P(array_ptr), 0); + Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(zobj->properties, 0); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } else { @@ -4795,9 +4801,11 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_ /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -4816,17 +4824,17 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_ Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_r_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -4834,11 +4842,18 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_ } } } - } else if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_r_copy: @@ -4889,9 +4904,11 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -4910,17 +4927,17 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_is_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -4928,9 +4945,15 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_is_copy: @@ -5944,6 +5967,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PRO zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = RT_CONSTANT(opline, opline->op1); @@ -5968,9 +5992,19 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PRO } } + if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } isset_object_finish: @@ -7245,9 +7279,11 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_ /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -7266,17 +7302,17 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_ Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_r_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -7284,11 +7320,18 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_ } } } - } else if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_r_copy: @@ -7339,9 +7382,11 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -7360,17 +7405,17 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_is_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -7378,9 +7423,15 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_is_copy: @@ -8071,6 +8122,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PRO zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = RT_CONSTANT(opline, opline->op1); @@ -8095,9 +8147,19 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PRO } } + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } isset_object_finish: zval_ptr_dtor_nogc(free_op2); @@ -10059,18 +10121,20 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_ count = zend_array_count(Z_ARRVAL_P(op1)); break; } else if (Z_TYPE_P(op1) == IS_OBJECT) { + zend_object *zobj = Z_OBJ_P(op1); + /* first, we check if the handler is defined */ - if (Z_OBJ_HT_P(op1)->count_elements) { - if (SUCCESS == Z_OBJ_HT_P(op1)->count_elements(op1, &count)) { + if (zobj->handlers->count_elements) { + if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) { break; } } /* if not and the object implements Countable we call its count() method */ - if (instanceof_function(Z_OBJCE_P(op1), zend_ce_countable)) { + if (instanceof_function(zobj->ce, zend_ce_countable)) { zval retval; - zend_call_method_with_0_params(op1, NULL, NULL, "count", &retval); + zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; @@ -10706,9 +10770,11 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_ /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -10727,17 +10793,17 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_ Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_r_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -10745,11 +10811,18 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_ } } } - } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_r_copy: @@ -10800,9 +10873,11 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -10821,17 +10896,17 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_is_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -10839,9 +10914,15 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_is_copy: @@ -11531,6 +11612,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PRO zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = RT_CONSTANT(opline, opline->op1); @@ -11555,9 +11637,19 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PRO } } + if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } isset_object_finish: @@ -13313,6 +13405,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_TMPVAR_HANDLER(ZEND USE_OPLINE zend_free_op free_op1; zval *obj; + zend_object *zobj; zend_class_entry *ce, *scope; zend_function *clone; zend_object_clone_obj_t clone_call; @@ -13346,9 +13439,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_TMPVAR_HANDLER(ZEND } } while (0); - ce = Z_OBJCE_P(obj); + zobj = Z_OBJ_P(obj); + ce = zobj->ce; clone = ce->clone; - clone_call = Z_OBJ_HT_P(obj)->clone_obj; + clone_call = zobj->handlers->clone_obj; if (UNEXPECTED(clone_call == NULL)) { zend_throw_error(NULL, "Trying to clone an uncloneable object of class %s", ZSTR_VAL(ce->name)); zval_ptr_dtor_nogc(free_op1); @@ -13369,7 +13463,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_TMPVAR_HANDLER(ZEND } } - ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(obj)); + ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(zobj)); zval_ptr_dtor_nogc(free_op1); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -14450,9 +14544,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_CONST_ /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -14471,17 +14567,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_CONST_ Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_r_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -14489,11 +14585,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_CONST_ } } } - } else if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_r_copy: @@ -14544,9 +14647,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMPVAR_CONST /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -14565,17 +14670,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMPVAR_CONST Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_is_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -14583,9 +14688,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMPVAR_CONST } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_is_copy: @@ -15242,6 +15353,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TM zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = _get_zval_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -15266,9 +15378,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TM } } + if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } isset_object_finish: @@ -16202,9 +16324,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_TMPVAR /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -16223,17 +16347,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_TMPVAR Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_r_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -16241,11 +16365,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_TMPVAR } } } - } else if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_r_copy: @@ -16296,9 +16427,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMPVAR_TMPVA /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -16317,17 +16450,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMPVAR_TMPVA Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_is_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -16335,9 +16468,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMPVAR_TMPVA } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_is_copy: @@ -16741,6 +16880,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TM zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = _get_zval_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -16765,9 +16905,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TM } } + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } isset_object_finish: zval_ptr_dtor_nogc(free_op2); @@ -18331,9 +18481,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_CV_HAN /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -18352,17 +18504,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_CV_HAN Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_r_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -18370,11 +18522,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_CV_HAN } } } - } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_r_copy: @@ -18425,9 +18584,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMPVAR_CV_HA /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -18446,17 +18607,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMPVAR_CV_HA Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_is_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -18464,9 +18625,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMPVAR_CV_HA } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_is_copy: @@ -18870,6 +19037,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TM zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = _get_zval_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -18894,9 +19062,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TM } } + if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } isset_object_finish: @@ -19338,20 +19516,24 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_TMP_HANDLER(ZE ZEND_VM_NEXT_OPCODE(); } else if (IS_TMP_VAR != IS_CONST && EXPECTED(Z_TYPE_P(array_ptr) == IS_OBJECT)) { - if (!Z_OBJCE_P(array_ptr)->get_iterator) { + zend_object *zobj = Z_OBJ_P(array_ptr); + if (!zobj->ce->get_iterator) { result = EX_VAR(opline->result.var); - ZVAL_COPY_VALUE(result, array_ptr); + ZVAL_OBJ(result, zobj); if (IS_TMP_VAR != IS_TMP_VAR) { - Z_ADDREF_P(array_ptr); + GC_ADDREF(zobj); } - if (Z_OBJ_P(array_ptr)->properties - && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { - if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_DELREF(Z_OBJ_P(array_ptr)->properties); + if (zobj->properties) { + if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { + if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { + GC_DELREF(zobj->properties); + } + zobj->properties = zend_array_dup(zobj->properties); } - Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); + } else { + zobj->properties = zobj->handlers->get_properties(zobj); } - Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(Z_OBJPROP_P(array_ptr), 0); + Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(zobj->properties, 0); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } else { @@ -21424,18 +21606,20 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMP_UNUSED_HANDLER( count = zend_array_count(Z_ARRVAL_P(op1)); break; } else if (Z_TYPE_P(op1) == IS_OBJECT) { + zend_object *zobj = Z_OBJ_P(op1); + /* first, we check if the handler is defined */ - if (Z_OBJ_HT_P(op1)->count_elements) { - if (SUCCESS == Z_OBJ_HT_P(op1)->count_elements(op1, &count)) { + if (zobj->handlers->count_elements) { + if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) { break; } } /* if not and the object implements Countable we call its count() method */ - if (instanceof_function(Z_OBJCE_P(op1), zend_ce_countable)) { + if (instanceof_function(zobj->ce, zend_ce_countable)) { zval retval; - zend_call_method_with_0_params(op1, NULL, NULL, "count", &retval); + zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; @@ -22836,20 +23020,24 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_VAR_HANDLER(ZE zval_ptr_dtor_nogc(free_op1); ZEND_VM_NEXT_OPCODE(); } else if (IS_VAR != IS_CONST && EXPECTED(Z_TYPE_P(array_ptr) == IS_OBJECT)) { - if (!Z_OBJCE_P(array_ptr)->get_iterator) { + zend_object *zobj = Z_OBJ_P(array_ptr); + if (!zobj->ce->get_iterator) { result = EX_VAR(opline->result.var); - ZVAL_COPY_VALUE(result, array_ptr); + ZVAL_OBJ(result, zobj); if (IS_VAR != IS_TMP_VAR) { - Z_ADDREF_P(array_ptr); + GC_ADDREF(zobj); } - if (Z_OBJ_P(array_ptr)->properties - && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { - if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_DELREF(Z_OBJ_P(array_ptr)->properties); + if (zobj->properties) { + if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { + if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { + GC_DELREF(zobj->properties); + } + zobj->properties = zend_array_dup(zobj->properties); } - Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); + } else { + zobj->properties = zobj->handlers->get_properties(zobj); } - Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(Z_OBJPROP_P(array_ptr), 0); + Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(zobj->properties, 0); zval_ptr_dtor_nogc(free_op1); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); @@ -23583,6 +23771,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -23609,8 +23799,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP assign_op_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CONST == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((IS_CONST == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -23647,7 +23843,10 @@ assign_op_object: } } } else { - zend_assign_op_overloaded_property(object, property, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + zend_assign_op_overloaded_property(zobj, name, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -24227,6 +24426,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -24251,8 +24452,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE pre_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -24266,7 +24473,10 @@ pre_incdec_object: zend_pre_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_pre_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_pre_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -24293,6 +24503,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -24317,8 +24529,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP post_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, cache_slot)) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { ZVAL_NULL(EX_VAR(opline->result.var)); } else { @@ -24331,7 +24549,10 @@ post_incdec_object: zend_post_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_post_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_post_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -24527,6 +24748,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_OP_D USE_OPLINE zend_free_op free_op1; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -24551,8 +24774,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_OP_D } assign_object: + zobj = Z_OBJ_P(object); if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -24642,7 +24866,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -24660,6 +24894,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_OP_D USE_OPLINE zend_free_op free_op1, free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -24684,8 +24920,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_OP_D } assign_object: + zobj = Z_OBJ_P(object); if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -24775,7 +25012,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -24793,6 +25040,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_OP_D USE_OPLINE zend_free_op free_op1, free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -24817,8 +25066,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_OP_D } assign_object: + zobj = Z_OBJ_P(object); if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -24908,7 +25158,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -24926,6 +25186,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_OP_D USE_OPLINE zend_free_op free_op1; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -24950,8 +25212,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_OP_D } assign_object: + zobj = Z_OBJ_P(object); if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -25041,7 +25304,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -26153,7 +26426,7 @@ num_index_dim: if (IS_CONST == IS_CONST && Z_EXTRA_P(offset) == ZEND_EXTRA_VALUE) { offset++; } - Z_OBJ_HT_P(container)->unset_dimension(container, offset); + Z_OBJ_HT_P(container)->unset_dimension(Z_OBJ_P(container), offset); } else if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) { zend_throw_error(NULL, "Cannot unset string offsets"); } @@ -26169,6 +26442,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_CONST_HANDL zend_free_op free_op1; zval *container; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -26188,7 +26462,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_CONST_HANDL break; } } - Z_OBJ_HT_P(container)->unset_property(container, offset, ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + Z_OBJ_HT_P(container)->unset_property(Z_OBJ_P(container), name, ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } } while (0); if (UNEXPECTED(free_op1)) {zval_ptr_dtor_nogc(free_op1);}; @@ -26383,6 +26665,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -26409,8 +26693,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP assign_op_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -26447,7 +26737,10 @@ assign_op_object: } } } else { - zend_assign_op_overloaded_property(object, property, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + zend_assign_op_overloaded_property(zobj, name, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + } + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -27029,6 +27322,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -27053,8 +27348,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE pre_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -27068,7 +27369,10 @@ pre_incdec_object: zend_pre_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_pre_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_pre_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -27096,6 +27400,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -27120,8 +27426,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP post_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, cache_slot)) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { ZVAL_NULL(EX_VAR(opline->result.var)); } else { @@ -27134,7 +27446,10 @@ post_incdec_object: zend_post_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_post_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_post_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -27332,6 +27647,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_TMPVAR_OP_ USE_OPLINE zend_free_op free_op1, free_op2; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -27356,8 +27673,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_TMPVAR_OP_ } assign_object: + zobj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -27447,7 +27765,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -27465,6 +27793,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_TMPVAR_OP_ USE_OPLINE zend_free_op free_op1, free_op2, free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -27489,8 +27819,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_TMPVAR_OP_ } assign_object: + zobj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -27580,7 +27911,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -27598,6 +27939,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_TMPVAR_OP_ USE_OPLINE zend_free_op free_op1, free_op2, free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -27622,8 +27965,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_TMPVAR_OP_ } assign_object: + zobj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -27713,7 +28057,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -27731,6 +28085,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_TMPVAR_OP_ USE_OPLINE zend_free_op free_op1, free_op2; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -27755,8 +28111,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_TMPVAR_OP_ } assign_object: + zobj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -27846,7 +28203,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -28831,7 +29198,7 @@ num_index_dim: if ((IS_TMP_VAR|IS_VAR) == IS_CONST && Z_EXTRA_P(offset) == ZEND_EXTRA_VALUE) { offset++; } - Z_OBJ_HT_P(container)->unset_dimension(container, offset); + Z_OBJ_HT_P(container)->unset_dimension(Z_OBJ_P(container), offset); } else if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) { zend_throw_error(NULL, "Cannot unset string offsets"); } @@ -28848,6 +29215,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_TMPVAR_HAND zend_free_op free_op1, free_op2; zval *container; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -28867,7 +29235,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_TMPVAR_HAND break; } } - Z_OBJ_HT_P(container)->unset_property(container, offset, (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + Z_OBJ_HT_P(container)->unset_property(Z_OBJ_P(container), name, (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } } while (0); zval_ptr_dtor_nogc(free_op2); @@ -30811,18 +31187,20 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_VAR_UNUSED_HANDLER( count = zend_array_count(Z_ARRVAL_P(op1)); break; } else if (Z_TYPE_P(op1) == IS_OBJECT) { + zend_object *zobj = Z_OBJ_P(op1); + /* first, we check if the handler is defined */ - if (Z_OBJ_HT_P(op1)->count_elements) { - if (SUCCESS == Z_OBJ_HT_P(op1)->count_elements(op1, &count)) { + if (zobj->handlers->count_elements) { + if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) { break; } } /* if not and the object implements Countable we call its count() method */ - if (instanceof_function(Z_OBJCE_P(op1), zend_ce_countable)) { + if (instanceof_function(zobj->ce, zend_ce_countable)) { zval retval; - zend_call_method_with_0_params(op1, NULL, NULL, "count", &retval); + zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; @@ -30903,6 +31281,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -30929,8 +31309,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP assign_op_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CV == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((IS_CV == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -30967,7 +31353,10 @@ assign_op_object: } } } else { - zend_assign_op_overloaded_property(object, property, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + zend_assign_op_overloaded_property(zobj, name, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -31405,6 +31794,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -31429,8 +31820,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE pre_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -31444,7 +31841,10 @@ pre_incdec_object: zend_pre_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_pre_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_pre_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -31471,6 +31871,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -31495,8 +31897,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP post_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, cache_slot)) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { ZVAL_NULL(EX_VAR(opline->result.var)); } else { @@ -31509,7 +31917,10 @@ post_incdec_object: zend_post_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_post_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_post_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -31705,6 +32116,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CV_OP_DATA USE_OPLINE zend_free_op free_op1; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -31729,8 +32142,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CV_OP_DATA } assign_object: + zobj = Z_OBJ_P(object); if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -31820,7 +32234,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -31838,6 +32262,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CV_OP_DATA USE_OPLINE zend_free_op free_op1, free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -31862,8 +32288,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CV_OP_DATA } assign_object: + zobj = Z_OBJ_P(object); if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -31953,7 +32380,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -31971,6 +32408,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CV_OP_DATA USE_OPLINE zend_free_op free_op1, free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -31995,8 +32434,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CV_OP_DATA } assign_object: + zobj = Z_OBJ_P(object); if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -32086,7 +32526,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -32104,6 +32554,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CV_OP_DATA USE_OPLINE zend_free_op free_op1; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -32128,8 +32580,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_VAR_CV_OP_DATA } assign_object: + zobj = Z_OBJ_P(object); if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -32219,7 +32672,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -33299,7 +33762,7 @@ num_index_dim: if (IS_CV == IS_CONST && Z_EXTRA_P(offset) == ZEND_EXTRA_VALUE) { offset++; } - Z_OBJ_HT_P(container)->unset_dimension(container, offset); + Z_OBJ_HT_P(container)->unset_dimension(Z_OBJ_P(container), offset); } else if (IS_VAR != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) { zend_throw_error(NULL, "Cannot unset string offsets"); } @@ -33315,6 +33778,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_CV_HANDLER( zend_free_op free_op1; zval *container; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = _get_zval_ptr_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); @@ -33334,7 +33798,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_VAR_CV_HANDLER( break; } } - Z_OBJ_HT_P(container)->unset_property(container, offset, ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + Z_OBJ_HT_P(container)->unset_property(Z_OBJ_P(container), name, ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } } while (0); if (UNEXPECTED(free_op1)) {zval_ptr_dtor_nogc(free_op1);}; @@ -33626,6 +34098,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND USE_OPLINE zval *obj; + zend_object *zobj; zend_class_entry *ce, *scope; zend_function *clone; zend_object_clone_obj_t clone_call; @@ -33659,9 +34132,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND } } while (0); - ce = Z_OBJCE_P(obj); + zobj = Z_OBJ_P(obj); + ce = zobj->ce; clone = ce->clone; - clone_call = Z_OBJ_HT_P(obj)->clone_obj; + clone_call = zobj->handlers->clone_obj; if (UNEXPECTED(clone_call == NULL)) { zend_throw_error(NULL, "Trying to clone an uncloneable object of class %s", ZSTR_VAL(ce->name)); @@ -33682,7 +34156,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND } } - ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(obj)); + ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(zobj)); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -33771,6 +34245,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -33797,8 +34273,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP assign_op_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CONST == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((IS_CONST == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -33835,7 +34317,10 @@ assign_op_object: } } } else { - zend_assign_op_overloaded_property(object, property, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + zend_assign_op_overloaded_property(zobj, name, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -33949,6 +34434,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -33973,8 +34460,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE pre_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -33988,7 +34481,10 @@ pre_incdec_object: zend_pre_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_pre_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_pre_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -34015,6 +34511,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -34039,8 +34537,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP post_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, cache_slot)) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { ZVAL_NULL(EX_VAR(opline->result.var)); } else { @@ -34053,7 +34557,10 @@ post_incdec_object: zend_post_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_post_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_post_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -34113,9 +34620,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_U /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -34134,17 +34643,17 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_U Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_r_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -34152,11 +34661,18 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_U } } } - } else if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_r_copy: @@ -34255,9 +34771,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CONST /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -34276,17 +34794,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CONST Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_is_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -34294,9 +34812,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CONST } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_is_copy: @@ -34351,6 +34875,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CONST_O USE_OPLINE zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -34375,8 +34901,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CONST_O } assign_object: + zobj = Z_OBJ_P(object); if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -34466,7 +34993,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -34484,6 +35021,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CONST_O USE_OPLINE zend_free_op free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -34508,8 +35047,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CONST_O } assign_object: + zobj = Z_OBJ_P(object); if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -34599,7 +35139,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -34617,6 +35167,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CONST_O USE_OPLINE zend_free_op free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -34641,8 +35193,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CONST_O } assign_object: + zobj = Z_OBJ_P(object); if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -34732,7 +35285,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -34750,6 +35313,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CONST_O USE_OPLINE zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -34774,8 +35339,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CONST_O } assign_object: + zobj = Z_OBJ_P(object); if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -34865,7 +35431,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -35490,6 +36066,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_CONST_HA zval *container; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = &EX(This); @@ -35509,7 +36086,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_CONST_HA break; } } - Z_OBJ_HT_P(container)->unset_property(container, offset, ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + Z_OBJ_HT_P(container)->unset_property(Z_OBJ_P(container), name, ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } } while (0); @@ -35523,6 +36108,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UN zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = &EX(This); @@ -35547,9 +36133,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UN } } + if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } isset_object_finish: @@ -35706,6 +36302,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -35732,8 +36330,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP assign_op_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -35770,7 +36374,10 @@ assign_op_object: } } } else { - zend_assign_op_overloaded_property(object, property, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + zend_assign_op_overloaded_property(zobj, name, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + } + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -35884,6 +36491,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -35908,8 +36517,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE pre_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -35923,7 +36538,10 @@ pre_incdec_object: zend_pre_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_pre_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_pre_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -35951,6 +36569,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -35975,8 +36595,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP post_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, cache_slot)) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { ZVAL_NULL(EX_VAR(opline->result.var)); } else { @@ -35989,7 +36615,10 @@ post_incdec_object: zend_post_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_post_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_post_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -36050,9 +36679,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_TMPVAR /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -36071,17 +36702,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_TMPVAR Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_r_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -36089,11 +36720,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_TMPVAR } } } - } else if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_r_copy: @@ -36192,9 +36830,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMPVA /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -36213,17 +36853,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMPVA Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_is_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -36231,9 +36871,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMPVA } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_is_copy: @@ -36288,6 +36934,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_TMPVAR_ USE_OPLINE zend_free_op free_op2; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -36312,8 +36960,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_TMPVAR_ } assign_object: + zobj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -36403,7 +37052,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -36421,6 +37080,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_TMPVAR_ USE_OPLINE zend_free_op free_op2, free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -36445,8 +37106,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_TMPVAR_ } assign_object: + zobj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -36536,7 +37198,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -36554,6 +37226,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_TMPVAR_ USE_OPLINE zend_free_op free_op2, free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -36578,8 +37252,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_TMPVAR_ } assign_object: + zobj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -36669,7 +37344,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -36687,6 +37372,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_TMPVAR_ USE_OPLINE zend_free_op free_op2; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -36711,8 +37398,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_TMPVAR_ } assign_object: + zobj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -36802,7 +37490,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -37341,6 +38039,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_TMPVAR_H zend_free_op free_op2; zval *container; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = &EX(This); @@ -37360,7 +38059,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_TMPVAR_H break; } } - Z_OBJ_HT_P(container)->unset_property(container, offset, (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + Z_OBJ_HT_P(container)->unset_property(Z_OBJ_P(container), name, (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } } while (0); zval_ptr_dtor_nogc(free_op2); @@ -37375,6 +38082,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UN zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = &EX(This); @@ -37399,9 +38107,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UN } } + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } isset_object_finish: zval_ptr_dtor_nogc(free_op2); @@ -38290,6 +39008,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -38316,8 +39036,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP assign_op_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CV == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((IS_CV == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -38354,7 +39080,10 @@ assign_op_object: } } } else { - zend_assign_op_overloaded_property(object, property, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + zend_assign_op_overloaded_property(zobj, name, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -38468,6 +39197,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -38492,8 +39223,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE pre_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -38507,7 +39244,10 @@ pre_incdec_object: zend_pre_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_pre_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_pre_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -38534,6 +39274,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -38558,8 +39300,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP post_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, cache_slot)) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { ZVAL_NULL(EX_VAR(opline->result.var)); } else { @@ -38572,7 +39320,10 @@ post_incdec_object: zend_post_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_post_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_post_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -38632,9 +39383,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CV_HAN /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -38653,17 +39406,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CV_HAN Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_r_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -38671,11 +39424,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CV_HAN } } } - } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_r_copy: @@ -38774,9 +39534,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CV_HA /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -38795,17 +39557,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CV_HA Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_is_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -38813,9 +39575,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CV_HA } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_is_copy: @@ -38870,6 +39638,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CV_OP_D USE_OPLINE zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -38894,8 +39664,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CV_OP_D } assign_object: + zobj = Z_OBJ_P(object); if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -38985,7 +39756,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -39003,6 +39784,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CV_OP_D USE_OPLINE zend_free_op free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -39027,8 +39810,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CV_OP_D } assign_object: + zobj = Z_OBJ_P(object); if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -39118,7 +39902,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -39136,6 +39930,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CV_OP_D USE_OPLINE zend_free_op free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -39160,8 +39956,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CV_OP_D } assign_object: + zobj = Z_OBJ_P(object); if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -39251,7 +40048,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -39269,6 +40076,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CV_OP_D USE_OPLINE zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = &EX(This); @@ -39293,8 +40102,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_UNUSED_CV_OP_D } assign_object: + zobj = Z_OBJ_P(object); if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -39384,7 +40194,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -39922,6 +40742,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_CV_HANDL zval *container; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = &EX(This); @@ -39941,7 +40762,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_UNUSED_CV_HANDL break; } } - Z_OBJ_HT_P(container)->unset_property(container, offset, ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + Z_OBJ_HT_P(container)->unset_property(Z_OBJ_P(container), name, ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } } while (0); @@ -39955,6 +40784,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UN zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = &EX(This); @@ -39979,9 +40809,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_UN } } + if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } isset_object_finish: @@ -41070,6 +41910,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPC USE_OPLINE zval *obj; + zend_object *zobj; zend_class_entry *ce, *scope; zend_function *clone; zend_object_clone_obj_t clone_call; @@ -41103,9 +41944,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPC } } while (0); - ce = Z_OBJCE_P(obj); + zobj = Z_OBJ_P(obj); + ce = zobj->ce; clone = ce->clone; - clone_call = Z_OBJ_HT_P(obj)->clone_obj; + clone_call = zobj->handlers->clone_obj; if (UNEXPECTED(clone_call == NULL)) { zend_throw_error(NULL, "Trying to clone an uncloneable object of class %s", ZSTR_VAL(ce->name)); @@ -41126,7 +41968,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPC } } - ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(obj)); + ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(zobj)); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -41310,20 +42152,24 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_CV_HANDLER(ZEN ZEND_VM_NEXT_OPCODE(); } else if (IS_CV != IS_CONST && EXPECTED(Z_TYPE_P(array_ptr) == IS_OBJECT)) { - if (!Z_OBJCE_P(array_ptr)->get_iterator) { + zend_object *zobj = Z_OBJ_P(array_ptr); + if (!zobj->ce->get_iterator) { result = EX_VAR(opline->result.var); - ZVAL_COPY_VALUE(result, array_ptr); + ZVAL_OBJ(result, zobj); if (IS_CV != IS_TMP_VAR) { - Z_ADDREF_P(array_ptr); + GC_ADDREF(zobj); } - if (Z_OBJ_P(array_ptr)->properties - && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(array_ptr)->properties) > 1)) { - if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(array_ptr)->properties) & IS_ARRAY_IMMUTABLE))) { - GC_DELREF(Z_OBJ_P(array_ptr)->properties); + if (zobj->properties) { + if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) { + if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) { + GC_DELREF(zobj->properties); + } + zobj->properties = zend_array_dup(zobj->properties); } - Z_OBJ_P(array_ptr)->properties = zend_array_dup(Z_OBJ_P(array_ptr)->properties); + } else { + zobj->properties = zobj->handlers->get_properties(zobj); } - Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(Z_OBJPROP_P(array_ptr), 0); + Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(zobj->properties, 0); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } else { @@ -42519,6 +43365,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(opline->op1.var EXECUTE_DATA_CC); @@ -42545,8 +43393,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP assign_op_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CONST == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((IS_CONST == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -42583,7 +43437,10 @@ assign_op_object: } } } else { - zend_assign_op_overloaded_property(object, property, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + zend_assign_op_overloaded_property(zobj, name, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -43163,6 +44020,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(opline->op1.var EXECUTE_DATA_CC); @@ -43187,8 +44046,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE pre_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -43202,7 +44067,10 @@ pre_incdec_object: zend_pre_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_pre_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_pre_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -43229,6 +44097,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(opline->op1.var EXECUTE_DATA_CC); @@ -43253,8 +44123,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP post_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, cache_slot)) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { ZVAL_NULL(EX_VAR(opline->result.var)); } else { @@ -43267,7 +44143,10 @@ post_incdec_object: zend_post_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_post_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_post_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -43557,9 +44436,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_C /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -43578,17 +44459,17 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_C Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_r_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -43596,11 +44477,18 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_C } } } - } else if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_r_copy: @@ -43699,9 +44587,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CONST_HAN /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -43720,17 +44610,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CONST_HAN Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_is_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -43738,9 +44628,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CONST_HAN } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_is_copy: @@ -43795,6 +44691,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CONST_OP_DA USE_OPLINE zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = EX_VAR(opline->op1.var); @@ -43819,8 +44717,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CONST_OP_DA } assign_object: + zobj = Z_OBJ_P(object); if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -43910,7 +44809,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -43928,6 +44837,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CONST_OP_DA USE_OPLINE zend_free_op free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = EX_VAR(opline->op1.var); @@ -43952,8 +44863,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CONST_OP_DA } assign_object: + zobj = Z_OBJ_P(object); if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -44043,7 +44955,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -44061,6 +44983,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CONST_OP_DA USE_OPLINE zend_free_op free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = EX_VAR(opline->op1.var); @@ -44085,8 +45009,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CONST_OP_DA } assign_object: + zobj = Z_OBJ_P(object); if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -44176,7 +45101,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -44194,6 +45129,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CONST_OP_DA USE_OPLINE zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = EX_VAR(opline->op1.var); @@ -44218,8 +45155,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CONST_OP_DA } assign_object: + zobj = Z_OBJ_P(object); if (IS_CONST == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -44309,7 +45247,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -45696,7 +46644,7 @@ num_index_dim: if (IS_CONST == IS_CONST && Z_EXTRA_P(offset) == ZEND_EXTRA_VALUE) { offset++; } - Z_OBJ_HT_P(container)->unset_dimension(container, offset); + Z_OBJ_HT_P(container)->unset_dimension(Z_OBJ_P(container), offset); } else if (IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) { zend_throw_error(NULL, "Cannot unset string offsets"); } @@ -45712,6 +46660,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_CONST_HANDLE zval *container; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_UNSET(opline->op1.var EXECUTE_DATA_CC); @@ -45731,7 +46680,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_CONST_HANDLE break; } } - Z_OBJ_HT_P(container)->unset_property(container, offset, ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + Z_OBJ_HT_P(container)->unset_property(Z_OBJ_P(container), name, ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } } while (0); @@ -45839,6 +46796,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_IS(opline->op1.var EXECUTE_DATA_CC); @@ -45863,9 +46821,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV } } + if (IS_CONST == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), ((IS_CONST == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if (IS_CONST != IS_CONST) { + zend_tmp_string_release(tmp_name); + } isset_object_finish: @@ -46977,6 +47945,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(opline->op1.var EXECUTE_DATA_CC); @@ -47003,8 +47973,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP assign_op_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -47041,7 +48017,10 @@ assign_op_object: } } } else { - zend_assign_op_overloaded_property(object, property, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + zend_assign_op_overloaded_property(zobj, name, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + } + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -47623,6 +48602,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(opline->op1.var EXECUTE_DATA_CC); @@ -47647,8 +48628,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE pre_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -47662,7 +48649,10 @@ pre_incdec_object: zend_pre_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_pre_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_pre_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -47690,6 +48680,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(opline->op1.var EXECUTE_DATA_CC); @@ -47714,8 +48706,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP post_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, cache_slot)) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { ZVAL_NULL(EX_VAR(opline->result.var)); } else { @@ -47728,7 +48726,10 @@ post_incdec_object: zend_post_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_post_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_post_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -47905,9 +48906,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_TMPVAR_HAN /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -47926,17 +48929,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_TMPVAR_HAN Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_r_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -47944,11 +48947,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_TMPVAR_HAN } } } - } else if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_r_copy: @@ -48047,9 +49057,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMPVAR_HA /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -48068,17 +49080,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMPVAR_HA Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_is_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -48086,9 +49098,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMPVAR_HA } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_is_copy: @@ -48143,6 +49161,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_TMPVAR_OP_D USE_OPLINE zend_free_op free_op2; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = EX_VAR(opline->op1.var); @@ -48167,8 +49187,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_TMPVAR_OP_D } assign_object: + zobj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -48258,7 +49279,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -48276,6 +49307,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_TMPVAR_OP_D USE_OPLINE zend_free_op free_op2, free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = EX_VAR(opline->op1.var); @@ -48300,8 +49333,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_TMPVAR_OP_D } assign_object: + zobj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -48391,7 +49425,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -48409,6 +49453,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_TMPVAR_OP_D USE_OPLINE zend_free_op free_op2, free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = EX_VAR(opline->op1.var); @@ -48433,8 +49479,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_TMPVAR_OP_D } assign_object: + zobj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -48524,7 +49571,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -48542,6 +49599,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_TMPVAR_OP_D USE_OPLINE zend_free_op free_op2; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = EX_VAR(opline->op1.var); @@ -48566,8 +49625,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_TMPVAR_OP_D } assign_object: + zobj = Z_OBJ_P(object); if ((IS_TMP_VAR|IS_VAR) == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -48657,7 +49717,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, ((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -49757,7 +50827,7 @@ num_index_dim: if ((IS_TMP_VAR|IS_VAR) == IS_CONST && Z_EXTRA_P(offset) == ZEND_EXTRA_VALUE) { offset++; } - Z_OBJ_HT_P(container)->unset_dimension(container, offset); + Z_OBJ_HT_P(container)->unset_dimension(Z_OBJ_P(container), offset); } else if (IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) { zend_throw_error(NULL, "Cannot unset string offsets"); } @@ -49774,6 +50844,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_TMPVAR_HANDL zend_free_op free_op2; zval *container; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_UNSET(opline->op1.var EXECUTE_DATA_CC); @@ -49793,7 +50864,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_TMPVAR_HANDL break; } } - Z_OBJ_HT_P(container)->unset_property(container, offset, (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + Z_OBJ_HT_P(container)->unset_property(Z_OBJ_P(container), name, (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } } while (0); zval_ptr_dtor_nogc(free_op2); @@ -49880,6 +50959,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_IS(opline->op1.var EXECUTE_DATA_CC); @@ -49904,9 +50984,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV } } + if ((IS_TMP_VAR|IS_VAR) == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if ((IS_TMP_VAR|IS_VAR) != IS_CONST) { + zend_tmp_string_release(tmp_name); + } isset_object_finish: zval_ptr_dtor_nogc(free_op2); @@ -52828,18 +53918,20 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z count = zend_array_count(Z_ARRVAL_P(op1)); break; } else if (Z_TYPE_P(op1) == IS_OBJECT) { + zend_object *zobj = Z_OBJ_P(op1); + /* first, we check if the handler is defined */ - if (Z_OBJ_HT_P(op1)->count_elements) { - if (SUCCESS == Z_OBJ_HT_P(op1)->count_elements(op1, &count)) { + if (zobj->handlers->count_elements) { + if (SUCCESS == zobj->handlers->count_elements(zobj, &count)) { break; } } /* if not and the object implements Countable we call its count() method */ - if (instanceof_function(Z_OBJCE_P(op1), zend_ce_countable)) { + if (instanceof_function(zobj->ce, zend_ce_countable)) { zval retval; - zend_call_method_with_0_params(op1, NULL, NULL, "count", &retval); + zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; @@ -53599,6 +54691,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(opline->op1.var EXECUTE_DATA_CC); @@ -53625,8 +54719,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_binary_assign_op_obj_helper_SP assign_op_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CV == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((IS_CV == IS_CONST) ? CACHE_ADDR((opline+1)->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -53663,7 +54763,10 @@ assign_op_object: } } } else { - zend_assign_op_overloaded_property(object, property, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + zend_assign_op_overloaded_property(zobj, name, cache_slot, value, binary_op OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -54101,6 +55204,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(opline->op1.var EXECUTE_DATA_CC); @@ -54125,8 +55230,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_incdec_property_helper_SPE pre_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL))) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_NULL(EX_VAR(opline->result.var)); @@ -54140,7 +55251,10 @@ pre_incdec_object: zend_pre_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_pre_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_pre_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -54167,6 +55281,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP zval *zptr; void **cache_slot; zend_property_info *prop_info; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = _get_zval_ptr_cv_BP_VAR_RW(opline->op1.var EXECUTE_DATA_CC); @@ -54191,8 +55307,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_post_incdec_property_helper_SP post_incdec_object: /* here we are sure we are dealing with an object */ + zobj = Z_OBJ_P(object); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } cache_slot = (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL; - if (EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, cache_slot)) != NULL)) { + if (EXPECTED((zptr = zobj->handlers->get_property_ptr_ptr(zobj, name, BP_VAR_RW, cache_slot)) != NULL)) { if (UNEXPECTED(Z_ISERROR_P(zptr))) { ZVAL_NULL(EX_VAR(opline->result.var)); } else { @@ -54205,7 +55327,10 @@ post_incdec_object: zend_post_incdec_property_zval(zptr, prop_info, inc OPLINE_CC EXECUTE_DATA_CC); } } else { - zend_post_incdec_overloaded_property(object, property, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + zend_post_incdec_overloaded_property(zobj, name, cache_slot, inc OPLINE_CC EXECUTE_DATA_CC); + } + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); } } while (0); @@ -54381,9 +55506,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CV_HANDLER /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_REF /* FUNC_ARG fetch may contain it */); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -54402,17 +55529,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CV_HANDLER Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_r_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -54420,11 +55547,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CV_HANDLER } } } - } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP2(); + } else { + if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(offset) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP2(); + } + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_r_copy: @@ -54523,9 +55657,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CV_HANDLE /* here we are sure we are dealing with an object */ do { zend_object *zobj = Z_OBJ_P(container); + zend_string *name, *tmp_name; zval *retval; if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); cache_slot = CACHE_ADDR(opline->extended_value); if (EXPECTED(zobj->ce == CACHED_PTR_EX(cache_slot))) { @@ -54544,17 +55680,17 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CV_HANDLE Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx); if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) && - (EXPECTED(p->key == Z_STR_P(offset)) || - (EXPECTED(p->h == ZSTR_H(Z_STR_P(offset))) && + (EXPECTED(p->key == name) || + (EXPECTED(p->h == ZSTR_H(name)) && EXPECTED(p->key != NULL) && - EXPECTED(zend_string_equal_content(p->key, Z_STR_P(offset)))))) { + EXPECTED(zend_string_equal_content(p->key, name))))) { retval = &p->val; goto fetch_obj_is_copy; } } CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET); } - retval = zend_hash_find_ex(zobj->properties, Z_STR_P(offset), 1); + retval = zend_hash_find_ex(zobj->properties, name, 1); if (EXPECTED(retval)) { uintptr_t idx = (char*)retval - (char*)zobj->properties->arData; CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx)); @@ -54562,9 +55698,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CV_HANDLE } } } + } else { + name = zval_get_tmp_string(offset, &tmp_name); } - retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, EX_VAR(opline->result.var)); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (retval != EX_VAR(opline->result.var)) { fetch_obj_is_copy: @@ -54619,6 +55761,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CV_OP_DATA_ USE_OPLINE zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = EX_VAR(opline->op1.var); @@ -54643,8 +55787,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CV_OP_DATA_ } assign_object: + zobj = Z_OBJ_P(object); if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -54734,7 +55879,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -54752,6 +55907,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CV_OP_DATA_ USE_OPLINE zend_free_op free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = EX_VAR(opline->op1.var); @@ -54776,8 +55933,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CV_OP_DATA_ } assign_object: + zobj = Z_OBJ_P(object); if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -54867,7 +56025,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -54885,6 +56053,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CV_OP_DATA_ USE_OPLINE zend_free_op free_op_data; zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = EX_VAR(opline->op1.var); @@ -54909,8 +56079,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CV_OP_DATA_ } assign_object: + zobj = Z_OBJ_P(object); if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -55000,7 +56171,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -55018,6 +56199,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CV_OP_DATA_ USE_OPLINE zval *object, *property, *value, tmp; + zend_object *zobj; + zend_string *name, *tmp_name; SAVE_OPLINE(); object = EX_VAR(opline->op1.var); @@ -55042,8 +56225,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ASSIGN_OBJ_SPEC_CV_CV_OP_DATA_ } assign_object: + zobj = Z_OBJ_P(object); if (IS_CV == IS_CONST && - EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(opline->extended_value))) { + EXPECTED(zobj->ce == CACHED_PTR(opline->extended_value))) { void **cache_slot = CACHE_ADDR(opline->extended_value); uintptr_t prop_offset = (uintptr_t)CACHED_PTR_EX(cache_slot + 1); zend_object *zobj = Z_OBJ_P(object); @@ -55133,7 +56317,17 @@ fast_assign_obj: ZVAL_DEREF(value); } - property = Z_OBJ_HT_P(object)->write_property(object, property, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + if (IS_CV == IS_CONST) { + name = Z_STR_P(property); + } else { + name = zval_get_tmp_string(property, &tmp_name); + } + + property = zobj->handlers->write_property(zobj, name, value, (IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), property); @@ -56328,7 +57522,7 @@ num_index_dim: if (IS_CV == IS_CONST && Z_EXTRA_P(offset) == ZEND_EXTRA_VALUE) { offset++; } - Z_OBJ_HT_P(container)->unset_dimension(container, offset); + Z_OBJ_HT_P(container)->unset_dimension(Z_OBJ_P(container), offset); } else if (IS_CV != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) { zend_throw_error(NULL, "Cannot unset string offsets"); } @@ -56344,6 +57538,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_CV_HANDLER(Z zval *container; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_UNSET(opline->op1.var EXECUTE_DATA_CC); @@ -56363,7 +57558,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_OBJ_SPEC_CV_CV_HANDLER(Z break; } } - Z_OBJ_HT_P(container)->unset_property(container, offset, ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + Z_OBJ_HT_P(container)->unset_property(Z_OBJ_P(container), name, ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value) : NULL)); + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } } while (0); @@ -56449,6 +57652,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV zval *container; int result; zval *offset; + zend_string *name, *tmp_name; SAVE_OPLINE(); container = _get_zval_ptr_cv_BP_VAR_IS(opline->op1.var EXECUTE_DATA_CC); @@ -56473,9 +57677,19 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV } } + if (IS_CV == IS_CONST) { + name = Z_STR_P(offset); + } else { + name = zval_get_tmp_string(offset, &tmp_name); + } + result = (opline->extended_value & ZEND_ISEMPTY) ^ - Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISEMPTY), ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + Z_OBJ_HT_P(container)->has_property(Z_OBJ_P(container), name, (opline->extended_value & ZEND_ISEMPTY), ((IS_CV == IS_CONST) ? CACHE_ADDR(opline->extended_value & ~ZEND_ISEMPTY) : NULL)); + + if (IS_CV != IS_CONST) { + zend_tmp_string_release(tmp_name); + } isset_object_finish: diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index cd37718430..f542bafb60 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -461,7 +461,7 @@ static int com_objects_compare(zval *object1, zval *object2) return ret; } -static int com_object_cast(zval *readobj, zval *writeobj, int type) +static int com_object_cast(zend_object *readobj, zval *writeobj, int type) { php_com_dotnet_object *obj; VARIANT v; diff --git a/ext/date/php_date.c b/ext/date/php_date.c index eb0ef5dc60..0c1ad6da70 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -642,28 +642,28 @@ static zend_object *date_object_new_timezone(zend_class_entry *class_type); static zend_object *date_object_new_interval(zend_class_entry *class_type); static zend_object *date_object_new_period(zend_class_entry *class_type); -static zend_object *date_object_clone_date(zval *this_ptr); -static zend_object *date_object_clone_timezone(zval *this_ptr); -static zend_object *date_object_clone_interval(zval *this_ptr); -static zend_object *date_object_clone_period(zval *this_ptr); +static zend_object *date_object_clone_date(zend_object *this_ptr); +static zend_object *date_object_clone_timezone(zend_object *this_ptr); +static zend_object *date_object_clone_interval(zend_object *this_ptr); +static zend_object *date_object_clone_period(zend_object *this_ptr); static int date_object_compare_date(zval *d1, zval *d2); -static HashTable *date_object_get_gc(zval *object, zval **table, int *n); -static HashTable *date_object_get_properties_for(zval *object, zend_prop_purpose purpose); -static HashTable *date_object_get_gc_interval(zval *object, zval **table, int *n); -static HashTable *date_object_get_properties_interval(zval *object); -static HashTable *date_object_get_gc_period(zval *object, zval **table, int *n); -static HashTable *date_object_get_properties_period(zval *object); -static HashTable *date_object_get_properties_for_timezone(zval *object, zend_prop_purpose purpose); -static HashTable *date_object_get_gc_timezone(zval *object, zval **table, int *n); -static HashTable *date_object_get_debug_info_timezone(zval *object, int *is_temp); +static HashTable *date_object_get_gc(zend_object *object, zval **table, int *n); +static HashTable *date_object_get_properties_for(zend_object *object, zend_prop_purpose purpose); +static HashTable *date_object_get_gc_interval(zend_object *object, zval **table, int *n); +static HashTable *date_object_get_properties_interval(zend_object *object); +static HashTable *date_object_get_gc_period(zend_object *object, zval **table, int *n); +static HashTable *date_object_get_properties_period(zend_object *object); +static HashTable *date_object_get_properties_for_timezone(zend_object *object, zend_prop_purpose purpose); +static HashTable *date_object_get_gc_timezone(zend_object *object, zval **table, int *n); +static HashTable *date_object_get_debug_info_timezone(zend_object *object, int *is_temp); static void php_timezone_to_string(php_timezone_obj *tzobj, zval *zv); -zval *date_interval_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv); -zval *date_interval_write_property(zval *object, zval *member, zval *value, void **cache_slot); -static zval *date_interval_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot); -static zval *date_period_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv); -static zval *date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot); +zval *date_interval_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv); +zval *date_interval_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot); +static zval *date_interval_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot); +static zval *date_period_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv); +static zval *date_period_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot); /* {{{ Module struct */ zend_module_entry date_module_entry = { @@ -2022,31 +2022,21 @@ static int implement_date_interface_handler(zend_class_entry *interface, zend_cl return SUCCESS; } /* }}} */ -static int date_interval_has_property(zval *object, zval *member, int type, void **cache_slot) /* {{{ */ +static int date_interval_has_property(zend_object *object, zend_string *name, int type, void **cache_slot) /* {{{ */ { php_interval_obj *obj; - zval tmp_member; zval rv; zval *prop; int retval = 0; - if (UNEXPECTED(Z_TYPE_P(member) != IS_STRING)) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - cache_slot = NULL; - } - - obj = Z_PHPINTERVAL_P(object); + obj = php_interval_obj_from_obj(object); if (!obj->initialized) { - retval = zend_std_has_property(object, member, type, cache_slot); - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } + retval = zend_std_has_property(object, name, type, cache_slot); return retval; } - prop = date_interval_read_property(object, member, BP_VAR_IS, cache_slot, &rv); + prop = date_interval_read_property(object, name, BP_VAR_IS, cache_slot, &rv); if (prop != &EG(uninitialized_zval)) { if (type == 2) { @@ -2057,11 +2047,7 @@ static int date_interval_has_property(zval *object, zval *member, int type, void retval = (Z_TYPE_P(prop) != IS_NULL); } } else { - retval = zend_std_has_property(object, member, type, cache_slot); - } - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); + retval = zend_std_has_property(object, name, type, cache_slot); } return retval; @@ -2191,9 +2177,9 @@ static zend_object *date_object_new_date(zend_class_entry *class_type) /* {{{ */ return &intern->std; } /* }}} */ -static zend_object *date_object_clone_date(zval *this_ptr) /* {{{ */ +static zend_object *date_object_clone_date(zend_object *this_ptr) /* {{{ */ { - php_date_obj *old_obj = Z_PHPDATE_P(this_ptr); + php_date_obj *old_obj = php_date_obj_from_obj(this_ptr); php_date_obj *new_obj = php_date_obj_from_obj(date_object_new_date(old_obj->std.ce)); zend_objects_clone_members(&new_obj->std, &old_obj->std); @@ -2216,7 +2202,7 @@ static zend_object *date_object_clone_date(zval *this_ptr) /* {{{ */ static void date_clone_immutable(zval *object, zval *new_object) /* {{{ */ { - ZVAL_OBJ(new_object, date_object_clone_date(object)); + ZVAL_OBJ(new_object, date_object_clone_date(Z_OBJ_P(object))); } /* }}} */ static int date_object_compare_date(zval *d1, zval *d2) /* {{{ */ @@ -2238,21 +2224,21 @@ static int date_object_compare_date(zval *d1, zval *d2) /* {{{ */ return timelib_time_compare(o1->time, o2->time); } /* }}} */ -static HashTable *date_object_get_gc(zval *object, zval **table, int *n) /* {{{ */ +static HashTable *date_object_get_gc(zend_object *object, zval **table, int *n) /* {{{ */ { *table = NULL; *n = 0; return zend_std_get_properties(object); } /* }}} */ -static HashTable *date_object_get_gc_timezone(zval *object, zval **table, int *n) /* {{{ */ +static HashTable *date_object_get_gc_timezone(zend_object *object, zval **table, int *n) /* {{{ */ { *table = NULL; *n = 0; return zend_std_get_properties(object); } /* }}} */ -static HashTable *date_object_get_properties_for(zval *object, zend_prop_purpose purpose) /* {{{ */ +static HashTable *date_object_get_properties_for(zend_object *object, zend_prop_purpose purpose) /* {{{ */ { HashTable *props; zval zv; @@ -2268,7 +2254,7 @@ static HashTable *date_object_get_properties_for(zval *object, zend_prop_purpose return zend_std_get_properties_for(object, purpose); } - dateobj = Z_PHPDATE_P(object); + dateobj = php_date_obj_from_obj(object); props = zend_array_dup(zend_std_get_properties(object)); if (!dateobj->time) { return props; @@ -2320,9 +2306,9 @@ static zend_object *date_object_new_timezone(zend_class_entry *class_type) /* {{ return &intern->std; } /* }}} */ -static zend_object *date_object_clone_timezone(zval *this_ptr) /* {{{ */ +static zend_object *date_object_clone_timezone(zend_object *this_ptr) /* {{{ */ { - php_timezone_obj *old_obj = Z_PHPTIMEZONE_P(this_ptr); + php_timezone_obj *old_obj = php_timezone_obj_from_obj(this_ptr); php_timezone_obj *new_obj = php_timezone_obj_from_obj(date_object_new_timezone(old_obj->std.ce)); zend_objects_clone_members(&new_obj->std, &old_obj->std); @@ -2373,7 +2359,7 @@ static void php_timezone_to_string(php_timezone_obj *tzobj, zval *zv) } } -static HashTable *date_object_get_properties_for_timezone(zval *object, zend_prop_purpose purpose) /* {{{ */ +static HashTable *date_object_get_properties_for_timezone(zend_object *object, zend_prop_purpose purpose) /* {{{ */ { HashTable *props; zval zv; @@ -2389,7 +2375,7 @@ static HashTable *date_object_get_properties_for_timezone(zval *object, zend_pro return zend_std_get_properties_for(object, purpose); } - tzobj = Z_PHPTIMEZONE_P(object); + tzobj = php_timezone_obj_from_obj(object); props = zend_array_dup(zend_std_get_properties(object)); if (!tzobj->initialized) { return props; @@ -2404,13 +2390,13 @@ static HashTable *date_object_get_properties_for_timezone(zval *object, zend_pro return props; } /* }}} */ -static HashTable *date_object_get_debug_info_timezone(zval *object, int *is_temp) /* {{{ */ +static HashTable *date_object_get_debug_info_timezone(zend_object *object, int *is_temp) /* {{{ */ { HashTable *ht, *props; zval zv; php_timezone_obj *tzobj; - tzobj = Z_PHPTIMEZONE_P(object); + tzobj = php_timezone_obj_from_obj(object); props = zend_std_get_properties(object); *is_temp = 1; @@ -2436,9 +2422,9 @@ static zend_object *date_object_new_interval(zend_class_entry *class_type) /* {{ return &intern->std; } /* }}} */ -static zend_object *date_object_clone_interval(zval *this_ptr) /* {{{ */ +static zend_object *date_object_clone_interval(zend_object *this_ptr) /* {{{ */ { - php_interval_obj *old_obj = Z_PHPINTERVAL_P(this_ptr); + php_interval_obj *old_obj = php_interval_obj_from_obj(this_ptr); php_interval_obj *new_obj = php_interval_obj_from_obj(date_object_new_interval(old_obj->std.ce)); zend_objects_clone_members(&new_obj->std, &old_obj->std); @@ -2450,7 +2436,7 @@ static zend_object *date_object_clone_interval(zval *this_ptr) /* {{{ */ return &new_obj->std; } /* }}} */ -static HashTable *date_object_get_gc_interval(zval *object, zval **table, int *n) /* {{{ */ +static HashTable *date_object_get_gc_interval(zend_object *object, zval **table, int *n) /* {{{ */ { *table = NULL; @@ -2458,13 +2444,13 @@ static HashTable *date_object_get_gc_interval(zval *object, zval **table, int *n return zend_std_get_properties(object); } /* }}} */ -static HashTable *date_object_get_properties_interval(zval *object) /* {{{ */ +static HashTable *date_object_get_properties_interval(zend_object *object) /* {{{ */ { HashTable *props; zval zv; php_interval_obj *intervalobj; - intervalobj = Z_PHPINTERVAL_P(object); + intervalobj = php_interval_obj_from_obj(object); props = zend_std_get_properties(object); if (!intervalobj->initialized) { return props; @@ -2512,9 +2498,9 @@ static zend_object *date_object_new_period(zend_class_entry *class_type) /* {{{ return &intern->std; } /* }}} */ -static zend_object *date_object_clone_period(zval *this_ptr) /* {{{ */ +static zend_object *date_object_clone_period(zend_object *this_ptr) /* {{{ */ { - php_period_obj *old_obj = Z_PHPPERIOD_P(this_ptr); + php_period_obj *old_obj = php_period_obj_from_obj(this_ptr); php_period_obj *new_obj = php_period_obj_from_obj(date_object_new_period(old_obj->std.ce)); zend_objects_clone_members(&new_obj->std, &old_obj->std); @@ -4137,34 +4123,24 @@ static int date_interval_initialize(timelib_rel_time **rt, /*const*/ char *forma } /* }}} */ /* {{{ date_interval_read_property */ -zval *date_interval_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +zval *date_interval_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { php_interval_obj *obj; zval *retval; - zval tmp_member; timelib_sll value = -1; double fvalue = -1; - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - cache_slot = NULL; - } - - obj = Z_PHPINTERVAL_P(object); + obj = php_interval_obj_from_obj(object); if (!obj->initialized) { - retval = zend_std_read_property(object, member, type, cache_slot, rv); - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } + retval = zend_std_read_property(object, name, type, cache_slot, rv); return retval; } #define GET_VALUE_FROM_STRUCT(n,m) \ - if (strcmp(Z_STRVAL_P(member), m) == 0) { \ - value = obj->diff->n; \ - break; \ + if (strcmp(ZSTR_VAL(name), m) == 0) { \ + value = obj->diff->n; \ + break; \ } do { GET_VALUE_FROM_STRUCT(y, "y"); @@ -4173,18 +4149,14 @@ zval *date_interval_read_property(zval *object, zval *member, int type, void **c GET_VALUE_FROM_STRUCT(h, "h"); GET_VALUE_FROM_STRUCT(i, "i"); GET_VALUE_FROM_STRUCT(s, "s"); - if (strcmp(Z_STRVAL_P(member), "f") == 0) { + if (strcmp(ZSTR_VAL(name), "f") == 0) { fvalue = obj->diff->us / 1000000.0; break; } GET_VALUE_FROM_STRUCT(invert, "invert"); GET_VALUE_FROM_STRUCT(days, "days"); /* didn't find any */ - retval = zend_std_read_property(object, member, type, cache_slot, rv); - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } + retval = zend_std_read_property(object, name, type, cache_slot, rv); return retval; } while(0); @@ -4199,38 +4171,23 @@ zval *date_interval_read_property(zval *object, zval *member, int type, void **c ZVAL_FALSE(retval); } - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } - return retval; } /* }}} */ /* {{{ date_interval_write_property */ -zval *date_interval_write_property(zval *object, zval *member, zval *value, void **cache_slot) +zval *date_interval_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { php_interval_obj *obj; - zval tmp_member; - - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - cache_slot = NULL; - } - obj = Z_PHPINTERVAL_P(object); + obj = php_interval_obj_from_obj(object); if (!obj->initialized) { - value = zend_std_write_property(object, member, value, cache_slot); - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } - return value; + return zend_std_write_property(object, name, value, cache_slot); } -#define SET_VALUE_FROM_STRUCT(n,m) \ - if (strcmp(Z_STRVAL_P(member), m) == 0) { \ +#define SET_VALUE_FROM_STRUCT(n,m) \ + if (strcmp(ZSTR_VAL(name), m) == 0) { \ obj->diff->n = zval_get_long(value); \ break; \ } @@ -4242,51 +4199,37 @@ zval *date_interval_write_property(zval *object, zval *member, zval *value, void SET_VALUE_FROM_STRUCT(h, "h"); SET_VALUE_FROM_STRUCT(i, "i"); SET_VALUE_FROM_STRUCT(s, "s"); - if (strcmp(Z_STRVAL_P(member), "f") == 0) { + if (strcmp(ZSTR_VAL(name), "f") == 0) { obj->diff->us = zval_get_double(value) * 1000000; break; } SET_VALUE_FROM_STRUCT(invert, "invert"); /* didn't find any */ - value = zend_std_write_property(object, member, value, cache_slot); + value = zend_std_write_property(object, name, value, cache_slot); } while(0); - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } - return value; } /* }}} */ /* {{{ date_interval_get_property_ptr_ptr */ -static zval *date_interval_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) -{ - zval tmp_member, *ret; - - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - cache_slot = NULL; - } - - if(zend_binary_strcmp("y", sizeof("y") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("m", sizeof("m") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("d", sizeof("d") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("h", sizeof("h") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("i", sizeof("i") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("s", sizeof("s") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("f", sizeof("f") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("days", sizeof("days") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0 || - zend_binary_strcmp("invert", sizeof("invert") - 1, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) { +static zval *date_interval_get_property_ptr_ptr(zend_object *object, zend_string *name, int type, void **cache_slot) +{ + zval *ret; + + if(zend_binary_strcmp("y", sizeof("y") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("m", sizeof("m") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("d", sizeof("d") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("h", sizeof("h") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("i", sizeof("i") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("s", sizeof("s") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("f", sizeof("f") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("days", sizeof("days") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0 || + zend_binary_strcmp("invert", sizeof("invert") - 1, ZSTR_VAL(name), ZSTR_LEN(name)) == 0) { /* Fallback to read_property. */ ret = NULL; } else { - ret = zend_std_get_property_ptr_ptr(object, member, type, cache_slot); - } - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); + ret = zend_std_get_property_ptr_ptr(object, name, type, cache_slot); } return ret; @@ -5082,20 +5025,20 @@ PHP_FUNCTION(date_sun_info) } /* }}} */ -static HashTable *date_object_get_gc_period(zval *object, zval **table, int *n) /* {{{ */ +static HashTable *date_object_get_gc_period(zend_object *object, zval **table, int *n) /* {{{ */ { *table = NULL; *n = 0; return zend_std_get_properties(object); } /* }}} */ -static HashTable *date_object_get_properties_period(zval *object) /* {{{ */ +static HashTable *date_object_get_properties_period(zend_object *object) /* {{{ */ { HashTable *props; zval zv; php_period_obj *period_obj; - period_obj = Z_PHPPERIOD_P(object); + period_obj = php_period_obj_from_obj(object); props = zend_std_get_properties(object); if (!period_obj->start) { return props; @@ -5273,7 +5216,7 @@ PHP_METHOD(DatePeriod, __wakeup) /* }}} */ /* {{{ date_period_read_property */ -static zval *date_period_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +static zval *date_period_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { zval *zv; if (type != BP_VAR_IS && type != BP_VAR_R) { @@ -5281,12 +5224,12 @@ static zval *date_period_read_property(zval *object, zval *member, int type, voi return &EG(uninitialized_zval); } - Z_OBJPROP_P(object); /* build properties hash table */ + object->handlers->get_properties(object); /* build properties hash table */ - zv = zend_std_read_property(object, member, type, cache_slot, rv); + zv = zend_std_read_property(object, name, type, cache_slot, rv); if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJ_HANDLER_P(zv, clone_obj)) { /* defensive copy */ - ZVAL_OBJ(zv, Z_OBJ_HANDLER_P(zv, clone_obj)(zv)); + ZVAL_OBJ(zv, Z_OBJ_HANDLER_P(zv, clone_obj)(Z_OBJ_P(zv))); } return zv; @@ -5294,7 +5237,7 @@ static zval *date_period_read_property(zval *object, zval *member, int type, voi /* }}} */ /* {{{ date_period_write_property */ -static zval *date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot) +static zval *date_period_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { zend_throw_error(NULL, "Writing to DatePeriod properties is unsupported"); return value; diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 726b74b934..1a3689926b 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -310,31 +310,27 @@ static void dom_register_prop_handler(HashTable *prop_handler, char *name, size_ } /* }}} */ -static zval *dom_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */ +static zval *dom_get_property_ptr_ptr(zend_object *object, zend_string *name, int type, void **cache_slot) /* {{{ */ { - dom_object *obj = Z_DOMOBJ_P(object); - zend_string *member_str = zval_get_string(member); + dom_object *obj = php_dom_obj_from_obj(object); zval *retval = NULL; - if (!obj->prop_handler || !zend_hash_exists(obj->prop_handler, member_str)) { - retval = zend_std_get_property_ptr_ptr(object, member, type, cache_slot); + if (!obj->prop_handler || !zend_hash_exists(obj->prop_handler, name)) { + retval = zend_std_get_property_ptr_ptr(object, name, type, cache_slot); } - - zend_string_release_ex(member_str, 0); return retval; } /* }}} */ /* {{{ dom_read_property */ -zval *dom_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +zval *dom_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { - dom_object *obj = Z_DOMOBJ_P(object); - zend_string *member_str = zval_get_string(member); + dom_object *obj = php_dom_obj_from_obj(object); zval *retval; dom_prop_handler *hnd = NULL; if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, member_str); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } else if (instanceof_function(obj->std.ce, dom_node_class_entry)) { php_error(E_WARNING, "Couldn't fetch %s. Node no longer exists", ZSTR_VAL(obj->std.ce->name)); } @@ -347,46 +343,41 @@ zval *dom_read_property(zval *object, zval *member, int type, void **cache_slot, retval = &EG(uninitialized_zval); } } else { - retval = zend_std_read_property(object, member, type, cache_slot, rv); + retval = zend_std_read_property(object, name, type, cache_slot, rv); } - zend_string_release_ex(member_str, 0); return retval; } /* }}} */ /* {{{ dom_write_property */ -zval *dom_write_property(zval *object, zval *member, zval *value, void **cache_slot) +zval *dom_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { - dom_object *obj = Z_DOMOBJ_P(object); - zend_string *member_str = zval_get_string(member); + dom_object *obj = php_dom_obj_from_obj(object); dom_prop_handler *hnd = NULL; if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, member_str); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd) { hnd->write_func(obj, value); } else { - value = zend_std_write_property(object, member, value, cache_slot); + value = zend_std_write_property(object, name, value, cache_slot); } - zend_string_release_ex(member_str, 0); - return value; } /* }}} */ /* {{{ dom_property_exists */ -static int dom_property_exists(zval *object, zval *member, int check_empty, void **cache_slot) +static int dom_property_exists(zend_object *object, zend_string *name, int check_empty, void **cache_slot) { - dom_object *obj = Z_DOMOBJ_P(object); - zend_string *member_str = zval_get_string(member); + dom_object *obj = php_dom_obj_from_obj(object); dom_prop_handler *hnd = NULL; int retval = 0; if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, member_str); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd) { zval tmp; @@ -402,17 +393,16 @@ static int dom_property_exists(zval *object, zval *member, int check_empty, void zval_ptr_dtor(&tmp); } } else { - retval = zend_std_has_property(object, member, check_empty, cache_slot); + retval = zend_std_has_property(object, name, check_empty, cache_slot); } - zend_string_release_ex(member_str, 0); return retval; } /* }}} */ -static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp) /* {{{ */ +static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /* {{{ */ { - dom_object *obj = Z_DOMOBJ_P(object); + dom_object *obj = php_dom_obj_from_obj(object); HashTable *debug_info, *prop_handlers = obj->prop_handler, *std_props; @@ -453,7 +443,7 @@ static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp) /* {{{ * } /* }}} */ -static HashTable* dom_get_debug_info(zval *object, int *is_temp) /* {{{ */ +static HashTable* dom_get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { return dom_get_debug_info_helper(object, is_temp); } @@ -500,9 +490,9 @@ PHP_FUNCTION(dom_import_simplexml) static dom_object* dom_objects_set_class(zend_class_entry *class_type); -static zend_object *dom_objects_store_clone_obj(zval *zobject) /* {{{ */ +static zend_object *dom_objects_store_clone_obj(zend_object *zobject) /* {{{ */ { - dom_object *intern = Z_DOMOBJ_P(zobject); + dom_object *intern = php_dom_obj_from_obj(zobject); dom_object *clone = dom_objects_set_class(intern->std.ce); clone->std.handlers = dom_get_obj_handlers(); @@ -583,7 +573,9 @@ ZEND_GET_MODULE(dom) void dom_objects_free_storage(zend_object *object); void dom_nnodemap_objects_free_storage(zend_object *object); -static zend_object *dom_objects_store_clone_obj(zval *zobject); +static zval *dom_nodelist_read_dimension(zend_object *object, zval *offset, int type, zval *rv); +static int dom_nodelist_has_dimension(zend_object *object, zval *member, int check_empty); +static zend_object *dom_objects_store_clone_obj(zend_object *zobject); static void dom_nnodemap_object_dtor(zend_object *object); #if defined(LIBXML_XPATH_ENABLED) void dom_xpath_objects_free_storage(zend_object *object); @@ -1530,7 +1522,7 @@ xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName) { } /* }}} end dom_get_nsdecl */ -zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type, zval *rv) /* {{{ */ +static zval *dom_nodelist_read_dimension(zend_object *object, zval *offset, int type, zval *rv) /* {{{ */ { zval offset_copy; @@ -1540,12 +1532,12 @@ zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type, zval *rv ZVAL_LONG(&offset_copy, zval_get_long(offset)); - zend_call_method_with_1_params(object, Z_OBJCE_P(object), NULL, "item", rv, &offset_copy); + zend_call_method_with_1_params(object, object->ce, NULL, "item", rv, &offset_copy); return rv; } /* }}} end dom_nodelist_read_dimension */ -int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty) +static int dom_nodelist_has_dimension(zend_object *object, zval *member, int check_empty) { zend_long offset = zval_get_long(member); zval rv; @@ -1553,8 +1545,11 @@ int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty) if (offset < 0) { return 0; } else { - zval *length = zend_read_property(Z_OBJCE_P(object), object, "length", sizeof("length") - 1, 0, &rv); + zval obj; + zval *length; + ZVAL_OBJ(&obj, object); + length = zend_read_property(object->ce, &obj, "length", sizeof("length") - 1, 0, &rv); return length && offset < Z_LVAL_P(length); } } /* }}} end dom_nodelist_has_dimension */ diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h index ce377b5ce7..c3b24c8691 100644 --- a/ext/dom/php_dom.h +++ b/ext/dom/php_dom.h @@ -125,8 +125,6 @@ xmlNode *php_dom_libxml_hash_iter(xmlHashTable *ht, int index); xmlNode *php_dom_libxml_notation_iter(xmlHashTable *ht, int index); zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, int by_ref); void dom_set_doc_classmap(php_libxml_ref_obj *document, zend_class_entry *basece, zend_class_entry *ce); -zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type, zval *rv); -int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty); #define REGISTER_DOM_CLASS(ce, name, parent_ce, funcs, entry) \ INIT_CLASS_ENTRY(ce, name, funcs); \ diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 1a8f866520..715628b5e5 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -880,9 +880,9 @@ static void *zend_ffi_create_callback(zend_ffi_type *type, zval *value) /* {{{ * /* }}} */ #endif -static zval* zend_ffi_cdata_get(zval *object, zval *rv) /* {{{ */ +static zval* zend_ffi_cdata_get(zend_object *obj, zval *rv) /* {{{ */ { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(object); + zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj; zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); #if 0 @@ -897,9 +897,9 @@ static zval* zend_ffi_cdata_get(zval *object, zval *rv) /* {{{ */ } /* }}} */ -static void zend_ffi_cdata_set(zval *object, zval *value) /* {{{ */ +static void zend_ffi_cdata_set(zend_object *obj, zval *value) /* {{{ */ { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(object); + zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj; zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); #if 0 @@ -913,15 +913,15 @@ static void zend_ffi_cdata_set(zval *object, zval *value) /* {{{ */ } /* }}} */ -static int zend_ffi_cdata_cast_object(zval *readobj, zval *writeobj, int type) /* {{{ */ +static int zend_ffi_cdata_cast_object(zend_object *readobj, zval *writeobj, int type) /* {{{ */ { return FAILURE; } /* }}} */ -static zval *zend_ffi_cdata_read_field(zval *object, zval *member, int read_type, void **cache_slot, zval *rv) /* {{{ */ +static zval *zend_ffi_cdata_read_field(zend_object *obj, zend_string *field_name, int read_type, void **cache_slot, zval *rv) /* {{{ */ { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(object); + zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj; zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); void *ptr = cdata->ptr; zend_ffi_field *field; @@ -929,28 +929,22 @@ static zval *zend_ffi_cdata_read_field(zval *object, zval *member, int read_type if (cache_slot && *cache_slot == type) { field = *(cache_slot + 1); } else { - zend_string *tmp_field_name; - zend_string *field_name = zval_get_tmp_string(member, &tmp_field_name); - if (UNEXPECTED(type->kind != ZEND_FFI_TYPE_STRUCT)) { if (type->kind == ZEND_FFI_TYPE_POINTER) { /* transparently dereference the pointer */ if (UNEXPECTED(!ptr)) { zend_throw_error(zend_ffi_exception_ce, "NULL pointer dereference"); - zend_tmp_string_release(tmp_field_name); return &EG(uninitialized_zval); } ptr = (void*)(*(char**)ptr); if (UNEXPECTED(!ptr)) { zend_throw_error(zend_ffi_exception_ce, "NULL pointer dereference"); - zend_tmp_string_release(tmp_field_name); return &EG(uninitialized_zval); } type = ZEND_FFI_TYPE(type->pointer.type); } if (UNEXPECTED(type->kind != ZEND_FFI_TYPE_STRUCT)) { zend_throw_error(zend_ffi_exception_ce, "Attempt to read field '%s' of non C struct/union", ZSTR_VAL(field_name)); - zend_tmp_string_release(tmp_field_name); return &EG(uninitialized_zval); } } @@ -958,12 +952,9 @@ static zval *zend_ffi_cdata_read_field(zval *object, zval *member, int read_type field = zend_hash_find_ptr(&type->record.fields, field_name); if (UNEXPECTED(!field)) { zend_throw_error(zend_ffi_exception_ce, "Attempt to read undefined field '%s' of C struct/union", ZSTR_VAL(field_name)); - zend_tmp_string_release(tmp_field_name); return &EG(uninitialized_zval); } - zend_tmp_string_release(tmp_field_name); - if (cache_slot) { *cache_slot = type; *(cache_slot + 1) = field; @@ -997,9 +988,9 @@ static zval *zend_ffi_cdata_read_field(zval *object, zval *member, int read_type } /* }}} */ -static zval *zend_ffi_cdata_write_field(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */ +static zval *zend_ffi_cdata_write_field(zend_object *obj, zend_string *field_name, zval *value, void **cache_slot) /* {{{ */ { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(object); + zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj; zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); void *ptr = cdata->ptr; zend_ffi_field *field; @@ -1007,28 +998,22 @@ static zval *zend_ffi_cdata_write_field(zval *object, zval *member, zval *value, if (cache_slot && *cache_slot == type) { field = *(cache_slot + 1); } else { - zend_string *tmp_field_name; - zend_string *field_name = zval_get_tmp_string(member, &tmp_field_name); - if (UNEXPECTED(type->kind != ZEND_FFI_TYPE_STRUCT)) { if (type->kind == ZEND_FFI_TYPE_POINTER) { /* transparently dereference the pointer */ if (UNEXPECTED(!ptr)) { zend_throw_error(zend_ffi_exception_ce, "NULL pointer dereference"); - zend_tmp_string_release(tmp_field_name); return value; } ptr = (void*)(*(char**)ptr); if (UNEXPECTED(!ptr)) { zend_throw_error(zend_ffi_exception_ce, "NULL pointer dereference"); - zend_tmp_string_release(tmp_field_name); return value; } type = ZEND_FFI_TYPE(type->pointer.type); } if (UNEXPECTED(type->kind != ZEND_FFI_TYPE_STRUCT)) { zend_throw_error(zend_ffi_exception_ce, "Attempt to assign field '%s' of non C struct/union", ZSTR_VAL(field_name)); - zend_tmp_string_release(tmp_field_name); return value; } } @@ -1036,12 +1021,9 @@ static zval *zend_ffi_cdata_write_field(zval *object, zval *member, zval *value, field = zend_hash_find_ptr(&type->record.fields, field_name); if (UNEXPECTED(!field)) { zend_throw_error(zend_ffi_exception_ce, "Attempt to assign undefined field '%s' of C struct/union", ZSTR_VAL(field_name)); - zend_tmp_string_release(tmp_field_name); return value; } - zend_tmp_string_release(tmp_field_name); - if (cache_slot) { *cache_slot = type; *(cache_slot + 1) = field; @@ -1059,10 +1041,7 @@ static zval *zend_ffi_cdata_write_field(zval *object, zval *member, zval *value, zend_throw_error(zend_ffi_exception_ce, "Attempt to assign read-only location"); return value; } else if (UNEXPECTED(field->is_const)) { - zend_string *tmp_field_name; - zend_string *field_name = zval_get_tmp_string(member, &tmp_field_name); zend_throw_error(zend_ffi_exception_ce, "Attempt to assign read-only field '%s'", ZSTR_VAL(field_name)); - zend_tmp_string_release(tmp_field_name); return value; } @@ -1076,9 +1055,9 @@ static zval *zend_ffi_cdata_write_field(zval *object, zval *member, zval *value, } /* }}} */ -static zval *zend_ffi_cdata_read_dim(zval *object, zval *offset, int read_type, zval *rv) /* {{{ */ +static zval *zend_ffi_cdata_read_dim(zend_object *obj, zval *offset, int read_type, zval *rv) /* {{{ */ { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(object); + zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj; zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); zend_long dim = zval_get_long(offset); zend_ffi_type *dim_type; @@ -1134,9 +1113,9 @@ static zval *zend_ffi_cdata_read_dim(zval *object, zval *offset, int read_type, } /* }}} */ -static void zend_ffi_cdata_write_dim(zval *object, zval *offset, zval *value) /* {{{ */ +static void zend_ffi_cdata_write_dim(zend_object *obj, zval *offset, zval *value) /* {{{ */ { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(object); + zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj; zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); zend_long dim = zval_get_long(offset); void *ptr; @@ -1388,9 +1367,9 @@ static int zend_ffi_cdata_compare_objects(zval *o1, zval *o2) /* {{{ */ } /* }}} */ -static int zend_ffi_cdata_count_elements(zval *object, zend_long *count) /* {{{ */ +static int zend_ffi_cdata_count_elements(zend_object *obj, zend_long *count) /* {{{ */ { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(object); + zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj; zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); if (type->kind != ZEND_FFI_TYPE_ARRAY) { @@ -1640,9 +1619,9 @@ static zend_object_iterator *zend_ffi_cdata_get_iterator(zend_class_entry *ce, z } /* }}} */ -static HashTable *zend_ffi_cdata_get_debug_info(zval *object, int *is_temp) /* {{{ */ +static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp) /* {{{ */ { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(object); + zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj; zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); void *ptr = cdata->ptr; HashTable *ht = NULL; @@ -1739,9 +1718,9 @@ static HashTable *zend_ffi_cdata_get_debug_info(zval *object, int *is_temp) /* { } /* }}} */ -static int zend_ffi_cdata_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr) /* {{{ */ +static int zend_ffi_cdata_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr) /* {{{ */ { - zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(obj); + zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj; zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type); zend_function *func; @@ -1870,7 +1849,7 @@ static int zend_ffi_ctype_compare_objects(zval *o1, zval *o2) /* {{{ */ } /* }}} */ -static HashTable *zend_ffi_ctype_get_debug_info(zval *object, int *is_temp) /* {{{ */ +static HashTable *zend_ffi_ctype_get_debug_info(zend_object *obj, int *is_temp) /* {{{ */ { return NULL; } @@ -2038,9 +2017,9 @@ static void zend_ffi_cdata_free_obj(zend_object *object) /* {{{ */ } /* }}} */ -static zend_object *zend_ffi_cdata_clone_obj(zval *zobject) /* {{{ */ +static zend_object *zend_ffi_cdata_clone_obj(zend_object *obj) /* {{{ */ { - zend_ffi_cdata *old_cdata = (zend_ffi_cdata*)Z_OBJ_P(zobject); + zend_ffi_cdata *old_cdata = (zend_ffi_cdata*)obj; zend_ffi_type *type = ZEND_FFI_TYPE(old_cdata->type); zend_ffi_cdata *new_cdata; @@ -2057,11 +2036,9 @@ static zend_object *zend_ffi_cdata_clone_obj(zval *zobject) /* {{{ */ } /* }}} */ -static zval *zend_ffi_read_var(zval *object, zval *member, int read_type, void **cache_slot, zval *rv) /* {{{ */ +static zval *zend_ffi_read_var(zend_object *obj, zend_string *var_name, int read_type, void **cache_slot, zval *rv) /* {{{ */ { - zend_ffi *ffi = (zend_ffi*)Z_OBJ_P(object); - zend_string *tmp_var_name; - zend_string *var_name = zval_get_tmp_string(member, &tmp_var_name); + zend_ffi *ffi = (zend_ffi*)obj; zend_ffi_symbol *sym = NULL; if (ffi->symbols) { @@ -2072,12 +2049,9 @@ static zval *zend_ffi_read_var(zval *object, zval *member, int read_type, void * } if (!sym) { zend_throw_error(zend_ffi_exception_ce, "Attempt to read undefined C variable '%s'", ZSTR_VAL(var_name)); - zend_tmp_string_release(tmp_var_name); return &EG(uninitialized_zval); } - zend_tmp_string_release(tmp_var_name); - if (sym->kind == ZEND_FFI_SYM_VAR) { zend_ffi_cdata_to_zval(NULL, sym->addr, ZEND_FFI_TYPE(sym->type), read_type, rv, (zend_ffi_flags)sym->is_const, 0); } else { @@ -2088,11 +2062,9 @@ static zval *zend_ffi_read_var(zval *object, zval *member, int read_type, void * } /* }}} */ -static zval *zend_ffi_write_var(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */ +static zval *zend_ffi_write_var(zend_object *obj, zend_string *var_name, zval *value, void **cache_slot) /* {{{ */ { - zend_ffi *ffi = (zend_ffi*)Z_OBJ_P(object); - zend_string *tmp_var_name; - zend_string *var_name = zval_get_tmp_string(member, &tmp_var_name); + zend_ffi *ffi = (zend_ffi*)obj; zend_ffi_symbol *sym = NULL; if (ffi->symbols) { @@ -2103,12 +2075,9 @@ static zval *zend_ffi_write_var(zval *object, zval *member, zval *value, void ** } if (!sym) { zend_throw_error(zend_ffi_exception_ce, "Attempt to assign undefined C variable '%s'", ZSTR_VAL(var_name)); - zend_tmp_string_release(tmp_var_name); return value; } - zend_tmp_string_release(tmp_var_name); - if (sym->is_const) { zend_throw_error(zend_ffi_exception_ce, "Attempt to assign read-only C variable '%s'", ZSTR_VAL(var_name)); return value; @@ -4270,33 +4239,29 @@ static ZEND_COLD zend_never_inline void zend_bad_array_access(zend_class_entry * } /* }}} */ -static ZEND_COLD zval *zend_fake_read_dimension(zval *object, zval *offset, int type, zval *rv) /* {{{ */ +static ZEND_COLD zval *zend_fake_read_dimension(zend_object *obj, zval *offset, int type, zval *rv) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); - zend_bad_array_access(ce); + zend_bad_array_access(obj->ce); return NULL; } /* }}} */ -static ZEND_COLD void zend_fake_write_dimension(zval *object, zval *offset, zval *value) /* {{{ */ +static ZEND_COLD void zend_fake_write_dimension(zend_object *obj, zval *offset, zval *value) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); - zend_bad_array_access(ce); + zend_bad_array_access(obj->ce); } /* }}} */ -static ZEND_COLD int zend_fake_has_dimension(zval *object, zval *offset, int check_empty) /* {{{ */ +static ZEND_COLD int zend_fake_has_dimension(zend_object *obj, zval *offset, int check_empty) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); - zend_bad_array_access(ce); + zend_bad_array_access(obj->ce); return 0; } /* }}} */ -static ZEND_COLD void zend_fake_unset_dimension(zval *object, zval *offset) /* {{{ */ +static ZEND_COLD void zend_fake_unset_dimension(zend_object *obj, zval *offset) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); - zend_bad_array_access(ce); + zend_bad_array_access(obj->ce); } /* }}} */ @@ -4306,38 +4271,34 @@ static ZEND_COLD zend_never_inline void zend_bad_property_access(zend_class_entr } /* }}} */ -static ZEND_COLD zval *zend_fake_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */ +static ZEND_COLD zval *zend_fake_read_property(zend_object *obj, zend_string *member, int type, void **cache_slot, zval *rv) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); - zend_bad_property_access(ce); + zend_bad_property_access(obj->ce); return &EG(uninitialized_zval); } /* }}} */ -static ZEND_COLD zval *zend_fake_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */ +static ZEND_COLD zval *zend_fake_write_property(zend_object *obj, zend_string *member, zval *value, void **cache_slot) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); - zend_bad_array_access(ce); + zend_bad_array_access(obj->ce); return value; } /* }}} */ -static ZEND_COLD int zend_fake_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) /* {{{ */ +static ZEND_COLD int zend_fake_has_property(zend_object *obj, zend_string *member, int has_set_exists, void **cache_slot) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); - zend_bad_array_access(ce); + zend_bad_array_access(obj->ce); return 0; } /* }}} */ -static ZEND_COLD void zend_fake_unset_property(zval *object, zval *member, void **cache_slot) /* {{{ */ +static ZEND_COLD void zend_fake_unset_property(zend_object *obj, zend_string *member, void **cache_slot) /* {{{ */ { - zend_class_entry *ce = Z_OBJCE_P(object); - zend_bad_array_access(ce); + zend_bad_array_access(obj->ce); } /* }}} */ -static zval *zend_fake_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */ +static zval *zend_fake_get_property_ptr_ptr(zend_object *obj, zend_string *member, int type, void **cache_slot) /* {{{ */ { return NULL; } @@ -4351,13 +4312,13 @@ static ZEND_COLD zend_function *zend_fake_get_method(zend_object **obj_ptr, zend } /* }}} */ -static HashTable *zend_fake_get_properties(zval *object) /* {{{ */ +static HashTable *zend_fake_get_properties(zend_object *obj) /* {{{ */ { return (HashTable*)&zend_empty_array; } /* }}} */ -static HashTable *zend_fake_get_gc(zval *object, zval **table, int *n) /* {{{ */ +static HashTable *zend_fake_get_gc(zend_object *ob, zval **table, int *n) /* {{{ */ { *table = NULL; *n = 0; @@ -4371,74 +4332,74 @@ static ZEND_COLD zend_never_inline void zend_ffi_use_after_free(void) /* {{{ */ } /* }}} */ -static zend_object *zend_ffi_free_clone_obj(zval *zobject) /* {{{ */ +static zend_object *zend_ffi_free_clone_obj(zend_object *obj) /* {{{ */ { zend_ffi_use_after_free(); return NULL; } /* }}} */ -static ZEND_COLD zval *zend_ffi_free_read_dimension(zval *object, zval *offset, int type, zval *rv) /* {{{ */ +static ZEND_COLD zval *zend_ffi_free_read_dimension(zend_object *obj, zval *offset, int type, zval *rv) /* {{{ */ { zend_ffi_use_after_free(); return NULL; } /* }}} */ -static ZEND_COLD void zend_ffi_free_write_dimension(zval *object, zval *offset, zval *value) /* {{{ */ +static ZEND_COLD void zend_ffi_free_write_dimension(zend_object *obj, zval *offset, zval *value) /* {{{ */ { zend_ffi_use_after_free(); } /* }}} */ -static ZEND_COLD int zend_ffi_free_has_dimension(zval *object, zval *offset, int check_empty) /* {{{ */ +static ZEND_COLD int zend_ffi_free_has_dimension(zend_object *obj, zval *offset, int check_empty) /* {{{ */ { zend_ffi_use_after_free(); return 0; } /* }}} */ -static ZEND_COLD void zend_ffi_free_unset_dimension(zval *object, zval *offset) /* {{{ */ +static ZEND_COLD void zend_ffi_free_unset_dimension(zend_object *obj, zval *offset) /* {{{ */ { zend_ffi_use_after_free(); } /* }}} */ -static ZEND_COLD zval *zend_ffi_free_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */ +static ZEND_COLD zval *zend_ffi_free_read_property(zend_object *obj, zend_string *member, int type, void **cache_slot, zval *rv) /* {{{ */ { zend_ffi_use_after_free(); return &EG(uninitialized_zval); } /* }}} */ -static ZEND_COLD zval *zend_ffi_free_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */ +static ZEND_COLD zval *zend_ffi_free_write_property(zend_object *obj, zend_string *member, zval *value, void **cache_slot) /* {{{ */ { zend_ffi_use_after_free(); return value; } /* }}} */ -static ZEND_COLD int zend_ffi_free_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) /* {{{ */ +static ZEND_COLD int zend_ffi_free_has_property(zend_object *obj, zend_string *member, int has_set_exists, void **cache_slot) /* {{{ */ { zend_ffi_use_after_free(); return 0; } /* }}} */ -static ZEND_COLD void zend_ffi_free_unset_property(zval *object, zval *member, void **cache_slot) /* {{{ */ +static ZEND_COLD void zend_ffi_free_unset_property(zend_object *obj, zend_string *member, void **cache_slot) /* {{{ */ { zend_ffi_use_after_free(); } /* }}} */ -static zval* zend_ffi_free_get(zval *object, zval *rv) /* {{{ */ +static zval* zend_ffi_free_get(zend_object *obj, zval *rv) /* {{{ */ { zend_ffi_use_after_free(); return NULL; } /* }}} */ -static HashTable *zend_ffi_free_get_debug_info(zval *object, int *is_temp) /* {{{ */ +static HashTable *zend_ffi_free_get_debug_info(zend_object *obj, int *is_temp) /* {{{ */ { zend_ffi_use_after_free(); return NULL; diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 26dae62ff2..73462b8313 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -404,24 +404,24 @@ static inline void gmp_create(zval *target, mpz_ptr *gmpnum_target) /* {{{ */ } /* }}} */ -static int gmp_cast_object(zval *readobj, zval *writeobj, int type) /* {{{ */ +static int gmp_cast_object(zend_object *readobj, zval *writeobj, int type) /* {{{ */ { mpz_ptr gmpnum; switch (type) { case IS_STRING: - gmpnum = GET_GMP_FROM_ZVAL(readobj); + gmpnum = GET_GMP_OBJECT_FROM_OBJ(readobj)->num; gmp_strval(writeobj, gmpnum, 10); return SUCCESS; case IS_LONG: - gmpnum = GET_GMP_FROM_ZVAL(readobj); + gmpnum = GET_GMP_OBJECT_FROM_OBJ(readobj)->num; ZVAL_LONG(writeobj, mpz_get_si(gmpnum)); return SUCCESS; case IS_DOUBLE: - gmpnum = GET_GMP_FROM_ZVAL(readobj); + gmpnum = GET_GMP_OBJECT_FROM_OBJ(readobj)->num; ZVAL_DOUBLE(writeobj, mpz_get_d(gmpnum)); return SUCCESS; case _IS_NUMBER: - gmpnum = GET_GMP_FROM_ZVAL(readobj); + gmpnum = GET_GMP_OBJECT_FROM_OBJ(readobj)->num; if (mpz_fits_slong_p(gmpnum)) { ZVAL_LONG(writeobj, mpz_get_si(gmpnum)); } else { @@ -434,10 +434,10 @@ static int gmp_cast_object(zval *readobj, zval *writeobj, int type) /* {{{ */ } /* }}} */ -static HashTable *gmp_get_debug_info(zval *obj, int *is_temp) /* {{{ */ +static HashTable *gmp_get_debug_info(zend_object *obj, int *is_temp) /* {{{ */ { HashTable *ht, *props = zend_std_get_properties(obj); - mpz_ptr gmpnum = GET_GMP_FROM_ZVAL(obj); + mpz_ptr gmpnum = GET_GMP_OBJECT_FROM_OBJ(obj)->num; zval zv; *is_temp = 1; @@ -450,10 +450,10 @@ static HashTable *gmp_get_debug_info(zval *obj, int *is_temp) /* {{{ */ } /* }}} */ -static zend_object *gmp_clone_obj(zval *obj) /* {{{ */ +static zend_object *gmp_clone_obj(zend_object *obj) /* {{{ */ { - gmp_object *old_object = GET_GMP_OBJECT_FROM_ZVAL(obj); - gmp_object *new_object = GET_GMP_OBJECT_FROM_OBJ(gmp_create_object(Z_OBJCE_P(obj))); + gmp_object *old_object = GET_GMP_OBJECT_FROM_OBJ(obj); + gmp_object *new_object = GET_GMP_OBJECT_FROM_OBJ(gmp_create_object(obj->ce)); zend_objects_clone_members( &new_object->std, &old_object->std); @@ -574,7 +574,7 @@ static int gmp_serialize(zval *object, unsigned char **buffer, size_t *buf_len, php_var_serialize(&buf, &zv, &serialize_data); zval_ptr_dtor_str(&zv); - ZVAL_ARR(&zv, zend_std_get_properties(object)); + ZVAL_ARR(&zv, zend_std_get_properties(Z_OBJ_P(object))); php_var_serialize(&buf, &zv, &serialize_data); PHP_VAR_SERIALIZE_DESTROY(serialize_data); @@ -593,14 +593,12 @@ static int gmp_unserialize(zval *object, zend_class_entry *ce, const unsigned ch zval *zv; int retval = FAILURE; php_unserialize_data_t unserialize_data; - zval object_copy; + zend_object *zobj; PHP_VAR_UNSERIALIZE_INIT(unserialize_data); gmp_create(object, &gmpnum); - /* The "object" variable may be modified during the execution of this unserialize handler - * (it may turn into a reference). Keep the original object around for further operations. */ - ZVAL_COPY_VALUE(&object_copy, object); + zobj = Z_OBJ_P(object); p = buf; max = buf + buf_len; @@ -624,7 +622,7 @@ static int gmp_unserialize(zval *object, zend_class_entry *ce, const unsigned ch if (zend_hash_num_elements(Z_ARRVAL_P(zv)) != 0) { zend_hash_copy( - zend_std_get_properties(&object_copy), Z_ARRVAL_P(zv), + zend_std_get_properties(zobj), Z_ARRVAL_P(zv), (copy_ctor_func_t) zval_add_ref ); } diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 1c1d0b4ece..1da1ae68e2 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -569,7 +569,7 @@ PHP_FUNCTION(hash_copy) return; } - RETVAL_OBJ(Z_OBJ_HANDLER_P(zhash, clone_obj)(zhash)); + RETVAL_OBJ(Z_OBJ_HANDLER_P(zhash, clone_obj)(Z_OBJ_P(zhash))); if (php_hashcontext_from_object(Z_OBJ_P(return_value))->context == NULL) { zval_ptr_dtor(return_value); @@ -1137,12 +1137,12 @@ static void php_hashcontext_dtor(zend_object *obj) { /* }}} */ /* {{{ php_hashcontext_clone */ -static zend_object *php_hashcontext_clone(zval *pzv) { - php_hashcontext_object *oldobj = php_hashcontext_from_object(Z_OBJ_P(pzv)); - zend_object *znew = php_hashcontext_create(Z_OBJCE_P(pzv)); +static zend_object *php_hashcontext_clone(zend_object *zobj) { + php_hashcontext_object *oldobj = php_hashcontext_from_object(zobj); + zend_object *znew = php_hashcontext_create(zobj->ce); php_hashcontext_object *newobj = php_hashcontext_from_object(znew); - zend_objects_clone_members(znew, Z_OBJ_P(pzv)); + zend_objects_clone_members(znew, zobj); newobj->ops = oldobj->ops; newobj->options = oldobj->options; diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp index 0d64efece4..7267ff2e7d 100644 --- a/ext/intl/breakiterator/breakiterator_class.cpp +++ b/ext/intl/breakiterator/breakiterator_class.cpp @@ -96,16 +96,16 @@ static int BreakIterator_compare_objects(zval *object1, /* }}} */ /* {{{ clone handler for BreakIterator */ -static zend_object *BreakIterator_clone_obj(zval *object) +static zend_object *BreakIterator_clone_obj(zend_object *object) { BreakIterator_object *bio_orig, *bio_new; zend_object *ret_val; - bio_orig = Z_INTL_BREAKITERATOR_P(object); + bio_orig = php_intl_breakiterator_fetch_object(object); intl_errors_reset(INTL_DATA_ERROR_P(bio_orig)); - ret_val = BreakIterator_ce_ptr->create_object(Z_OBJCE_P(object)); + ret_val = BreakIterator_ce_ptr->create_object(object->ce); bio_new = php_intl_breakiterator_fetch_object(ret_val); zend_objects_clone_members(&bio_new->zo, &bio_orig->zo); @@ -136,7 +136,7 @@ static zend_object *BreakIterator_clone_obj(zval *object) /* }}} */ /* {{{ get_debug_info handler for BreakIterator */ -static HashTable *BreakIterator_get_debug_info(zval *object, int *is_temp) +static HashTable *BreakIterator_get_debug_info(zend_object *object, int *is_temp) { zval val; HashTable *debug_info; @@ -147,7 +147,7 @@ static HashTable *BreakIterator_get_debug_info(zval *object, int *is_temp) debug_info = zend_new_array(8); - bio = Z_INTL_BREAKITERATOR_P(object); + bio = php_intl_breakiterator_fetch_object(object); biter = bio->biter; if (biter == NULL) { diff --git a/ext/intl/calendar/calendar_class.cpp b/ext/intl/calendar/calendar_class.cpp index 29eb9eef44..f7cb8739e0 100644 --- a/ext/intl/calendar/calendar_class.cpp +++ b/ext/intl/calendar/calendar_class.cpp @@ -78,17 +78,17 @@ U_CFUNC void calendar_object_construct(zval *object, } /* {{{ clone handler for Calendar */ -static zend_object *Calendar_clone_obj(zval *object) +static zend_object *Calendar_clone_obj(zend_object *object) { Calendar_object *co_orig, *co_new; zend_object *ret_val; intl_error_reset(NULL); - co_orig = Z_INTL_CALENDAR_P(object); + co_orig = php_intl_calendar_fetch_object(object); intl_error_reset(INTL_DATA_ERROR_P(co_orig)); - ret_val = Calendar_ce_ptr->create_object(Z_OBJCE_P(object)); + ret_val = Calendar_ce_ptr->create_object(object->ce); co_new = php_intl_calendar_fetch_object(ret_val); zend_objects_clone_members(&co_new->zo, &co_orig->zo); @@ -147,7 +147,7 @@ static const struct { }; /* {{{ get_debug_info handler for Calendar */ -static HashTable *Calendar_get_debug_info(zval *object, int *is_temp) +static HashTable *Calendar_get_debug_info(zend_object *object, int *is_temp) { zval zv, zfields; @@ -159,7 +159,7 @@ static HashTable *Calendar_get_debug_info(zval *object, int *is_temp) debug_info = zend_new_array(8); - co = Z_INTL_CALENDAR_P(object); + co = php_intl_calendar_fetch_object(object); cal = co->ucal; if (cal == NULL) { @@ -179,7 +179,7 @@ static HashTable *Calendar_get_debug_info(zval *object, int *is_temp) HashTable *debug_info_tz; timezone_object_construct(&cal->getTimeZone(), &ztz , 0); - debug_info_tz = Z_OBJ_HANDLER(ztz, get_debug_info)(&ztz, &is_tmp); + debug_info_tz = Z_OBJ_HANDLER(ztz, get_debug_info)(Z_OBJ(ztz), &is_tmp); assert(is_tmp == 1); array_init(&ztz_debug); diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp index dfe34a4f03..2188fb8276 100644 --- a/ext/intl/calendar/calendar_methods.cpp +++ b/ext/intl/calendar/calendar_methods.cpp @@ -1133,7 +1133,7 @@ U_CFUNC PHP_FUNCTION(intlcal_from_date_time) if (!(Z_TYPE_P(zv_arg) == IS_OBJECT && instanceof_function( Z_OBJCE_P(zv_arg), php_date_get_date_ce()))) { object_init_ex(&zv_tmp, php_date_get_date_ce()); - zend_call_method_with_1_params(&zv_tmp, NULL, &Z_OBJCE(zv_tmp)->constructor, "__construct", NULL, zv_arg); + zend_call_method_with_1_params(Z_OBJ(zv_tmp), NULL, &Z_OBJCE(zv_tmp)->constructor, "__construct", NULL, zv_arg); zv_datetime = &zv_tmp; if (EG(exception)) { zend_object_store_ctor_failed(Z_OBJ(zv_tmp)); @@ -1151,7 +1151,7 @@ U_CFUNC PHP_FUNCTION(intlcal_from_date_time) goto error; } - zend_call_method_with_0_params(zv_datetime, php_date_get_date_ce(), NULL, "gettimestamp", &zv_timestamp); + zend_call_method_with_0_params(Z_OBJ_P(zv_datetime), php_date_get_date_ce(), NULL, "gettimestamp", &zv_timestamp); if (Z_TYPE(zv_timestamp) != IS_LONG) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intlcal_from_date_time: bad DateTime; call to " @@ -1249,7 +1249,7 @@ U_CFUNC PHP_FUNCTION(intlcal_to_date_time) /* Finally, instantiate object and call constructor */ object_init_ex(return_value, php_date_get_date_ce()); - zend_call_method_with_2_params(return_value, NULL, &Z_OBJCE_P(return_value)->constructor, "__construct", NULL, &ts_zval, timezone_zval); + zend_call_method_with_2_params(Z_OBJ_P(return_value), NULL, &Z_OBJCE_P(return_value)->constructor, "__construct", NULL, &ts_zval, timezone_zval); if (EG(exception)) { intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR, "intlcal_to_date_time: DateTime constructor has thrown exception", @@ -1264,7 +1264,7 @@ U_CFUNC PHP_FUNCTION(intlcal_to_date_time) zval_ptr_dtor(&ts_zval); /* due to bug #40743, we have to set the time zone again */ - zend_call_method_with_1_params(return_value, NULL, NULL, "settimezone", + zend_call_method_with_1_params(Z_OBJ_P(return_value), NULL, NULL, "settimezone", &retval, timezone_zval); if (Z_ISUNDEF(retval) || Z_TYPE(retval) == IS_FALSE) { intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR, diff --git a/ext/intl/collator/collator_convert.c b/ext/intl/collator/collator_convert.c index 2f0a80468e..fc9d7da41f 100644 --- a/ext/intl/collator/collator_convert.c +++ b/ext/intl/collator/collator_convert.c @@ -228,7 +228,7 @@ zval* collator_convert_object_to_string( zval* obj, zval *rv ) /* Try object's handlers. */ if( Z_OBJ_HT_P(obj)->get ) { - zstr = Z_OBJ_HT_P(obj)->get( obj, rv ); + zstr = Z_OBJ_HT_P(obj)->get( Z_OBJ_P(obj), rv ); switch( Z_TYPE_P( zstr ) ) { @@ -252,7 +252,7 @@ zval* collator_convert_object_to_string( zval* obj, zval *rv ) { zstr = rv; - if( Z_OBJ_HT_P(obj)->cast_object( obj, zstr, IS_STRING ) == FAILURE ) + if( Z_OBJ_HT_P(obj)->cast_object( Z_OBJ_P(obj), zstr, IS_STRING ) == FAILURE ) { /* cast_object failed => bail out. */ zval_ptr_dtor( zstr ); diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index 992a1bade7..09fa699b00 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -1042,9 +1042,9 @@ static zend_object *php_converter_create_object(zend_class_entry *ce) { return retval; } -static zend_object *php_converter_clone_object(zval *object) { - php_converter_object *objval, *oldobj = Z_INTL_CONVERTER_P(object); - zend_object *retval = php_converter_object_ctor(Z_OBJCE_P(object), &objval); +static zend_object *php_converter_clone_object(zend_object *object) { + php_converter_object *objval, *oldobj = php_converter_fetch_object(object); + zend_object *retval = php_converter_object_ctor(object->ce, &objval); UErrorCode error = U_ZERO_ERROR; intl_errors_reset(&oldobj->error); diff --git a/ext/intl/dateformat/dateformat_class.c b/ext/intl/dateformat/dateformat_class.c index b923f70508..036641cf95 100644 --- a/ext/intl/dateformat/dateformat_class.c +++ b/ext/intl/dateformat/dateformat_class.c @@ -77,14 +77,14 @@ zend_object *IntlDateFormatter_object_create(zend_class_entry *ce) /* }}} */ /* {{{ IntlDateFormatter_object_clone */ -zend_object *IntlDateFormatter_object_clone(zval *object) +zend_object *IntlDateFormatter_object_clone(zend_object *object) { IntlDateFormatter_object *dfo, *new_dfo; zend_object *new_obj; - DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; + dfo = php_intl_dateformatter_fetch_object(object); - new_obj = IntlDateFormatter_ce_ptr->create_object(Z_OBJCE_P(object)); + new_obj = IntlDateFormatter_ce_ptr->create_object(object->ce); new_dfo = php_intl_dateformatter_fetch_object(new_obj); /* clone standard parts */ zend_objects_clone_members(&new_dfo->zo, &dfo->zo); diff --git a/ext/intl/formatter/formatter_class.c b/ext/intl/formatter/formatter_class.c index ad39f39392..31ef45a0fd 100644 --- a/ext/intl/formatter/formatter_class.c +++ b/ext/intl/formatter/formatter_class.c @@ -61,13 +61,13 @@ zend_object *NumberFormatter_object_create(zend_class_entry *ce) /* }}} */ /* {{{ NumberFormatter_object_clone */ -zend_object *NumberFormatter_object_clone(zval *object) +zend_object *NumberFormatter_object_clone(zend_object *object) { NumberFormatter_object *nfo, *new_nfo; zend_object *new_obj; - FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK; - new_obj = NumberFormatter_ce_ptr->create_object(Z_OBJCE_P(object)); + nfo = php_intl_number_format_fetch_object(object); + new_obj = NumberFormatter_ce_ptr->create_object(object->ce); new_nfo = php_intl_number_format_fetch_object(new_obj); /* clone standard parts */ zend_objects_clone_members(&new_nfo->zo, &nfo->zo); diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c index a6d5b593a6..854fb95fc3 100644 --- a/ext/intl/msgformat/msgformat_class.c +++ b/ext/intl/msgformat/msgformat_class.c @@ -61,13 +61,13 @@ zend_object *MessageFormatter_object_create(zend_class_entry *ce) /* }}} */ /* {{{ MessageFormatter_object_clone */ -zend_object *MessageFormatter_object_clone(zval *object) +zend_object *MessageFormatter_object_clone(zend_object *object) { MessageFormatter_object *mfo, *new_mfo; zend_object *new_obj; - MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; - new_obj = MessageFormatter_ce_ptr->create_object(Z_OBJCE_P(object)); + mfo = php_intl_messageformatter_fetch_object(object); + new_obj = MessageFormatter_ce_ptr->create_object(object->ce); new_mfo = php_intl_messageformatter_fetch_object(new_obj); /* clone standard parts */ zend_objects_clone_members(&new_mfo->zo, &mfo->zo); diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index 2feb6edb13..9b9cb9f9a6 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -176,7 +176,7 @@ PHP_FUNCTION( resourcebundle_create ) /* }}} */ /* {{{ resourcebundle_array_fetch */ -static void resourcebundle_array_fetch(zval *object, zval *offset, zval *return_value, int fallback) +static void resourcebundle_array_fetch(zend_object *object, zval *offset, zval *return_value, int fallback) { int32_t meindex = 0; char * mekey = NULL; @@ -185,7 +185,7 @@ static void resourcebundle_array_fetch(zval *object, zval *offset, zval *return_ ResourceBundle_object *rb; intl_error_reset( NULL ); - RESOURCEBUNDLE_METHOD_FETCH_OBJECT; + rb = php_intl_resourcebundle_fetch_object(object); if(Z_TYPE_P(offset) == IS_LONG) { is_numeric = 1; @@ -230,7 +230,7 @@ static void resourcebundle_array_fetch(zval *object, zval *offset, zval *return_ /* }}} */ /* {{{ resourcebundle_array_get */ -zval *resourcebundle_array_get(zval *object, zval *offset, int type, zval *rv) +zval *resourcebundle_array_get(zend_object *object, zval *offset, int type, zval *rv) { if(offset == NULL) { php_error( E_ERROR, "Cannot apply [] to ResourceBundle object" ); @@ -264,15 +264,14 @@ PHP_FUNCTION( resourcebundle_get ) RETURN_FALSE; } - resourcebundle_array_fetch(object, offset, return_value, fallback); + resourcebundle_array_fetch(Z_OBJ_P(object), offset, return_value, fallback); } /* }}} */ /* {{{ resourcebundle_array_count */ -int resourcebundle_array_count(zval *object, zend_long *count) +int resourcebundle_array_count(zend_object *object, zend_long *count) { - ResourceBundle_object *rb; - RESOURCEBUNDLE_METHOD_FETCH_OBJECT_NO_CHECK; + ResourceBundle_object *rb = php_intl_resourcebundle_fetch_object(object); if (rb->me == NULL) { intl_errors_set(&rb->error, U_ILLEGAL_ARGUMENT_ERROR, diff --git a/ext/intl/spoofchecker/spoofchecker_class.c b/ext/intl/spoofchecker/spoofchecker_class.c index d8bca44dba..52632ed122 100644 --- a/ext/intl/spoofchecker/spoofchecker_class.c +++ b/ext/intl/spoofchecker/spoofchecker_class.c @@ -108,15 +108,15 @@ static const zend_function_entry Spoofchecker_class_functions[] = { }; /* }}} */ -static zend_object *spoofchecker_clone_obj(zval *object) /* {{{ */ +static zend_object *spoofchecker_clone_obj(zend_object *object) /* {{{ */ { zend_object *new_obj_val; Spoofchecker_object *sfo, *new_sfo; - sfo = Z_INTL_SPOOFCHECKER_P(object); + sfo = php_intl_spoofchecker_fetch_object(object); intl_error_reset(SPOOFCHECKER_ERROR_P(sfo)); - new_obj_val = Spoofchecker_ce_ptr->create_object(Z_OBJCE_P(object)); + new_obj_val = Spoofchecker_ce_ptr->create_object(object->ce); new_sfo = php_intl_spoofchecker_fetch_object(new_obj_val); /* clone standard parts */ zend_objects_clone_members(&new_sfo->zo, &sfo->zo); diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp index aabb0f3f55..6caf42cacd 100644 --- a/ext/intl/timezone/timezone_class.cpp +++ b/ext/intl/timezone/timezone_class.cpp @@ -98,7 +98,7 @@ U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, goto error; } ZVAL_STR(&arg, u8str); - zend_call_method_with_1_params(ret, NULL, &Z_OBJCE_P(ret)->constructor, "__construct", NULL, &arg); + zend_call_method_with_1_params(Z_OBJ_P(ret), NULL, &Z_OBJCE_P(ret)->constructor, "__construct", NULL, &arg); if (EG(exception)) { spprintf(&message, 0, "%s: DateTimeZone constructor threw exception", func); @@ -221,17 +221,17 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone, /* }}} */ /* {{{ clone handler for TimeZone */ -static zend_object *TimeZone_clone_obj(zval *object) +static zend_object *TimeZone_clone_obj(zend_object *object) { TimeZone_object *to_orig, *to_new; zend_object *ret_val; intl_error_reset(NULL); - to_orig = Z_INTL_TIMEZONE_P(object); + to_orig = php_intl_timezone_fetch_object(object); intl_error_reset(TIMEZONE_ERROR_P(to_orig)); - ret_val = TimeZone_ce_ptr->create_object(Z_OBJCE_P(object)); + ret_val = TimeZone_ce_ptr->create_object(object->ce); to_new = php_intl_timezone_fetch_object(ret_val); zend_objects_clone_members(&to_new->zo, &to_orig->zo); @@ -285,7 +285,7 @@ static int TimeZone_compare_objects(zval *object1, zval *object2) /* }}} */ /* {{{ get_debug_info handler for TimeZone */ -static HashTable *TimeZone_get_debug_info(zval *object, int *is_temp) +static HashTable *TimeZone_get_debug_info(zend_object *object, int *is_temp) { zval zv; TimeZone_object *to; @@ -299,7 +299,7 @@ static HashTable *TimeZone_get_debug_info(zval *object, int *is_temp) debug_info = zend_new_array(8); - to = Z_INTL_TIMEZONE_P(object); + to = php_intl_timezone_fetch_object(object); tz = to->utimezone; if (tz == NULL) { diff --git a/ext/intl/transliterator/transliterator_class.c b/ext/intl/transliterator/transliterator_class.c index a662dcee7d..c9e0f83c0b 100644 --- a/ext/intl/transliterator/transliterator_class.c +++ b/ext/intl/transliterator/transliterator_class.c @@ -130,16 +130,16 @@ static zend_object *Transliterator_object_create( zend_class_entry *ce ) */ /* {{{ clone handler for Transliterator */ -static zend_object *Transliterator_clone_obj( zval *object ) +static zend_object *Transliterator_clone_obj( zend_object *object ) { Transliterator_object *to_orig, *to_new; zend_object *ret_val; intl_error_reset( NULL ); - to_orig = Z_INTL_TRANSLITERATOR_P( object ); + to_orig = php_intl_transliterator_fetch_object( object ); intl_error_reset( INTL_DATA_ERROR_P( to_orig ) ); - ret_val = Transliterator_ce_ptr->create_object( Z_OBJCE_P( object ) ); + ret_val = Transliterator_ce_ptr->create_object( object->ce ); to_new = php_intl_transliterator_fetch_object( ret_val ); zend_objects_clone_members( &to_new->zo, &to_orig->zo ); @@ -189,76 +189,52 @@ err: } /* }}} */ -#define TRANSLITERATOR_PROPERTY_HANDLER_PROLOG \ - zval tmp_member; \ - if( Z_TYPE_P( member ) != IS_STRING ) \ - { \ - ZVAL_STR(&tmp_member, \ - zval_get_string_func(member)); \ - member = &tmp_member; \ - cache_slot = NULL; \ - } - -#define TRANSLITERATOR_PROPERTY_HANDLER_EPILOG \ - if( member == &tmp_member ) \ - { \ - zval_ptr_dtor_str( &tmp_member ); \ - } - /* {{{ get_property_ptr_ptr handler */ -static zval *Transliterator_get_property_ptr_ptr( zval *object, zval *member, int type, void **cache_slot ) +static zval *Transliterator_get_property_ptr_ptr( zend_object *object, zend_string *name, int type, void **cache_slot ) { zval *retval; - TRANSLITERATOR_PROPERTY_HANDLER_PROLOG; - if(zend_binary_strcmp( "id", sizeof( "id" ) - 1, - Z_STRVAL_P( member ), Z_STRLEN_P( member ) ) == 0 ) + ZSTR_VAL( name ), ZSTR_LEN( name ) ) == 0 ) { retval = NULL; /* fallback to read_property */ } else { - retval = zend_std_get_property_ptr_ptr( object, member, type, cache_slot ); + retval = zend_std_get_property_ptr_ptr( object, name, type, cache_slot ); } - TRANSLITERATOR_PROPERTY_HANDLER_EPILOG; - return retval; } /* }}} */ /* {{{ read_property handler */ -static zval *Transliterator_read_property( zval *object, zval *member, int type, void **cache_slot, zval *rv ) +static zval *Transliterator_read_property( zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv ) { zval *retval; - TRANSLITERATOR_PROPERTY_HANDLER_PROLOG; - if( ( type != BP_VAR_R && type != BP_VAR_IS ) && ( zend_binary_strcmp( "id", sizeof( "id" ) - 1, - Z_STRVAL_P( member ), Z_STRLEN_P( member ) ) == 0 ) ) + ZSTR_VAL( name ), ZSTR_LEN( name ) ) == 0 ) ) { php_error_docref0( NULL, E_WARNING, "The property \"id\" is read-only" ); retval = &EG( uninitialized_zval ); } else { - retval = zend_std_read_property( object, member, type, cache_slot, rv ); + retval = zend_std_read_property( object, name, type, cache_slot, rv ); } - TRANSLITERATOR_PROPERTY_HANDLER_EPILOG; - return retval; } /* }}} */ /* {{{ write_property handler */ -static zval *Transliterator_write_property( zval *object, zval *member, zval *value, void **cache_slot ) +static zval *Transliterator_write_property( zend_object *object, zend_string *name, zval *value, + void **cache_slot ) { zend_class_entry *scope; - TRANSLITERATOR_PROPERTY_HANDLER_PROLOG; if (EG(fake_scope)) { scope = EG(fake_scope); @@ -267,17 +243,15 @@ static zval *Transliterator_write_property( zval *object, zval *member, zval *va } if( ( scope != Transliterator_ce_ptr ) && ( zend_binary_strcmp( "id", sizeof( "id" ) - 1, - Z_STRVAL_P( member ), Z_STRLEN_P( member ) ) == 0 ) ) + ZSTR_VAL( name ), ZSTR_LEN( name ) ) == 0 ) ) { php_error_docref0( NULL, E_WARNING, "The property \"id\" is read-only" ); } else { - value = zend_std_write_property( object, member, value, cache_slot ); + value = zend_std_write_property( object, name, value, cache_slot ); } - TRANSLITERATOR_PROPERTY_HANDLER_EPILOG; - return value; } /* }}} */ diff --git a/ext/json/json_parser.y b/ext/json/json_parser.y index aa37c03658..e251d6e0d4 100644 --- a/ext/json/json_parser.y +++ b/ext/json/json_parser.y @@ -274,7 +274,6 @@ static int php_json_parser_object_update(php_json_parser *parser, zval *object, if (Z_TYPE_P(object) == IS_ARRAY) { zend_symtable_update(Z_ARRVAL_P(object), key, zvalue); } else { - zval zkey; if (ZSTR_LEN(key) > 0 && ZSTR_VAL(key)[0] == '\0') { parser->scanner.errcode = PHP_JSON_ERROR_INVALID_PROPERTY_NAME; zend_string_release_ex(key, 0); @@ -282,8 +281,7 @@ static int php_json_parser_object_update(php_json_parser *parser, zval *object, zval_ptr_dtor_nogc(object); return FAILURE; } - ZVAL_NEW_STR(&zkey, key); - zend_std_write_property(object, &zkey, zvalue, NULL); + zend_std_write_property(Z_OBJ_P(object), key, zvalue, NULL); Z_TRY_DELREF_P(zvalue); } zend_string_release_ex(key, 0); diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 02ec94f478..4745ea0499 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -297,22 +297,16 @@ static int mysqli_write_na(mysqli_object *obj, zval *newval) /* }}} */ /* {{{ mysqli_read_property */ -zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +zval *mysqli_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { - zval tmp_member; zval *retval; mysqli_object *obj; mysqli_prop_handler *hnd = NULL; - obj = Z_MYSQLI_P(object); - - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - } + obj = php_mysqli_fetch_object(object); if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member)); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd) { @@ -321,11 +315,7 @@ zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_sl retval = &EG(uninitialized_zval); } } else { - retval = zend_std_read_property(object, member, type, cache_slot, rv); - } - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); + retval = zend_std_read_property(object, name, type, cache_slot, rv); } return retval; @@ -333,31 +323,21 @@ zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_sl /* }}} */ /* {{{ mysqli_write_property */ -zval *mysqli_write_property(zval *object, zval *member, zval *value, void **cache_slot) +zval *mysqli_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { - zval tmp_member; mysqli_object *obj; mysqli_prop_handler *hnd = NULL; - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - } - - obj = Z_MYSQLI_P(object); + obj = php_mysqli_fetch_object(object); if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member)); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd) { hnd->write_func(obj, value); } else { - value = zend_std_write_property(object, member, value, cache_slot); - } - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); + value = zend_std_write_property(object, name, value, cache_slot); } return value; @@ -376,20 +356,20 @@ void mysqli_add_property(HashTable *h, const char *pname, size_t pname_len, mysq } /* }}} */ -static int mysqli_object_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) /* {{{ */ +static int mysqli_object_has_property(zend_object *object, zend_string *name, int has_set_exists, void **cache_slot) /* {{{ */ { - mysqli_object *obj = Z_MYSQLI_P(object); + mysqli_object *obj = php_mysqli_fetch_object(object); mysqli_prop_handler *p; int ret = 0; - if ((p = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member))) != NULL) { + if ((p = zend_hash_find_ptr(obj->prop_handler, name)) != NULL) { switch (has_set_exists) { case ZEND_PROPERTY_EXISTS: ret = 1; break; case ZEND_PROPERTY_NOT_EMPTY: { zval rv; - zval *value = mysqli_read_property(object, member, BP_VAR_IS, cache_slot, &rv); + zval *value = mysqli_read_property(object, name, BP_VAR_IS, cache_slot, &rv); if (value != &EG(uninitialized_zval)) { convert_to_boolean(value); ret = Z_TYPE_P(value) == IS_TRUE ? 1 : 0; @@ -398,7 +378,7 @@ static int mysqli_object_has_property(zval *object, zval *member, int has_set_ex } case ZEND_PROPERTY_ISSET: { zval rv; - zval *value = mysqli_read_property(object, member, BP_VAR_IS, cache_slot, &rv); + zval *value = mysqli_read_property(object, name, BP_VAR_IS, cache_slot, &rv); if (value != &EG(uninitialized_zval)) { ret = Z_TYPE_P(value) != IS_NULL? 1 : 0; zval_ptr_dtor(value); @@ -409,27 +389,26 @@ static int mysqli_object_has_property(zval *object, zval *member, int has_set_ex php_error_docref(NULL, E_WARNING, "Invalid value for has_set_exists"); } } else { - ret = zend_std_has_property(object, member, has_set_exists, cache_slot); + ret = zend_std_has_property(object, name, has_set_exists, cache_slot); } return ret; } /* }}} */ -HashTable *mysqli_object_get_debug_info(zval *object, int *is_temp) +HashTable *mysqli_object_get_debug_info(zend_object *object, int *is_temp) { - mysqli_object *obj = Z_MYSQLI_P(object); + mysqli_object *obj = php_mysqli_fetch_object(object); HashTable *retval, *props = obj->prop_handler; mysqli_prop_handler *entry; retval = zend_new_array(zend_hash_num_elements(props) + 1); ZEND_HASH_FOREACH_PTR(props, entry) { - zval rv, member; + zval rv; zval *value; - ZVAL_STR(&member, entry->name); - value = mysqli_read_property(object, &member, BP_VAR_IS, 0, &rv); + value = mysqli_read_property(object, entry->name, BP_VAR_IS, 0, &rv); if (value != &EG(uninitialized_zval)) { - zend_hash_add(retval, Z_STR(member), value); + zend_hash_add(retval, entry->name, value); } } ZEND_HASH_FOREACH_END(); diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 0e3f63fe3f..5805a05686 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -419,13 +419,13 @@ static zval *pdo_stmt_instantiate(pdo_dbh_t *dbh, zval *object, zend_class_entry static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt, zval *object, zend_class_entry *dbstmt_ce, zval *ctor_args) /* {{{ */ { zval query_string; - zval z_key; + zend_string *key; ZVAL_STRINGL(&query_string, stmt->query_string, stmt->query_stringlen); - ZVAL_STRINGL(&z_key, "queryString", sizeof("queryString") - 1); - zend_std_write_property(object, &z_key, &query_string, NULL); + key = zend_string_init("queryString", sizeof("queryString") - 1, 0); + zend_std_write_property(Z_OBJ_P(object), key, &query_string, NULL); zval_ptr_dtor(&query_string); - zval_ptr_dtor(&z_key); + zend_string_release_ex(key, 0); if (dbstmt_ce->constructor) { zend_fcall_info fci; @@ -1350,9 +1350,9 @@ static int dbh_compare(zval *object1, zval *object2) return -1; } -static HashTable *dbh_get_gc(zval *object, zval **gc_data, int *gc_count) +static HashTable *dbh_get_gc(zend_object *object, zval **gc_data, int *gc_count) { - pdo_dbh_t *dbh = Z_PDO_DBH_P(object); + pdo_dbh_t *dbh = php_pdo_dbh_fetch_inner(object); *gc_data = &dbh->def_stmt_ctor_args; *gc_count = 1; return zend_std_get_properties(object); diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index d18782437a..50820499cf 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2176,30 +2176,26 @@ const zend_function_entry pdo_dbstmt_functions[] = { }; /* {{{ overloaded handlers for PDOStatement class */ -static zval *dbstmt_prop_write(zval *object, zval *member, zval *value, void **cache_slot) +static zval *dbstmt_prop_write(zend_object *object, zend_string *name, zval *value, void **cache_slot) { - pdo_stmt_t *stmt = Z_PDO_STMT_P(object); - - convert_to_string(member); + pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(object); - if (strcmp(Z_STRVAL_P(member), "queryString") == 0) { + if (strcmp(ZSTR_VAL(name), "queryString") == 0) { pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "property queryString is read only"); return value; } else { - return zend_std_write_property(object, member, value, cache_slot); + return zend_std_write_property(object, name, value, cache_slot); } } -static void dbstmt_prop_delete(zval *object, zval *member, void **cache_slot) +static void dbstmt_prop_delete(zend_object *object, zend_string *name, void **cache_slot) { - pdo_stmt_t *stmt = Z_PDO_STMT_P(object); - - convert_to_string(member); + pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(object); - if (strcmp(Z_STRVAL_P(member), "queryString") == 0) { + if (strcmp(ZSTR_VAL(name), "queryString") == 0) { pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "property queryString is read only"); } else { - zend_std_unset_property(object, member, cache_slot); + zend_std_unset_property(object, name, cache_slot); } } @@ -2246,16 +2242,16 @@ static int dbstmt_compare(zval *object1, zval *object2) return -1; } -static zend_object *dbstmt_clone_obj(zval *zobject) +static zend_object *dbstmt_clone_obj(zend_object *zobject) { pdo_stmt_t *stmt; pdo_stmt_t *old_stmt; - stmt = zend_object_alloc(sizeof(pdo_stmt_t), Z_OBJCE_P(zobject)); - zend_object_std_init(&stmt->std, Z_OBJCE_P(zobject)); - object_properties_init(&stmt->std, Z_OBJCE_P(zobject)); + stmt = zend_object_alloc(sizeof(pdo_stmt_t), zobject->ce); + zend_object_std_init(&stmt->std, zobject->ce); + object_properties_init(&stmt->std, zobject->ce); - old_stmt = Z_PDO_STMT_P(zobject); + old_stmt = php_pdo_stmt_fetch_object(zobject); zend_objects_clone_members(&stmt->std, &old_stmt->std); @@ -2454,12 +2450,44 @@ const zend_function_entry pdo_row_functions[] = { PHP_FE_END }; -static zval *row_prop_read(zval *object, zval *member, int type, void **cache_slot, zval *rv) +static zval *row_prop_read(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) +{ + pdo_row_t *row = (pdo_row_t *)object; + pdo_stmt_t *stmt = row->stmt; + int colno = -1; + zend_long lval; + + ZVAL_NULL(rv); + if (stmt) { + if (is_numeric_string_ex(ZSTR_VAL(name), ZSTR_LEN(name), &lval, NULL, 0, NULL) == IS_LONG) { + if (lval >= 0 && lval < stmt->column_count) { + fetch_value(stmt, rv, lval, NULL); + } + } else { + /* TODO: replace this with a hash of available column names to column + * numbers */ + for (colno = 0; colno < stmt->column_count; colno++) { + if (ZSTR_LEN(stmt->columns[colno].name) == ZSTR_LEN(name) && + strncmp(ZSTR_VAL(stmt->columns[colno].name), ZSTR_VAL(name), ZSTR_LEN(name)) == 0) { + fetch_value(stmt, rv, colno, NULL); + return rv; + } + } + if (strcmp(ZSTR_VAL(name), "queryString") == 0) { + //zval_ptr_dtor(rv); + return zend_std_read_property(&stmt->std, name, type, cache_slot, rv); + } + } + } + + return rv; +} + +static zval *row_dim_read(zend_object *object, zval *member, int type, zval *rv) { - pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object); + pdo_row_t *row = (pdo_row_t *)object; pdo_stmt_t *stmt = row->stmt; int colno = -1; - zval zobj; zend_long lval; ZVAL_NULL(rv); @@ -2485,9 +2513,8 @@ static zval *row_prop_read(zval *object, zval *member, int type, void **cache_sl } } if (strcmp(Z_STRVAL_P(member), "queryString") == 0) { - ZVAL_OBJ(&zobj, &stmt->std); //zval_ptr_dtor(rv); - return zend_std_read_property(&zobj, member, type, cache_slot, rv); + return zend_std_read_property(&stmt->std, Z_STR_P(member), type, NULL, rv); } } } @@ -2495,25 +2522,52 @@ static zval *row_prop_read(zval *object, zval *member, int type, void **cache_sl return rv; } -static zval *row_dim_read(zval *object, zval *member, int type, zval *rv) +static zval *row_prop_write(zend_object *object, zend_string *name, zval *value, void **cache_slot) { - return row_prop_read(object, member, type, NULL, rv); + php_error_docref(NULL, E_WARNING, "This PDORow is not from a writable result set"); + return value; } -static zval *row_prop_write(zval *object, zval *member, zval *value, void **cache_slot) +static void row_dim_write(zend_object *object, zval *member, zval *value) { php_error_docref(NULL, E_WARNING, "This PDORow is not from a writable result set"); - return value; } -static void row_dim_write(zval *object, zval *member, zval *value) +static int row_prop_exists(zend_object *object, zend_string *name, int check_empty, void **cache_slot) { - php_error_docref(NULL, E_WARNING, "This PDORow is not from a writable result set"); + pdo_row_t *row = (pdo_row_t *)object; + pdo_stmt_t *stmt = row->stmt; + int colno = -1; + zend_long lval; + + if (stmt) { + if (is_numeric_string_ex(ZSTR_VAL(name), ZSTR_LEN(name), &lval, NULL, 0, NULL) == IS_LONG) { + return lval >=0 && lval < stmt->column_count; + } + + /* TODO: replace this with a hash of available column names to column + * numbers */ + for (colno = 0; colno < stmt->column_count; colno++) { + if (ZSTR_LEN(stmt->columns[colno].name) == ZSTR_LEN(name) && + strncmp(ZSTR_VAL(stmt->columns[colno].name), ZSTR_VAL(name), ZSTR_LEN(name)) == 0) { + int res; + zval val; + + fetch_value(stmt, &val, colno, NULL); + res = check_empty ? i_zend_is_true(&val) : Z_TYPE(val) != IS_NULL; + zval_ptr_dtor_nogc(&val); + + return res; + } + } + } + + return 0; } -static int row_prop_exists(zval *object, zval *member, int check_empty, void **cache_slot) +static int row_dim_exists(zend_object *object, zval *member, int check_empty) { - pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object); + pdo_row_t *row = (pdo_row_t *)object; pdo_stmt_t *stmt = row->stmt; int colno = -1; zend_long lval; @@ -2549,24 +2603,19 @@ static int row_prop_exists(zval *object, zval *member, int check_empty, void **c return 0; } -static int row_dim_exists(zval *object, zval *member, int check_empty) -{ - return row_prop_exists(object, member, check_empty, NULL); -} - -static void row_prop_delete(zval *object, zval *offset, void **cache_slot) +static void row_prop_delete(zend_object *object, zend_string *offset, void **cache_slot) { php_error_docref(NULL, E_WARNING, "Cannot delete properties from a PDORow"); } -static void row_dim_delete(zval *object, zval *offset) +static void row_dim_delete(zend_object *object, zval *offset) { php_error_docref(NULL, E_WARNING, "Cannot delete properties from a PDORow"); } -static HashTable *row_get_properties_for(zval *object, zend_prop_purpose purpose) +static HashTable *row_get_properties_for(zend_object *object, zend_prop_purpose purpose) { - pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object); + pdo_row_t *row = (pdo_row_t *)object; pdo_stmt_t *stmt = row->stmt; HashTable *props; int i; diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index ff863d20d7..560576ca52 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1224,7 +1224,7 @@ PHP_METHOD(Phar, __construct) ZVAL_STRINGL(&arg1, fname, fname_len); ZVAL_LONG(&arg2, flags); - zend_call_method_with_2_params(zobj, Z_OBJCE_P(zobj), + zend_call_method_with_2_params(Z_OBJ_P(zobj), Z_OBJCE_P(zobj), &spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg1, &arg2); zval_ptr_dtor(&arg1); @@ -1733,7 +1733,7 @@ PHP_METHOD(Phar, buildFromDirectory) ZVAL_STRINGL(&arg, dir, dir_len); ZVAL_LONG(&arg2, SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS); - zend_call_method_with_2_params(&iter, spl_ce_RecursiveDirectoryIterator, + zend_call_method_with_2_params(Z_OBJ(iter), spl_ce_RecursiveDirectoryIterator, &spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg, &arg2); zval_ptr_dtor(&arg); @@ -1749,7 +1749,7 @@ PHP_METHOD(Phar, buildFromDirectory) RETURN_FALSE; } - zend_call_method_with_1_params(&iteriter, spl_ce_RecursiveIteratorIterator, + zend_call_method_with_1_params(Z_OBJ(iteriter), spl_ce_RecursiveIteratorIterator, &spl_ce_RecursiveIteratorIterator->constructor, "__construct", NULL, &iter); if (EG(exception)) { @@ -1772,7 +1772,7 @@ PHP_METHOD(Phar, buildFromDirectory) ZVAL_STRINGL(&arg2, regex, regex_len); - zend_call_method_with_2_params(®exiter, spl_ce_RegexIterator, + zend_call_method_with_2_params(Z_OBJ(regexiter), spl_ce_RegexIterator, &spl_ce_RegexIterator->constructor, "__construct", NULL, &iteriter, &arg2); zval_ptr_dtor(&arg2); } @@ -2223,7 +2223,7 @@ its_ok: ZVAL_STRINGL(&arg1, phar->fname, phar->fname_len); - zend_call_method_with_1_params(&ret, ce, &ce->constructor, "__construct", NULL, &arg1); + zend_call_method_with_1_params(Z_OBJ(ret), ce, &ce->constructor, "__construct", NULL, &arg1); zval_ptr_dtor(&arg1); return Z_OBJ(ret); } @@ -4480,7 +4480,7 @@ PHP_METHOD(PharFileInfo, __construct) ZVAL_STRINGL(&arg1, fname, fname_len); - zend_call_method_with_1_params(zobj, Z_OBJCE_P(zobj), + zend_call_method_with_1_params(Z_OBJ_P(zobj), Z_OBJCE_P(zobj), &spl_ce_SplFileInfo->constructor, "__construct", NULL, &arg1); zval_ptr_dtor(&arg1); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index b09953b897..92d9d9138a 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -43,11 +43,8 @@ #include "zend_smart_str.h" #define reflection_update_property(object, name, value) do { \ - zval member; \ - ZVAL_STR(&member, name); \ - zend_std_write_property(object, &member, value, NULL); \ + zend_std_write_property(Z_OBJ_P(object), name, value, NULL); \ Z_TRY_DELREF_P(value); \ - zval_ptr_dtor(&member); \ } while (0) #define reflection_update_property_name(object, value) \ @@ -236,9 +233,9 @@ static void reflection_free_objects_storage(zend_object *object) /* {{{ */ } /* }}} */ -static HashTable *reflection_get_gc(zval *obj, zval **gc_data, int *gc_data_count) /* {{{ */ +static HashTable *reflection_get_gc(zend_object *obj, zval **gc_data, int *gc_data_count) /* {{{ */ { - reflection_object *intern = Z_REFLECTION_P(obj); + reflection_object *intern = reflection_object_from_obj(obj); *gc_data = &intern->obj; *gc_data_count = 1; return zend_std_get_properties(obj); @@ -435,7 +432,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char smart_str_append_printf(str, "%s }\n", indent); if (obj && Z_TYPE_P(obj) == IS_OBJECT) { - HashTable *properties = Z_OBJ_HT_P(obj)->get_properties(obj); + HashTable *properties = Z_OBJ_HT_P(obj)->get_properties(Z_OBJ_P(obj)); zend_string *prop_name; smart_str prop_str = {0}; @@ -1843,7 +1840,7 @@ ZEND_METHOD(reflection_function, invoke) if (!Z_ISUNDEF(intern->obj)) { Z_OBJ_HT(intern->obj)->get_closure( - &intern->obj, &fcc.called_scope, &fcc.function_handler, &fcc.object); + Z_OBJ(intern->obj), &fcc.called_scope, &fcc.function_handler, &fcc.object); } result = zend_call_function(&fci, &fcc); @@ -1906,7 +1903,7 @@ ZEND_METHOD(reflection_function, invokeArgs) if (!Z_ISUNDEF(intern->obj)) { Z_OBJ_HT(intern->obj)->get_closure( - &intern->obj, &fcc.called_scope, &fcc.function_handler, &fcc.object); + Z_OBJ(intern->obj), &fcc.called_scope, &fcc.function_handler, &fcc.object); } result = zend_call_function(&fci, &fcc); @@ -4180,7 +4177,6 @@ ZEND_METHOD(reflection_class, hasProperty) zend_property_info *property_info; zend_class_entry *ce; zend_string *name; - zval property; if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) { return; @@ -4194,12 +4190,9 @@ ZEND_METHOD(reflection_class, hasProperty) RETURN_TRUE; } else { if (Z_TYPE(intern->obj) != IS_UNDEF) { - ZVAL_STR_COPY(&property, name); - if (Z_OBJ_HANDLER(intern->obj, has_property)(&intern->obj, &property, 2, NULL)) { - zval_ptr_dtor(&property); + if (Z_OBJ_HANDLER(intern->obj, has_property)(Z_OBJ(intern->obj), name, 2, NULL)) { RETURN_TRUE; } - zval_ptr_dtor(&property); } RETURN_FALSE; } @@ -4229,7 +4222,7 @@ ZEND_METHOD(reflection_class, getProperty) } } else if (Z_TYPE(intern->obj) != IS_UNDEF) { /* Check for dynamic properties */ - if (zend_hash_exists(Z_OBJ_HT(intern->obj)->get_properties(&intern->obj), name)) { + if (zend_hash_exists(Z_OBJ_HT(intern->obj)->get_properties(Z_OBJ(intern->obj)), name)) { zend_property_info property_info_tmp; property_info_tmp.flags = ZEND_ACC_PUBLIC; property_info_tmp.name = name; @@ -4343,7 +4336,7 @@ ZEND_METHOD(reflection_class, getProperties) } ZEND_HASH_FOREACH_END(); if (Z_TYPE(intern->obj) != IS_UNDEF && (filter & ZEND_ACC_PUBLIC) != 0) { - HashTable *properties = Z_OBJ_HT(intern->obj)->get_properties(&intern->obj); + HashTable *properties = Z_OBJ_HT(intern->obj)->get_properties(Z_OBJ(intern->obj)); zval *prop; ZEND_HASH_FOREACH_STR_KEY_VAL(properties, key, prop) { _adddynproperty(prop, key, ce, return_value); @@ -5248,7 +5241,7 @@ ZEND_METHOD(reflection_property, __construct) && property_info->ce != ce)) { /* Check for dynamic properties */ if (property_info == NULL && Z_TYPE_P(classname) == IS_OBJECT) { - if (zend_hash_exists(Z_OBJ_HT_P(classname)->get_properties(classname), name)) { + if (zend_hash_exists(Z_OBJ_HT_P(classname)->get_properties(Z_OBJ_P(classname)), name)) { dynam_prop = 1; } } @@ -5514,7 +5507,6 @@ ZEND_METHOD(reflection_property, isInitialized) } RETURN_FALSE; } else { - zval name_zv; zend_class_entry *old_scope; int retval; @@ -5529,8 +5521,7 @@ ZEND_METHOD(reflection_property, isInitialized) old_scope = EG(fake_scope); EG(fake_scope) = intern->ce; - ZVAL_STR(&name_zv, ref->unmangled_name); - retval = Z_OBJ_HT_P(object)->has_property(object, &name_zv, ZEND_PROPERTY_EXISTS, NULL); + retval = Z_OBJ_HT_P(object)->has_property(Z_OBJ_P(object), ref->unmangled_name, ZEND_PROPERTY_EXISTS, NULL); EG(fake_scope) = old_scope; RETVAL_BOOL(retval); @@ -6644,20 +6635,19 @@ static const zend_function_entry reflection_ext_functions[] = { /* {{{ */ }; /* }}} */ /* {{{ _reflection_write_property */ -static zval *_reflection_write_property(zval *object, zval *member, zval *value, void **cache_slot) +static zval *_reflection_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { - if ((Z_TYPE_P(member) == IS_STRING) - && zend_hash_exists(&Z_OBJCE_P(object)->properties_info, Z_STR_P(member)) - && ((Z_STRLEN_P(member) == sizeof("name") - 1 && !memcmp(Z_STRVAL_P(member), "name", sizeof("name"))) - || (Z_STRLEN_P(member) == sizeof("class") - 1 && !memcmp(Z_STRVAL_P(member), "class", sizeof("class"))))) + if (zend_hash_exists(&object->ce->properties_info, name) + && ((ZSTR_LEN(name) == sizeof("name") - 1 && !memcmp(ZSTR_VAL(name), "name", sizeof("name"))) + || (ZSTR_LEN(name) == sizeof("class") - 1 && !memcmp(ZSTR_VAL(name), "class", sizeof("class"))))) { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Cannot set read-only property %s::$%s", ZSTR_VAL(Z_OBJCE_P(object)->name), Z_STRVAL_P(member)); + "Cannot set read-only property %s::$%s", ZSTR_VAL(object->ce->name), ZSTR_VAL(name)); return &EG(uninitialized_zval); } else { - return zend_std_write_property(object, member, value, cache_slot); + return zend_std_write_property(object, name, value, cache_slot); } } /* }}} */ diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index b7eaf90de6..cf459311b7 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -50,7 +50,7 @@ PHP_SXE_API zend_class_entry *sxe_get_element_class_entry() /* {{{ */ static php_sxe_object* php_sxe_object_new(zend_class_entry *ce, zend_function *fptr_count); static xmlNodePtr php_sxe_reset_iterator(php_sxe_object *sxe, int use_data); static xmlNodePtr php_sxe_iterator_fetch(php_sxe_object *sxe, xmlNodePtr node, int use_data); -static zval *sxe_get_value(zval *z, zval *rv); +static zval *sxe_get_value(zend_object *z, zval *rv); static void php_sxe_iterator_dtor(zend_object_iterator *iter); static int php_sxe_iterator_valid(zend_object_iterator *iter); static zval *php_sxe_iterator_current_data(zend_object_iterator *iter); @@ -228,7 +228,7 @@ next_iter: /* {{{ sxe_prop_dim_read() */ -static zval *sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, zend_bool attribs, int type, zval *rv) +static zval *sxe_prop_dim_read(zend_object *object, zval *member, zend_bool elements, zend_bool attribs, int type, zval *rv) { php_sxe_object *sxe; char *name; @@ -238,7 +238,7 @@ static zval *sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, z int nodendx = 0; int test = 0; - sxe = Z_SXEOBJ_P(object); + sxe = php_sxe_fetch_object(object); if (!member) { if (sxe->iter.type == SXE_ITER_ATTRLIST) { @@ -365,15 +365,17 @@ long_dim: /* {{{ sxe_property_read() */ -static zval *sxe_property_read(zval *object, zval *member, int type, void **cache_slot, zval *rv) +static zval *sxe_property_read(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { - return sxe_prop_dim_read(object, member, 1, 0, type, rv); + zval member; + ZVAL_STR(&member, name); + return sxe_prop_dim_read(object, &member, 1, 0, type, rv); } /* }}} */ /* {{{ sxe_dimension_read() */ -static zval *sxe_dimension_read(zval *object, zval *offset, int type, zval *rv) +static zval *sxe_dimension_read(zend_object *object, zval *offset, int type, zval *rv) { return sxe_prop_dim_read(object, offset, 0, 1, type, rv); } @@ -415,7 +417,7 @@ static void change_node_zval(xmlNodePtr node, zval *value) /* {{{ sxe_property_write() */ -static zval *sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool elements, zend_bool attribs, xmlNodePtr *pnewnode) +static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, zend_bool elements, zend_bool attribs, xmlNodePtr *pnewnode) { php_sxe_object *sxe; xmlNodePtr node; @@ -432,7 +434,7 @@ static zval *sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bo zval tmp_zv, zval_copy; zend_string *trim_str; - sxe = Z_SXEOBJ_P(object); + sxe = php_sxe_fetch_object(object); if (!member) { if (sxe->iter.type == SXE_ITER_ATTRLIST) { @@ -517,7 +519,7 @@ long_dim: break; case IS_OBJECT: if (Z_OBJCE_P(value) == sxe_class_entry) { - value = sxe_get_value(value, &zval_copy); + value = sxe_get_value(Z_OBJ_P(value), &zval_copy); new_value = 1; break; } @@ -648,40 +650,42 @@ next_iter: /* {{{ sxe_property_write() */ -static zval *sxe_property_write(zval *object, zval *member, zval *value, void **cache_slot) +static zval *sxe_property_write(zend_object *object, zend_string *name, zval *value, void **cache_slot) { - zval *retval = sxe_prop_dim_write(object, member, value, 1, 0, NULL); - + zval member; + ZVAL_STR(&member, name); + zval *retval = sxe_prop_dim_write(object, &member, value, 1, 0, NULL); return retval == &EG(error_zval) ? &EG(uninitialized_zval) : retval; } /* }}} */ /* {{{ sxe_dimension_write() */ -static void sxe_dimension_write(zval *object, zval *offset, zval *value) +static void sxe_dimension_write(zend_object *object, zval *offset, zval *value) { sxe_prop_dim_write(object, offset, value, 0, 1, NULL); } /* }}} */ -static zval *sxe_property_get_adr(zval *object, zval *member, int fetch_type, void **cache_slot) /* {{{ */ +static zval *sxe_property_get_adr(zend_object *object, zend_string *zname, int fetch_type, void **cache_slot) /* {{{ */ { php_sxe_object *sxe; xmlNodePtr node; zval ret; char *name; SXE_ITER type; + zval member; - sxe = Z_SXEOBJ_P(object); + sxe = php_sxe_fetch_object(object); GET_NODE(sxe, node); - convert_to_string(member); - name = Z_STRVAL_P(member); + name = ZSTR_VAL(zname); node = sxe_get_element_by_name(sxe, node, &name, &type); if (node) { return NULL; } - if (sxe_prop_dim_write(object, member, NULL, 1, 0, &node) == &EG(error_zval)) { + ZVAL_STR(&member, zname); + if (sxe_prop_dim_write(object, &member, NULL, 1, 0, &node) == &EG(error_zval)) { return NULL; } type = SXE_ITER_NONE; @@ -701,7 +705,7 @@ static zval *sxe_property_get_adr(zval *object, zval *member, int fetch_type, vo /* {{{ sxe_prop_dim_exists() */ -static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend_bool elements, zend_bool attribs) +static int sxe_prop_dim_exists(zend_object *object, zval *member, int check_empty, zend_bool elements, zend_bool attribs) { php_sxe_object *sxe; xmlNodePtr node; @@ -715,7 +719,7 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend member = &tmp_zv; } - sxe = Z_SXEOBJ_P(object); + sxe = php_sxe_fetch_object(object); GET_NODE(sxe, node); @@ -803,15 +807,17 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend /* {{{ sxe_property_exists() */ -static int sxe_property_exists(zval *object, zval *member, int check_empty, void **cache_slot) +static int sxe_property_exists(zend_object *object, zend_string *name, int check_empty, void **cache_slot) { - return sxe_prop_dim_exists(object, member, check_empty, 1, 0); + zval member; + ZVAL_STR(&member, name); + return sxe_prop_dim_exists(object, &member, check_empty, 1, 0); } /* }}} */ /* {{{ sxe_dimension_exists() */ -static int sxe_dimension_exists(zval *object, zval *member, int check_empty) +static int sxe_dimension_exists(zend_object *object, zval *member, int check_empty) { return sxe_prop_dim_exists(object, member, check_empty, 0, 1); } @@ -819,7 +825,7 @@ static int sxe_dimension_exists(zval *object, zval *member, int check_empty) /* {{{ sxe_prop_dim_delete() */ -static void sxe_prop_dim_delete(zval *object, zval *member, zend_bool elements, zend_bool attribs) +static void sxe_prop_dim_delete(zend_object *object, zval *member, zend_bool elements, zend_bool attribs) { php_sxe_object *sxe; xmlNodePtr node; @@ -834,7 +840,7 @@ static void sxe_prop_dim_delete(zval *object, zval *member, zend_bool elements, member = &tmp_zv; } - sxe = Z_SXEOBJ_P(object); + sxe = php_sxe_fetch_object(object); GET_NODE(sxe, node); @@ -926,15 +932,17 @@ next_iter: /* {{{ sxe_property_delete() */ -static void sxe_property_delete(zval *object, zval *member, void **cache_slot) +static void sxe_property_delete(zend_object *object, zend_string *name, void **cache_slot) { - sxe_prop_dim_delete(object, member, 1, 0); + zval member; + ZVAL_STR(&member, name); + sxe_prop_dim_delete(object, &member, 1, 0); } /* }}} */ /* {{{ sxe_dimension_unset() */ -static void sxe_dimension_delete(zval *object, zval *offset) +static void sxe_dimension_delete(zend_object *object, zval *offset) { sxe_prop_dim_delete(object, offset, 0, 1); } @@ -1008,7 +1016,7 @@ static void sxe_properties_add(HashTable *rv, char *name, int namelen, zval *val } /* }}} */ -static int sxe_prop_is_empty(zval *object) /* {{{ */ +static int sxe_prop_is_empty(zend_object *object) /* {{{ */ { php_sxe_object *sxe; xmlNodePtr node; @@ -1017,7 +1025,7 @@ static int sxe_prop_is_empty(zval *object) /* {{{ */ int test; int is_empty; - sxe = Z_SXEOBJ_P(object); + sxe = php_sxe_fetch_object(object); GET_NODE(sxe, node); if (!node) { @@ -1099,7 +1107,7 @@ next_iter: } /* }}} */ -static HashTable *sxe_get_prop_hash(zval *object, int is_debug) /* {{{ */ +static HashTable *sxe_get_prop_hash(zend_object *object, int is_debug) /* {{{ */ { zval value; zval zattr; @@ -1115,7 +1123,7 @@ static HashTable *sxe_get_prop_hash(zval *object, int is_debug) /* {{{ */ use_iter = 0; - sxe = Z_SXEOBJ_P(object); + sxe = php_sxe_fetch_object(object); if (is_debug) { rv = zend_new_array(0); @@ -1229,9 +1237,9 @@ next_iter: } /* }}} */ -static HashTable *sxe_get_gc(zval *object, zval **table, int *n) /* {{{ */ { +static HashTable *sxe_get_gc(zend_object *object, zval **table, int *n) /* {{{ */ { php_sxe_object *sxe; - sxe = Z_SXEOBJ_P(object); + sxe = php_sxe_fetch_object(object); *table = NULL; *n = 0; @@ -1239,13 +1247,13 @@ static HashTable *sxe_get_gc(zval *object, zval **table, int *n) /* {{{ */ { } /* }}} */ -static HashTable *sxe_get_properties(zval *object) /* {{{ */ +static HashTable *sxe_get_properties(zend_object *object) /* {{{ */ { return sxe_get_prop_hash(object, 0); } /* }}} */ -static HashTable * sxe_get_debug_info(zval *object, int *is_temp) /* {{{ */ +static HashTable * sxe_get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { *is_temp = 1; return sxe_get_prop_hash(object, 1); @@ -1855,14 +1863,14 @@ static int cast_object(zval *object, int type, char *contents) /* {{{ sxe_object_cast() */ -static int sxe_object_cast_ex(zval *readobj, zval *writeobj, int type) +static int sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int type) { php_sxe_object *sxe; xmlChar *contents = NULL; xmlNodePtr node; int rv; - sxe = Z_SXEOBJ_P(readobj); + sxe = php_sxe_fetch_object(readobj); if (type == _IS_BOOL) { node = php_sxe_get_first_node(sxe, NULL); @@ -1904,7 +1912,7 @@ static int sxe_object_cast_ex(zval *readobj, zval *writeobj, int type) /* }}} */ /* {{{ Variant of sxe_object_cast_ex that handles overwritten __toString() method */ -static int sxe_object_cast(zval *readobj, zval *writeobj, int type) +static int sxe_object_cast(zend_object *readobj, zval *writeobj, int type) { if (type == IS_STRING && zend_std_cast_object_tostring(readobj, writeobj, IS_STRING) == SUCCESS @@ -1920,7 +1928,7 @@ static int sxe_object_cast(zval *readobj, zval *writeobj, int type) Returns the string content */ SXE_METHOD(__toString) { - if (sxe_object_cast_ex(ZEND_THIS, return_value, IS_STRING) != SUCCESS) { + if (sxe_object_cast_ex(Z_OBJ_P(ZEND_THIS), return_value, IS_STRING) != SUCCESS) { zval_ptr_dtor(return_value); RETURN_EMPTY_STRING(); } @@ -1954,10 +1962,10 @@ static int php_sxe_count_elements_helper(php_sxe_object *sxe, zend_long *count) } /* }}} */ -static int sxe_count_elements(zval *object, zend_long *count) /* {{{ */ +static int sxe_count_elements(zend_object *object, zend_long *count) /* {{{ */ { php_sxe_object *intern; - intern = Z_SXEOBJ_P(object); + intern = php_sxe_fetch_object(object); if (intern->fptr_count) { zval rv; zend_call_method_with_0_params(object, intern->zo.ce, &intern->fptr_count, "count", &rv); @@ -1989,9 +1997,9 @@ SXE_METHOD(count) } /* }}} */ -static zval *sxe_get_value(zval *z, zval *rv) /* {{{ */ +static zval *sxe_get_value(zend_object *zobj, zval *rv) /* {{{ */ { - if (sxe_object_cast_ex(z, rv, IS_STRING) == FAILURE) { + if (sxe_object_cast_ex(zobj, rv, IS_STRING) == FAILURE) { zend_error(E_ERROR, "Unable to cast node to string"); /* FIXME: Should not be fatal */ } @@ -2005,9 +2013,9 @@ static zend_object_handlers sxe_object_handlers; /* {{{ sxe_object_clone() */ static zend_object * -sxe_object_clone(zval *object) +sxe_object_clone(zend_object *object) { - php_sxe_object *sxe = Z_SXEOBJ_P(object); + php_sxe_object *sxe = php_sxe_fetch_object(object); php_sxe_object *clone; xmlNodePtr nodep = NULL; xmlDocPtr docp = NULL; diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 1cf4999f33..a68ea14e5c 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -1911,22 +1911,16 @@ void php_snmp_add_property(HashTable *h, const char *name, size_t name_length, p /* {{{ php_snmp_read_property(zval *object, zval *member, int type[, const zend_literal *key]) Generic object property reader */ -zval *php_snmp_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +zval *php_snmp_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { - zval tmp_member; zval *retval; php_snmp_object *obj; php_snmp_prop_handler *hnd; int ret; - obj = Z_SNMP_P(object); + obj = php_snmp_fetch_object(object); - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - } - - hnd = zend_hash_find_ptr(&php_snmp_properties, Z_STR_P(member)); + hnd = zend_hash_find_ptr(&php_snmp_properties, name); if (hnd && hnd->read_func) { ret = hnd->read_func(obj, rv); @@ -1936,11 +1930,7 @@ zval *php_snmp_read_property(zval *object, zval *member, int type, void **cache_ retval = &EG(uninitialized_zval); } } else { - retval = zend_std_read_property(object, member, type, cache_slot, rv); - } - - if (member == &tmp_member) { - zval_ptr_dtor(member); + retval = zend_std_read_property(object, name, type, cache_slot, rv); } return retval; @@ -1949,20 +1939,14 @@ zval *php_snmp_read_property(zval *object, zval *member, int type, void **cache_ /* {{{ php_snmp_write_property(zval *object, zval *member, zval *value[, const zend_literal *key]) Generic object property writer */ -zval *php_snmp_write_property(zval *object, zval *member, zval *value, void **cache_slot) +zval *php_snmp_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { - zval tmp_member; php_snmp_object *obj; php_snmp_prop_handler *hnd; - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - } - - obj = Z_SNMP_P(object); + obj = php_snmp_fetch_object(object); - hnd = zend_hash_find_ptr(&php_snmp_properties, Z_STR_P(member)); + hnd = zend_hash_find_ptr(&php_snmp_properties, name); if (hnd && hnd->write_func) { hnd->write_func(obj, value); @@ -1973,11 +1957,7 @@ zval *php_snmp_write_property(zval *object, zval *member, zval *value, void **ca } */ } else { - value = zend_std_write_property(object, member, value, cache_slot); - } - - if (member == &tmp_member) { - zval_ptr_dtor(member); + value = zend_std_write_property(object, name, value, cache_slot); } return value; @@ -1986,19 +1966,19 @@ zval *php_snmp_write_property(zval *object, zval *member, zval *value, void **ca /* {{{ php_snmp_has_property(zval *object, zval *member, int has_set_exists[, const zend_literal *key]) Generic object property checker */ -static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) +static int php_snmp_has_property(zend_object *object, zend_string *name, int has_set_exists, void **cache_slot) { zval rv; php_snmp_prop_handler *hnd; int ret = 0; - if ((hnd = zend_hash_find_ptr(&php_snmp_properties, Z_STR_P(member))) != NULL) { + if ((hnd = zend_hash_find_ptr(&php_snmp_properties, name)) != NULL) { switch (has_set_exists) { case ZEND_PROPERTY_EXISTS: ret = 1; break; case ZEND_PROPERTY_ISSET: { - zval *value = php_snmp_read_property(object, member, BP_VAR_IS, cache_slot, &rv); + zval *value = php_snmp_read_property(object, name, BP_VAR_IS, cache_slot, &rv); if (value != &EG(uninitialized_zval)) { ret = Z_TYPE_P(value) != IS_NULL? 1 : 0; zval_ptr_dtor(value); @@ -2006,7 +1986,7 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, break; } default: { - zval *value = php_snmp_read_property(object, member, BP_VAR_IS, cache_slot, &rv); + zval *value = php_snmp_read_property(object, name, BP_VAR_IS, cache_slot, &rv); if (value != &EG(uninitialized_zval)) { convert_to_boolean(value); ret = Z_TYPE_P(value) == IS_TRUE? 1:0; @@ -2015,13 +1995,13 @@ static int php_snmp_has_property(zval *object, zval *member, int has_set_exists, } } } else { - ret = zend_std_has_property(object, member, has_set_exists, cache_slot); + ret = zend_std_has_property(object, name, has_set_exists, cache_slot); } return ret; } /* }}} */ -static HashTable *php_snmp_get_gc(zval *object, zval ***gc_data, int *gc_data_count) /* {{{ */ +static HashTable *php_snmp_get_gc(zend_object *object, zval **gc_data, int *gc_data_count) /* {{{ */ { *gc_data = NULL; *gc_data_count = 0; @@ -2031,7 +2011,7 @@ static HashTable *php_snmp_get_gc(zval *object, zval ***gc_data, int *gc_data_co /* {{{ php_snmp_get_properties(zval *object) Returns all object properties. Injects SNMP properties into object on first call */ -static HashTable *php_snmp_get_properties(zval *object) +static HashTable *php_snmp_get_properties(zend_object *object) { php_snmp_object *obj; php_snmp_prop_handler *hnd; @@ -2039,7 +2019,7 @@ static HashTable *php_snmp_get_properties(zval *object) zval rv; zend_string *key; - obj = Z_SNMP_P(object); + obj = php_snmp_fetch_object(object); props = zend_std_get_properties(object); ZEND_HASH_FOREACH_STR_KEY_PTR(&php_snmp_properties, key, hnd) { diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 1198885505..fcab6fbae1 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -165,7 +165,7 @@ static void spl_array_object_free_storage(zend_object *object) zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object, int by_ref); /* {{{ spl_array_object_new_ex */ -static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval *orig, int clone_orig) +static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zend_object *orig, int clone_orig) { spl_array_object *intern; zend_class_entry *parent = class_type; @@ -179,7 +179,7 @@ static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval * intern->ar_flags = 0; intern->ce_get_iterator = spl_ce_ArrayIterator; if (orig) { - spl_array_object *other = Z_SPLARRAY_P(orig); + spl_array_object *other = spl_array_from_obj(orig); intern->ar_flags &= ~ SPL_ARRAY_CLONE_MASK; intern->ar_flags |= (other->ar_flags & SPL_ARRAY_CLONE_MASK); @@ -187,16 +187,18 @@ static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval * if (clone_orig) { if (other->ar_flags & SPL_ARRAY_IS_SELF) { ZVAL_UNDEF(&intern->array); - } else if (Z_OBJ_HT_P(orig) == &spl_handler_ArrayObject) { + } else if (orig->handlers == &spl_handler_ArrayObject) { ZVAL_ARR(&intern->array, zend_array_dup(spl_array_get_hash_table(other))); } else { - ZEND_ASSERT(Z_OBJ_HT_P(orig) == &spl_handler_ArrayIterator); - ZVAL_COPY(&intern->array, orig); + ZEND_ASSERT(orig->handlers == &spl_handler_ArrayIterator); + GC_ADDREF(orig); + ZVAL_OBJ(&intern->array, orig); intern->ar_flags |= SPL_ARRAY_USE_OTHER; } } else { - ZVAL_COPY(&intern->array, orig); + GC_ADDREF(orig); + ZVAL_OBJ(&intern->array, orig); intern->ar_flags |= SPL_ARRAY_USE_OTHER; } } else { @@ -274,13 +276,11 @@ static zend_object *spl_array_object_new(zend_class_entry *class_type) /* }}} */ /* {{{ spl_array_object_clone */ -static zend_object *spl_array_object_clone(zval *zobject) +static zend_object *spl_array_object_clone(zend_object *old_object) { - zend_object *old_object; zend_object *new_object; - old_object = Z_OBJ_P(zobject); - new_object = spl_array_object_new_ex(old_object->ce, zobject, 1); + new_object = spl_array_object_new_ex(old_object->ce, old_object, 1); zend_objects_clone_members(new_object, old_object); @@ -394,11 +394,11 @@ num_index: } } /* }}} */ -static int spl_array_has_dimension(zval *object, zval *offset, int check_empty); +static int spl_array_has_dimension(zend_object *object, zval *offset, int check_empty); -static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval *offset, int type, zval *rv) /* {{{ */ +static zval *spl_array_read_dimension_ex(int check_inherited, zend_object *object, zval *offset, int type, zval *rv) /* {{{ */ { - spl_array_object *intern = Z_SPLARRAY_P(object); + spl_array_object *intern = spl_array_from_obj(object); zval *ret; if (check_inherited && @@ -417,7 +417,7 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval } else { SEPARATE_ARG_IF_REF(offset); } - zend_call_method_with_1_params(object, Z_OBJCE_P(object), &intern->fptr_offset_get, "offsetGet", rv, offset); + zend_call_method_with_1_params(object, object->ce, &intern->fptr_offset_get, "offsetGet", rv, offset); zval_ptr_dtor(offset); if (!Z_ISUNDEF_P(rv)) { @@ -443,14 +443,14 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval return ret; } /* }}} */ -static zval *spl_array_read_dimension(zval *object, zval *offset, int type, zval *rv) /* {{{ */ +static zval *spl_array_read_dimension(zend_object *object, zval *offset, int type, zval *rv) /* {{{ */ { return spl_array_read_dimension_ex(1, object, offset, type, rv); } /* }}} */ -static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval *offset, zval *value) /* {{{ */ +static void spl_array_write_dimension_ex(int check_inherited, zend_object *object, zval *offset, zval *value) /* {{{ */ { - spl_array_object *intern = Z_SPLARRAY_P(object); + spl_array_object *intern = spl_array_from_obj(object); zend_long index; HashTable *ht; @@ -463,7 +463,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval } else { SEPARATE_ARG_IF_REF(offset); } - zend_call_method_with_2_params(object, Z_OBJCE_P(object), &intern->fptr_offset_set, "offsetSet", NULL, offset, value); + zend_call_method_with_2_params(object, object->ce, &intern->fptr_offset_set, "offsetSet", NULL, offset, value); zval_ptr_dtor(offset); return; } @@ -518,20 +518,20 @@ num_index: } } /* }}} */ -static void spl_array_write_dimension(zval *object, zval *offset, zval *value) /* {{{ */ +static void spl_array_write_dimension(zend_object *object, zval *offset, zval *value) /* {{{ */ { spl_array_write_dimension_ex(1, object, offset, value); } /* }}} */ -static void spl_array_unset_dimension_ex(int check_inherited, zval *object, zval *offset) /* {{{ */ +static void spl_array_unset_dimension_ex(int check_inherited, zend_object *object, zval *offset) /* {{{ */ { zend_long index; HashTable *ht; - spl_array_object *intern = Z_SPLARRAY_P(object); + spl_array_object *intern = spl_array_from_obj(object); if (check_inherited && intern->fptr_offset_del) { SEPARATE_ARG_IF_REF(offset); - zend_call_method_with_1_params(object, Z_OBJCE_P(object), &intern->fptr_offset_del, "offsetUnset", NULL, offset); + zend_call_method_with_1_params(object, object->ce, &intern->fptr_offset_del, "offsetUnset", NULL, offset); zval_ptr_dtor(offset); return; } @@ -603,20 +603,20 @@ num_index: } } /* }}} */ -static void spl_array_unset_dimension(zval *object, zval *offset) /* {{{ */ +static void spl_array_unset_dimension(zend_object *object, zval *offset) /* {{{ */ { spl_array_unset_dimension_ex(1, object, offset); } /* }}} */ -static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *offset, int check_empty) /* {{{ */ +static int spl_array_has_dimension_ex(int check_inherited, zend_object *object, zval *offset, int check_empty) /* {{{ */ { - spl_array_object *intern = Z_SPLARRAY_P(object); + spl_array_object *intern = spl_array_from_obj(object); zend_long index; zval rv, *value = NULL, *tmp; if (check_inherited && intern->fptr_offset_has) { SEPARATE_ARG_IF_REF(offset); - zend_call_method_with_1_params(object, Z_OBJCE_P(object), &intern->fptr_offset_has, "offsetExists", &rv, offset); + zend_call_method_with_1_params(object, object->ce, &intern->fptr_offset_has, "offsetExists", &rv, offset); zval_ptr_dtor(offset); if (zend_is_true(&rv)) { @@ -694,7 +694,7 @@ num_index: } } /* }}} */ -static int spl_array_has_dimension(zval *object, zval *offset, int check_empty) /* {{{ */ +static int spl_array_has_dimension(zend_object *object, zval *offset, int check_empty) /* {{{ */ { return spl_array_has_dimension_ex(1, object, offset, check_empty); } /* }}} */ @@ -708,7 +708,7 @@ SPL_METHOD(Array, offsetExists) if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &index) == FAILURE) { return; } - RETURN_BOOL(spl_array_has_dimension_ex(0, ZEND_THIS, index, 2)); + RETURN_BOOL(spl_array_has_dimension_ex(0, Z_OBJ_P(ZEND_THIS), index, 2)); } /* }}} */ /* {{{ proto mixed ArrayObject::offsetGet(mixed $index) @@ -720,7 +720,7 @@ SPL_METHOD(Array, offsetGet) if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &index) == FAILURE) { return; } - value = spl_array_read_dimension_ex(0, ZEND_THIS, index, BP_VAR_R, return_value); + value = spl_array_read_dimension_ex(0, Z_OBJ_P(ZEND_THIS), index, BP_VAR_R, return_value); if (value != return_value) { ZVAL_COPY_DEREF(return_value, value); } @@ -735,7 +735,7 @@ SPL_METHOD(Array, offsetSet) if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &index, &value) == FAILURE) { return; } - spl_array_write_dimension_ex(0, ZEND_THIS, index, value); + spl_array_write_dimension_ex(0, Z_OBJ_P(ZEND_THIS), index, value); } /* }}} */ void spl_array_iterator_append(zval *object, zval *append_value) /* {{{ */ @@ -747,7 +747,7 @@ void spl_array_iterator_append(zval *object, zval *append_value) /* {{{ */ return; } - spl_array_write_dimension(object, NULL, append_value); + spl_array_write_dimension(Z_OBJ_P(object), NULL, append_value); } /* }}} */ /* {{{ proto void ArrayObject::append(mixed $newval) @@ -772,7 +772,7 @@ SPL_METHOD(Array, offsetUnset) if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &index) == FAILURE) { return; } - spl_array_unset_dimension_ex(0, ZEND_THIS, index); + spl_array_unset_dimension_ex(0, Z_OBJ_P(ZEND_THIS), index); } /* }}} */ /* {{{ proto array ArrayObject::getArrayCopy() @@ -786,9 +786,9 @@ SPL_METHOD(Array, getArrayCopy) RETURN_ARR(zend_array_dup(spl_array_get_hash_table(intern))); } /* }}} */ -static HashTable *spl_array_get_properties_for(zval *object, zend_prop_purpose purpose) /* {{{ */ +static HashTable *spl_array_get_properties_for(zend_object *object, zend_prop_purpose purpose) /* {{{ */ { - spl_array_object *intern = Z_SPLARRAY_P(object); + spl_array_object *intern = spl_array_from_obj(object); HashTable *ht; zend_bool dup; @@ -823,12 +823,12 @@ static HashTable *spl_array_get_properties_for(zval *object, zend_prop_purpose p return ht; } /* }}} */ -static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp) /* {{{ */ +static HashTable* spl_array_get_debug_info(zend_object *obj, int *is_temp) /* {{{ */ { zval *storage; zend_string *zname; zend_class_entry *base; - spl_array_object *intern = Z_SPLARRAY_P(obj); + spl_array_object *intern = spl_array_from_obj(obj); if (!intern->std.properties) { rebuild_object_properties(&intern->std); @@ -847,7 +847,7 @@ static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp) /* {{{ */ storage = &intern->array; Z_TRY_ADDREF_P(storage); - base = Z_OBJ_HT_P(obj) == &spl_handler_ArrayIterator + base = obj->handlers == &spl_handler_ArrayIterator ? spl_ce_ArrayIterator : spl_ce_ArrayObject; zname = spl_gen_private_prop_name(base, "storage", sizeof("storage")-1); zend_symtable_update(debug_info, zname, storage); @@ -858,75 +858,85 @@ static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp) /* {{{ */ } /* }}} */ -static HashTable *spl_array_get_gc(zval *obj, zval **gc_data, int *gc_data_count) /* {{{ */ +static HashTable *spl_array_get_gc(zend_object *obj, zval **gc_data, int *gc_data_count) /* {{{ */ { - spl_array_object *intern = Z_SPLARRAY_P(obj); + spl_array_object *intern = spl_array_from_obj(obj); *gc_data = &intern->array; *gc_data_count = 1; return zend_std_get_properties(obj); } /* }}} */ -static zval *spl_array_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */ +static zval *spl_array_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) /* {{{ */ { - spl_array_object *intern = Z_SPLARRAY_P(object); + spl_array_object *intern = spl_array_from_obj(object); if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0 - && !zend_std_has_property(object, member, ZEND_PROPERTY_EXISTS, NULL)) { - return spl_array_read_dimension(object, member, type, rv); + && !zend_std_has_property(object, name, ZEND_PROPERTY_EXISTS, NULL)) { + zval member; + ZVAL_STR(&member, name); + return spl_array_read_dimension(object, &member, type, rv); } - return zend_std_read_property(object, member, type, cache_slot, rv); + return zend_std_read_property(object, name, type, cache_slot, rv); } /* }}} */ -static zval *spl_array_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */ +static zval *spl_array_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) /* {{{ */ { - spl_array_object *intern = Z_SPLARRAY_P(object); + spl_array_object *intern = spl_array_from_obj(object); if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0 - && !zend_std_has_property(object, member, ZEND_PROPERTY_EXISTS, NULL)) { - spl_array_write_dimension(object, member, value); + && !zend_std_has_property(object, name, ZEND_PROPERTY_EXISTS, NULL)) { + zval member; + ZVAL_STR(&member, name); + spl_array_write_dimension(object, &member, value); return value; } - return zend_std_write_property(object, member, value, cache_slot); + return zend_std_write_property(object, name, value, cache_slot); } /* }}} */ -static zval *spl_array_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */ +static zval *spl_array_get_property_ptr_ptr(zend_object *object, zend_string *name, int type, void **cache_slot) /* {{{ */ { - spl_array_object *intern = Z_SPLARRAY_P(object); + spl_array_object *intern = spl_array_from_obj(object); if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0 - && !zend_std_has_property(object, member, ZEND_PROPERTY_EXISTS, NULL)) { + && !zend_std_has_property(object, name, ZEND_PROPERTY_EXISTS, NULL)) { /* If object has offsetGet() overridden, then fallback to read_property, * which will call offsetGet(). */ + zval member; if (intern->fptr_offset_get) { return NULL; } - return spl_array_get_dimension_ptr(1, intern, member, type); + ZVAL_STR(&member, name); + return spl_array_get_dimension_ptr(1, intern, &member, type); } - return zend_std_get_property_ptr_ptr(object, member, type, cache_slot); + return zend_std_get_property_ptr_ptr(object, name, type, cache_slot); } /* }}} */ -static int spl_array_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) /* {{{ */ +static int spl_array_has_property(zend_object *object, zend_string *name, int has_set_exists, void **cache_slot) /* {{{ */ { - spl_array_object *intern = Z_SPLARRAY_P(object); + spl_array_object *intern = spl_array_from_obj(object); if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0 - && !zend_std_has_property(object, member, ZEND_PROPERTY_EXISTS, NULL)) { - return spl_array_has_dimension(object, member, has_set_exists); + && !zend_std_has_property(object, name, ZEND_PROPERTY_EXISTS, NULL)) { + zval member; + ZVAL_STR(&member, name); + return spl_array_has_dimension(object, &member, has_set_exists); } - return zend_std_has_property(object, member, has_set_exists, cache_slot); + return zend_std_has_property(object, name, has_set_exists, cache_slot); } /* }}} */ -static void spl_array_unset_property(zval *object, zval *member, void **cache_slot) /* {{{ */ +static void spl_array_unset_property(zend_object *object, zend_string *name, void **cache_slot) /* {{{ */ { - spl_array_object *intern = Z_SPLARRAY_P(object); + spl_array_object *intern = spl_array_from_obj(object); if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0 - && !zend_std_has_property(object, member, ZEND_PROPERTY_EXISTS, NULL)) { - spl_array_unset_dimension(object, member); + && !zend_std_has_property(object, name, ZEND_PROPERTY_EXISTS, NULL)) { + zval member; + ZVAL_STR(&member, name); + spl_array_unset_dimension(object, &member); return; } - zend_std_unset_property(object, member, cache_slot); + zend_std_unset_property(object, name, cache_slot); } /* }}} */ static int spl_array_compare_objects(zval *o1, zval *o2) /* {{{ */ @@ -1323,7 +1333,7 @@ SPL_METHOD(Array, getIterator) return; } - ZVAL_OBJ(return_value, spl_array_object_new_ex(intern->ce_get_iterator, object, 0)); + ZVAL_OBJ(return_value, spl_array_object_new_ex(intern->ce_get_iterator, Z_OBJ_P(object), 0)); } /* }}} */ @@ -1392,9 +1402,9 @@ static zend_long spl_array_object_count_elements_helper(spl_array_object *intern } } /* }}} */ -int spl_array_object_count_elements(zval *object, zend_long *count) /* {{{ */ +int spl_array_object_count_elements(zend_object *object, zend_long *count) /* {{{ */ { - spl_array_object *intern = Z_SPLARRAY_P(object); + spl_array_object *intern = spl_array_from_obj(object); if (intern->fptr_count) { zval rv; diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 5270c264f7..119ba42556 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -337,15 +337,13 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu Open the directory Clone other members (properties) */ -static zend_object *spl_filesystem_object_clone(zval *zobject) +static zend_object *spl_filesystem_object_clone(zend_object *old_object) { - zend_object *old_object; zend_object *new_object; spl_filesystem_object *intern; spl_filesystem_object *source; int index, skip_dots; - old_object = Z_OBJ_P(zobject); source = spl_filesystem_from_obj(old_object); new_object = spl_filesystem_object_new_ex(old_object->ce); intern = spl_filesystem_from_obj(new_object); @@ -457,7 +455,7 @@ static spl_filesystem_object *spl_filesystem_object_create_info(spl_filesystem_o if (ce->constructor->common.scope != spl_ce_SplFileInfo) { ZVAL_STRINGL(&arg1, file_path, file_path_len); - zend_call_method_with_1_params(return_value, ce, &ce->constructor, "__construct", NULL, &arg1); + zend_call_method_with_1_params(Z_OBJ_P(return_value), ce, &ce->constructor, "__construct", NULL, &arg1); zval_ptr_dtor(&arg1); } else { spl_filesystem_info_set_filename(intern, file_path, file_path_len, use_copy); @@ -502,7 +500,7 @@ static spl_filesystem_object *spl_filesystem_object_create_type(int ht, spl_file spl_filesystem_object_get_file_name(source); if (ce->constructor->common.scope != spl_ce_SplFileInfo) { ZVAL_STRINGL(&arg1, source->file_name, source->file_name_len); - zend_call_method_with_1_params(return_value, ce, &ce->constructor, "__construct", NULL, &arg1); + zend_call_method_with_1_params(Z_OBJ_P(return_value), ce, &ce->constructor, "__construct", NULL, &arg1); zval_ptr_dtor(&arg1); } else { intern->file_name = estrndup(source->file_name, source->file_name_len); @@ -527,7 +525,7 @@ static spl_filesystem_object *spl_filesystem_object_create_type(int ht, spl_file if (ce->constructor->common.scope != spl_ce_SplFileObject) { ZVAL_STRINGL(&arg1, source->file_name, source->file_name_len); ZVAL_STRINGL(&arg2, "r", 1); - zend_call_method_with_2_params(return_value, ce, &ce->constructor, "__construct", NULL, &arg1, &arg2); + zend_call_method_with_2_params(Z_OBJ_P(return_value), ce, &ce->constructor, "__construct", NULL, &arg1, &arg2); zval_ptr_dtor(&arg1); zval_ptr_dtor(&arg2); } else { @@ -591,9 +589,9 @@ static char *spl_filesystem_object_get_pathname(spl_filesystem_object *intern, s } /* }}} */ -static HashTable *spl_filesystem_object_get_debug_info(zval *object, int *is_temp) /* {{{ */ +static HashTable *spl_filesystem_object_get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { - spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(object); + spl_filesystem_object *intern = spl_filesystem_from_obj(object); zval tmp; HashTable *rv; zend_string *pnstr; @@ -840,19 +838,19 @@ SPL_METHOD(DirectoryIterator, seek) if (intern->u.dir.index > pos) { /* we first rewind */ - zend_call_method_with_0_params(ZEND_THIS, Z_OBJCE_P(ZEND_THIS), &intern->u.dir.func_rewind, "rewind", NULL); + zend_call_method_with_0_params(Z_OBJ_P(ZEND_THIS), Z_OBJCE_P(ZEND_THIS), &intern->u.dir.func_rewind, "rewind", NULL); } while (intern->u.dir.index < pos) { int valid = 0; - zend_call_method_with_0_params(ZEND_THIS, Z_OBJCE_P(ZEND_THIS), &intern->u.dir.func_valid, "valid", &retval); + zend_call_method_with_0_params(Z_OBJ_P(ZEND_THIS), Z_OBJCE_P(ZEND_THIS), &intern->u.dir.func_valid, "valid", &retval); valid = zend_is_true(&retval); zval_ptr_dtor(&retval); if (!valid) { zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0, "Seek position " ZEND_LONG_FMT " is out of range", pos); return; } - zend_call_method_with_0_params(ZEND_THIS, Z_OBJCE_P(ZEND_THIS), &intern->u.dir.func_next, "next", NULL); + zend_call_method_with_0_params(Z_OBJ_P(ZEND_THIS), Z_OBJCE_P(ZEND_THIS), &intern->u.dir.func_next, "next", NULL); } } /* }}} */ @@ -1851,12 +1849,12 @@ zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zva /* }}} */ /* {{{ spl_filesystem_object_cast */ -static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type) +static int spl_filesystem_object_cast(zend_object *readobj, zval *writeobj, int type) { - spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(readobj); + spl_filesystem_object *intern = spl_filesystem_from_obj(readobj); if (type == IS_STRING) { - if (Z_OBJCE_P(readobj)->__tostring) { + if (readobj->ce->__tostring) { return zend_std_cast_object_tostring(readobj, writeobj, type); } @@ -2153,7 +2151,7 @@ static int spl_filesystem_file_read_line_ex(zval * this_ptr, spl_filesystem_obje return spl_filesystem_file_read_csv(intern, intern->u.file.delimiter, intern->u.file.enclosure, intern->u.file.escape, NULL); } else { zend_execute_data *execute_data = EG(current_execute_data); - zend_call_method_with_0_params(this_ptr, Z_OBJCE_P(ZEND_THIS), &intern->u.file.func_getCurr, "getCurrentLine", &retval); + zend_call_method_with_0_params(Z_OBJ_P(this_ptr), Z_OBJCE_P(ZEND_THIS), &intern->u.file.func_getCurr, "getCurrentLine", &retval); } if (!Z_ISUNDEF(retval)) { if (intern->u.file.current_line || !Z_ISUNDEF(intern->u.file.current_zval)) { diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 2a274595f3..fd59724b5a 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -365,7 +365,7 @@ static void spl_dllist_object_free_storage(zend_object *object) /* {{{ */ zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object, int by_ref); -static zend_object *spl_dllist_object_new_ex(zend_class_entry *class_type, zval *orig, int clone_orig) /* {{{ */ +static zend_object *spl_dllist_object_new_ex(zend_class_entry *class_type, zend_object *orig, int clone_orig) /* {{{ */ { spl_dllist_object *intern; zend_class_entry *parent = class_type; @@ -380,7 +380,7 @@ static zend_object *spl_dllist_object_new_ex(zend_class_entry *class_type, zval intern->traverse_position = 0; if (orig) { - spl_dllist_object *other = Z_SPLDLLIST_P(orig); + spl_dllist_object *other = spl_dllist_from_obj(orig); intern->ce_get_iterator = other->ce_get_iterator; if (clone_orig) { @@ -455,13 +455,9 @@ static zend_object *spl_dllist_object_new(zend_class_entry *class_type) /* {{{ * } /* }}} */ -static zend_object *spl_dllist_object_clone(zval *zobject) /* {{{ */ +static zend_object *spl_dllist_object_clone(zend_object *old_object) /* {{{ */ { - zend_object *old_object; - zend_object *new_object; - - old_object = Z_OBJ_P(zobject); - new_object = spl_dllist_object_new_ex(old_object->ce, zobject, 1); + zend_object *new_object = spl_dllist_object_new_ex(old_object->ce, old_object, 1); zend_objects_clone_members(new_object, old_object); @@ -469,9 +465,9 @@ static zend_object *spl_dllist_object_clone(zval *zobject) /* {{{ */ } /* }}} */ -static int spl_dllist_object_count_elements(zval *object, zend_long *count) /* {{{ */ +static int spl_dllist_object_count_elements(zend_object *object, zend_long *count) /* {{{ */ { - spl_dllist_object *intern = Z_SPLDLLIST_P(object); + spl_dllist_object *intern = spl_dllist_from_obj(object); if (intern->fptr_count) { zval rv; @@ -490,9 +486,9 @@ static int spl_dllist_object_count_elements(zval *object, zend_long *count) /* { } /* }}} */ -static HashTable* spl_dllist_object_get_debug_info(zval *obj, int *is_temp) /* {{{{ */ +static HashTable* spl_dllist_object_get_debug_info(zend_object *obj, int *is_temp) /* {{{{ */ { - spl_dllist_object *intern = Z_SPLDLLIST_P(obj); + spl_dllist_object *intern = spl_dllist_from_obj(obj); spl_ptr_llist_element *current = intern->llist->head, *next; zval tmp, dllist_array; zend_string *pnstr; @@ -534,9 +530,9 @@ static HashTable* spl_dllist_object_get_debug_info(zval *obj, int *is_temp) /* { } /* }}}} */ -static HashTable *spl_dllist_object_get_gc(zval *obj, zval **gc_data, int *gc_data_count) /* {{{ */ +static HashTable *spl_dllist_object_get_gc(zend_object *obj, zval **gc_data, int *gc_data_count) /* {{{ */ { - spl_dllist_object *intern = Z_SPLDLLIST_P(obj); + spl_dllist_object *intern = spl_dllist_from_obj(obj); spl_ptr_llist_element *current = intern->llist->head; int i = 0; @@ -704,7 +700,7 @@ SPL_METHOD(SplDoublyLinkedList, isEmpty) return; } - spl_dllist_object_count_elements(ZEND_THIS, &count); + spl_dllist_object_count_elements(Z_OBJ_P(ZEND_THIS), &count); RETURN_BOOL(count == 0); } /* }}} */ diff --git a/ext/spl/spl_engine.h b/ext/spl/spl_engine.h index c5614a691d..bf14c78b11 100644 --- a/ext/spl/spl_engine.h +++ b/ext/spl/spl_engine.h @@ -33,7 +33,7 @@ static inline int spl_instantiate_arg_ex1(zend_class_entry *pce, zval *retval, z zend_function *func = pce->constructor; spl_instantiate(pce, retval); - zend_call_method(retval, pce, &func, ZSTR_VAL(func->common.function_name), ZSTR_LEN(func->common.function_name), NULL, 1, arg1, NULL); + zend_call_method(Z_OBJ_P(retval), pce, &func, ZSTR_VAL(func->common.function_name), ZSTR_LEN(func->common.function_name), NULL, 1, arg1, NULL); return 0; } /* }}} */ @@ -44,7 +44,7 @@ static inline int spl_instantiate_arg_ex2(zend_class_entry *pce, zval *retval, z zend_function *func = pce->constructor; spl_instantiate(pce, retval); - zend_call_method(retval, pce, &func, ZSTR_VAL(func->common.function_name), ZSTR_LEN(func->common.function_name), NULL, 2, arg1, arg2); + zend_call_method(Z_OBJ_P(retval), pce, &func, ZSTR_VAL(func->common.function_name), ZSTR_LEN(func->common.function_name), NULL, 2, arg1, arg2); return 0; } /* }}} */ diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 71548abf16..0399c3ce37 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -141,9 +141,9 @@ static void spl_fixedarray_copy(spl_fixedarray *to, spl_fixedarray *from) /* {{{ } /* }}} */ -static HashTable* spl_fixedarray_object_get_gc(zval *obj, zval **table, int *n) /* {{{{ */ +static HashTable* spl_fixedarray_object_get_gc(zend_object *obj, zval **table, int *n) /* {{{{ */ { - spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(obj); + spl_fixedarray_object *intern = spl_fixed_array_from_obj(obj); HashTable *ht = zend_std_get_properties(obj); *table = intern->array.elements; @@ -153,9 +153,9 @@ static HashTable* spl_fixedarray_object_get_gc(zval *obj, zval **table, int *n) } /* }}}} */ -static HashTable* spl_fixedarray_object_get_properties(zval *obj) /* {{{{ */ +static HashTable* spl_fixedarray_object_get_properties(zend_object *obj) /* {{{{ */ { - spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(obj); + spl_fixedarray_object *intern = spl_fixed_array_from_obj(obj); HashTable *ht = zend_std_get_properties(obj); zend_long i = 0; @@ -202,7 +202,7 @@ static void spl_fixedarray_object_free_storage(zend_object *object) /* {{{ */ zend_object_iterator *spl_fixedarray_get_iterator(zend_class_entry *ce, zval *object, int by_ref); -static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, zval *orig, int clone_orig) /* {{{ */ +static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, zend_object *orig, int clone_orig) /* {{{ */ { spl_fixedarray_object *intern; zend_class_entry *parent = class_type; @@ -218,7 +218,7 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z intern->flags = 0; if (orig && clone_orig) { - spl_fixedarray_object *other = Z_SPLFIXEDARRAY_P(orig); + spl_fixedarray_object *other = spl_fixed_array_from_obj(orig); intern->ce_get_iterator = other->ce_get_iterator; spl_fixedarray_init(&intern->array, other->array.size); spl_fixedarray_copy(&intern->array, &other->array); @@ -296,13 +296,9 @@ static zend_object *spl_fixedarray_new(zend_class_entry *class_type) /* {{{ */ } /* }}} */ -static zend_object *spl_fixedarray_object_clone(zval *zobject) /* {{{ */ +static zend_object *spl_fixedarray_object_clone(zend_object *old_object) /* {{{ */ { - zend_object *old_object; - zend_object *new_object; - - old_object = Z_OBJ_P(zobject); - new_object = spl_fixedarray_object_new_ex(old_object->ce, zobject, 1); + zend_object *new_object = spl_fixedarray_object_new_ex(old_object->ce, old_object, 1); zend_objects_clone_members(new_object, old_object); @@ -338,11 +334,11 @@ static inline zval *spl_fixedarray_object_read_dimension_helper(spl_fixedarray_o } /* }}} */ -static zval *spl_fixedarray_object_read_dimension(zval *object, zval *offset, int type, zval *rv) /* {{{ */ +static zval *spl_fixedarray_object_read_dimension(zend_object *object, zval *offset, int type, zval *rv) /* {{{ */ { spl_fixedarray_object *intern; - intern = Z_SPLFIXEDARRAY_P(object); + intern = spl_fixed_array_from_obj(object); if (type == BP_VAR_IS && intern->fptr_offset_has) { SEPARATE_ARG_IF_REF(offset); @@ -407,12 +403,12 @@ static inline void spl_fixedarray_object_write_dimension_helper(spl_fixedarray_o } /* }}} */ -static void spl_fixedarray_object_write_dimension(zval *object, zval *offset, zval *value) /* {{{ */ +static void spl_fixedarray_object_write_dimension(zend_object *object, zval *offset, zval *value) /* {{{ */ { spl_fixedarray_object *intern; zval tmp; - intern = Z_SPLFIXEDARRAY_P(object); + intern = spl_fixed_array_from_obj(object); if (intern->fptr_offset_set) { if (!offset) { @@ -452,11 +448,11 @@ static inline void spl_fixedarray_object_unset_dimension_helper(spl_fixedarray_o } /* }}} */ -static void spl_fixedarray_object_unset_dimension(zval *object, zval *offset) /* {{{ */ +static void spl_fixedarray_object_unset_dimension(zend_object *object, zval *offset) /* {{{ */ { spl_fixedarray_object *intern; - intern = Z_SPLFIXEDARRAY_P(object); + intern = spl_fixed_array_from_obj(object); if (intern->fptr_offset_del) { SEPARATE_ARG_IF_REF(offset); @@ -501,11 +497,11 @@ static inline int spl_fixedarray_object_has_dimension_helper(spl_fixedarray_obje } /* }}} */ -static int spl_fixedarray_object_has_dimension(zval *object, zval *offset, int check_empty) /* {{{ */ +static int spl_fixedarray_object_has_dimension(zend_object *object, zval *offset, int check_empty) /* {{{ */ { spl_fixedarray_object *intern; - intern = Z_SPLFIXEDARRAY_P(object); + intern = spl_fixed_array_from_obj(object); if (intern->fptr_offset_has) { zval rv; @@ -523,11 +519,11 @@ static int spl_fixedarray_object_has_dimension(zval *object, zval *offset, int c } /* }}} */ -static int spl_fixedarray_object_count_elements(zval *object, zend_long *count) /* {{{ */ +static int spl_fixedarray_object_count_elements(zend_object *object, zend_long *count) /* {{{ */ { spl_fixedarray_object *intern; - intern = Z_SPLFIXEDARRAY_P(object); + intern = spl_fixed_array_from_obj(object); if (intern->fptr_count) { zval rv; zend_call_method_with_0_params(object, intern->std.ce, &intern->fptr_count, "count", &rv); @@ -577,7 +573,7 @@ SPL_METHOD(SplFixedArray, __construct) SPL_METHOD(SplFixedArray, __wakeup) { spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(ZEND_THIS); - HashTable *intern_ht = zend_std_get_properties(ZEND_THIS); + HashTable *intern_ht = zend_std_get_properties(Z_OBJ_P(ZEND_THIS)); zval *data; if (zend_parse_parameters_none() == FAILURE) { diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index aad9ed4f36..ebb63481a7 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -126,7 +126,7 @@ static void spl_ptr_heap_pqueue_elem_ctor(zval *zv) { /* {{{ */ static int spl_ptr_heap_cmp_cb_helper(zval *object, spl_heap_object *heap_object, zval *a, zval *b, zend_long *result) { /* {{{ */ zval zresult; - zend_call_method_with_2_params(object, heap_object->std.ce, &heap_object->fptr_cmp, "compare", &zresult, a, b); + zend_call_method_with_2_params(Z_OBJ_P(object), heap_object->std.ce, &heap_object->fptr_cmp, "compare", &zresult, a, b); if (EG(exception)) { return FAILURE; @@ -378,7 +378,7 @@ static void spl_heap_object_free_storage(zend_object *object) /* {{{ */ } /* }}} */ -static zend_object *spl_heap_object_new_ex(zend_class_entry *class_type, zval *orig, int clone_orig) /* {{{ */ +static zend_object *spl_heap_object_new_ex(zend_class_entry *class_type, zend_object *orig, int clone_orig) /* {{{ */ { spl_heap_object *intern; zend_class_entry *parent = class_type; @@ -393,7 +393,7 @@ static zend_object *spl_heap_object_new_ex(zend_class_entry *class_type, zval *o intern->fptr_cmp = NULL; if (orig) { - spl_heap_object *other = Z_SPLHEAP_P(orig); + spl_heap_object *other = spl_heap_from_obj(orig); intern->ce_get_iterator = other->ce_get_iterator; if (clone_orig) { @@ -462,13 +462,9 @@ static zend_object *spl_heap_object_new(zend_class_entry *class_type) /* {{{ */ } /* }}} */ -static zend_object *spl_heap_object_clone(zval *zobject) /* {{{ */ +static zend_object *spl_heap_object_clone(zend_object *old_object) /* {{{ */ { - zend_object *old_object; - zend_object *new_object; - - old_object = Z_OBJ_P(zobject); - new_object = spl_heap_object_new_ex(old_object->ce, zobject, 1); + zend_object *new_object = spl_heap_object_new_ex(old_object->ce, old_object, 1); zend_objects_clone_members(new_object, old_object); @@ -476,9 +472,9 @@ static zend_object *spl_heap_object_clone(zval *zobject) /* {{{ */ } /* }}} */ -static int spl_heap_object_count_elements(zval *object, zend_long *count) /* {{{ */ +static int spl_heap_object_count_elements(zend_object *object, zend_long *count) /* {{{ */ { - spl_heap_object *intern = Z_SPLHEAP_P(object); + spl_heap_object *intern = spl_heap_from_obj(object); if (intern->fptr_count) { zval rv; @@ -498,8 +494,8 @@ static int spl_heap_object_count_elements(zval *object, zend_long *count) /* {{{ } /* }}} */ -static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zval *obj, int *is_temp) { /* {{{ */ - spl_heap_object *intern = Z_SPLHEAP_P(obj); +static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zend_object *obj, int *is_temp) { /* {{{ */ + spl_heap_object *intern = spl_heap_from_obj(obj); zval tmp, heap_array; zend_string *pnstr; HashTable *debug_info; @@ -545,9 +541,9 @@ static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zv } /* }}} */ -static HashTable *spl_heap_object_get_gc(zval *obj, zval **gc_data, int *gc_data_count) /* {{{ */ +static HashTable *spl_heap_object_get_gc(zend_object *obj, zval **gc_data, int *gc_data_count) /* {{{ */ { - spl_heap_object *intern = Z_SPLHEAP_P(obj); + spl_heap_object *intern = spl_heap_from_obj(obj); *gc_data = intern->heap->elements; *gc_data_count = intern->heap->count; @@ -555,13 +551,13 @@ static HashTable *spl_heap_object_get_gc(zval *obj, zval **gc_data, int *gc_data } /* }}} */ -static HashTable* spl_heap_object_get_debug_info(zval *obj, int *is_temp) /* {{{ */ +static HashTable* spl_heap_object_get_debug_info(zend_object *obj, int *is_temp) /* {{{ */ { return spl_heap_object_get_debug_info_helper(spl_ce_SplHeap, obj, is_temp); } /* }}} */ -static HashTable* spl_pqueue_object_get_debug_info(zval *obj, int *is_temp) /* {{{ */ +static HashTable* spl_pqueue_object_get_debug_info(zend_object *obj, int *is_temp) /* {{{ */ { return spl_heap_object_get_debug_info_helper(spl_ce_SplPriorityQueue, obj, is_temp); } diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 5cddf4d460..dcd9a05f9e 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -201,7 +201,7 @@ static int spl_recursive_it_valid_ex(spl_recursive_it_object *object, zval *zthi level--; } if (object->endIteration && object->in_iteration) { - zend_call_method_with_0_params(zthis, object->ce, &object->endIteration, "endIteration", NULL); + zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->endIteration, "endIteration", NULL); } object->in_iteration = 0; return FAILURE; @@ -267,9 +267,9 @@ next_step: ce = object->iterators[object->level].ce; zobject = &object->iterators[object->level].zobject; if (object->callHasChildren) { - zend_call_method_with_0_params(zthis, object->ce, &object->callHasChildren, "callHasChildren", &retval); + zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->callHasChildren, "callHasChildren", &retval); } else { - zend_call_method_with_0_params(zobject, ce, NULL, "haschildren", &retval); + zend_call_method_with_0_params(Z_OBJ_P(zobject), ce, NULL, "haschildren", &retval); } if (EG(exception)) { if (!(object->flags & RIT_CATCH_GET_CHILD)) { @@ -304,7 +304,7 @@ next_step: } } if (object->nextElement) { - zend_call_method_with_0_params(zthis, object->ce, &object->nextElement, "nextelement", NULL); + zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->nextElement, "nextelement", NULL); } object->iterators[object->level].state = RS_NEXT; if (EG(exception)) { @@ -317,7 +317,7 @@ next_step: return /* self */; case RS_SELF: if (object->nextElement && (object->mode == RIT_SELF_FIRST || object->mode == RIT_CHILD_FIRST)) { - zend_call_method_with_0_params(zthis, object->ce, &object->nextElement, "nextelement", NULL); + zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->nextElement, "nextelement", NULL); } if (object->mode == RIT_SELF_FIRST) { object->iterators[object->level].state = RS_CHILD; @@ -329,9 +329,9 @@ next_step: ce = object->iterators[object->level].ce; zobject = &object->iterators[object->level].zobject; if (object->callGetChildren) { - zend_call_method_with_0_params(zthis, object->ce, &object->callGetChildren, "callGetChildren", &child); + zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->callGetChildren, "callGetChildren", &child); } else { - zend_call_method_with_0_params(zobject, ce, NULL, "getchildren", &child); + zend_call_method_with_0_params(Z_OBJ_P(zobject), ce, NULL, "getchildren", &child); } if (EG(exception)) { @@ -367,7 +367,7 @@ next_step: sub_iter->funcs->rewind(sub_iter); } if (object->beginChildren) { - zend_call_method_with_0_params(zthis, object->ce, &object->beginChildren, "beginchildren", NULL); + zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->beginChildren, "beginchildren", NULL); if (EG(exception)) { if (!(object->flags & RIT_CATCH_GET_CHILD)) { return; @@ -381,7 +381,7 @@ next_step: /* no more elements */ if (object->level > 0) { if (object->endChildren) { - zend_call_method_with_0_params(zthis, object->ce, &object->endChildren, "endchildren", NULL); + zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->endChildren, "endchildren", NULL); if (EG(exception)) { if (!(object->flags & RIT_CATCH_GET_CHILD)) { return; @@ -415,7 +415,7 @@ static void spl_recursive_it_rewind_ex(spl_recursive_it_object *object, zval *zt zend_iterator_dtor(sub_iter); zval_ptr_dtor(&object->iterators[object->level--].zobject); if (!EG(exception) && (!object->endChildren || object->endChildren->common.scope != spl_ce_RecursiveIteratorIterator)) { - zend_call_method_with_0_params(zthis, object->ce, &object->endChildren, "endchildren", NULL); + zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->endChildren, "endchildren", NULL); } } object->iterators = erealloc(object->iterators, sizeof(spl_sub_iterator)); @@ -425,7 +425,7 @@ static void spl_recursive_it_rewind_ex(spl_recursive_it_object *object, zval *zt sub_iter->funcs->rewind(sub_iter); } if (!EG(exception) && object->beginIteration && !object->in_iteration) { - zend_call_method_with_0_params(zthis, object->ce, &object->beginIteration, "beginIteration", NULL); + zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->beginIteration, "beginIteration", NULL); } object->in_iteration = 1; spl_recursive_it_move_forward_ex(object, zthis); @@ -494,7 +494,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "o|lzl", &iterator, &flags, &user_caching_it_flags, &mode) == SUCCESS) { if (instanceof_function(Z_OBJCE_P(iterator), zend_ce_aggregate)) { - zend_call_method_with_0_params(iterator, Z_OBJCE_P(iterator), &Z_OBJCE_P(iterator)->iterator_funcs_ptr->zf_new_iterator, "getiterator", &aggregate_retval); + zend_call_method_with_0_params(Z_OBJ_P(iterator), Z_OBJCE_P(iterator), &Z_OBJCE_P(iterator)->iterator_funcs_ptr->zf_new_iterator, "getiterator", &aggregate_retval); iterator = &aggregate_retval; } else { Z_ADDREF_P(iterator); @@ -522,7 +522,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "o|ll", &iterator, &mode, &flags) == SUCCESS) { if (instanceof_function(Z_OBJCE_P(iterator), zend_ce_aggregate)) { - zend_call_method_with_0_params(iterator, Z_OBJCE_P(iterator), &Z_OBJCE_P(iterator)->iterator_funcs_ptr->zf_new_iterator, "getiterator", &aggregate_retval); + zend_call_method_with_0_params(Z_OBJ_P(iterator), Z_OBJCE_P(iterator), &Z_OBJCE_P(iterator)->iterator_funcs_ptr->zf_new_iterator, "getiterator", &aggregate_retval); iterator = &aggregate_retval; } else { Z_ADDREF_P(iterator); @@ -783,7 +783,7 @@ SPL_METHOD(RecursiveIteratorIterator, callHasChildren) if (Z_TYPE_P(zobject) == IS_UNDEF) { RETURN_FALSE; } else { - zend_call_method_with_0_params(zobject, ce, NULL, "haschildren", return_value); + zend_call_method_with_0_params(Z_OBJ_P(zobject), ce, NULL, "haschildren", return_value); if (Z_TYPE_P(return_value) == IS_UNDEF) { RETURN_FALSE; } @@ -808,7 +808,7 @@ SPL_METHOD(RecursiveIteratorIterator, callGetChildren) if (Z_TYPE_P(zobject) == IS_UNDEF) { return; } else { - zend_call_method_with_0_params(zobject, ce, NULL, "getchildren", return_value); + zend_call_method_with_0_params(Z_OBJ_P(zobject), ce, NULL, "getchildren", return_value); if (Z_TYPE_P(return_value) == IS_UNDEF) { RETURN_NULL(); } @@ -1035,7 +1035,7 @@ static void spl_recursive_tree_iterator_get_prefix(spl_recursive_it_object *obje smart_str_appendl(&str, ZSTR_VAL(object->prefix[0].s), ZSTR_LEN(object->prefix[0].s)); for (level = 0; level < object->level; ++level) { - zend_call_method_with_0_params(&object->iterators[level].zobject, object->iterators[level].ce, NULL, "hasnext", &has_next); + zend_call_method_with_0_params(Z_OBJ(object->iterators[level].zobject), object->iterators[level].ce, NULL, "hasnext", &has_next); if (Z_TYPE(has_next) != IS_UNDEF) { if (Z_TYPE(has_next) == IS_TRUE) { smart_str_appendl(&str, ZSTR_VAL(object->prefix[1].s), ZSTR_LEN(object->prefix[1].s)); @@ -1045,7 +1045,7 @@ static void spl_recursive_tree_iterator_get_prefix(spl_recursive_it_object *obje zval_ptr_dtor(&has_next); } } - zend_call_method_with_0_params(&object->iterators[level].zobject, object->iterators[level].ce, NULL, "hasnext", &has_next); + zend_call_method_with_0_params(Z_OBJ(object->iterators[level].zobject), object->iterators[level].ce, NULL, "hasnext", &has_next); if (Z_TYPE(has_next) != IS_UNDEF) { if (Z_TYPE(has_next) == IS_TRUE) { smart_str_appendl(&str, ZSTR_VAL(object->prefix[3].s), ZSTR_LEN(object->prefix[3].s)); @@ -1498,7 +1498,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z ce = ce_cast; } if (instanceof_function(ce, zend_ce_aggregate)) { - zend_call_method_with_0_params(zobject, ce, &ce->iterator_funcs_ptr->zf_new_iterator, "getiterator", &retval); + zend_call_method_with_0_params(Z_OBJ_P(zobject), ce, &ce->iterator_funcs_ptr->zf_new_iterator, "getiterator", &retval); if (EG(exception)) { zval_ptr_dtor(&retval); return NULL; @@ -1517,7 +1517,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z case DIT_AppendIterator: zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling); spl_instantiate(spl_ce_ArrayIterator, &intern->u.append.zarrayit); - zend_call_method_with_0_params(&intern->u.append.zarrayit, spl_ce_ArrayIterator, &spl_ce_ArrayIterator->constructor, "__construct", NULL); + zend_call_method_with_0_params(Z_OBJ(intern->u.append.zarrayit), spl_ce_ArrayIterator, &spl_ce_ArrayIterator->constructor, "__construct", NULL); intern->u.append.iterator = spl_ce_ArrayIterator->get_iterator(spl_ce_ArrayIterator, &intern->u.append.zarrayit, 0); zend_restore_error_handling(&error_handling); return intern; @@ -1815,7 +1815,7 @@ static inline void spl_filter_it_fetch(zval *zthis, spl_dual_it_object *intern) zval retval; while (spl_dual_it_fetch(intern, 1) == SUCCESS) { - zend_call_method_with_0_params(zthis, intern->std.ce, NULL, "accept", &retval); + zend_call_method_with_0_params(Z_OBJ_P(zthis), intern->std.ce, NULL, "accept", &retval); if (Z_TYPE(retval) != IS_UNDEF) { if (zend_is_true(&retval)) { zval_ptr_dtor(&retval); @@ -1899,7 +1899,7 @@ SPL_METHOD(RecursiveFilterIterator, hasChildren) SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS); - zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "haschildren", &retval); + zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "haschildren", &retval); if (Z_TYPE(retval) != IS_UNDEF) { RETURN_ZVAL(&retval, 0, 1); } else { @@ -1920,7 +1920,7 @@ SPL_METHOD(RecursiveFilterIterator, getChildren) SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS); - zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval); + zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &retval); if (!EG(exception) && Z_TYPE(retval) != IS_UNDEF) { spl_instantiate_arg_ex1(Z_OBJCE_P(ZEND_THIS), return_value, &retval); } @@ -1940,7 +1940,7 @@ SPL_METHOD(RecursiveCallbackFilterIterator, getChildren) SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS); - zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval); + zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &retval); if (!EG(exception) && Z_TYPE(retval) != IS_UNDEF) { spl_instantiate_arg_ex2(Z_OBJCE_P(ZEND_THIS), return_value, &retval, &intern->u.cbfilter->fci.function_name); } @@ -2228,7 +2228,7 @@ SPL_METHOD(RecursiveRegexIterator, getChildren) SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS); - zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval); + zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &retval); if (!EG(exception)) { zval args[5]; @@ -2262,7 +2262,7 @@ SPL_METHOD(RecursiveRegexIterator, accept) RETURN_BOOL(zend_hash_num_elements(Z_ARRVAL(intern->current.data)) > 0); } - zend_call_method_with_0_params(ZEND_THIS, spl_ce_RegexIterator, NULL, "accept", return_value); + zend_call_method_with_0_params(Z_OBJ_P(ZEND_THIS), spl_ce_RegexIterator, NULL, "accept", return_value); } #endif @@ -2480,7 +2480,7 @@ static inline void spl_limit_it_seek(spl_dual_it_object *intern, zend_long pos) if (pos != intern->current.pos && instanceof_function(intern->inner.ce, spl_ce_SeekableIterator)) { ZVAL_LONG(&zpos, pos); spl_dual_it_free(intern); - zend_call_method_with_1_params(&intern->inner.zobject, intern->inner.ce, NULL, "seek", NULL, &zpos); + zend_call_method_with_1_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "seek", NULL, &zpos); if (!EG(exception)) { intern->current.pos = pos; if (spl_limit_it_valid(intern) == SUCCESS) { @@ -2630,7 +2630,7 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern) /* Recursion ? */ if (intern->dit_type == DIT_RecursiveCachingIterator) { zval retval, zchildren, zflags; - zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "haschildren", &retval); + zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "haschildren", &retval); if (EG(exception)) { zval_ptr_dtor(&retval); if (intern->u.caching.flags & CIT_CATCH_GET_CHILD) { @@ -2640,7 +2640,7 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern) } } else { if (zend_is_true(&retval)) { - zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &zchildren); + zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &zchildren); if (EG(exception)) { zval_ptr_dtor(&zchildren); if (intern->u.caching.flags & CIT_CATCH_GET_CHILD) { diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index 8b170afaee..a072b3b537 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -115,7 +115,7 @@ void spl_SplObjectStorage_free_storage(zend_object *object) /* {{{ */ } /* }}} */ -static int spl_object_storage_get_hash(zend_hash_key *key, spl_SplObjectStorage *intern, zval *this, zval *obj) { +static int spl_object_storage_get_hash(zend_hash_key *key, spl_SplObjectStorage *intern, zend_object *this, zval *obj) { if (intern->fptr_get_hash) { zval rv; zend_call_method_with_1_params(this, intern->std.ce, &intern->fptr_get_hash, "getHash", &rv, obj); @@ -162,7 +162,7 @@ static spl_SplObjectStorageElement* spl_object_storage_get(spl_SplObjectStorage } } /* }}} */ -spl_SplObjectStorageElement *spl_object_storage_attach(spl_SplObjectStorage *intern, zval *this, zval *obj, zval *inf) /* {{{ */ +spl_SplObjectStorageElement *spl_object_storage_attach(spl_SplObjectStorage *intern, zend_object *this, zval *obj, zval *inf) /* {{{ */ { spl_SplObjectStorageElement *pelement, element; zend_hash_key key; @@ -202,7 +202,7 @@ static int spl_object_storage_detach(spl_SplObjectStorage *intern, zval *this, z { int ret = FAILURE; zend_hash_key key; - if (spl_object_storage_get_hash(&key, intern, this, obj) == FAILURE) { + if (spl_object_storage_get_hash(&key, intern, Z_OBJ_P(this), obj) == FAILURE) { return ret; } if (key.key) { @@ -215,7 +215,7 @@ static int spl_object_storage_detach(spl_SplObjectStorage *intern, zval *this, z return ret; } /* }}}*/ -void spl_object_storage_addall(spl_SplObjectStorage *intern, zval *this, spl_SplObjectStorage *other) { /* {{{ */ +void spl_object_storage_addall(spl_SplObjectStorage *intern, zend_object *this, spl_SplObjectStorage *other) { /* {{{ */ spl_SplObjectStorageElement *element; ZEND_HASH_FOREACH_PTR(&other->storage, element) { @@ -225,7 +225,7 @@ void spl_object_storage_addall(spl_SplObjectStorage *intern, zval *this, spl_Spl intern->index = 0; } /* }}} */ -static zend_object *spl_object_storage_new_ex(zend_class_entry *class_type, zval *orig) /* {{{ */ +static zend_object *spl_object_storage_new_ex(zend_class_entry *class_type, zend_object *orig) /* {{{ */ { spl_SplObjectStorage *intern; zend_class_entry *parent = class_type; @@ -256,7 +256,7 @@ static zend_object *spl_object_storage_new_ex(zend_class_entry *class_type, zval } if (orig) { - spl_SplObjectStorage *other = Z_SPLOBJSTORAGE_P(orig); + spl_SplObjectStorage *other = spl_object_storage_from_obj(orig); spl_object_storage_addall(intern, orig, other); } @@ -265,13 +265,11 @@ static zend_object *spl_object_storage_new_ex(zend_class_entry *class_type, zval /* }}} */ /* {{{ spl_object_storage_clone */ -static zend_object *spl_object_storage_clone(zval *zobject) +static zend_object *spl_object_storage_clone(zend_object *old_object) { - zend_object *old_object; zend_object *new_object; - old_object = Z_OBJ_P(zobject); - new_object = spl_object_storage_new_ex(old_object->ce, zobject); + new_object = spl_object_storage_new_ex(old_object->ce, old_object); zend_objects_clone_members(new_object, old_object); @@ -279,9 +277,9 @@ static zend_object *spl_object_storage_clone(zval *zobject) } /* }}} */ -static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp) /* {{{ */ +static HashTable* spl_object_storage_debug_info(zend_object *obj, int *is_temp) /* {{{ */ { - spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(obj); + spl_SplObjectStorage *intern = spl_object_storage_from_obj(obj); spl_SplObjectStorageElement *element; HashTable *props; zval tmp, storage; @@ -291,7 +289,7 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp) /* {{{ *is_temp = 1; - props = Z_OBJPROP_P(obj); + props = obj->handlers->get_properties(obj); debug_info = zend_new_array(zend_hash_num_elements(props) + 1); zend_hash_copy(debug_info, props, (copy_ctor_func_t)zval_add_ref); @@ -319,10 +317,10 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp) /* {{{ /* }}} */ /* overridden for garbage collection */ -static HashTable *spl_object_storage_get_gc(zval *obj, zval **table, int *n) /* {{{ */ +static HashTable *spl_object_storage_get_gc(zend_object *obj, zval **table, int *n) /* {{{ */ { int i = 0; - spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(obj); + spl_SplObjectStorage *intern = spl_object_storage_from_obj(obj); spl_SplObjectStorageElement *element; if (intern->storage.nNumOfElements * 2 > intern->gcdata_num) { @@ -380,7 +378,7 @@ int spl_object_storage_contains(spl_SplObjectStorage *intern, zval *this, zval * { int found; zend_hash_key key; - if (spl_object_storage_get_hash(&key, intern, this, obj) == FAILURE) { + if (spl_object_storage_get_hash(&key, intern, Z_OBJ_P(this), obj) == FAILURE) { return 0; } @@ -404,7 +402,7 @@ SPL_METHOD(SplObjectStorage, attach) if (zend_parse_parameters(ZEND_NUM_ARGS(), "o|z!", &obj, &inf) == FAILURE) { return; } - spl_object_storage_attach(intern, ZEND_THIS, obj, inf); + spl_object_storage_attach(intern, Z_OBJ_P(ZEND_THIS), obj, inf); } /* }}} */ /* {{{ proto void SplObjectStorage::detach(object obj) @@ -450,7 +448,7 @@ SPL_METHOD(SplObjectStorage, offsetGet) return; } - if (spl_object_storage_get_hash(&key, intern, ZEND_THIS, obj) == FAILURE) { + if (spl_object_storage_get_hash(&key, intern, Z_OBJ_P(ZEND_THIS), obj) == FAILURE) { return; } @@ -480,7 +478,7 @@ SPL_METHOD(SplObjectStorage, addAll) other = Z_SPLOBJSTORAGE_P(obj); - spl_object_storage_addall(intern, ZEND_THIS, other); + spl_object_storage_addall(intern, Z_OBJ_P(ZEND_THIS), other); RETURN_LONG(zend_hash_num_elements(&intern->storage)); } /* }}} */ @@ -729,7 +727,7 @@ SPL_METHOD(SplObjectStorage, serialize) /* members */ smart_str_appendl(&buf, "m:", 2); - ZVAL_ARR(&members, zend_array_dup(zend_std_get_properties(ZEND_THIS))); + ZVAL_ARR(&members, zend_array_dup(zend_std_get_properties(Z_OBJ_P(ZEND_THIS)))); php_var_serialize(&buf, &members, &var_hash); /* finishes the string */ zval_ptr_dtor(&members); @@ -815,7 +813,7 @@ SPL_METHOD(SplObjectStorage, unserialize) goto outexcept; } - if (spl_object_storage_get_hash(&key, intern, ZEND_THIS, &entry) == FAILURE) { + if (spl_object_storage_get_hash(&key, intern, Z_OBJ_P(ZEND_THIS), &entry) == FAILURE) { zval_ptr_dtor(&entry); zval_ptr_dtor(&inf); goto outexcept; @@ -830,7 +828,7 @@ SPL_METHOD(SplObjectStorage, unserialize) var_push_dtor(&var_hash, &pelement->obj); } } - element = spl_object_storage_attach(intern, ZEND_THIS, &entry, Z_ISUNDEF(inf)?NULL:&inf); + element = spl_object_storage_attach(intern, Z_OBJ_P(ZEND_THIS), &entry, Z_ISUNDEF(inf)?NULL:&inf); var_replace(&var_hash, &entry, &element->obj); var_replace(&var_hash, &inf, &element->inf); zval_ptr_dtor(&entry); @@ -1008,7 +1006,7 @@ SPL_METHOD(MultipleIterator, attachIterator) } } - spl_object_storage_attach(intern, ZEND_THIS, iterator, info); + spl_object_storage_attach(intern, Z_OBJ_P(ZEND_THIS), iterator, info); } /* }}} */ @@ -1029,7 +1027,7 @@ SPL_METHOD(MultipleIterator, rewind) zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos); while ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) != NULL && !EG(exception)) { it = &element->obj; - zend_call_method_with_0_params(it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs_ptr->zf_rewind, "rewind", NULL); + zend_call_method_with_0_params(Z_OBJ_P(it), Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs_ptr->zf_rewind, "rewind", NULL); zend_hash_move_forward_ex(&intern->storage, &intern->pos); } } @@ -1052,7 +1050,7 @@ SPL_METHOD(MultipleIterator, next) zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos); while ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) != NULL && !EG(exception)) { it = &element->obj; - zend_call_method_with_0_params(it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs_ptr->zf_next, "next", NULL); + zend_call_method_with_0_params(Z_OBJ_P(it), Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs_ptr->zf_next, "next", NULL); zend_hash_move_forward_ex(&intern->storage, &intern->pos); } } @@ -1082,7 +1080,7 @@ SPL_METHOD(MultipleIterator, valid) zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos); while ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) != NULL && !EG(exception)) { it = &element->obj; - zend_call_method_with_0_params(it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs_ptr->zf_valid, "valid", &retval); + zend_call_method_with_0_params(Z_OBJ_P(it), Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs_ptr->zf_valid, "valid", &retval); if (!Z_ISUNDEF(retval)) { valid = (Z_TYPE(retval) == IS_TRUE); @@ -1118,7 +1116,7 @@ static void spl_multiple_iterator_get_all(spl_SplObjectStorage *intern, int get_ zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos); while ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) != NULL && !EG(exception)) { it = &element->obj; - zend_call_method_with_0_params(it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs_ptr->zf_valid, "valid", &retval); + zend_call_method_with_0_params(Z_OBJ_P(it), Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs_ptr->zf_valid, "valid", &retval); if (!Z_ISUNDEF(retval)) { valid = Z_TYPE(retval) == IS_TRUE; @@ -1129,9 +1127,9 @@ static void spl_multiple_iterator_get_all(spl_SplObjectStorage *intern, int get_ if (valid) { if (SPL_MULTIPLE_ITERATOR_GET_ALL_CURRENT == get_type) { - zend_call_method_with_0_params(it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs_ptr->zf_current, "current", &retval); + zend_call_method_with_0_params(Z_OBJ_P(it), Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs_ptr->zf_current, "current", &retval); } else { - zend_call_method_with_0_params(it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs_ptr->zf_key, "key", &retval); + zend_call_method_with_0_params(Z_OBJ_P(it), Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs_ptr->zf_key, "key", &retval); } if (Z_ISUNDEF(retval)) { zend_throw_exception(spl_ce_RuntimeException, "Failed to call sub iterator method", 0); diff --git a/ext/standard/array.c b/ext/standard/array.c index b77f711c46..e8b0c64f3c 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -799,13 +799,13 @@ PHP_FUNCTION(count) /* first, we check if the handler is defined */ if (Z_OBJ_HT_P(array)->count_elements) { RETVAL_LONG(1); - if (SUCCESS == Z_OBJ_HT(*array)->count_elements(array, &Z_LVAL_P(return_value))) { + if (SUCCESS == Z_OBJ_HT(*array)->count_elements(Z_OBJ_P(array), &Z_LVAL_P(return_value))) { return; } } /* if not and the object implements Countable we call its count() method */ if (instanceof_function(Z_OBJCE_P(array), zend_ce_countable)) { - zend_call_method_with_0_params(array, NULL, NULL, "count", &retval); + zend_call_method_with_0_params(Z_OBJ_P(array), NULL, NULL, "count", &retval); if (Z_TYPE(retval) != IS_UNDEF) { RETVAL_LONG(zval_get_long(&retval)); zval_ptr_dtor(&retval); @@ -4150,9 +4150,12 @@ static inline zval *array_column_fetch_prop(zval *data, zval *name, zval *rv) /* /* The has_property check is first performed in "exists" mode (which returns true for * properties that are null but exist) and then in "has" mode to handle objects that * implement __isset (which is not called in "exists" mode). */ - if (Z_OBJ_HANDLER_P(data, has_property)(data, name, ZEND_PROPERTY_EXISTS, NULL) - || Z_OBJ_HANDLER_P(data, has_property)(data, name, ZEND_PROPERTY_ISSET, NULL)) { - prop = Z_OBJ_HANDLER_P(data, read_property)(data, name, BP_VAR_R, NULL, rv); + zend_string *str, *tmp_str; + + str = zval_get_tmp_string(name, &tmp_str); + if (Z_OBJ_HANDLER_P(data, has_property)(Z_OBJ_P(data), str, ZEND_PROPERTY_EXISTS, NULL) + || Z_OBJ_HANDLER_P(data, has_property)(Z_OBJ_P(data), str, ZEND_PROPERTY_ISSET, NULL)) { + prop = Z_OBJ_HANDLER_P(data, read_property)(Z_OBJ_P(data), str, BP_VAR_R, NULL, rv); if (prop) { ZVAL_DEREF(prop); if (prop != rv) { @@ -4160,6 +4163,7 @@ static inline zval *array_column_fetch_prop(zval *data, zval *name, zval *rv) /* } } } + zend_tmp_string_release(tmp_str); } else if (Z_TYPE_P(data) == IS_ARRAY) { if (Z_TYPE_P(name) == IS_STRING) { prop = zend_symtable_find(Z_ARRVAL_P(data), Z_STR_P(name)); diff --git a/ext/standard/file.c b/ext/standard/file.c index 70fb6abdeb..df4c50545b 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -691,7 +691,7 @@ PHP_FUNCTION(file_put_contents) if (Z_OBJ_HT_P(data) != NULL) { zval out; - if (zend_std_cast_object_tostring(data, &out, IS_STRING) == SUCCESS) { + if (zend_std_cast_object_tostring(Z_OBJ_P(data), &out, IS_STRING) == SUCCESS) { numbytes = php_stream_write(stream, Z_STRVAL(out), Z_STRLEN(out)); if (numbytes != Z_STRLEN(out)) { php_error_docref(NULL, E_WARNING, "Only "ZEND_LONG_FMT" of %zd bytes written, possibly out of free disk space", numbytes, Z_STRLEN(out)); diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c index f38fae5f53..0df21e37d7 100644 --- a/ext/standard/incomplete_class.c +++ b/ext/standard/incomplete_class.c @@ -32,7 +32,7 @@ static zend_object_handlers php_incomplete_object_handlers; /* {{{ incomplete_class_message */ -static void incomplete_class_message(zval *object, int error_type) +static void incomplete_class_message(zend_object *object, int error_type) { zend_string *class_name; @@ -47,7 +47,7 @@ static void incomplete_class_message(zval *object, int error_type) } /* }}} */ -static zval *incomplete_class_get_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */ +static zval *incomplete_class_get_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv) /* {{{ */ { incomplete_class_message(object, E_NOTICE); @@ -60,27 +60,27 @@ static zval *incomplete_class_get_property(zval *object, zval *member, int type, } /* }}} */ -static zval *incomplete_class_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */ +static zval *incomplete_class_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot) /* {{{ */ { incomplete_class_message(object, E_NOTICE); return value; } /* }}} */ -static zval *incomplete_class_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */ +static zval *incomplete_class_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot) /* {{{ */ { incomplete_class_message(object, E_NOTICE); return &EG(error_zval); } /* }}} */ -static void incomplete_class_unset_property(zval *object, zval *member, void **cache_slot) /* {{{ */ +static void incomplete_class_unset_property(zend_object *object, zend_string *member, void **cache_slot) /* {{{ */ { incomplete_class_message(object, E_NOTICE); } /* }}} */ -static int incomplete_class_has_property(zval *object, zval *member, int check_empty, void **cache_slot) /* {{{ */ +static int incomplete_class_has_property(zend_object *object, zend_string *member, int check_empty, void **cache_slot) /* {{{ */ { incomplete_class_message(object, E_NOTICE); return 0; @@ -89,10 +89,7 @@ static int incomplete_class_has_property(zval *object, zval *member, int check_e static zend_function *incomplete_class_get_method(zend_object **object, zend_string *method, const zval *key) /* {{{ */ { - zval zobject; - - ZVAL_OBJ(&zobject, *object); - incomplete_class_message(&zobject, E_ERROR); + incomplete_class_message(*object, E_ERROR); return NULL; } /* }}} */ @@ -132,15 +129,14 @@ PHPAPI zend_class_entry *php_create_incomplete_class(void) /* {{{ php_lookup_class_name */ -PHPAPI zend_string *php_lookup_class_name(zval *object) +PHPAPI zend_string *php_lookup_class_name(zend_object *object) { - zval *val; - HashTable *object_properties; - - object_properties = Z_OBJPROP_P(object); + if (object->properties) { + zval *val = zend_hash_str_find(object->properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER)-1); - if ((val = zend_hash_str_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER)-1)) != NULL && Z_TYPE_P(val) == IS_STRING) { - return zend_string_copy(Z_STR_P(val)); + if (val != NULL && Z_TYPE_P(val) == IS_STRING) { + return zend_string_copy(Z_STR_P(val)); + } } return NULL; diff --git a/ext/standard/php_incomplete_class.h b/ext/standard/php_incomplete_class.h index d768f25bdb..eeb4461965 100644 --- a/ext/standard/php_incomplete_class.h +++ b/ext/standard/php_incomplete_class.h @@ -27,7 +27,7 @@ #define PHP_SET_CLASS_ATTRIBUTES(struc) \ /* OBJECTS_FIXME: Fix for new object model */ \ if (Z_OBJCE_P(struc) == BG(incomplete_class)) { \ - class_name = php_lookup_class_name(struc); \ + class_name = php_lookup_class_name(Z_OBJ_P(struc)); \ if (!class_name) { \ class_name = zend_string_init(INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1, 0); \ } \ @@ -51,7 +51,7 @@ extern "C" { #endif PHPAPI zend_class_entry *php_create_incomplete_class(void); -PHPAPI zend_string *php_lookup_class_name(zval *object); +PHPAPI zend_string *php_lookup_class_name(zend_object *object); PHPAPI void php_store_class_name(zval *object, const char *name, size_t len); #ifdef __cplusplus diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index 34e877707c..bc1010243e 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -164,7 +164,7 @@ php_stream_filter_status_t userfilter_filter( zval func_name; zval retval; zval args[4]; - zval zpropname; + zend_string *propname; int call_result; /* the userfilter object probably doesn't exist anymore */ @@ -239,9 +239,9 @@ php_stream_filter_status_t userfilter_filter( /* filter resources are cleaned up by the stream destructor, * keeping a reference to the stream resource here would prevent it * from being destroyed properly */ - ZVAL_STRINGL(&zpropname, "stream", sizeof("stream")-1); - Z_OBJ_HANDLER_P(obj, unset_property)(obj, &zpropname, NULL); - zval_ptr_dtor(&zpropname); + propname = zend_string_init("stream", sizeof("stream")-1, 0); + Z_OBJ_HANDLER_P(obj, unset_property)(Z_OBJ_P(obj), propname, NULL); + zend_string_release_ex(propname, 0); zval_ptr_dtor(&args[3]); zval_ptr_dtor(&args[2]); diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index a7935dbcf1..c2d5a30cfc 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -215,8 +215,8 @@ static void tidy_object_free_storage(zend_object *); static zend_object *tidy_object_new_node(zend_class_entry *); static zend_object *tidy_object_new_doc(zend_class_entry *); static zval * tidy_instanciate(zend_class_entry *, zval *); -static int tidy_doc_cast_handler(zval *, zval *, int); -static int tidy_node_cast_handler(zval *, zval *, int); +static int tidy_doc_cast_handler(zend_object *, zval *, int); +static int tidy_node_cast_handler(zend_object *, zval *, int); static void tidy_doc_update_properties(PHPTidyObj *); static void tidy_add_default_properties(PHPTidyObj *, tidy_obj_type); static void *php_tidy_get_opt_val(PHPTidyDoc *, TidyOption, TidyOptionType *); @@ -752,7 +752,7 @@ static zval * tidy_instanciate(zend_class_entry *pce, zval *object) return object; } -static int tidy_doc_cast_handler(zval *in, zval *out, int type) +static int tidy_doc_cast_handler(zend_object *in, zval *out, int type) { TidyBuffer output; PHPTidyObj *obj; @@ -772,7 +772,7 @@ static int tidy_doc_cast_handler(zval *in, zval *out, int type) break; case IS_STRING: - obj = Z_TIDY_P(in); + obj = php_tidy_fetch_object(in); tidyBufInit(&output); tidySaveBuffer (obj->ptdoc->doc, &output); ZVAL_STRINGL(out, (char *) output.bp, output.size ? output.size-1 : 0); @@ -786,7 +786,7 @@ static int tidy_doc_cast_handler(zval *in, zval *out, int type) return SUCCESS; } -static int tidy_node_cast_handler(zval *in, zval *out, int type) +static int tidy_node_cast_handler(zend_object *in, zval *out, int type) { TidyBuffer buf; PHPTidyObj *obj; @@ -806,7 +806,7 @@ static int tidy_node_cast_handler(zval *in, zval *out, int type) break; case IS_STRING: - obj = Z_TIDY_P(in); + obj = php_tidy_fetch_object(in); tidyBufInit(&buf); if (obj->ptdoc) { tidyNodeGetText(obj->ptdoc->doc, obj->node, &buf); diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c index 007623f1fc..6e211adc86 100644 --- a/ext/xmlreader/php_xmlreader.c +++ b/ext/xmlreader/php_xmlreader.c @@ -114,30 +114,20 @@ static int xmlreader_property_reader(xmlreader_object *obj, xmlreader_prop_handl /* }}} */ /* {{{ xmlreader_get_property_ptr_ptr */ -zval *xmlreader_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) +zval *xmlreader_get_property_ptr_ptr(zend_object *object, zend_string *name, int type, void **cache_slot) { xmlreader_object *obj; - zval tmp_member; zval *retval = NULL; xmlreader_prop_handler *hnd = NULL; - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - } - - obj = Z_XMLREADER_P(object); + obj = php_xmlreader_fetch_object(object); if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member)); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd == NULL) { - retval = zend_std_get_property_ptr_ptr(object, member, type, cache_slot); - } - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); + retval = zend_std_get_property_ptr_ptr(object, name, type, cache_slot); } return retval; @@ -145,22 +135,16 @@ zval *xmlreader_get_property_ptr_ptr(zval *object, zval *member, int type, void /* }}} */ /* {{{ xmlreader_read_property */ -zval *xmlreader_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +zval *xmlreader_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { xmlreader_object *obj; - zval tmp_member; zval *retval = NULL; xmlreader_prop_handler *hnd = NULL; - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - } - - obj = Z_XMLREADER_P(object); + obj = php_xmlreader_fetch_object(object); if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member)); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd != NULL) { @@ -170,41 +154,28 @@ zval *xmlreader_read_property(zval *object, zval *member, int type, void **cache retval = rv; } } else { - retval = zend_std_read_property(object, member, type, cache_slot, rv); + retval = zend_std_read_property(object, name, type, cache_slot, rv); } - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } return retval; } /* }}} */ /* {{{ xmlreader_write_property */ -zval *xmlreader_write_property(zval *object, zval *member, zval *value, void **cache_slot) +zval *xmlreader_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { xmlreader_object *obj; - zval tmp_member; xmlreader_prop_handler *hnd = NULL; - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - } - - obj = Z_XMLREADER_P(object); + obj = php_xmlreader_fetch_object(object); if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member)); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd != NULL) { php_error_docref(NULL, E_WARNING, "Cannot write to read-only property"); } else { - value = zend_std_write_property(object, member, value, cache_slot); - } - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); + value = zend_std_write_property(object, name, value, cache_slot); } return value; diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index d71460efcf..2bb8fc0849 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -397,7 +397,8 @@ PHP_FUNCTION(xsl_xsltprocessor_import_stylesheet) xsl_object *intern; int prevSubstValue, prevExtDtdValue, clone_docu = 0; xmlNode *nodep = NULL; - zval *cloneDocu, member, rv; + zval *cloneDocu, rv; + zend_string *member; id = ZEND_THIS; if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &docp) == FAILURE) { @@ -433,13 +434,13 @@ PHP_FUNCTION(xsl_xsltprocessor_import_stylesheet) intern = Z_XSL_P(id); - ZVAL_STRING(&member, "cloneDocument"); - cloneDocu = zend_std_read_property(id, &member, BP_VAR_IS, NULL, &rv); + member = zend_string_init("cloneDocument", sizeof("cloneDocument")-1, 0); + cloneDocu = zend_std_read_property(Z_OBJ_P(id), member, BP_VAR_IS, NULL, &rv); if (Z_TYPE_P(cloneDocu) != IS_NULL) { convert_to_long(cloneDocu); clone_docu = Z_LVAL_P(cloneDocu); } - zval_ptr_dtor(&member); + zend_string_release_ex(member, 0); if (clone_docu == 0) { /* check if the stylesheet is using xsl:key, if yes, we have to clone the document _always_ before a transformation */ nodep = xmlDocGetRootElement(sheetp->doc); @@ -479,7 +480,8 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl php_libxml_node_object *object; char **params = NULL; int clone; - zval *doXInclude, member, rv; + zval *doXInclude, rv; + zend_string *member; FILE *f; int secPrefsError = 0; int secPrefsValue; @@ -529,13 +531,13 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl ctxt = xsltNewTransformContext(style, doc); ctxt->_private = (void *) intern; - ZVAL_STRING(&member, "doXInclude"); - doXInclude = zend_std_read_property(id, &member, BP_VAR_IS, NULL, &rv); + member = zend_string_init("doXInclude", sizeof("doXInclude")-1, 0); + doXInclude = zend_std_read_property(Z_OBJ_P(id), member, BP_VAR_IS, NULL, &rv); if (Z_TYPE_P(doXInclude) != IS_NULL) { convert_to_long(doXInclude); ctxt->xinclude = Z_LVAL_P(doXInclude); } - zval_ptr_dtor(&member); + zend_string_release_ex(member, 0); secPrefsValue = intern->securityPrefs; diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 9275ab1c46..6c4ada63bd 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -872,54 +872,36 @@ static zval *php_zip_property_reader(ze_zip_object *obj, zip_prop_handler *hnd, } /* }}} */ -static zval *php_zip_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */ +static zval *php_zip_get_property_ptr_ptr(zend_object *object, zend_string *name, int type, void **cache_slot) /* {{{ */ { ze_zip_object *obj; - zval tmp_member; zval *retval = NULL; zip_prop_handler *hnd = NULL; - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - cache_slot = NULL; - } - - obj = Z_ZIP_P(object); + obj = php_zip_fetch_object(object); if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member)); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd == NULL) { - retval = zend_std_get_property_ptr_ptr(object, member, type, cache_slot); - } - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); + retval = zend_std_get_property_ptr_ptr(object, name, type, cache_slot); } return retval; } /* }}} */ -static zval *php_zip_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) /* {{{ */ +static zval *php_zip_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) /* {{{ */ { ze_zip_object *obj; - zval tmp_member; zval *retval = NULL; zip_prop_handler *hnd = NULL; - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - cache_slot = NULL; - } - - obj = Z_ZIP_P(object); + obj = php_zip_fetch_object(object); if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member)); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd != NULL) { @@ -928,34 +910,23 @@ static zval *php_zip_read_property(zval *object, zval *member, int type, void ** retval = &EG(uninitialized_zval); } } else { - retval = zend_std_read_property(object, member, type, cache_slot, rv); - } - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); + retval = zend_std_read_property(object, name, type, cache_slot, rv); } return retval; } /* }}} */ -static int php_zip_has_property(zval *object, zval *member, int type, void **cache_slot) /* {{{ */ +static int php_zip_has_property(zend_object *object, zend_string *name, int type, void **cache_slot) /* {{{ */ { ze_zip_object *obj; - zval tmp_member; zip_prop_handler *hnd = NULL; int retval = 0; - if (Z_TYPE_P(member) != IS_STRING) { - ZVAL_STR(&tmp_member, zval_get_string_func(member)); - member = &tmp_member; - cache_slot = NULL; - } - - obj = Z_ZIP_P(object); + obj = php_zip_fetch_object(object); if (obj->prop_handler != NULL) { - hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member)); + hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd != NULL) { @@ -973,18 +944,14 @@ static int php_zip_has_property(zval *object, zval *member, int type, void **cac zval_ptr_dtor(&tmp); } else { - retval = zend_std_has_property(object, member, type, cache_slot); - } - - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); + retval = zend_std_has_property(object, name, type, cache_slot); } return retval; } /* }}} */ -static HashTable *php_zip_get_gc(zval *object, zval **gc_data, int *gc_data_count) /* {{{ */ +static HashTable *php_zip_get_gc(zend_object *object, zval **gc_data, int *gc_data_count) /* {{{ */ { *gc_data = NULL; *gc_data_count = 0; @@ -992,14 +959,14 @@ static HashTable *php_zip_get_gc(zval *object, zval **gc_data, int *gc_data_coun } /* }}} */ -static HashTable *php_zip_get_properties(zval *object)/* {{{ */ +static HashTable *php_zip_get_properties(zend_object *object)/* {{{ */ { ze_zip_object *obj; HashTable *props; zip_prop_handler *hnd; zend_string *key; - obj = Z_ZIP_P(object); + obj = php_zip_fetch_object(object); props = zend_std_get_properties(object); if (obj->prop_handler == NULL) { diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 608f1b0e25..22025fa59a 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -1104,7 +1104,7 @@ static int do_cli(int argc, char **argv) /* {{{ */ memset(&execute_data, 0, sizeof(zend_execute_data)); EG(current_execute_data) = &execute_data; - zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, &arg); + zend_call_method_with_1_params(Z_OBJ(ref), pce, &pce->constructor, "__construct", NULL, &arg); if (EG(exception)) { zval tmp, *msg, rv; diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index f0d0e13e3b..64fece82fd 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -775,7 +775,7 @@ static inline void phpdbg_handle_exception(void) /* {{{ */ EG(exception) = NULL; ZVAL_OBJ(&zv, ex); - zend_call_method_with_0_params(&zv, ex->ce, &ex->ce->__tostring, "__tostring", &tmp); + zend_call_method_with_0_params(ex, ex->ce, &ex->ce->__tostring, "__tostring", &tmp); file = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("file"), 1, &rv)); line = zval_get_long(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("line"), 1, &rv)); |