diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-03-28 02:11:22 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-03-28 02:11:22 +0400 |
commit | ea85451b65b904d0670c4011c819a15431720432 (patch) | |
tree | 83bde21b41665b493d7337ff34d622f67cd5c78c | |
parent | 68385716a4bb233ba17acb587b0a7aa5d2e3d448 (diff) | |
download | php-git-ea85451b65b904d0670c4011c819a15431720432.tar.gz |
Refactored data structures to keep zend_object* instead of a whole zval in some places
37 files changed, 636 insertions, 628 deletions
diff --git a/Zend/zend.c b/Zend/zend.c index e764abb999..c7564daa47 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -370,7 +370,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC) /* {{{ */ zend_string *class_name = NULL; if (Z_OBJ_HANDLER_P(expr, get_class_name)) { - class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(expr, 0 TSRMLS_CC); + class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr), 0 TSRMLS_CC); } if (class_name) { zend_printf("%s Object (", class_name->val); @@ -429,7 +429,7 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int int is_temp; if (Z_OBJ_HANDLER_P(expr, get_class_name)) { - class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(expr, 0 TSRMLS_CC); + class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr), 0 TSRMLS_CC); } if (class_name) { ZEND_PUTS_EX(class_name->val); diff --git a/Zend/zend.h b/Zend/zend.h index 28c31a3987..9f41978b1f 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -286,8 +286,13 @@ typedef enum { #include "zend_hash.h" #include "zend_llist.h" -#define INTERNAL_FUNCTION_PARAMETERS zend_uint param_count, zval *return_value, zval *this_ptr, int return_value_used TSRMLS_DC -#define INTERNAL_FUNCTION_PARAM_PASSTHRU param_count, return_value, this_ptr, return_value_used TSRMLS_CC +#define INTERNAL_FUNCTION_PARAMETERS zend_uint param_count, zval *return_value TSRMLS_DC +#define INTERNAL_FUNCTION_PARAM_PASSTHRU param_count, return_value TSRMLS_CC + +#define USED_RET() \ + (!EG(current_execute_data) || \ + !EG(current_execute_data)->opline || \ + !(EG(current_execute_data)->opline->result_type & EXT_TYPE_UNUSED)) #if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__) void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((noreturn)); diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 63bcab7368..bcca30e1a3 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -232,10 +232,10 @@ ZEND_API char *zend_zval_type_name(const zval *arg) /* {{{ */ } /* }}} */ -ZEND_API zend_class_entry *zend_get_class_entry(const zval *zobject TSRMLS_DC) /* {{{ */ +ZEND_API zend_class_entry *zend_get_class_entry(const zend_object *zobject TSRMLS_DC) /* {{{ */ { - if (Z_OBJ_HT_P(zobject)->get_class_entry) { - return Z_OBJ_HT_P(zobject)->get_class_entry(zobject TSRMLS_CC); + if (zobject->handlers->get_class_entry) { + return zobject->handlers->get_class_entry(zobject TSRMLS_CC); } else { zend_error(E_ERROR, "Class entry requested for an object without PHP class"); return NULL; @@ -244,17 +244,17 @@ ZEND_API zend_class_entry *zend_get_class_entry(const zval *zobject TSRMLS_DC) / /* }}} */ /* returns 1 if you need to copy result, 0 if it's already a copy */ -ZEND_API zend_string *zend_get_object_classname(const zval *object TSRMLS_DC) /* {{{ */ +ZEND_API zend_string *zend_get_object_classname(const zend_object *object TSRMLS_DC) /* {{{ */ { zend_string *ret; - if (Z_OBJ_HT_P(object)->get_class_name != NULL) { - ret = Z_OBJ_HT_P(object)->get_class_name(object, 0 TSRMLS_CC); + if (object->handlers->get_class_name != NULL) { + ret = object->handlers->get_class_name(object, 0 TSRMLS_CC); if (ret) { return ret; } } - return Z_OBJCE_P(object)->name; + return zend_get_class_entry(object TSRMLS_CC)->name; } /* }}} */ @@ -2807,8 +2807,8 @@ static int zend_is_callable_check_class(zend_string *name, zend_fcall_info_cache } else { fcc->called_scope = EG(called_scope); fcc->calling_scope = EG(scope); - if (Z_TYPE(fcc->object) == IS_UNDEF && Z_TYPE(EG(This)) == IS_OBJECT) { - ZVAL_COPY_VALUE(&fcc->object, &EG(This)); + if (!fcc->object && Z_OBJ(EG(This))) { + fcc->object = Z_OBJ(EG(This)); } ret = 1; } @@ -2821,8 +2821,8 @@ static int zend_is_callable_check_class(zend_string *name, zend_fcall_info_cache } else { fcc->called_scope = EG(called_scope); fcc->calling_scope = EG(scope)->parent; - if (Z_TYPE(fcc->object) == IS_UNDEF && Z_TYPE(EG(This)) == IS_OBJECT) { - ZVAL_COPY_VALUE(&fcc->object, &EG(This)); + if (!fcc->object && Z_OBJ(EG(This))) { + fcc->object = Z_OBJ(EG(This)); } *strict_class = 1; ret = 1; @@ -2834,8 +2834,8 @@ static int zend_is_callable_check_class(zend_string *name, zend_fcall_info_cache } else { fcc->called_scope = EG(called_scope); fcc->calling_scope = EG(called_scope); - if (Z_TYPE(fcc->object) == IS_UNDEF && Z_TYPE(EG(This)) == IS_OBJECT) { - ZVAL_COPY_VALUE(&fcc->object, &EG(This)); + if (!fcc->object && Z_OBJ(EG(This))) { + fcc->object = Z_OBJ(EG(This)); } *strict_class = 1; ret = 1; @@ -2844,13 +2844,13 @@ static int zend_is_callable_check_class(zend_string *name, zend_fcall_info_cache zend_class_entry *scope = EG(active_op_array) ? EG(active_op_array)->scope : NULL; fcc->calling_scope = ce; - if (scope && Z_TYPE(fcc->object) == IS_UNDEF && Z_TYPE(EG(This)) != IS_UNDEF && + if (scope && !fcc->object && Z_OBJ(EG(This)) && instanceof_function(Z_OBJCE(EG(This)), scope TSRMLS_CC) && instanceof_function(scope, fcc->calling_scope TSRMLS_CC)) { - ZVAL_COPY_VALUE(&fcc->object, &EG(This)); - fcc->called_scope = Z_OBJCE(fcc->object); + fcc->object = Z_OBJ(EG(This)); + fcc->called_scope = Z_OBJCE(EG(This)); } else { - fcc->called_scope = Z_TYPE(fcc->object) == IS_OBJECT ? Z_OBJCE(fcc->object) : fcc->calling_scope; + fcc->called_scope = fcc->object ? zend_get_class_entry(fcc->object TSRMLS_CC) : fcc->calling_scope; } *strict_class = 1; ret = 1; @@ -2976,10 +2976,10 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca } if ((check_flags & IS_CALLABLE_CHECK_NO_ACCESS) == 0 && (fcc->calling_scope && - ((Z_TYPE(fcc->object) == IS_OBJECT && fcc->calling_scope->__call) || - (Z_TYPE(fcc->object) == IS_UNDEF && fcc->calling_scope->__callstatic)))) { + ((fcc->object && fcc->calling_scope->__call) || + (!fcc->object && fcc->calling_scope->__callstatic)))) { if (fcc->function_handler->op_array.fn_flags & ZEND_ACC_PRIVATE) { - if (!zend_check_private(fcc->function_handler, Z_TYPE(fcc->object) == IS_OBJECT ? Z_OBJCE(fcc->object) : EG(scope), lmname TSRMLS_CC)) { + if (!zend_check_private(fcc->function_handler, fcc->object ? zend_get_class_entry(fcc->object TSRMLS_CC) : EG(scope), lmname TSRMLS_CC)) { retval = 0; fcc->function_handler = NULL; goto get_function_via_handler; @@ -2994,7 +2994,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca } } else { get_function_via_handler: - if (Z_TYPE(fcc->object) == IS_OBJECT && fcc->calling_scope == ce_org) { + if (fcc->object && fcc->calling_scope == ce_org) { if (strict_class && ce_org->__call) { fcc->function_handler = emalloc(sizeof(zend_internal_function)); fcc->function_handler->internal_function.type = ZEND_INTERNAL_FUNCTION; @@ -3008,8 +3008,8 @@ get_function_via_handler: STR_ADDREF(mname); call_via_handler = 1; retval = 1; - } else if (Z_OBJ_HT(fcc->object)->get_method) { - fcc->function_handler = Z_OBJ_HT(fcc->object)->get_method(&fcc->object, mname, NULL TSRMLS_CC); + } else if (fcc->object->handlers->get_method) { + fcc->function_handler = fcc->object->handlers->get_method(&fcc->object, mname, NULL TSRMLS_CC); if (fcc->function_handler) { if (strict_class && (!fcc->function_handler->common.scope || @@ -3035,10 +3035,10 @@ get_function_via_handler: if (fcc->function_handler) { retval = 1; call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0; - if (call_via_handler && Z_TYPE(fcc->object) == IS_UNDEF && Z_TYPE(EG(This)) != IS_UNDEF && + if (call_via_handler && !fcc->object && Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && instanceof_function(Z_OBJCE(EG(This)), fcc->calling_scope TSRMLS_CC)) { - ZVAL_COPY_VALUE(&fcc->object, &EG(This)); + fcc->object = Z_OBJ(EG(This)); } } } @@ -3046,14 +3046,14 @@ get_function_via_handler: if (retval) { if (fcc->calling_scope && !call_via_handler) { - if (Z_TYPE(fcc->object) == IS_UNDEF && (fcc->function_handler->common.fn_flags & ZEND_ACC_ABSTRACT)) { + if (!fcc->object && (fcc->function_handler->common.fn_flags & ZEND_ACC_ABSTRACT)) { if (error) { zend_spprintf(error, 0, "cannot call abstract method %s::%s()", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val); retval = 0; } else { zend_error(E_ERROR, "Cannot call abstract method %s::%s()", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val); } - } else if (Z_TYPE(fcc->object) == IS_UNDEF && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) { + } else if (!fcc->object && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) { int severity; char *verb; if (fcc->function_handler->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { @@ -3067,8 +3067,8 @@ get_function_via_handler: if ((check_flags & IS_CALLABLE_CHECK_IS_STATIC) != 0) { retval = 0; } - if (Z_TYPE(EG(This)) != IS_UNDEF && instanceof_function(Z_OBJCE(EG(This)), fcc->calling_scope TSRMLS_CC)) { - ZVAL_COPY_VALUE(&fcc->object, &EG(This)); + if (Z_OBJ(EG(This)) && instanceof_function(Z_OBJCE(EG(This)), fcc->calling_scope TSRMLS_CC)) { + fcc->object = Z_OBJ(EG(This)); if (error) { zend_spprintf(error, 0, "non-static method %s::%s() %s be called statically, assuming $this from compatible context %s", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val, verb, Z_OBJCE(EG(This))->name->val); if (severity == E_ERROR) { @@ -3090,7 +3090,7 @@ get_function_via_handler: } if (retval && (check_flags & IS_CALLABLE_CHECK_NO_ACCESS) == 0) { if (fcc->function_handler->op_array.fn_flags & ZEND_ACC_PRIVATE) { - if (!zend_check_private(fcc->function_handler, Z_TYPE(fcc->object) == IS_OBJECT ? Z_OBJCE(fcc->object) : EG(scope), lmname TSRMLS_CC)) { + if (!zend_check_private(fcc->function_handler, fcc->object ? zend_get_class_entry(fcc->object TSRMLS_CC) : EG(scope), lmname TSRMLS_CC)) { if (error) { if (*error) { efree(*error); @@ -3122,8 +3122,8 @@ get_function_via_handler: STR_FREE(lmname); STR_RELEASE(mname); - if (Z_TYPE(fcc->object) == IS_OBJECT) { - fcc->called_scope = Z_OBJCE(fcc->object); + if (fcc->object) { + fcc->called_scope = zend_get_class_entry(fcc->object TSRMLS_CC); } if (retval) { fcc->initialized = 1; @@ -3132,7 +3132,7 @@ get_function_via_handler: } /* }}} */ -ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */ +ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error TSRMLS_DC) /* {{{ */ { zend_bool ret; zend_fcall_info_cache fcc_local; @@ -3152,23 +3152,19 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch fcc->called_scope = NULL; fcc->function_handler = NULL; fcc->calling_scope = NULL; - ZVAL_UNDEF(&fcc->object); + fcc->object = NULL; - if (object_ptr && Z_TYPE_P(object_ptr) != IS_OBJECT) { - object_ptr = NULL; - } - - if (object_ptr && + if (object && (!EG(objects_store).object_buckets || - !IS_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(object_ptr)]))) { + !IS_VALID(EG(objects_store).object_buckets[object->handle]))) { return 0; } switch (Z_TYPE_P(callable)) { case IS_STRING: - if (object_ptr) { - ZVAL_COPY_VALUE(&fcc->object, object_ptr); - fcc->calling_scope = Z_OBJCE_P(object_ptr); + if (object) { + fcc->object = object; + fcc->calling_scope = zend_get_class_entry(object TSRMLS_CC); if (callable_name) { char *ptr; @@ -3254,7 +3250,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch fcc->calling_scope = Z_OBJCE_P(obj); /* TBFixed: what if it's overloaded? */ - ZVAL_COPY_VALUE(&fcc->object, obj); + fcc->object = Z_OBJ_P(obj); if (callable_name) { char *ptr; @@ -3378,7 +3374,7 @@ ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_i fci->size = sizeof(*fci); fci->function_table = fcc->calling_scope ? &fcc->calling_scope->function_table : EG(function_table); - fci->object_ptr = &fcc->object; + fci->object = fcc->object; ZVAL_COPY_VALUE(&fci->function_name, callable); fci->retval = NULL; fci->param_count = 0; @@ -3752,7 +3748,7 @@ ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const EG(scope) = scope; if (!Z_OBJ_HT_P(object)->write_property) { - zend_string *class_name = zend_get_object_classname(object TSRMLS_CC); + zend_string *class_name = zend_get_object_classname(Z_OBJ_P(object) TSRMLS_CC); zend_error(E_CORE_ERROR, "Property %s of class %s cannot be updated", name, class_name->val); } ZVAL_STRINGL(&property, name, name_length); @@ -3930,7 +3926,7 @@ ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const c EG(scope) = scope; if (!Z_OBJ_HT_P(object)->read_property) { - zend_string *class_name = zend_get_object_classname(object TSRMLS_CC); + zend_string *class_name = zend_get_object_classname(Z_OBJ_P(object) TSRMLS_CC); zend_error(E_CORE_ERROR, "Property %s of class %s cannot be read", name, class_name->val); } diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 05973d63dc..c6f30fada3 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -48,7 +48,7 @@ typedef struct _zend_fcall_info { zval *retval; zend_uint param_count; zval *params; - zval *object_ptr; + zend_object *object; zend_bool no_separation; } zend_fcall_info; @@ -57,7 +57,7 @@ typedef struct _zend_fcall_info_cache { zend_function *function_handler; zend_class_entry *calling_scope; zend_class_entry *called_scope; - zval object; + zend_object *object; } zend_fcall_info_cache; #define ZEND_NS_NAME(ns, name) ns "\\" name @@ -295,7 +295,7 @@ ZEND_API void zend_wrong_param_count(TSRMLS_D); #define IS_CALLABLE_STRICT (IS_CALLABLE_CHECK_IS_STATIC) -ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error TSRMLS_DC); +ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error TSRMLS_DC); ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, zend_string **callable_name TSRMLS_DC); ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_name TSRMLS_DC); ZEND_API const char *zend_get_module_version(const char *module_name); @@ -339,11 +339,11 @@ ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const c ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, int name_length, zend_bool silent TSRMLS_DC); -ZEND_API zend_class_entry *zend_get_class_entry(const zval *zobject TSRMLS_DC); -ZEND_API zend_string *zend_get_object_classname(const zval *object TSRMLS_DC); +ZEND_API zend_class_entry *zend_get_class_entry(const zend_object *object TSRMLS_DC); +ZEND_API zend_string *zend_get_object_classname(const zend_object *object TSRMLS_DC); ZEND_API char *zend_get_type_by_const(int type); -#define getThis() (this_ptr) +#define getThis() (Z_OBJ(EG(This)) ? &EG(This) : NULL) #define WRONG_PARAM_COUNT ZEND_WRONG_PARAM_COUNT() #define WRONG_PARAM_COUNT_WITH_RETVAL(ret) ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 64be0e4b46..af9667ed8d 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -771,7 +771,7 @@ ZEND_FUNCTION(get_class) } } - RETURN_STR(zend_get_object_classname(obj TSRMLS_CC)); + RETURN_STR(zend_get_object_classname(Z_OBJ_P(obj) TSRMLS_CC)); } /* }}} */ @@ -817,10 +817,10 @@ ZEND_FUNCTION(get_parent_class) if (Z_TYPE_P(arg) == IS_OBJECT) { if (Z_OBJ_HT_P(arg)->get_class_name - && (name = Z_OBJ_HT_P(arg)->get_class_name(arg, 1 TSRMLS_CC)) != NULL) { + && (name = Z_OBJ_HT_P(arg)->get_class_name(Z_OBJ_P(arg), 1 TSRMLS_CC)) != NULL) { RETURN_STR(name); } else { - ce = zend_get_class_entry(arg TSRMLS_CC); + ce = zend_get_class_entry(Z_OBJ_P(arg) TSRMLS_CC); } } else if (Z_TYPE_P(arg) == IS_STRING) { ce = zend_lookup_class(Z_STR_P(arg) TSRMLS_CC); @@ -1134,7 +1134,7 @@ ZEND_FUNCTION(method_exists) if (Z_TYPE_P(klass) == IS_OBJECT && Z_OBJ_HT_P(klass)->get_method != NULL - && (func = Z_OBJ_HT_P(klass)->get_method(klass, method_name, NULL TSRMLS_CC)) != NULL + && (func = Z_OBJ_HT_P(klass)->get_method(&Z_OBJ_P(klass), method_name, NULL TSRMLS_CC)) != NULL ) { if (func->type == ZEND_INTERNAL_FUNCTION && (func->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0 @@ -2071,8 +2071,8 @@ ZEND_FUNCTION(debug_print_backtrace) function_name = (ptr->function_state.function->common.scope && ptr->function_state.function->common.scope->trait_aliases) ? zend_resolve_method_name( - Z_TYPE(ptr->object) != IS_UNDEF ? - Z_OBJCE(ptr->object) : + ptr->object ? + zend_get_class_entry(ptr->object TSRMLS_CC) : ptr->function_state.function->common.scope, ptr->function_state.function)->val : (ptr->function_state.function->common.function_name ? @@ -2080,11 +2080,11 @@ ZEND_FUNCTION(debug_print_backtrace) NULL); if (function_name) { - if (Z_TYPE(ptr->object) != IS_UNDEF) { + if (ptr->object) { if (ptr->function_state.function->common.scope) { class_name = ptr->function_state.function->common.scope->name; } else { - class_name = zend_get_object_classname(&ptr->object TSRMLS_CC); + class_name = zend_get_object_classname(ptr->object TSRMLS_CC); } call_type = "->"; @@ -2250,8 +2250,8 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int function_name = (ptr->function_state.function->common.scope && ptr->function_state.function->common.scope->trait_aliases) ? zend_resolve_method_name( - Z_TYPE(ptr->object) != IS_UNDEF ? - Z_OBJCE(ptr->object) : + ptr->object ? + zend_get_class_entry(ptr->object TSRMLS_CC) : ptr->function_state.function->common.scope, ptr->function_state.function)->val : (ptr->function_state.function->common.function_name ? @@ -2261,17 +2261,19 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int if (function_name) { add_assoc_string_ex(&stack_frame, "function", sizeof("function")-1, (char*)function_name, 1); - if (Z_TYPE(ptr->object) == IS_OBJECT) { + if (ptr->object) { if (ptr->function_state.function->common.scope) { add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, STR_COPY(ptr->function_state.function->common.scope->name)); } else { - class_name = zend_get_object_classname(&ptr->object TSRMLS_CC); + class_name = zend_get_object_classname(ptr->object TSRMLS_CC); add_assoc_str_ex(&stack_frame, "class", sizeof("class")-1, STR_COPY(class_name)); } if ((options & DEBUG_BACKTRACE_PROVIDE_OBJECT) != 0) { - add_assoc_zval_ex(&stack_frame, "object", sizeof("object")-1, &ptr->object); - Z_ADDREF(ptr->object); + zval object; + ZVAL_OBJ(&object, ptr->object); + add_assoc_zval_ex(&stack_frame, "object", sizeof("object")-1, &object); + Z_ADDREF(object); } add_assoc_string_ex(&stack_frame, "type", sizeof("type")-1, "->", 1); diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 9b4c2b4bce..0fa0a6aec3 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -55,7 +55,7 @@ ZEND_METHOD(Closure, __invoke) /* {{{ */ efree(arguments); zend_error(E_RECOVERABLE_ERROR, "Cannot get arguments for calling closure"); RETVAL_FALSE; - } else if (call_user_function_ex(CG(function_table), NULL, this_ptr, return_value, ZEND_NUM_ARGS(), arguments, 1, NULL TSRMLS_CC) == FAILURE) { + } else if (call_user_function_ex(CG(function_table), NULL, getThis(), return_value, ZEND_NUM_ARGS(), arguments, 1, NULL TSRMLS_CC) == FAILURE) { RETVAL_FALSE; } efree(arguments); @@ -121,7 +121,7 @@ ZEND_METHOD(Closure, bind) } /* }}} */ -static zend_function *zend_closure_get_constructor(zval *object TSRMLS_DC) /* {{{ */ +static zend_function *zend_closure_get_constructor(zend_object *object TSRMLS_DC) /* {{{ */ { zend_error(E_RECOVERABLE_ERROR, "Instantiation of 'Closure' is not allowed"); return NULL; @@ -134,9 +134,9 @@ static int zend_closure_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */ } /* }}} */ -ZEND_API zend_function *zend_get_closure_invoke_method(zval *obj TSRMLS_DC) /* {{{ */ +ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object TSRMLS_DC) /* {{{ */ { - zend_closure *closure = (zend_closure *)Z_OBJ_P(obj); + zend_closure *closure = (zend_closure *)object; zend_function *invoke = (zend_function*)emalloc(sizeof(zend_function)); invoke->common = closure->func.common; @@ -164,7 +164,7 @@ ZEND_API zval* zend_get_closure_this_ptr(zval *obj TSRMLS_DC) /* {{{ */ } /* }}} */ -static zend_function *zend_closure_get_method(zval *object_ptr, zend_string *method, const zend_literal *key TSRMLS_DC) /* {{{ */ +static zend_function *zend_closure_get_method(zend_object **object, zend_string *method, const zend_literal *key TSRMLS_DC) /* {{{ */ { zend_string *lc_name; @@ -174,10 +174,10 @@ static zend_function *zend_closure_get_method(zval *object_ptr, zend_string *met memcmp(lc_name->val, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 ) { STR_FREE(lc_name); - return zend_get_closure_invoke_method(object_ptr TSRMLS_CC); + return zend_get_closure_invoke_method(*object TSRMLS_CC); } STR_FREE(lc_name); - return std_object_handlers.get_method(object_ptr, method, key TSRMLS_CC); + return std_object_handlers.get_method(object, method, key TSRMLS_CC); } /* }}} */ @@ -271,7 +271,7 @@ static zend_object *zend_closure_clone(zval *zobject TSRMLS_DC) /* {{{ */ } /* }}} */ -int zend_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zval *zobj_ptr TSRMLS_DC) /* {{{ */ +int zend_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr TSRMLS_DC) /* {{{ */ { zend_closure *closure; @@ -283,13 +283,13 @@ int zend_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function *fptr_ptr = &closure->func; if (Z_TYPE(closure->this_ptr) != IS_UNDEF) { - if (zobj_ptr) { - ZVAL_COPY_VALUE(zobj_ptr, &closure->this_ptr); + if (obj_ptr) { + *obj_ptr = Z_OBJ(closure->this_ptr); } *ce_ptr = Z_OBJCE(closure->this_ptr); } else { - if (zobj_ptr) { - ZVAL_UNDEF(zobj_ptr); + if (obj_ptr) { + *obj_ptr = NULL; } *ce_ptr = closure->func.common.scope; } diff --git a/Zend/zend_closures.h b/Zend/zend_closures.h index fa66e9747d..4f8ae6dd91 100644 --- a/Zend/zend_closures.h +++ b/Zend/zend_closures.h @@ -29,7 +29,7 @@ void zend_register_closure_ce(TSRMLS_D); extern ZEND_API zend_class_entry *zend_ce_closure; ZEND_API void zend_create_closure(zval *res, zend_function *op_array, zend_class_entry *scope, zval *this_ptr TSRMLS_DC); -ZEND_API zend_function *zend_get_closure_invoke_method(zval *obj TSRMLS_DC); +ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *obj TSRMLS_DC); ZEND_API const zend_function *zend_get_closure_method_def(zval *obj TSRMLS_DC); ZEND_API zval* zend_get_closure_this_ptr(zval *obj TSRMLS_DC); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 3aacbff993..33f1007257 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -368,7 +368,7 @@ typedef struct _list_llist_element { typedef struct _call_slot { zend_function *fbc; zend_class_entry *called_scope; - zval object; + zend_object *object; zend_uint num_additional_args; zend_bool is_ctor_call; zend_bool is_ctor_result_used; @@ -378,7 +378,7 @@ struct _zend_execute_data { struct _zend_op *opline; zend_function_state function_state; zend_op_array *op_array; - zval object; + zend_object *object; zend_array *symbol_table; struct _zend_execute_data *prev_execute_data; zval old_error_reporting; @@ -387,7 +387,7 @@ struct _zend_execute_data { //??? zend_class_entry *current_scope; zend_class_entry *current_called_scope; - zval current_this; + zend_object *current_this; struct _zend_op *fast_ret; /* used by FAST_CALL/FAST_RET (finally keyword) */ zend_object *delayed_exception; call_slot *call_slots; diff --git a/Zend/zend_dtrace.c b/Zend/zend_dtrace.c index 51bd1f421c..8d854f1ef8 100644 --- a/Zend/zend_dtrace.c +++ b/Zend/zend_dtrace.c @@ -81,7 +81,7 @@ ZEND_API void dtrace_execute_ex(zend_execute_data *execute_data TSRMLS_DC) } } -ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC) +ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_info *fci TSRMLS_DC) { int lineno; const char *filename; @@ -94,7 +94,7 @@ ZEND_API void dtrace_execute_internal(zend_execute_data *execute_data_ptr, zend_ DTRACE_EXECUTE_ENTRY((char *)filename, lineno); } - execute_internal(execute_data_ptr, fci, return_value_used TSRMLS_CC); + execute_internal(execute_data_ptr, fci TSRMLS_CC); if (DTRACE_EXECUTE_RETURN_ENABLED()) { DTRACE_EXECUTE_RETURN((char *)filename, lineno); diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 5ba0ae3bc3..5cb2e6f618 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -92,7 +92,7 @@ void zend_throw_exception_internal(zval *exception TSRMLS_DC) /* {{{ */ zend_uint name_len; if (exception != NULL) { - zend_get_object_classname(exception, &classname, &name_len TSRMLS_CC); + zend_get_object_classname(Z_OBJ_P(exception), &classname, &name_len TSRMLS_CC); DTRACE_EXCEPTION_THROWN((char *)classname); } else { DTRACE_EXCEPTION_THROWN(NULL); @@ -445,7 +445,7 @@ static int _build_trace_args(zval *arg TSRMLS_DC, int num_args, va_list args, ze TRACE_APPEND_STR("Object("); - class_name = zend_get_object_classname(arg TSRMLS_CC); + class_name = zend_get_object_classname(Z_OBJ_P(arg) TSRMLS_CC); TRACE_APPEND_STRL(class_name->val, class_name->len); //??? if(!dup) { @@ -612,7 +612,7 @@ ZEND_METHOD(exception, __toString) fci.function_table = &Z_OBJCE_P(exception)->function_table; ZVAL_COPY_VALUE(&fci.function_name, &fname); fci.symbol_table = NULL; - fci.object_ptr = exception; + fci.object = Z_OBJ_P(exception); fci.retval = &trace; fci.param_count = 0; fci.params = NULL; diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 2852d17af4..344b21bc4f 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -480,7 +480,7 @@ static zend_always_inline zval *_get_zval_ptr_var_fast(zend_uint var, const zend static zend_always_inline zval *_get_obj_zval_ptr_unused(TSRMLS_D) { - if (EXPECTED(Z_TYPE(EG(This)) != IS_UNDEF)) { + if (EXPECTED(Z_OBJ(EG(This)) != NULL)) { return &EG(This); } else { zend_error_noreturn(E_ERROR, "Using $this when not in object context"); @@ -491,7 +491,7 @@ static zend_always_inline zval *_get_obj_zval_ptr_unused(TSRMLS_D) static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) { if (op_type == IS_UNUSED) { - if (EXPECTED(Z_TYPE(EG(This)) != IS_UNDEF)) { + if (EXPECTED(Z_OBJ(EG(This)) != NULL)) { should_free->var = NULL; return &EG(This); } else { @@ -1423,18 +1423,16 @@ static int zend_check_symbol(zval **pz TSRMLS_DC) ZEND_API opcode_handler_t *zend_opcode_handlers; -ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC) +ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_info *fci TSRMLS_DC) { if (fci != NULL) { execute_data_ptr->function_state.function->internal_function.handler( - fci->param_count, fci->retval, - fci->object_ptr, 1 TSRMLS_CC + fci->param_count, fci->retval TSRMLS_CC ); } else { zval *return_value = EX_VAR_2(execute_data_ptr, execute_data_ptr->opline->result.var); execute_data_ptr->function_state.function->internal_function.handler( - execute_data_ptr->opline->extended_value, return_value, - &execute_data_ptr->object, return_value_used TSRMLS_CC + execute_data_ptr->opline->extended_value, return_value TSRMLS_CC ); } } @@ -1582,8 +1580,8 @@ static zend_always_inline zend_execute_data *i_create_execute_data_from_op_array EG(argument_stack)->top = (zval*)zend_vm_stack_frame_base(execute_data); - ZVAL_UNDEF(&EX(object)); - ZVAL_UNDEF(&EX(current_this)); + EX(object) = NULL; + EX(current_this) = NULL; ZVAL_UNDEF(&EX(old_error_reporting)); EX(symbol_table) = EG(active_symbol_table); EX(call) = NULL; @@ -1600,7 +1598,7 @@ static zend_always_inline zend_execute_data *i_create_execute_data_from_op_array zend_attach_symbol_table(TSRMLS_C); } - if (op_array->this_var != -1 && Z_TYPE(EG(This)) != IS_UNDEF) { + if (op_array->this_var != -1 && Z_OBJ(EG(This))) { ZVAL_COPY(EX_VAR(op_array->this_var), &EG(This)); } diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index fcd3441eb1..6f1fc97893 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -50,7 +50,7 @@ BEGIN_EXTERN_C() struct _zend_fcall_info; ZEND_API extern void (*zend_execute_ex)(zend_execute_data *execute_data TSRMLS_DC); -ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC); +ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci TSRMLS_DC); void init_executor(TSRMLS_D); void shutdown_executor(TSRMLS_D); @@ -58,7 +58,7 @@ void shutdown_destructors(TSRMLS_D); ZEND_API zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_array, zval *return_value, zend_bool nested TSRMLS_DC); ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value TSRMLS_DC); ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC); -ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC); +ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci TSRMLS_DC); ZEND_API int zend_is_true(zval *op TSRMLS_DC); ZEND_API zend_class_entry *zend_lookup_class(zend_string *name TSRMLS_DC); ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zend_literal *key, int use_autoload TSRMLS_DC); @@ -347,7 +347,7 @@ void zend_shutdown_timeout_thread(void); /* The following tries to resolve the classname of a zval of type object. * Since it is slow it should be only used in error messages. */ -#define Z_OBJ_CLASS_NAME_P(zval) ((zval) && Z_TYPE_P(zval) == IS_OBJECT && Z_OBJ_HT_P(zval)->get_class_entry != NULL && Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC) ? Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC)->name->val : "") +#define Z_OBJ_CLASS_NAME_P(obj) (((obj) && (obj)->handlers->get_class_entry != NULL && (obj)->handlers->get_class_entry) ? (obj)->handlers->get_class_entry(obj TSRMLS_CC)->name->val : "") ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, zend_uint var); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index c0b61b820b..363f401230 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -39,11 +39,11 @@ #endif ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data TSRMLS_DC); -ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC); +ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, zend_fcall_info *fci TSRMLS_DC); /* true globals */ ZEND_API const zend_fcall_info empty_fcall_info = { 0, NULL, {{0},0}, NULL, NULL, 0, NULL, NULL, 0 }; -ZEND_API const zend_fcall_info_cache empty_fcall_info_cache = { 0, NULL, NULL, NULL, {{0},0} }; +ZEND_API const zend_fcall_info_cache empty_fcall_info_cache = { 0, NULL, NULL, NULL, NULL }; #ifdef ZEND_WIN32 #include <process.h> @@ -191,7 +191,7 @@ void init_executor(TSRMLS_D) /* {{{ */ EG(scope) = NULL; EG(called_scope) = NULL; - ZVAL_UNDEF(&EG(This)); + ZVAL_OBJ(&EG(This), NULL); EG(active_op_array) = NULL; @@ -213,7 +213,7 @@ static int zval_call_destructor(zval *zv TSRMLS_DC) /* {{{ */ } /* }}} */ -static int zend_unclean_zval_ptr_dtor(zval *zv) /* {{{ */ +static void zend_unclean_zval_ptr_dtor(zval *zv) /* {{{ */ { TSRMLS_FETCH(); @@ -745,7 +745,7 @@ int call_user_function_ex(HashTable *function_table, zval *object, zval *functio fci.size = sizeof(fci); fci.function_table = function_table; - fci.object_ptr = object; + fci.object = object ? Z_OBJ_P(object) : NULL; ZVAL_COPY_VALUE(&fci.function_name, function_name); fci.retval = retval_ptr; fci.param_count = param_count; @@ -767,7 +767,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS zend_class_entry *current_called_scope; zend_class_entry *calling_scope = NULL; zend_class_entry *called_scope = NULL; - zval current_this; + zend_object *current_this; zend_execute_data execute_data; zend_fcall_info_cache fci_cache_local; zval tmp; @@ -795,7 +795,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS execute_data = *EG(current_execute_data); EX(op_array) = NULL; EX(opline) = NULL; - ZVAL_UNDEF(&EX(object)); + EX(object) = NULL; } else { /* This only happens when we're called outside any execute()'s * It shouldn't be strictly necessary to NULL execute_data out, @@ -812,7 +812,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS fci_cache = &fci_cache_local; } - if (!zend_is_callable_ex(&fci->function_name, fci->object_ptr, IS_CALLABLE_CHECK_SILENT, &callable_name, fci_cache, &error TSRMLS_CC)) { + if (!zend_is_callable_ex(&fci->function_name, fci->object, IS_CALLABLE_CHECK_SILENT, &callable_name, fci_cache, &error TSRMLS_CC)) { if (error) { zend_error(E_WARNING, "Invalid callback %s, %s", callable_name->val, error); efree(error); @@ -835,11 +835,10 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS EX(function_state).function = fci_cache->function_handler; calling_scope = fci_cache->calling_scope; called_scope = fci_cache->called_scope; - fci->object_ptr = &fci_cache->object; - ZVAL_COPY_VALUE(&EX(object), fci->object_ptr); - if (fci->object_ptr && Z_TYPE_P(fci->object_ptr) == IS_OBJECT && + EX(object) = fci->object = fci_cache->object; + if (fci->object && (!EG(objects_store).object_buckets || - !IS_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(fci->object_ptr)]))) { + !IS_VALID(EG(objects_store).object_buckets[fci->object->handle]))) { return FAILURE; } @@ -913,7 +912,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS current_scope = EG(scope); EG(scope) = calling_scope; - ZVAL_COPY_VALUE(¤t_this, &EG(This)); + current_this = Z_OBJ(EG(This)); current_called_scope = EG(called_scope); if (called_scope) { @@ -922,14 +921,12 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS EG(called_scope) = NULL; } - if (fci->object_ptr) { - if ((EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) { - ZVAL_UNDEF(&EG(This)); - } else { - ZVAL_COPY(&EG(This), fci->object_ptr); - } + if (!fci->object || + (EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) { + Z_OBJ(EG(This)) = NULL; } else { - ZVAL_UNDEF(&EG(This)); + Z_OBJ(EG(This)) = fci->object; + Z_ADDREF(EG(This)); } EX(prev_execute_data) = EG(current_execute_data); @@ -968,9 +965,9 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS } if (EXPECTED(zend_execute_internal == NULL)) { /* saves one function call if zend_execute_internal is not used */ - EX(function_state).function->internal_function.handler(fci->param_count, fci->retval, fci->object_ptr, 1 TSRMLS_CC); + EX(function_state).function->internal_function.handler(fci->param_count, fci->retval TSRMLS_CC); } else { - zend_execute_internal(&execute_data, fci, 1 TSRMLS_CC); + zend_execute_internal(&execute_data, fci TSRMLS_CC); } /* We shouldn't fix bad extensions here, because it can break proper ones (Bug #34045) @@ -991,8 +988,8 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS //??? ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr); /* Not sure what should be done here if it's a static method */ - if (fci->object_ptr) { - Z_OBJ_HT_P(fci->object_ptr)->call_method(EX(function_state).function->common.function_name, fci->param_count, fci->retval, fci->object_ptr, 1 TSRMLS_CC); + if (fci->object) { + fci->object->handlers->call_method(EX(function_state).function->common.function_name, fci->object, fci->param_count, fci->retval TSRMLS_CC); } else { zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); } @@ -1009,10 +1006,12 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS } zend_vm_stack_clear_multiple(0 TSRMLS_CC); - zval_ptr_dtor(&EG(This)); + if (Z_OBJ(EG(This))) { + zval_ptr_dtor(&EG(This)); + } EG(called_scope) = current_called_scope; EG(scope) = current_scope; - ZVAL_COPY_VALUE(&EG(This), ¤t_this); + Z_OBJ(EG(This)) = current_this; EG(current_execute_data) = EX(prev_execute_data); if (EG(exception)) { @@ -1101,14 +1100,14 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zend_li fcall_info.retval = &local_retval; fcall_info.param_count = 1; fcall_info.params = args; - fcall_info.object_ptr = NULL; + fcall_info.object = NULL; fcall_info.no_separation = 1; fcall_cache.initialized = EG(autoload_func) ? 1 : 0; fcall_cache.function_handler = EG(autoload_func); fcall_cache.calling_scope = NULL; fcall_cache.called_scope = NULL; - ZVAL_UNDEF(&fcall_cache.object); + fcall_cache.object = NULL; zend_exception_save(TSRMLS_C); retval = zend_call_function(&fcall_info, &fcall_cache TSRMLS_CC); @@ -1697,7 +1696,7 @@ ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */ if (ex->op_array->this_var != -1 && Z_TYPE_P(EX_VAR_2(ex, ex->op_array->this_var)) == IS_UNDEF && - Z_TYPE(EG(This)) != IS_UNDEF) { + Z_OBJ(EG(This))) { ZVAL_COPY_VALUE(EX_VAR_2(ex, ex->op_array->this_var), &EG(This)); } for (i = 0; i < ex->op_array->last_var; i++) { @@ -1790,7 +1789,7 @@ ZEND_API int zend_set_local_var(const char *name, int len, zval *value, int forc return FAILURE; } } else { - return zend_hash_str_update_ind(&EG(active_symbol_table)->ht, name, len, value); + return (zend_hash_str_update_ind(&EG(active_symbol_table)->ht, name, len, value) != NULL) ? SUCCESS : FAILURE; } return SUCCESS; } diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 49385015e8..13808a0eb4 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -88,7 +88,9 @@ static void zend_generator_cleanup_unfinished_execution(zend_generator *generato /* If yield was used as a function argument there may be active * method calls those objects need to be freed */ while (execute_data->call >= execute_data->call_slots) { - zval_ptr_dtor(&execute_data->call->object); + if (execute_data->call->object) { + OBJ_RELEASE(execute_data->call->object); + } execute_data->call--; } } @@ -116,7 +118,9 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished zend_clean_and_cache_symbol_table(execute_data->symbol_table TSRMLS_CC); } - zval_ptr_dtor(&execute_data->current_this); + if (execute_data->current_this) { + OBJ_RELEASE(execute_data->current_this); + } /* A fatal error / die occurred during the generator execution. Trying to clean * up the stack may not be safe in this case. */ @@ -293,7 +297,7 @@ ZEND_API void zend_generator_create_zval(zend_op_array *op_array, zval *return_v object_init_ex(return_value, zend_ce_generator); - if (Z_TYPE(EG(This)) != IS_UNDEF) { + if (Z_OBJ(EG(This))) { Z_ADDREF(EG(This)); } @@ -301,7 +305,7 @@ ZEND_API void zend_generator_create_zval(zend_op_array *op_array, zval *return_v execute_data->current_scope = EG(scope); execute_data->current_called_scope = EG(called_scope); execute_data->symbol_table = EG(active_symbol_table); - ZVAL_COPY_VALUE(&execute_data->current_this, &EG(This)); + execute_data->current_this = Z_OBJ(EG(This)); /* Save execution context in generator object. */ generator = (zend_generator *) Z_OBJ_P(return_value); @@ -314,7 +318,7 @@ ZEND_API void zend_generator_create_zval(zend_op_array *op_array, zval *return_v } /* }}} */ -static zend_function *zend_generator_get_constructor(zval *object TSRMLS_DC) /* {{{ */ +static zend_function *zend_generator_get_constructor(zend_object *object TSRMLS_DC) /* {{{ */ { zend_error(E_RECOVERABLE_ERROR, "The \"Generator\" class is reserved for internal use and cannot be manually instantiated"); @@ -342,19 +346,19 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ zend_op **original_opline_ptr = EG(opline_ptr); zend_op_array *original_active_op_array = EG(active_op_array); zend_array *original_active_symbol_table = EG(active_symbol_table); - zval original_This; + zend_object *original_This; zend_class_entry *original_scope = EG(scope); zend_class_entry *original_called_scope = EG(called_scope); zend_vm_stack original_stack = EG(argument_stack); - ZVAL_COPY_VALUE(&original_This, &EG(This)); + original_This = Z_OBJ(EG(This)); /* Set executor globals */ EG(current_execute_data) = generator->execute_data; EG(opline_ptr) = &generator->execute_data->opline; EG(active_op_array) = generator->execute_data->op_array; EG(active_symbol_table) = generator->execute_data->symbol_table; - ZVAL_COPY_VALUE(&EG(This), &generator->execute_data->current_this); + Z_OBJ(EG(This)) = generator->execute_data->current_this; EG(scope) = generator->execute_data->current_scope; EG(called_scope) = generator->execute_data->current_called_scope; EG(argument_stack) = generator->stack; @@ -377,7 +381,7 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ EG(opline_ptr) = original_opline_ptr; EG(active_op_array) = original_active_op_array; EG(active_symbol_table) = original_active_symbol_table; - EG(This) = original_This; + Z_OBJ(EG(This)) = original_This; EG(scope) = original_scope; EG(called_scope) = original_called_scope; EG(argument_stack) = original_stack; diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 4f36c91f2e..ce659ba32a 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -49,7 +49,7 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun fci.size = sizeof(fci); /*fci.function_table = NULL; will be read form zend_class_entry of object if needed */ - fci.object_ptr = object; + fci.object = (object && Z_TYPE_P(object) == IS_OBJECT) ? Z_OBJ_P(object) : NULL; ZVAL_STRINGL(&fci.function_name, function_name, function_name_len); fci.retval = retval_ptr ? retval_ptr : &retval; fci.param_count = param_count; @@ -96,11 +96,7 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun } else { fcic.called_scope = EG(called_scope); } - if (object) { - ZVAL_COPY_VALUE(&fcic.object, object); - } else { - ZVAL_UNDEF(&fcic.object); - } + fcic.object = object ? Z_OBJ_P(object) : NULL; result = zend_call_function(&fci, &fcic TSRMLS_CC); zval_ptr_dtor(&fci.function_name); } diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 45cc4f56e9..4c7ddab4ac 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -897,7 +897,7 @@ ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ zend_internal_function *func = (zend_internal_function *)EG(current_execute_data)->function_state.function; zval method_name, method_args; zval method_result; - zend_class_entry *ce = Z_OBJCE_P(this_ptr); + zend_class_entry *ce = Z_OBJCE_P(getThis()); array_init_size(&method_args, ZEND_NUM_ARGS()); @@ -915,7 +915,7 @@ ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ */ ZVAL_UNDEF(&method_result); - zend_call_method_with_2_params(this_ptr, ce, &ce->__call, ZEND_CALL_FUNC_NAME, &method_result, &method_name, &method_args); + zend_call_method_with_2_params(getThis(), ce, &ce->__call, ZEND_CALL_FUNC_NAME, &method_result, &method_name, &method_args); if (Z_TYPE(method_result) != IS_UNDEF) { RETVAL_ZVAL_FAST(&method_result); @@ -1025,11 +1025,11 @@ static inline union _zend_function *zend_get_user_call_function(zend_class_entry } /* }}} */ -static union _zend_function *zend_std_get_method(zval *object, zend_string *method_name, const zend_literal *key TSRMLS_DC) /* {{{ */ +static union _zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string *method_name, const zend_literal *key TSRMLS_DC) /* {{{ */ { + zend_object *zobj = *obj_ptr; zval *func; zend_function *fbc; - zend_object *zobj = Z_OBJ_P(object); zend_string *lc_method_name; if (EXPECTED(key != NULL)) { @@ -1058,7 +1058,7 @@ static union _zend_function *zend_std_get_method(zval *object, zend_string *meth /* Ensure that if we're calling a private function, we're allowed to do so. * If we're not and __call() handler exists, invoke it, otherwise error out. */ - updated_fbc = zend_check_private_int(fbc, Z_OBJ_HANDLER_P(object, get_class_entry)(object TSRMLS_CC), lc_method_name TSRMLS_CC); + updated_fbc = zend_check_private_int(fbc, zobj->handlers->get_class_entry(zobj TSRMLS_CC), lc_method_name TSRMLS_CC); if (EXPECTED(updated_fbc != NULL)) { fbc = updated_fbc; } else { @@ -1193,7 +1193,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st STR_FREE(lc_function_name); } if (ce->__call && - Z_TYPE(EG(This)) == IS_OBJECT && + Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { return zend_get_user_call_function(ce, function_name); @@ -1303,9 +1303,8 @@ ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_str } /* }}} */ -ZEND_API union _zend_function *zend_std_get_constructor(zval *object TSRMLS_DC) /* {{{ */ +ZEND_API union _zend_function *zend_std_get_constructor(zend_object *zobj TSRMLS_DC) /* {{{ */ { - zend_object *zobj = Z_OBJ_P(object); zend_function *constructor = zobj->ce->constructor; if (constructor) { @@ -1496,20 +1495,15 @@ exit: } /* }}} */ -zend_class_entry *zend_std_object_get_class(const zval *object TSRMLS_DC) /* {{{ */ +zend_class_entry *zend_std_object_get_class(const zend_object *object TSRMLS_DC) /* {{{ */ { - zend_object *zobj; - zobj = Z_OBJ_P(object); - - return zobj->ce; + return object->ce; } /* }}} */ -zend_string* zend_std_object_get_class_name(const zval *object, int parent TSRMLS_DC) /* {{{ */ +zend_string* zend_std_object_get_class_name(const zend_object *zobj, int parent TSRMLS_DC) /* {{{ */ { - zend_object *zobj; zend_class_entry *ce; - zobj = Z_OBJ_P(object); if (parent) { if (!zobj->ce->parent) { @@ -1590,7 +1584,7 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty } /* }}} */ -int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zval *zobj_ptr TSRMLS_DC) /* {{{ */ +int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr TSRMLS_DC) /* {{{ */ { zval *func; zend_class_entry *ce; @@ -1608,12 +1602,12 @@ int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **f *ce_ptr = ce; if ((*fptr_ptr)->common.fn_flags & ZEND_ACC_STATIC) { - if (zobj_ptr) { - ZVAL_UNDEF(zobj_ptr); + if (obj_ptr) { + *obj_ptr = NULL; } } else { - if (zobj_ptr) { - ZVAL_COPY_VALUE(zobj_ptr, obj); + if (obj_ptr) { + *obj_ptr = Z_OBJ_P(obj); } } return SUCCESS; diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index 64225cebd2..be099aee81 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -87,20 +87,17 @@ typedef HashTable *(*zend_object_get_debug_info_t)(zval *object, int *is_temp TS /* args on stack! */ /* Andi - EX(fbc) (function being called) needs to be initialized already in the INIT fcall opcode so that the parameters can be parsed the right way. We need to add another callback for this. */ -typedef int (*zend_object_call_method_t)(zend_string *method, INTERNAL_FUNCTION_PARAMETERS); -typedef union _zend_function *(*zend_object_get_method_t)(zval *object_ptr, zend_string *method, const struct _zend_literal *key TSRMLS_DC); -typedef union _zend_function *(*zend_object_get_constructor_t)(zval *object TSRMLS_DC); +typedef int (*zend_object_call_method_t)(zend_string *method, zend_object *object, INTERNAL_FUNCTION_PARAMETERS); +typedef union _zend_function *(*zend_object_get_method_t)(zend_object **object, zend_string *method, const struct _zend_literal *key TSRMLS_DC); +typedef union _zend_function *(*zend_object_get_constructor_t)(zend_object *object TSRMLS_DC); /* Object maintenance/destruction */ -typedef void (*zend_object_add_ref_t)(zval *object TSRMLS_DC); -typedef void (*zend_object_del_ref_t)(zval *object TSRMLS_DC); -typedef void (*zend_object_delete_obj_t)(zval *object TSRMLS_DC); typedef void (*zend_object_dtor_obj_t)(zend_object *object TSRMLS_DC); typedef void (*zend_object_free_obj_t)(zend_object *object TSRMLS_DC); typedef zend_object* (*zend_object_clone_obj_t)(zval *object TSRMLS_DC); -typedef zend_class_entry *(*zend_object_get_class_entry_t)(const zval *object TSRMLS_DC); -typedef zend_string *(*zend_object_get_class_name_t)(const zval *object, int parent TSRMLS_DC); +typedef zend_class_entry *(*zend_object_get_class_entry_t)(const zend_object *object TSRMLS_DC); +typedef zend_string *(*zend_object_get_class_name_t)(const zend_object *object, int parent TSRMLS_DC); typedef int (*zend_object_compare_t)(zval *object1, zval *object2 TSRMLS_DC); typedef int (*zend_object_compare_zvals_t)(zval *resul, zval *op1, zval *op2 TSRMLS_DC); @@ -112,7 +109,7 @@ typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type TSRMLS_D * Returns FAILURE if the object does not have any sense of overloaded dimensions */ typedef int (*zend_object_count_elements_t)(zval *object, long *count TSRMLS_DC); -typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zval *zobj_ptr TSRMLS_DC); +typedef int (*zend_object_get_closure_t)(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zend_object **obj_ptr TSRMLS_DC); typedef HashTable *(*zend_object_get_gc_t)(zval *object, zval **table, int *n TSRMLS_DC); @@ -160,7 +157,7 @@ BEGIN_EXTERN_C() ZEND_API union _zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const struct _zend_literal *key TSRMLS_DC); ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, zend_bool silent, const struct _zend_literal *key TSRMLS_DC); ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name, const struct _zend_literal *key TSRMLS_DC); -ZEND_API union _zend_function *zend_std_get_constructor(zval *object TSRMLS_DC); +ZEND_API union _zend_function *zend_std_get_constructor(zend_object *object TSRMLS_DC); ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zval *member, int silent TSRMLS_DC); ZEND_API HashTable *zend_std_get_properties(zval *object TSRMLS_DC); ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp TSRMLS_DC); diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c index f0db534cc3..be215ed086 100644 --- a/Zend/zend_objects_API.c +++ b/Zend/zend_objects_API.c @@ -216,10 +216,8 @@ ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object TS } /* Called when the ctor was terminated by an exception */ -ZEND_API void zend_object_store_ctor_failed(zval *zobject TSRMLS_DC) +ZEND_API void zend_object_store_ctor_failed(zend_object *obj TSRMLS_DC) { - zend_object *obj = Z_OBJ_P(zobject); - obj->gc.u.v.flags |= IS_OBJ_DESTRUCTOR_CALLED; } diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h index e6578ea306..e54d9f53b6 100644 --- a/Zend/zend_objects_API.h +++ b/Zend/zend_objects_API.h @@ -94,7 +94,7 @@ ZEND_API void zend_objects_store_free(zend_object *object TSRMLS_DC); /* See comment in zend_objects_API.c before you use this */ ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object TSRMLS_DC); -ZEND_API void zend_object_store_ctor_failed(zval *zobject TSRMLS_DC); +ZEND_API void zend_object_store_ctor_failed(zend_object *object TSRMLS_DC); ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects TSRMLS_DC); diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 91c59c7679..6d8a10b57a 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -304,7 +304,7 @@ struct _zend_ast_ref { #define Z_OBJ_HANDLE(zval) (Z_OBJ((zval)))->handle #define Z_OBJ_HANDLE_P(zval_p) Z_OBJ_HANDLE(*(zval_p)) -#define Z_OBJCE(zval) zend_get_class_entry(&(zval) TSRMLS_CC) +#define Z_OBJCE(zval) zend_get_class_entry(Z_OBJ(zval) TSRMLS_CC) #define Z_OBJCE_P(zval_p) Z_OBJCE(*(zval_p)) #define Z_OBJPROP(zval) Z_OBJ_HT((zval))->get_properties(&(zval) TSRMLS_CC) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 4df525a718..1bcffd5d3c 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1912,18 +1912,18 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY) EX(function_state).function = (zend_function *) EX(op_array); EX(function_state).arguments = NULL; - if (Z_TYPE(EG(This)) != IS_UNDEF) { + if (Z_OBJ(EG(This))) { if (UNEXPECTED(EG(exception) != NULL) && EX(call)->is_ctor_call) { if (EX(call)->is_ctor_result_used) { Z_DELREF(EG(This)); } if (Z_REFCOUNT(EG(This)) == 1) { - zend_object_store_ctor_failed(&EG(This) TSRMLS_CC); + zend_object_store_ctor_failed(Z_OBJ(EG(This)) TSRMLS_CC); } } zval_ptr_dtor(&EG(This)); } - ZVAL_COPY_VALUE(&EG(This), &EX(current_this)); + Z_OBJ(EG(This)) = EX(current_this); EG(scope) = EX(current_scope); EG(called_scope) = EX(current_called_scope); @@ -1954,7 +1954,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) zend_uint num_args; SAVE_OPLINE(); - ZVAL_COPY_VALUE(&EX(object), &EX(call)->object); + EX(object) = EX(call)->object; if (UNEXPECTED((fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) != 0)) { if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_ABSTRACT) != 0)) { zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", fbc->common.scope->name->val, fbc->common.function_name->val); @@ -1971,7 +1971,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) } if (fbc->common.scope && !(fbc->common.fn_flags & ZEND_ACC_STATIC) && - Z_TYPE(EX(object)) == IS_UNDEF) { + !EX(object)) { if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { /* FIXME: output identifiers properly */ @@ -1988,20 +1988,22 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) if (fbc->type == ZEND_USER_FUNCTION || fbc->common.scope) { should_change_scope = 1; - ZVAL_COPY_VALUE(&EX(current_this), &EG(This)); + EX(current_this) = Z_OBJ(EG(This)); EX(current_scope) = EG(scope); EX(current_called_scope) = EG(called_scope); - EG(This) = EX(object); - EG(scope) = (fbc->type == ZEND_USER_FUNCTION || Z_TYPE(EX(object)) == IS_UNDEF) ? fbc->common.scope : NULL; + Z_OBJ(EG(This)) = EX(object); +//??? EG(scope) = (fbc->type == ZEND_USER_FUNCTION || !EX(object)) ? fbc->common.scope : NULL; + EG(scope) = fbc->common.scope; EG(called_scope) = EX(call)->called_scope; } - num_args = opline->extended_value + EX(call)->num_additional_args; - if (EX(call)->num_additional_args) { + if (UNEXPECTED(EX(call)->num_additional_args != 0)) { + num_args = opline->extended_value + EX(call)->num_additional_args; EX(function_state).arguments = zend_vm_stack_push_args(num_args TSRMLS_CC); } else { zval tmp; + num_args = opline->extended_value; ZVAL_LONG(&tmp, num_args); EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C); zend_vm_stack_push(&tmp TSRMLS_CC); @@ -2027,9 +2029,9 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) if (!zend_execute_internal) { /* saves one function call if zend_execute_internal is not used */ - fbc->internal_function.handler(num_args, ret, &EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); + fbc->internal_function.handler(num_args, ret TSRMLS_CC); } else { - zend_execute_internal(execute_data, NULL, RETURN_VALUE_USED(opline) TSRMLS_CC); + zend_execute_internal(execute_data, NULL TSRMLS_CC); } if (!RETURN_VALUE_USED(opline)) { @@ -2074,8 +2076,8 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) ZVAL_NULL(EX_VAR(opline->result.var)); /* Not sure what should be done here if it's a static method */ - if (EXPECTED(Z_TYPE(EX(object)) != IS_UNDEF)) { - Z_OBJ_HT_P(&EX(object))->call_method(fbc->common.function_name, num_args, EX_VAR(opline->result.var), &EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); + if (EXPECTED(EX(object) != NULL)) { + EX(object)->handlers->call_method(fbc->common.function_name, EX(object), num_args, EX_VAR(opline->result.var) TSRMLS_CC); } else { zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); } @@ -2099,18 +2101,18 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) EX(function_state).arguments = NULL; if (should_change_scope) { - if (Z_TYPE(EG(This)) != IS_UNDEF) { + if (Z_OBJ(EG(This))) { if (UNEXPECTED(EG(exception) != NULL) && EX(call)->is_ctor_call) { if (EX(call)->is_ctor_result_used) { Z_DELREF(EG(This)); } if (Z_REFCOUNT(EG(This)) == 1) { - zend_object_store_ctor_failed(&EG(This) TSRMLS_CC); + zend_object_store_ctor_failed(Z_OBJ(EG(This)) TSRMLS_CC); } } zval_ptr_dtor(&EG(This)); } - ZVAL_COPY_VALUE(&EG(This), &EX(current_this)); + Z_OBJ(EG(This)) = EX(current_this); EG(scope) = EX(current_scope); EG(called_scope) = EX(current_called_scope); } @@ -2463,29 +2465,28 @@ ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV) } object = GET_OP1_OBJ_ZVAL_PTR_DEREF(BP_VAR_R); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (OP2_TYPE != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((OP2_TYPE == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((OP2_TYPE == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (OP2_TYPE == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -2498,9 +2499,9 @@ ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV) } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -2593,16 +2594,16 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS if (UNEXPECTED(ce->constructor == NULL)) { zend_error_noreturn(E_ERROR, "Cannot call constructor"); } - if (Z_TYPE(EG(This)) != IS_UNDEF && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { + if (Z_OBJ(EG(This)) && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val); } call->fbc = ce->constructor; } if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - if (Z_TYPE(EG(This)) != IS_UNDEF && + if (Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, @@ -2614,7 +2615,10 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name->val, call->fbc->common.function_name->val); } } - ZVAL_COPY(&call->object, &EG(This)); + call->object = Z_OBJ(EG(This)); + if (call->object) { + call->object->gc.refcount++; + } } call->num_additional_args = 0; @@ -2643,7 +2647,7 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV) CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -2674,7 +2678,7 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV) FREE_OP2(); call->fbc = Z_FUNC_P(func); - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -2686,8 +2690,8 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV) EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) && Z_OBJ_HANDLER_P(function_name, get_closure) && Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &call->called_scope, &call->fbc, &call->object TSRMLS_CC) == SUCCESS) { - if (Z_REFCOUNTED(call->object)) { - Z_ADDREF(call->object); + if (call->object) { + call->object->gc.refcount++; } if (OP2_TYPE == IS_VAR && OP2_FREE && Z_REFCOUNT_P(function_name) == 1 && call->fbc->common.fn_flags & ZEND_ACC_CLOSURE) { @@ -2725,7 +2729,7 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV) } if (Z_TYPE_P(obj) == IS_STRING) { - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, 0 TSRMLS_CC); if (UNEXPECTED(call->called_scope == NULL)) { CHECK_EXCEPTION(); @@ -2742,17 +2746,17 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV) } } else { call->called_scope = Z_OBJCE_P(obj); - ZVAL_COPY_VALUE(&call->object, obj); + call->object = Z_OBJ_P(obj); - call->fbc = Z_OBJ_HT_P(obj)->get_method(obj, Z_STR_P(method), NULL TSRMLS_CC); + call->fbc = Z_OBJ_HT_P(obj)->get_method(&call->object, Z_STR_P(method), NULL TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(obj), Z_STRVAL_P(method)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(method)); } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } } @@ -2798,7 +2802,7 @@ ZEND_VM_HANDLER(69, ZEND_INIT_NS_FCALL_BY_NAME, ANY, CONST) CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -2832,7 +2836,7 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, CONST, ANY) } call->fbc = EX(function_state).function; - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -3554,7 +3558,7 @@ ZEND_VM_HANDLER(68, ZEND_NEW, ANY, ANY) } } object_init_ex(&object_zval, Z_CE_P(EX_VAR(opline->op1.var))); - constructor = Z_OBJ_HT(object_zval)->get_constructor(&object_zval TSRMLS_CC); + constructor = Z_OBJ_HT(object_zval)->get_constructor(Z_OBJ(object_zval) TSRMLS_CC); if (constructor == NULL) { if (RETURN_VALUE_USED(opline)) { @@ -3572,7 +3576,7 @@ ZEND_VM_HANDLER(68, ZEND_NEW, ANY, ANY) /* We are not handling overloaded classes right now */ call->fbc = constructor; - ZVAL_COPY_VALUE(&call->object, &object_zval); + call->object = Z_OBJ(object_zval); call->called_scope = Z_CE_P(EX_VAR(opline->op1.var)); call->num_additional_args = 0; call->is_ctor_call = 1; @@ -3986,7 +3990,7 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY) } EX(function_state).function = (zend_function *) new_op_array; - ZVAL_UNDEF(&EX(object)); + EX(object) = NULL; if (!EG(active_symbol_table)) { zend_rebuild_symbol_table(TSRMLS_C); @@ -5194,16 +5198,16 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) if (EX(call) >= EX(call_slots)) { call_slot *call = EX(call); do { - if (Z_TYPE(call->object) != IS_UNDEF) { + if (call->object) { if (call->is_ctor_call) { if (call->is_ctor_result_used) { - Z_DELREF(call->object); + call->object->gc.refcount--; } - if (Z_REFCOUNT(call->object) == 1) { - zend_object_store_ctor_failed(&call->object TSRMLS_CC); + if (call->object->gc.refcount == 1) { + zend_object_store_ctor_failed(call->object TSRMLS_CC); } } - zval_ptr_dtor(&call->object); + OBJ_RELEASE(call->object); } call--; } while (call >= EX(call_slots)); @@ -5368,7 +5372,7 @@ ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA_FUNCTION, CONST, UNUSED) zend_error_noreturn(E_ERROR, "Base lambda function for closure not found"); } - zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), &EG(This) TSRMLS_CC); + zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), Z_OBJ(EG(This)) ? &EG(This) : NULL TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index d3085be28f..de7d9b4834 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -441,18 +441,18 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) EX(function_state).function = (zend_function *) EX(op_array); EX(function_state).arguments = NULL; - if (Z_TYPE(EG(This)) != IS_UNDEF) { + if (Z_OBJ(EG(This))) { if (UNEXPECTED(EG(exception) != NULL) && EX(call)->is_ctor_call) { if (EX(call)->is_ctor_result_used) { Z_DELREF(EG(This)); } if (Z_REFCOUNT(EG(This)) == 1) { - zend_object_store_ctor_failed(&EG(This) TSRMLS_CC); + zend_object_store_ctor_failed(Z_OBJ(EG(This)) TSRMLS_CC); } } zval_ptr_dtor(&EG(This)); } - ZVAL_COPY_VALUE(&EG(This), &EX(current_this)); + Z_OBJ(EG(This)) = EX(current_this); EG(scope) = EX(current_scope); EG(called_scope) = EX(current_called_scope); @@ -483,7 +483,7 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR zend_uint num_args; SAVE_OPLINE(); - ZVAL_COPY_VALUE(&EX(object), &EX(call)->object); + EX(object) = EX(call)->object; if (UNEXPECTED((fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) != 0)) { if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_ABSTRACT) != 0)) { zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", fbc->common.scope->name->val, fbc->common.function_name->val); @@ -500,7 +500,7 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR } if (fbc->common.scope && !(fbc->common.fn_flags & ZEND_ACC_STATIC) && - Z_TYPE(EX(object)) == IS_UNDEF) { + !EX(object)) { if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { /* FIXME: output identifiers properly */ @@ -517,20 +517,22 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR if (fbc->type == ZEND_USER_FUNCTION || fbc->common.scope) { should_change_scope = 1; - ZVAL_COPY_VALUE(&EX(current_this), &EG(This)); + EX(current_this) = Z_OBJ(EG(This)); EX(current_scope) = EG(scope); EX(current_called_scope) = EG(called_scope); - EG(This) = EX(object); - EG(scope) = (fbc->type == ZEND_USER_FUNCTION || Z_TYPE(EX(object)) == IS_UNDEF) ? fbc->common.scope : NULL; + Z_OBJ(EG(This)) = EX(object); +//??? EG(scope) = (fbc->type == ZEND_USER_FUNCTION || !EX(object)) ? fbc->common.scope : NULL; + EG(scope) = fbc->common.scope; EG(called_scope) = EX(call)->called_scope; } - num_args = opline->extended_value + EX(call)->num_additional_args; - if (EX(call)->num_additional_args) { + if (UNEXPECTED(EX(call)->num_additional_args != 0)) { + num_args = opline->extended_value + EX(call)->num_additional_args; EX(function_state).arguments = zend_vm_stack_push_args(num_args TSRMLS_CC); } else { zval tmp; + num_args = opline->extended_value; ZVAL_LONG(&tmp, num_args); EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C); zend_vm_stack_push(&tmp TSRMLS_CC); @@ -556,9 +558,9 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR if (!zend_execute_internal) { /* saves one function call if zend_execute_internal is not used */ - fbc->internal_function.handler(num_args, ret, &EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); + fbc->internal_function.handler(num_args, ret TSRMLS_CC); } else { - zend_execute_internal(execute_data, NULL, RETURN_VALUE_USED(opline) TSRMLS_CC); + zend_execute_internal(execute_data, NULL TSRMLS_CC); } if (!RETURN_VALUE_USED(opline)) { @@ -603,8 +605,8 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR ZVAL_NULL(EX_VAR(opline->result.var)); /* Not sure what should be done here if it's a static method */ - if (EXPECTED(Z_TYPE(EX(object)) != IS_UNDEF)) { - Z_OBJ_HT_P(&EX(object))->call_method(fbc->common.function_name, num_args, EX_VAR(opline->result.var), &EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC); + if (EXPECTED(EX(object) != NULL)) { + EX(object)->handlers->call_method(fbc->common.function_name, EX(object), num_args, EX_VAR(opline->result.var) TSRMLS_CC); } else { zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); } @@ -628,18 +630,18 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR EX(function_state).arguments = NULL; if (should_change_scope) { - if (Z_TYPE(EG(This)) != IS_UNDEF) { + if (Z_OBJ(EG(This))) { if (UNEXPECTED(EG(exception) != NULL) && EX(call)->is_ctor_call) { if (EX(call)->is_ctor_result_used) { Z_DELREF(EG(This)); } if (Z_REFCOUNT(EG(This)) == 1) { - zend_object_store_ctor_failed(&EG(This) TSRMLS_CC); + zend_object_store_ctor_failed(Z_OBJ(EG(This)) TSRMLS_CC); } } zval_ptr_dtor(&EG(This)); } - ZVAL_COPY_VALUE(&EG(This), &EX(current_this)); + Z_OBJ(EG(This)) = EX(current_this); EG(scope) = EX(current_scope); EG(called_scope) = EX(current_called_scope); } @@ -935,7 +937,7 @@ static int ZEND_FASTCALL ZEND_NEW_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } } object_init_ex(&object_zval, Z_CE_P(EX_VAR(opline->op1.var))); - constructor = Z_OBJ_HT(object_zval)->get_constructor(&object_zval TSRMLS_CC); + constructor = Z_OBJ_HT(object_zval)->get_constructor(Z_OBJ(object_zval) TSRMLS_CC); if (constructor == NULL) { if (RETURN_VALUE_USED(opline)) { @@ -953,7 +955,7 @@ static int ZEND_FASTCALL ZEND_NEW_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) /* We are not handling overloaded classes right now */ call->fbc = constructor; - ZVAL_COPY_VALUE(&call->object, &object_zval); + call->object = Z_OBJ(object_zval); call->called_scope = Z_CE_P(EX_VAR(opline->op1.var)); call->num_additional_args = 0; call->is_ctor_call = 1; @@ -1193,16 +1195,16 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER if (EX(call) >= EX(call_slots)) { call_slot *call = EX(call); do { - if (Z_TYPE(call->object) != IS_UNDEF) { + if (call->object) { if (call->is_ctor_call) { if (call->is_ctor_result_used) { - Z_DELREF(call->object); + call->object->gc.refcount--; } - if (Z_REFCOUNT(call->object) == 1) { - zend_object_store_ctor_failed(&call->object TSRMLS_CC); + if (call->object->gc.refcount == 1) { + zend_object_store_ctor_failed(call->object TSRMLS_CC); } } - zval_ptr_dtor(&call->object); + OBJ_RELEASE(call->object); } call--; } while (call >= EX(call_slots)); @@ -1432,7 +1434,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -1462,7 +1464,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE STR_FREE(lcname); call->fbc = Z_FUNC_P(func); - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -1474,8 +1476,8 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) && Z_OBJ_HANDLER_P(function_name, get_closure) && Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &call->called_scope, &call->fbc, &call->object TSRMLS_CC) == SUCCESS) { - if (Z_REFCOUNTED(call->object)) { - Z_ADDREF(call->object); + if (call->object) { + call->object->gc.refcount++; } if (IS_CONST == IS_VAR && 0 && Z_REFCOUNT_P(function_name) == 1 && call->fbc->common.fn_flags & ZEND_ACC_CLOSURE) { @@ -1513,7 +1515,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE } if (Z_TYPE_P(obj) == IS_STRING) { - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, 0 TSRMLS_CC); if (UNEXPECTED(call->called_scope == NULL)) { CHECK_EXCEPTION(); @@ -1530,17 +1532,17 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE } } else { call->called_scope = Z_OBJCE_P(obj); - ZVAL_COPY_VALUE(&call->object, obj); + call->object = Z_OBJ_P(obj); - call->fbc = Z_OBJ_HT_P(obj)->get_method(obj, Z_STR_P(method), NULL TSRMLS_CC); + call->fbc = Z_OBJ_HT_P(obj)->get_method(&call->object, Z_STR_P(method), NULL TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(obj), Z_STRVAL_P(method)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(method)); } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } } @@ -1585,7 +1587,7 @@ static int ZEND_FASTCALL ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPC CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -1758,7 +1760,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -1789,7 +1791,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H zval_dtor(free_op2.var); call->fbc = Z_FUNC_P(func); - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -1801,8 +1803,8 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) && Z_OBJ_HANDLER_P(function_name, get_closure) && Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &call->called_scope, &call->fbc, &call->object TSRMLS_CC) == SUCCESS) { - if (Z_REFCOUNTED(call->object)) { - Z_ADDREF(call->object); + if (call->object) { + call->object->gc.refcount++; } if (IS_TMP_VAR == IS_VAR && 1 && Z_REFCOUNT_P(function_name) == 1 && call->fbc->common.fn_flags & ZEND_ACC_CLOSURE) { @@ -1840,7 +1842,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H } if (Z_TYPE_P(obj) == IS_STRING) { - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, 0 TSRMLS_CC); if (UNEXPECTED(call->called_scope == NULL)) { CHECK_EXCEPTION(); @@ -1857,17 +1859,17 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H } } else { call->called_scope = Z_OBJCE_P(obj); - ZVAL_COPY_VALUE(&call->object, obj); + call->object = Z_OBJ_P(obj); - call->fbc = Z_OBJ_HT_P(obj)->get_method(obj, Z_STR_P(method), NULL TSRMLS_CC); + call->fbc = Z_OBJ_HT_P(obj)->get_method(&call->object, Z_STR_P(method), NULL TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(obj), Z_STRVAL_P(method)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(method)); } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } } @@ -1947,7 +1949,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -1978,7 +1980,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H zval_ptr_dtor_nogc(free_op2.var); call->fbc = Z_FUNC_P(func); - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -1990,8 +1992,8 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) && Z_OBJ_HANDLER_P(function_name, get_closure) && Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &call->called_scope, &call->fbc, &call->object TSRMLS_CC) == SUCCESS) { - if (Z_REFCOUNTED(call->object)) { - Z_ADDREF(call->object); + if (call->object) { + call->object->gc.refcount++; } if (IS_VAR == IS_VAR && (free_op2.var != NULL) && Z_REFCOUNT_P(function_name) == 1 && call->fbc->common.fn_flags & ZEND_ACC_CLOSURE) { @@ -2029,7 +2031,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H } if (Z_TYPE_P(obj) == IS_STRING) { - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, 0 TSRMLS_CC); if (UNEXPECTED(call->called_scope == NULL)) { CHECK_EXCEPTION(); @@ -2046,17 +2048,17 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H } } else { call->called_scope = Z_OBJCE_P(obj); - ZVAL_COPY_VALUE(&call->object, obj); + call->object = Z_OBJ_P(obj); - call->fbc = Z_OBJ_HT_P(obj)->get_method(obj, Z_STR_P(method), NULL TSRMLS_CC); + call->fbc = Z_OBJ_HT_P(obj)->get_method(&call->object, Z_STR_P(method), NULL TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(obj), Z_STRVAL_P(method)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(method)); } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } } @@ -2174,7 +2176,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HA CACHE_PTR(opline->op2.literal->cache_slot, call->fbc); } - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -2204,7 +2206,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HA STR_FREE(lcname); call->fbc = Z_FUNC_P(func); - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -2216,8 +2218,8 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HA EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT) && Z_OBJ_HANDLER_P(function_name, get_closure) && Z_OBJ_HANDLER_P(function_name, get_closure)(function_name, &call->called_scope, &call->fbc, &call->object TSRMLS_CC) == SUCCESS) { - if (Z_REFCOUNTED(call->object)) { - Z_ADDREF(call->object); + if (call->object) { + call->object->gc.refcount++; } if (IS_CV == IS_VAR && 0 && Z_REFCOUNT_P(function_name) == 1 && call->fbc->common.fn_flags & ZEND_ACC_CLOSURE) { @@ -2255,7 +2257,7 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HA } if (Z_TYPE_P(obj) == IS_STRING) { - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = zend_fetch_class_by_name(Z_STR_P(obj), NULL, 0 TSRMLS_CC); if (UNEXPECTED(call->called_scope == NULL)) { CHECK_EXCEPTION(); @@ -2272,17 +2274,17 @@ static int ZEND_FASTCALL ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HA } } else { call->called_scope = Z_OBJCE_P(obj); - ZVAL_COPY_VALUE(&call->object, obj); + call->object = Z_OBJ_P(obj); - call->fbc = Z_OBJ_HT_P(obj)->get_method(obj, Z_STR_P(method), NULL TSRMLS_CC); + call->fbc = Z_OBJ_HT_P(obj)->get_method(&call->object, Z_STR_P(method), NULL TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(obj), Z_STRVAL_P(method)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(method)); } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } } @@ -2525,7 +2527,7 @@ static int ZEND_FASTCALL ZEND_DO_FCALL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A } call->fbc = EX(function_state).function; - ZVAL_UNDEF(&call->object); + call->object = NULL; call->called_scope = NULL; call->num_additional_args = 0; call->is_ctor_call = 0; @@ -2915,7 +2917,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HA } EX(function_state).function = (zend_function *) new_op_array; - ZVAL_UNDEF(&EX(object)); + EX(object) = NULL; if (!EG(active_symbol_table)) { zend_rebuild_symbol_table(TSRMLS_C); @@ -3810,16 +3812,16 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER( if (UNEXPECTED(ce->constructor == NULL)) { zend_error_noreturn(E_ERROR, "Cannot call constructor"); } - if (Z_TYPE(EG(This)) != IS_UNDEF && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { + if (Z_OBJ(EG(This)) && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val); } call->fbc = ce->constructor; } if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - if (Z_TYPE(EG(This)) != IS_UNDEF && + if (Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, @@ -3831,7 +3833,10 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER( zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name->val, call->fbc->common.function_name->val); } } - ZVAL_COPY(&call->object, &EG(This)); + call->object = Z_OBJ(EG(This)); + if (call->object) { + call->object->gc.refcount++; + } } call->num_additional_args = 0; @@ -4731,16 +4736,16 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZE if (UNEXPECTED(ce->constructor == NULL)) { zend_error_noreturn(E_ERROR, "Cannot call constructor"); } - if (Z_TYPE(EG(This)) != IS_UNDEF && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { + if (Z_OBJ(EG(This)) && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val); } call->fbc = ce->constructor; } if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - if (Z_TYPE(EG(This)) != IS_UNDEF && + if (Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, @@ -4752,7 +4757,10 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZE zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name->val, call->fbc->common.function_name->val); } } - ZVAL_COPY(&call->object, &EG(This)); + call->object = Z_OBJ(EG(This)); + if (call->object) { + call->object->gc.refcount++; + } } call->num_additional_args = 0; @@ -5559,16 +5567,16 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZE if (UNEXPECTED(ce->constructor == NULL)) { zend_error_noreturn(E_ERROR, "Cannot call constructor"); } - if (Z_TYPE(EG(This)) != IS_UNDEF && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { + if (Z_OBJ(EG(This)) && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val); } call->fbc = ce->constructor; } if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - if (Z_TYPE(EG(This)) != IS_UNDEF && + if (Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, @@ -5580,7 +5588,10 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZE zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name->val, call->fbc->common.function_name->val); } } - ZVAL_COPY(&call->object, &EG(This)); + call->object = Z_OBJ(EG(This)); + if (call->object) { + call->object->gc.refcount++; + } } call->num_additional_args = 0; @@ -6242,16 +6253,16 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_UNUSED_HANDLER if (UNEXPECTED(ce->constructor == NULL)) { zend_error_noreturn(E_ERROR, "Cannot call constructor"); } - if (Z_TYPE(EG(This)) != IS_UNDEF && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { + if (Z_OBJ(EG(This)) && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val); } call->fbc = ce->constructor; } if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - if (Z_TYPE(EG(This)) != IS_UNDEF && + if (Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, @@ -6263,7 +6274,10 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_UNUSED_HANDLER zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name->val, call->fbc->common.function_name->val); } } - ZVAL_COPY(&call->object, &EG(This)); + call->object = Z_OBJ(EG(This)); + if (call->object) { + call->object->gc.refcount++; + } } call->num_additional_args = 0; @@ -6524,7 +6538,7 @@ static int ZEND_FASTCALL ZEND_DECLARE_LAMBDA_FUNCTION_SPEC_CONST_UNUSED_HANDLER zend_error_noreturn(E_ERROR, "Base lambda function for closure not found"); } - zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), &EG(This) TSRMLS_CC); + zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EG(scope), Z_OBJ(EG(This)) ? &EG(This) : NULL TSRMLS_CC); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); @@ -7041,16 +7055,16 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEN if (UNEXPECTED(ce->constructor == NULL)) { zend_error_noreturn(E_ERROR, "Cannot call constructor"); } - if (Z_TYPE(EG(This)) != IS_UNDEF && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { + if (Z_OBJ(EG(This)) && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val); } call->fbc = ce->constructor; } if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - if (Z_TYPE(EG(This)) != IS_UNDEF && + if (Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, @@ -7062,7 +7076,10 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEN zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name->val, call->fbc->common.function_name->val); } } - ZVAL_COPY(&call->object, &EG(This)); + call->object = Z_OBJ(EG(This)); + if (call->object) { + call->object->gc.refcount++; + } } call->num_additional_args = 0; @@ -7971,7 +7988,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND } EX(function_state).function = (zend_function *) new_op_array; - ZVAL_UNDEF(&EX(object)); + EX(object) = NULL; if (!EG(active_symbol_table)) { zend_rebuild_symbol_table(TSRMLS_C); @@ -8896,29 +8913,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_CONST_HANDLER(ZEND_OPCO } object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_CONST != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_CONST == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -8931,9 +8947,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_CONST_HANDLER(ZEND_OPCO } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -9694,29 +9710,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE } object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_TMP_VAR != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_TMP_VAR == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -9729,9 +9744,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -10526,29 +10541,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE } object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_VAR != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_VAR == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -10561,9 +10575,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -11882,29 +11896,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_ } object = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_CV != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_CV == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -11917,9 +11930,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_ } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -13088,7 +13101,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND } EX(function_state).function = (zend_function *) new_op_array; - ZVAL_UNDEF(&EX(object)); + EX(object) = NULL; if (!EG(active_symbol_table)) { zend_rebuild_symbol_table(TSRMLS_C); @@ -15094,29 +15107,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCO } object = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_CONST != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_CONST == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -15129,9 +15141,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCO } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -15223,16 +15235,16 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZE if (UNEXPECTED(ce->constructor == NULL)) { zend_error_noreturn(E_ERROR, "Cannot call constructor"); } - if (Z_TYPE(EG(This)) != IS_UNDEF && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { + if (Z_OBJ(EG(This)) && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val); } call->fbc = ce->constructor; } if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - if (Z_TYPE(EG(This)) != IS_UNDEF && + if (Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, @@ -15244,7 +15256,10 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZE zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name->val, call->fbc->common.function_name->val); } } - ZVAL_COPY(&call->object, &EG(This)); + call->object = Z_OBJ(EG(This)); + if (call->object) { + call->object->gc.refcount++; + } } call->num_additional_args = 0; @@ -17379,29 +17394,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE } object = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_TMP_VAR != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_TMP_VAR == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -17414,9 +17428,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -17509,16 +17523,16 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND if (UNEXPECTED(ce->constructor == NULL)) { zend_error_noreturn(E_ERROR, "Cannot call constructor"); } - if (Z_TYPE(EG(This)) != IS_UNDEF && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { + if (Z_OBJ(EG(This)) && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val); } call->fbc = ce->constructor; } if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - if (Z_TYPE(EG(This)) != IS_UNDEF && + if (Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, @@ -17530,7 +17544,10 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name->val, call->fbc->common.function_name->val); } } - ZVAL_COPY(&call->object, &EG(This)); + call->object = Z_OBJ(EG(This)); + if (call->object) { + call->object->gc.refcount++; + } } call->num_additional_args = 0; @@ -19665,29 +19682,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE } object = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_VAR != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_VAR == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -19700,9 +19716,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -19795,16 +19811,16 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND if (UNEXPECTED(ce->constructor == NULL)) { zend_error_noreturn(E_ERROR, "Cannot call constructor"); } - if (Z_TYPE(EG(This)) != IS_UNDEF && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { + if (Z_OBJ(EG(This)) && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val); } call->fbc = ce->constructor; } if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - if (Z_TYPE(EG(This)) != IS_UNDEF && + if (Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, @@ -19816,7 +19832,10 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name->val, call->fbc->common.function_name->val); } } - ZVAL_COPY(&call->object, &EG(This)); + call->object = Z_OBJ(EG(This)); + if (call->object) { + call->object->gc.refcount++; + } } call->num_additional_args = 0; @@ -21210,16 +21229,16 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_UNUSED_HANDLER(Z if (UNEXPECTED(ce->constructor == NULL)) { zend_error_noreturn(E_ERROR, "Cannot call constructor"); } - if (Z_TYPE(EG(This)) != IS_UNDEF && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { + if (Z_OBJ(EG(This)) && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val); } call->fbc = ce->constructor; } if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - if (Z_TYPE(EG(This)) != IS_UNDEF && + if (Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, @@ -21231,7 +21250,10 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_UNUSED_HANDLER(Z zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name->val, call->fbc->common.function_name->val); } } - ZVAL_COPY(&call->object, &EG(This)); + call->object = Z_OBJ(EG(This)); + if (call->object) { + call->object->gc.refcount++; + } } call->num_additional_args = 0; @@ -23039,29 +23061,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_ } object = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_CV != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_CV == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -23074,9 +23095,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_ } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -23168,16 +23189,16 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_ if (UNEXPECTED(ce->constructor == NULL)) { zend_error_noreturn(E_ERROR, "Cannot call constructor"); } - if (Z_TYPE(EG(This)) != IS_UNDEF && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { + if (Z_OBJ(EG(This)) && Z_OBJCE(EG(This)) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) { zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val); } call->fbc = ce->constructor; } if (call->fbc->common.fn_flags & ZEND_ACC_STATIC) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - if (Z_TYPE(EG(This)) != IS_UNDEF && + if (Z_OBJ(EG(This)) && Z_OBJ_HT(EG(This))->get_class_entry && !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, @@ -23189,7 +23210,10 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_ zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", call->fbc->common.scope->name->val, call->fbc->common.function_name->val); } } - ZVAL_COPY(&call->object, &EG(This)); + call->object = Z_OBJ(EG(This)); + if (call->object) { + call->object->gc.refcount++; + } } call->num_additional_args = 0; @@ -24611,29 +24635,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CONST_HANDLER(ZEND_O } object = _get_obj_zval_ptr_unused(TSRMLS_C); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_CONST != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_CONST == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -24646,9 +24669,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CONST_HANDLER(ZEND_O } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -25993,29 +26016,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_TMP_HANDLER(ZEND_OPC } object = _get_obj_zval_ptr_unused(TSRMLS_C); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_TMP_VAR != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_TMP_VAR == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -26028,9 +26050,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_TMP_HANDLER(ZEND_OPC } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -27283,29 +27305,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_VAR_HANDLER(ZEND_OPC } object = _get_obj_zval_ptr_unused(TSRMLS_C); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_VAR != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_VAR == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -27318,9 +27339,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_VAR_HANDLER(ZEND_OPC } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -28973,29 +28994,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CV_HANDLER(ZEND_OPCO } object = _get_obj_zval_ptr_unused(TSRMLS_C); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_CV != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_CV == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -29008,9 +29028,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CV_HANDLER(ZEND_OPCO } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -30346,7 +30366,7 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL } EX(function_state).function = (zend_function *) new_op_array; - ZVAL_UNDEF(&EX(object)); + EX(object) = NULL; if (!EG(active_symbol_table)) { zend_rebuild_symbol_table(TSRMLS_C); @@ -32203,29 +32223,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CONST_HANDLER(ZEND_OPCOD } object = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_CONST != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_CONST == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -32238,9 +32257,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CONST_HANDLER(ZEND_OPCOD } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -34270,29 +34289,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_ } object = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_TMP_VAR != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_TMP_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_TMP_VAR == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -34305,9 +34323,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_ } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -36430,29 +36448,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_ } object = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_VAR != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_VAR == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_VAR == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -36465,9 +36482,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_ } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; @@ -39544,29 +39561,28 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_H } object = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - ZVAL_COPY_VALUE(&call->object, object); + call->object = Z_TYPE_P(object) == IS_OBJECT ? Z_OBJ_P(object) : NULL; - if (EXPECTED(Z_TYPE(call->object) != IS_UNDEF) && - EXPECTED(Z_TYPE(call->object) == IS_OBJECT)) { - call->called_scope = Z_OBJCE(call->object); + if (EXPECTED(call->object != NULL)) { + call->called_scope = zend_get_class_entry(call->object TSRMLS_CC); if (IS_CV != IS_CONST || (call->fbc = CACHED_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope)) == NULL) { - zend_object *object = Z_OBJ(call->object); + zend_object *object = call->object; - if (UNEXPECTED(Z_OBJ_HT(call->object)->get_method == NULL)) { + if (UNEXPECTED(object->handlers->get_method == NULL)) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ - call->fbc = Z_OBJ_HT(call->object)->get_method(&call->object, Z_STR_P(function_name), ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); + call->fbc = object->handlers->get_method(&call->object, Z_STR_P(function_name), ((IS_CV == IS_CONST) ? (opline->op2.literal + 1) : NULL) TSRMLS_CC); if (UNEXPECTED(call->fbc == NULL)) { - zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(&call->object), Z_STRVAL_P(function_name)); + zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(call->object), Z_STRVAL_P(function_name)); } if (IS_CV == IS_CONST && EXPECTED(call->fbc->type <= ZEND_USER_FUNCTION) && EXPECTED((call->fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_NEVER_CACHE)) == 0) && - EXPECTED(Z_OBJ(call->object) == object)) { + EXPECTED(call->object == object)) { CACHE_POLYMORPHIC_PTR(opline->op2.literal->cache_slot, call->called_scope, call->fbc); } } @@ -39579,9 +39595,9 @@ static int ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_H } if ((call->fbc->common.fn_flags & ZEND_ACC_STATIC) != 0) { - ZVAL_UNDEF(&call->object); + call->object = NULL; } else { - Z_ADDREF(call->object); /* For $this pointer */ + call->object->gc.refcount++; /* For $this pointer */ } call->num_additional_args = 0; diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 9070c3ba4e..5164072104 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -3635,8 +3635,8 @@ PHP_METHOD(DateTimeZone, __construct) tzobj->type = TIMELIB_ZONETYPE_ID; tzobj->tzi.tz = tzi; tzobj->initialized = 1; - } else { - ZVAL_NULL(getThis()); +//??? } else { +//??? ZVAL_NULL(getThis()); } } zend_restore_error_handling(&error_handling TSRMLS_CC); @@ -4103,8 +4103,8 @@ PHP_METHOD(DateInterval, __construct) diobj = Z_PHPINTERVAL_P(getThis()); diobj->diff = reltime; diobj->initialized = 1; - } else { - ZVAL_NULL(getThis()); +//??? } else { +//??? ZVAL_NULL(getThis()); } } zend_restore_error_handling(&error_handling TSRMLS_CC); diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index eb34d442ac..40672f3ef6 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -2177,7 +2177,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, fci.function_table = &ce->function_table; ZVAL_UNDEF(&fci.function_name); fci.symbol_table = NULL; - fci.object_ptr = return_value; + fci.object = Z_OBJ_P(return_value); fci.retval = &retval; if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) { if (Z_TYPE_P(ctor_params) == IS_ARRAY) { @@ -2212,7 +2212,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, fcc.function_handler = ce->constructor; fcc.calling_scope = EG(scope); fcc.called_scope = Z_OBJCE_P(return_value); - ZVAL_COPY_VALUE(&fcc.object, return_value); + fcc.object = Z_OBJ_P(return_value); if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) { zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Could not execute %s::%s()", ce->name->val, ce->constructor->common.function_name->val); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 53101b4623..20d3eb0e73 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -83,7 +83,7 @@ ZEND_DECLARE_MODULE_GLOBALS(reflection) /* Method macros */ #define METHOD_NOTSTATIC(ce) \ - if (!this_ptr || !instanceof_function(Z_OBJCE_P(this_ptr), ce TSRMLS_CC)) { \ + if (!Z_OBJ(EG(This)) || !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { \ php_error_docref(NULL TSRMLS_CC, E_ERROR, "%s() cannot be called statically", get_active_function_name(TSRMLS_C)); \ return; \ } \ @@ -624,7 +624,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in /* see if this is a closure */ if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) && memcmp(mptr->common.function_name->val, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 - && (closure = zend_get_closure_invoke_method(obj TSRMLS_CC)) != NULL) + && (closure = zend_get_closure_invoke_method(Z_OBJ_P(obj) TSRMLS_CC)) != NULL) { mptr = closure; } else { @@ -1394,7 +1394,7 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c fci.function_table = NULL; ZVAL_UNDEF(&fci.function_name); fci.symbol_table = NULL; - fci.object_ptr = &reflector; + fci.object = Z_OBJ(reflector); fci.retval = &retval; fci.param_count = ctor_argc; fci.params = params; @@ -1404,7 +1404,7 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c fcc.function_handler = ce_ptr->constructor; fcc.calling_scope = ce_ptr; fcc.called_scope = Z_OBJCE(reflector); - ZVAL_COPY_VALUE(&fcc.object, &reflector); + fcc.object = Z_OBJ(reflector); result = zend_call_function(&fci, &fcc TSRMLS_CC); @@ -1426,7 +1426,7 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c ZVAL_STRINGL(&fci.function_name, "reflection::export", sizeof("reflection::export") - 1); fci.function_table = &reflection_ptr->function_table; - fci.object_ptr = NULL; + fci.object = NULL; fci.retval = &retval; fci.param_count = 2; fci.params = params; @@ -1910,7 +1910,7 @@ ZEND_METHOD(reflection_function, invoke) fci.function_table = NULL; ZVAL_UNDEF(&fci.function_name); fci.symbol_table = NULL; - fci.object_ptr = NULL; + fci.object = NULL; fci.retval = &retval; fci.param_count = num_args; fci.params = params; @@ -1920,7 +1920,7 @@ ZEND_METHOD(reflection_function, invoke) fcc.function_handler = fptr; fcc.calling_scope = EG(scope); fcc.called_scope = NULL; - ZVAL_UNDEF(&fcc.object); + fcc.object = NULL; result = zend_call_function(&fci, &fcc TSRMLS_CC); @@ -1974,7 +1974,7 @@ ZEND_METHOD(reflection_function, invokeArgs) fci.function_table = NULL; ZVAL_UNDEF(&fci.function_name); fci.symbol_table = NULL; - fci.object_ptr = NULL; + fci.object = NULL; fci.retval = &retval; fci.param_count = argc; fci.params = params; @@ -1984,7 +1984,7 @@ ZEND_METHOD(reflection_function, invokeArgs) fcc.function_handler = fptr; fcc.calling_scope = EG(scope); fcc.called_scope = NULL; - ZVAL_UNDEF(&fcc.object); + fcc.object = NULL; result = zend_call_function(&fci, &fcc TSRMLS_CC); @@ -2200,7 +2200,7 @@ ZEND_METHOD(reflection_parameter, __construct) if (ce == zend_ce_closure && Z_TYPE_P(classref) == IS_OBJECT && (lcname_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) && memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 - && (fptr = zend_get_closure_invoke_method(classref TSRMLS_CC)) != NULL) + && (fptr = zend_get_closure_invoke_method(Z_OBJ_P(classref) TSRMLS_CC)) != NULL) { /* nothing to do. don't set is_closure since is the invoke handler, - not the closure itself */ @@ -2741,7 +2741,7 @@ ZEND_METHOD(reflection_method, __construct) if (ce == zend_ce_closure && orig_obj && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) && memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 - && (mptr = zend_get_closure_invoke_method(orig_obj TSRMLS_CC)) != NULL) + && (mptr = zend_get_closure_invoke_method(Z_OBJ_P(orig_obj) TSRMLS_CC)) != NULL) { /* do nothing, mptr already set */ } else if ((mptr = zend_hash_str_find_ptr(&ce->function_table, lcname, name_len)) == NULL) { @@ -2821,7 +2821,7 @@ ZEND_METHOD(reflection_method, invoke) { zval retval; zval *params = NULL; - zval object; + zend_object *object; reflection_object *intern; zend_function *mptr; int result, num_args = 0; @@ -2862,7 +2862,7 @@ ZEND_METHOD(reflection_method, invoke) * Else, we verify that the given object is an instance of the class. */ if (mptr->common.fn_flags & ZEND_ACC_STATIC) { - ZVAL_UNDEF(&object); + object = NULL; obj_ce = mptr->common.scope; } else { if (Z_TYPE(params[0]) != IS_OBJECT) { @@ -2877,14 +2877,14 @@ ZEND_METHOD(reflection_method, invoke) /* Returns from this function */ } - ZVAL_COPY_VALUE(&object, ¶ms[0]); + object = Z_OBJ(params[0]); } fci.size = sizeof(fci); fci.function_table = NULL; ZVAL_UNDEF(&fci.function_name); fci.symbol_table = NULL; - fci.object_ptr = &object; + fci.object = object; fci.retval = &retval; fci.param_count = num_args - 1; fci.params = params + 1; @@ -2894,7 +2894,7 @@ ZEND_METHOD(reflection_method, invoke) fcc.function_handler = mptr; fcc.calling_scope = obj_ce; fcc.called_scope = intern->ce; - ZVAL_COPY_VALUE(&fcc.object, &object); + fcc.object = object; result = zend_call_function(&fci, &fcc TSRMLS_CC); @@ -2989,7 +2989,7 @@ ZEND_METHOD(reflection_method, invokeArgs) fci.function_table = NULL; ZVAL_UNDEF(&fci.function_name); fci.symbol_table = NULL; - fci.object_ptr = object; + fci.object = object ? Z_OBJ_P(object) : NULL; fci.retval = &retval; fci.param_count = argc; fci.params = params; @@ -2999,11 +2999,7 @@ ZEND_METHOD(reflection_method, invokeArgs) fcc.function_handler = mptr; fcc.calling_scope = obj_ce; fcc.called_scope = intern->ce; - if (object) { - ZVAL_COPY_VALUE(&fcc.object, object); - } else { - ZVAL_UNDEF(&fcc.object); - } + fcc.object = (object) ? Z_OBJ_P(object) : NULL; /* * Copy the zend_function when calling via handler (e.g. Closure::__invoke()) @@ -3700,7 +3696,7 @@ ZEND_METHOD(reflection_class, getMethod) lc_name = zend_str_tolower_dup(name, name_len); if (ce == zend_ce_closure && !ZVAL_IS_UNDEF(&intern->obj) && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) && memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 - && (mptr = zend_get_closure_invoke_method(&intern->obj TSRMLS_CC)) != NULL) + && (mptr = zend_get_closure_invoke_method(Z_OBJ(intern->obj) TSRMLS_CC)) != NULL) { /* don't assign closure_object since we only reflect the invoke handler method and not the closure definition itself */ @@ -3708,7 +3704,7 @@ ZEND_METHOD(reflection_class, getMethod) efree(lc_name); } else if (ce == zend_ce_closure && ZVAL_IS_UNDEF(&intern->obj) && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) && memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 - && object_init_ex(&obj_tmp, ce) == SUCCESS && (mptr = zend_get_closure_invoke_method(&obj_tmp TSRMLS_CC)) != NULL) { + && object_init_ex(&obj_tmp, ce) == SUCCESS && (mptr = zend_get_closure_invoke_method(Z_OBJ(obj_tmp) TSRMLS_CC)) != NULL) { /* don't assign closure_object since we only reflect the invoke handler method and not the closure definition itself */ reflection_method_factory(ce, mptr, NULL, return_value TSRMLS_CC); @@ -3735,7 +3731,7 @@ static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval, if (mptr->common.fn_flags & filter) { if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) && memcmp(mptr->common.function_name->val, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 - && (closure = zend_get_closure_invoke_method(obj TSRMLS_CC)) != NULL) + && (closure = zend_get_closure_invoke_method(Z_OBJ_P(obj) TSRMLS_CC)) != NULL) { mptr = closure; } @@ -3786,7 +3782,7 @@ ZEND_METHOD(reflection_class, getMethods) array_init(return_value); zend_hash_apply_with_arguments(&ce->function_table TSRMLS_CC, (apply_func_args_t) _addmethod_va, 4, &ce, return_value, filter, intern->obj); if (Z_TYPE(intern->obj) != IS_UNDEF && instanceof_function(ce, zend_ce_closure TSRMLS_CC)) { - zend_function *closure = zend_get_closure_invoke_method(&intern->obj TSRMLS_CC); + zend_function *closure = zend_get_closure_invoke_method(Z_OBJ(intern->obj) TSRMLS_CC); if (closure) { _addmethod(closure, ce, return_value, filter, &intern->obj TSRMLS_CC); _free_function(closure TSRMLS_CC); @@ -4198,7 +4194,7 @@ ZEND_METHOD(reflection_class, newInstance) old_scope = EG(scope); EG(scope) = ce; - constructor = Z_OBJ_HT_P(return_value)->get_constructor(return_value TSRMLS_CC); + constructor = Z_OBJ_HT_P(return_value)->get_constructor(Z_OBJ_P(return_value) TSRMLS_CC); EG(scope) = old_scope; /* Run the constructor if there is one */ @@ -4223,7 +4219,7 @@ ZEND_METHOD(reflection_class, newInstance) fci.function_table = EG(function_table); ZVAL_UNDEF(&fci.function_name); fci.symbol_table = NULL; - fci.object_ptr = return_value; + fci.object = Z_OBJ_P(return_value); fci.retval = &retval; fci.param_count = num_args; fci.params = params; @@ -4233,7 +4229,7 @@ ZEND_METHOD(reflection_class, newInstance) fcc.function_handler = constructor; fcc.calling_scope = EG(scope); fcc.called_scope = Z_OBJCE_P(return_value); - ZVAL_COPY_VALUE(&fcc.object, return_value); + fcc.object = Z_OBJ_P(return_value); if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) { if (!ZVAL_IS_UNDEF(&retval)) { @@ -4297,7 +4293,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs) old_scope = EG(scope); EG(scope) = ce; - constructor = Z_OBJ_HT_P(return_value)->get_constructor(return_value TSRMLS_CC); + constructor = Z_OBJ_HT_P(return_value)->get_constructor(Z_OBJ_P(return_value) TSRMLS_CC); EG(scope) = old_scope; /* Run the constructor if there is one */ @@ -4322,7 +4318,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs) fci.function_table = EG(function_table); ZVAL_UNDEF(&fci.function_name); fci.symbol_table = NULL; - fci.object_ptr = return_value; + fci.object = Z_OBJ_P(return_value); fci.retval = &retval; fci.param_count = argc; fci.params = params; @@ -4332,7 +4328,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs) fcc.function_handler = constructor; fcc.calling_scope = EG(scope); fcc.called_scope = Z_OBJCE_P(return_value); - ZVAL_COPY_VALUE(&fcc.object, return_value); + fcc.object = Z_OBJ_P(return_value); if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) { if (params) { diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 935e64be60..55d72e6753 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -485,7 +485,7 @@ PHP_FUNCTION(spl_autoload_register) zend_bool prepend = 0; zend_function *spl_func_ptr; autoload_func_info alfi; - zval *obj_ptr; + zend_object *obj_ptr; zend_fcall_info_cache fcc; if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "|zbb", &zcallable, &do_throw, &prepend) == FAILURE) { @@ -496,9 +496,9 @@ PHP_FUNCTION(spl_autoload_register) if (!zend_is_callable_ex(zcallable, NULL, IS_CALLABLE_STRICT, &func_name, &fcc, &error TSRMLS_CC)) { alfi.ce = fcc.calling_scope; alfi.func_ptr = fcc.function_handler; - obj_ptr = &fcc.object; + obj_ptr = fcc.object; if (Z_TYPE_P(zcallable) == IS_ARRAY) { - if (Z_TYPE_P(obj_ptr) == IS_UNDEF && alfi.func_ptr && !(alfi.func_ptr->common.fn_flags & ZEND_ACC_STATIC)) { + if (!obj_ptr && alfi.func_ptr && !(alfi.func_ptr->common.fn_flags & ZEND_ACC_STATIC)) { if (do_throw) { zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Passed array specifies a non static method but no object (%s)", error); } @@ -508,7 +508,7 @@ PHP_FUNCTION(spl_autoload_register) STR_RELEASE(func_name); RETURN_FALSE; } else if (do_throw) { - zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Passed array does not specify %s %smethod (%s)", alfi.func_ptr ? "a callable" : "an existing", Z_TYPE_P(obj_ptr) == IS_UNDEF ? "static " : "", error); + zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Passed array does not specify %s %smethod (%s)", alfi.func_ptr ? "a callable" : "an existing", !obj_ptr ? "static " : "", error); } if (error) { efree(error); @@ -547,7 +547,7 @@ PHP_FUNCTION(spl_autoload_register) } alfi.ce = fcc.calling_scope; alfi.func_ptr = fcc.function_handler; - obj_ptr = &fcc.object; + obj_ptr = fcc.object; if (error) { efree(error); } @@ -573,12 +573,13 @@ PHP_FUNCTION(spl_autoload_register) goto skip; } - if (Z_TYPE_P(obj_ptr) == IS_OBJECT && !(alfi.func_ptr->common.fn_flags & ZEND_ACC_STATIC)) { + if (obj_ptr && !(alfi.func_ptr->common.fn_flags & ZEND_ACC_STATIC)) { /* add object id to the hash to ensure uniqueness, for more reference look at bug #40091 */ lc_name = STR_REALLOC(lc_name, lc_name->len + sizeof(zend_uint), 0); - memcpy(lc_name->val + lc_name->len - sizeof(zend_uint), &Z_OBJ_HANDLE_P(obj_ptr), sizeof(zend_uint)); + memcpy(lc_name->val + lc_name->len - sizeof(zend_uint), &obj_ptr->handle, sizeof(zend_uint)); lc_name->val[lc_name->len] = '\0'; - ZVAL_COPY(&alfi.obj, obj_ptr); + ZVAL_OBJ(&alfi.obj, obj_ptr); + Z_ADDREF(alfi.obj); } else { ZVAL_UNDEF(&alfi.obj); } @@ -606,7 +607,7 @@ PHP_FUNCTION(spl_autoload_register) } if (zend_hash_add_mem(SPL_G(autoload_functions), lc_name, &alfi, sizeof(autoload_func_info)) == NULL) { - if (Z_TYPE_P(obj_ptr) == IS_OBJECT && !(alfi.func_ptr->common.fn_flags & ZEND_ACC_STATIC)) { + if (obj_ptr && !(alfi.func_ptr->common.fn_flags & ZEND_ACC_STATIC)) { Z_DELREF(alfi.obj); } if (!ZVAL_IS_UNDEF(&alfi.closure)) { @@ -640,7 +641,7 @@ PHP_FUNCTION(spl_autoload_unregister) zval *zcallable; int success = FAILURE; zend_function *spl_func_ptr; - zval *obj_ptr; + zend_object *obj_ptr; zend_fcall_info_cache fcc; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zcallable) == FAILURE) { @@ -657,7 +658,7 @@ PHP_FUNCTION(spl_autoload_unregister) } RETURN_FALSE; } - obj_ptr = &fcc.object; + obj_ptr = fcc.object; if (error) { efree(error); } @@ -684,9 +685,9 @@ PHP_FUNCTION(spl_autoload_unregister) } else { /* remove specific */ success = zend_hash_del(SPL_G(autoload_functions), lc_name); - if (success != SUCCESS && Z_TYPE_P(obj_ptr) == IS_OBJECT) { + if (success != SUCCESS && obj_ptr) { lc_name = STR_REALLOC(lc_name, lc_name->len + sizeof(zend_uint), 0); - memcpy(lc_name->val + lc_name->len - sizeof(zend_uint), &Z_OBJ_HANDLE_P(obj_ptr), sizeof(zend_uint)); + memcpy(lc_name->val + lc_name->len - sizeof(zend_uint), &obj_ptr->handle, sizeof(zend_uint)); lc_name->val[lc_name->len] = '\0'; success = zend_hash_del(SPL_G(autoload_functions), lc_name); } diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 86d745463f..8a60979307 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -578,9 +578,9 @@ static char *spl_filesystem_object_get_pathname(spl_filesystem_object *intern, i } /* }}} */ -static HashTable *spl_filesystem_object_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /* {{{ */ +static HashTable *spl_filesystem_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */ { - spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(obj); + spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(object); zval tmp; HashTable *rv; zend_string *pnstr; @@ -659,19 +659,19 @@ static HashTable *spl_filesystem_object_get_debug_info(zval *obj, int *is_temp T } /* }}} */ -zend_function *spl_filesystem_object_get_method_check(zval *object_ptr, zend_string *method, const struct _zend_literal *key TSRMLS_DC) /* {{{ */ +zend_function *spl_filesystem_object_get_method_check(zend_object **object, zend_string *method, const struct _zend_literal *key TSRMLS_DC) /* {{{ */ { - spl_filesystem_object *fsobj = Z_SPLFILESYSTEM_P(object_ptr); + spl_filesystem_object *fsobj = spl_filesystem_from_obj(*object); if (fsobj->u.dir.entry.d_name[0] == '\0' && fsobj->orig_path == NULL) { zend_function *func; zend_string *tmp = STR_INIT("_bad_state_ex", sizeof("_bad_state_ex") - 1, 0); - func = zend_get_std_object_handlers()->get_method(object_ptr, tmp, NULL TSRMLS_CC); + func = zend_get_std_object_handlers()->get_method(object, tmp, NULL TSRMLS_CC); STR_RELEASE(tmp); return func; } - return zend_get_std_object_handlers()->get_method(object_ptr, method, key TSRMLS_CC); + return zend_get_std_object_handlers()->get_method(object, method, key TSRMLS_CC); } /* }}} */ @@ -828,12 +828,12 @@ SPL_METHOD(DirectoryIterator, seek) if (intern->u.dir.index > pos) { /* we first rewind */ - zend_call_method_with_0_params(this_ptr, Z_OBJCE_P(getThis()), &intern->u.dir.func_rewind, "rewind", NULL); + zend_call_method_with_0_params(&EG(This), Z_OBJCE(EG(This)), &intern->u.dir.func_rewind, "rewind", NULL); } while (intern->u.dir.index < pos) { int valid = 0; - zend_call_method_with_0_params(this_ptr, Z_OBJCE_P(getThis()), &intern->u.dir.func_valid, "valid", &retval); + zend_call_method_with_0_params(&EG(This), Z_OBJCE(EG(This)), &intern->u.dir.func_valid, "valid", &retval); if (!ZVAL_IS_UNDEF(&retval)) { valid = zend_is_true(&retval TSRMLS_CC); zval_ptr_dtor(&retval); @@ -841,7 +841,7 @@ SPL_METHOD(DirectoryIterator, seek) if (!valid) { break; } - zend_call_method_with_0_params(this_ptr, Z_OBJCE_P(getThis()), &intern->u.dir.func_next, "next", NULL); + zend_call_method_with_0_params(&EG(This), Z_OBJCE(EG(This)), &intern->u.dir.func_next, "next", NULL); } } /* }}} */ @@ -2091,7 +2091,7 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function fci.size = sizeof(fci); fci.function_table = EG(function_table); - fci.object_ptr = NULL; + fci.object = NULL; fci.retval = &retval; fci.param_count = num_args; fci.params = params; @@ -2103,7 +2103,7 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function fcic.function_handler = func_ptr; fcic.calling_scope = NULL; fcic.called_scope = NULL; - ZVAL_UNDEF(&fcic.object); + fcic.object = NULL; result = zend_call_function(&fci, &fcic TSRMLS_CC); diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 76dc200ee8..a1271dc070 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -829,24 +829,24 @@ SPL_METHOD(RecursiveIteratorIterator, getMaxDepth) } } /* }}} */ -static union _zend_function *spl_recursive_it_get_method(zval *object_ptr, zend_string *method, const zend_literal *key TSRMLS_DC) +static union _zend_function *spl_recursive_it_get_method(zend_object **zobject, zend_string *method, const zend_literal *key TSRMLS_DC) { union _zend_function *function_handler; - spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(object_ptr); + spl_recursive_it_object *object = spl_recursive_it_from_obj(*zobject); long level = object->level; zval *zobj; if (!object->iterators) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "The %s instance wasn't initialized properly", Z_OBJCE_P(object_ptr)->name->val); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "The %s instance wasn't initialized properly", zend_get_class_entry(*zobject TSRMLS_CC)->name->val); } zobj = &object->iterators[level].zobject; - function_handler = std_object_handlers.get_method(object_ptr, method, key TSRMLS_CC); + function_handler = std_object_handlers.get_method(zobject, method, key TSRMLS_CC); if (!function_handler) { if ((function_handler = zend_hash_find_ptr(&Z_OBJCE_P(zobj)->function_table, method)) == NULL) { if (Z_OBJ_HT_P(zobj)->get_method) { - ZVAL_COPY_VALUE(object_ptr, zobj); - function_handler = Z_OBJ_HT_P(object_ptr)->get_method(object_ptr, method, key TSRMLS_CC); + *zobject = Z_OBJ_P(zobj); + function_handler = (*zobject)->handlers->get_method(zobject, method, key TSRMLS_CC); } } } @@ -1276,22 +1276,22 @@ static int spl_dual_it_gets_implemented(zend_class_entry *interface, zend_class_ } #endif -static union _zend_function *spl_dual_it_get_method(zval *object_ptr, zend_string *method, const zend_literal *key TSRMLS_DC) +static union _zend_function *spl_dual_it_get_method(zend_object **object, zend_string *method, const zend_literal *key TSRMLS_DC) { union _zend_function *function_handler; spl_dual_it_object *intern; - intern = Z_SPLDUAL_IT_P(object_ptr); + intern = spl_dual_it_from_obj(*object); - function_handler = std_object_handlers.get_method(object_ptr, method, key TSRMLS_CC); + function_handler = std_object_handlers.get_method(object, method, key TSRMLS_CC); if (!function_handler && intern->inner.ce) { if ((function_handler = zend_hash_find_ptr(&intern->inner.ce->function_table, method)) == NULL) { if (Z_OBJ_HT(intern->inner.zobject)->get_method) { - ZVAL_COPY_VALUE(object_ptr, &intern->inner.zobject); - function_handler = Z_OBJ_HT_P(object_ptr)->get_method(object_ptr, method, key TSRMLS_CC); + *object = Z_OBJ(intern->inner.zobject); + function_handler = (*object)->handlers->get_method(object, method, key TSRMLS_CC); } } else { - ZVAL_COPY_VALUE(object_ptr, &intern->inner.zobject); + *object = Z_OBJ(intern->inner.zobject); } } return function_handler; @@ -1498,7 +1498,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z case DIT_CallbackFilterIterator: case DIT_RecursiveCallbackFilterIterator: { _spl_cbfilter_it_intern *cfi = emalloc(sizeof(*cfi)); - cfi->fci.object_ptr = NULL; + cfi->fci.object = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Of", &zobject, ce_inner, &cfi->fci, &cfi->fcc) == FAILURE) { zend_restore_error_handling(&error_handling TSRMLS_CC); efree(cfi); @@ -1507,9 +1507,8 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z if (Z_REFCOUNTED_P(&cfi->fci.function_name)) { Z_ADDREF(cfi->fci.function_name); } - if (Z_TYPE(cfi->fcc.object) == IS_OBJECT) { - ZVAL_COPY(&cfi->object, &cfi->fcc.object); - } + cfi->object = cfi->fcc.object; + if (cfi->object) cfi->object->gc.refcount++; intern->u.cbfilter = cfi; break; } @@ -2260,8 +2259,8 @@ static void spl_dual_it_free_storage(zend_object *_object TSRMLS_DC) _spl_cbfilter_it_intern *cbfilter = object->u.cbfilter; object->u.cbfilter = NULL; zval_ptr_dtor(&cbfilter->fci.function_name); - if (cbfilter->fci.object_ptr) { - zval_ptr_dtor(cbfilter->fci.object_ptr); + if (cbfilter->fci.object) { + OBJ_RELEASE(cbfilter->fci.object); } efree(cbfilter); } diff --git a/ext/spl/spl_iterators.h b/ext/spl/spl_iterators.h index d20caad5ba..f51fc3a990 100644 --- a/ext/spl/spl_iterators.h +++ b/ext/spl/spl_iterators.h @@ -121,7 +121,7 @@ typedef enum { typedef struct _spl_cbfilter_it_intern { zend_fcall_info fci; zend_fcall_info_cache fcc; - zval object; + zend_object *object; } _spl_cbfilter_it_intern; typedef struct _spl_dual_it_object { diff --git a/ext/standard/array.c b/ext/standard/array.c index 60df41f9cd..5e5fa73cd7 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -827,7 +827,7 @@ PHP_FUNCTION(end) zend_hash_internal_pointer_end(array); - if (return_value_used) { + if (USED_RET()) { if ((entry = zend_hash_get_current_data(array)) == NULL) { RETURN_FALSE; } @@ -850,7 +850,7 @@ PHP_FUNCTION(prev) zend_hash_move_backwards(array); - if (return_value_used) { + if (USED_RET()) { if ((entry = zend_hash_get_current_data(array)) == NULL) { RETURN_FALSE; } @@ -873,7 +873,7 @@ PHP_FUNCTION(next) zend_hash_move_forward(array); - if (return_value_used) { + if (USED_RET()) { if ((entry = zend_hash_get_current_data(array)) == NULL) { RETURN_FALSE; } @@ -896,7 +896,7 @@ PHP_FUNCTION(reset) zend_hash_internal_pointer_reset(array); - if (return_value_used) { + if (USED_RET()) { if ((entry = zend_hash_get_current_data(array)) == NULL) { RETURN_FALSE; } @@ -2126,7 +2126,7 @@ PHP_FUNCTION(array_splice) /* Don't create the array of removed elements if it's not going * to be used; e.g. only removing and/or replacing elements */ - if (return_value_used) { + if (USED_RET()) { int size = length; /* Clamp the offset.. */ diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 4744b16229..b305c9451b 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -80,7 +80,7 @@ static zend_class_entry *dir_class_entry_ptr; } \ if (ZEND_NUM_ARGS() == 0) { \ myself = getThis(); \ - if (!ZVAL_IS_UNDEF(myself)) { \ + if (myself) { \ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(myself), "handle", sizeof("handle")-1)) == NULL) { \ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find my handle property"); \ RETURN_FALSE; \ diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c index fc82eb8923..c017edff89 100644 --- a/ext/standard/incomplete_class.c +++ b/ext/standard/incomplete_class.c @@ -87,9 +87,12 @@ static int incomplete_class_has_property(zval *object, zval *member, int check_e } /* }}} */ -static union _zend_function *incomplete_class_get_method(zval *object, zend_string *method, const zend_literal *key TSRMLS_DC) /* {{{ */ +static union _zend_function *incomplete_class_get_method(zend_object **object, zend_string *method, const zend_literal *key TSRMLS_DC) /* {{{ */ { - incomplete_class_message(object, E_ERROR TSRMLS_CC); + zval zobject; + + ZVAL_OBJ(&zobject, *object); + incomplete_class_message(&zobject, E_ERROR TSRMLS_CC); return NULL; } /* }}} */ diff --git a/ext/standard/php_incomplete_class.h b/ext/standard/php_incomplete_class.h index 9afc5d7d5b..804ca05206 100644 --- a/ext/standard/php_incomplete_class.h +++ b/ext/standard/php_incomplete_class.h @@ -36,7 +36,7 @@ } \ incomplete_class = 1; \ } else { \ - class_name = zend_get_object_classname(struc TSRMLS_CC); \ + class_name = zend_get_object_classname(Z_OBJ_P(struc) TSRMLS_CC); \ } #define PHP_CLEANUP_CLASS_ATTRIBUTES() \ diff --git a/ext/standard/var.c b/ext/standard/var.c index 9ea1119cea..8881b70079 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -166,7 +166,7 @@ again: } if (Z_OBJ_HANDLER_P(struc, get_class_name)) { - class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(struc, 0 TSRMLS_CC); + class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc), 0 TSRMLS_CC); php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name->val, Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0); STR_RELEASE(class_name); } else { @@ -336,7 +336,7 @@ again: PUTS("*RECURSION*\n"); return; } - class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(struc, 0 TSRMLS_CC); + class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc), 0 TSRMLS_CC); php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name->val, Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0, Z_REFCOUNT_P(struc)); STR_RELEASE(class_name); zval_element_dump_func = zval_object_property_dump; @@ -552,7 +552,7 @@ again: smart_str_appendc(buf, '\n'); buffer_append_spaces(buf, level - 1); } - class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(struc, 0 TSRMLS_CC); + class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc), 0 TSRMLS_CC); smart_str_appendl(buf, class_name->val, class_name->len); smart_str_appendl(buf, "::__set_state(array(\n", 21); @@ -749,7 +749,7 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); } else { zend_class_entry *ce; - ce = zend_get_class_entry(struc TSRMLS_CC); + ce = zend_get_class_entry(Z_OBJ_P(struc) TSRMLS_CC); if (ce) { zend_string *prot_name, *priv_name; diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 45689ecfb4..f27055c180 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -303,7 +303,7 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php fci.function_table = &uwrap->ce->function_table; ZVAL_UNDEF(&fci.function_name); fci.symbol_table = NULL; - fci.object_ptr = object; + fci.object = Z_OBJ_P(object); fci.retval = &retval; fci.param_count = 0; fci.params = NULL; @@ -313,7 +313,7 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php fcc.function_handler = uwrap->ce->constructor; fcc.calling_scope = EG(scope); fcc.called_scope = Z_OBJCE_P(object); - ZVAL_COPY_VALUE(&fcc.object, object); + fcc.object = Z_OBJ_P(object); if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not execute %s::%s()", uwrap->ce->name->val, uwrap->ce->constructor->common.function_name->val); @@ -978,7 +978,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value switch (value) { case PHP_STREAM_TRUNCATE_SUPPORTED: if (zend_is_callable_ex(&func_name, - ZVAL_IS_UNDEF(&us->object)? NULL : &us->object, + ZVAL_IS_UNDEF(&us->object)? NULL : Z_OBJ(us->object), IS_CALLABLE_CHECK_SILENT, NULL, NULL, NULL TSRMLS_CC)) ret = PHP_STREAM_OPTION_RETURN_OK; else diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c index 133eaff1ab..965e9bc2e2 100644 --- a/sapi/phpdbg/phpdbg_frame.c +++ b/sapi/phpdbg/phpdbg_frame.c @@ -40,7 +40,7 @@ void phpdbg_restore_frame(TSRMLS_D) /* {{{ */ EG(opline_ptr) = &PHPDBG_EX(opline); EG(active_op_array) = PHPDBG_EX(op_array); EG(active_symbol_table) = PHPDBG_EX(symbol_table); - ZVAL_COPY_VALUE(&EG(This), &PHPDBG_EX(current_this)); + Z_OBJ(EG(This)) = PHPDBG_EX(current_this); EG(scope) = PHPDBG_EX(current_scope); EG(called_scope) = PHPDBG_EX(current_called_scope); } /* }}} */ @@ -82,7 +82,7 @@ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */ EG(opline_ptr) = &PHPDBG_EX(opline); EG(active_op_array) = PHPDBG_EX(op_array); EG(active_symbol_table) = PHPDBG_EX(symbol_table); - ZVAL_COPY_VALUE(&EG(This), &PHPDBG_EX(current_this)); + Z_OBJ(EG(This)) = PHPDBG_EX(current_this); EG(scope) = PHPDBG_EX(current_scope); EG(called_scope) = PHPDBG_EX(current_called_scope); } @@ -107,7 +107,7 @@ static void phpdbg_dump_prototype(zval *tmp TSRMLS_DC) /* {{{ */ if ((class = zend_hash_str_find(Z_ARRVAL_P(tmp), "object", sizeof("object") - 1)) == NULL) { class = zend_hash_str_find(Z_ARRVAL_P(tmp), "class", sizeof("class") - 1); } else { - class_name = zend_get_object_classname(class TSRMLS_CC); + class_name = zend_get_object_classname(Z_OBJ_P(class) TSRMLS_CC); } if (class) { diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 78aa4d87f3..d1dd468acb 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -84,7 +84,7 @@ static inline int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ * fci.function_table = &PHPDBG_G(registered); ZVAL_STRINGL(&fci.function_name, function->string, function->length); fci.symbol_table = EG(active_symbol_table); - fci.object_ptr = NULL; + fci.object = NULL; fci.retval = &fretval; fci.no_separation = 1; @@ -512,7 +512,7 @@ static inline void phpdbg_handle_exception(TSRMLS_D) /* }}} */ fci.function_table = &Z_OBJCE(exception)->function_table; ZVAL_STRINGL(&fci.function_name, "__tostring", sizeof("__tostring") - 1); fci.symbol_table = NULL; - fci.object_ptr = &exception; + fci.object = EG(exception); fci.retval = &trace; fci.param_count = 0; fci.params = NULL; |