Revert "Move zend_objects_store_put out of zend_object_std_init"

This reverts commit 8ced4f0ac9.
This commit is contained in:
Xinchen Hui 2014-02-28 13:59:07 +08:00
parent 3231174749
commit a5ce7d526e
13 changed files with 33 additions and 43 deletions

View file

@ -254,7 +254,6 @@ static zend_object *zend_closure_new(zend_class_entry *class_type TSRMLS_DC) /*
zend_object_std_init(&closure->std, class_type TSRMLS_CC);
closure->std.handlers = &closure_handlers;
zend_objects_store_put(&closure->std);
return (zend_object*)closure;
}

View file

@ -222,7 +222,6 @@ static zend_object *zend_generator_create(zend_class_entry *class_type TSRMLS_DC
generator->largest_used_integer_key = -1;
zend_object_std_init(&generator->std, class_type TSRMLS_CC);
zend_objects_store_put(&generator->std TSRMLS_CC);
generator->std.handlers = &zend_generator_handlers;
return (zend_object*)generator;

View file

@ -36,6 +36,7 @@ ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce TSR
object->properties = NULL;
object->guards = NULL;
memset(object->properties_table, 0, sizeof(zval) * ce->default_properties_count);
zend_objects_store_put(object);
}
ZEND_API void zend_object_std_dtor(zend_object *object TSRMLS_DC)
@ -132,7 +133,6 @@ ZEND_API zend_object *zend_objects_new(zend_class_entry *ce TSRMLS_DC)
zend_object *object = emalloc(sizeof(zend_object) + sizeof(zval) * (ce->default_properties_count - 1));
zend_object_std_init(object, ce);
zend_objects_store_put(object);
object->handlers = &std_object_handlers;
return object;
}

View file

@ -2108,7 +2108,6 @@ static inline zend_object *date_object_new_date_ex(zend_class_entry *class_type
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->std.handlers = &date_object_handlers_date;
zend_objects_store_put(&intern->std TSRMLS_CC);
return (zend_object*)intern;
}
@ -2243,7 +2242,6 @@ static inline zend_object *date_object_new_timezone_ex(zend_class_entry *class_t
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->std.handlers = &date_object_handlers_timezone;
zend_objects_store_put(&intern->std TSRMLS_CC);
return (zend_object*)intern;
}
@ -2335,7 +2333,6 @@ static inline zend_object *date_object_new_interval_ex(zend_class_entry *class_t
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->std.handlers = &date_object_handlers_interval;
zend_objects_store_put(&intern->std TSRMLS_CC);
return (zend_object*)intern;
}
@ -2417,7 +2414,6 @@ static inline zend_object *date_object_new_period_ex(zend_class_entry *class_typ
object_properties_init(&intern->std, class_type);
//??? date_object_free_storage_period, NULL TSRMLS_CC);
intern->std.handlers = &date_object_handlers_period;
zend_objects_store_put(&intern->std TSRMLS_CC);
return (zend_object*)intern;
}

View file

@ -325,7 +325,6 @@ static zend_object *reflection_objects_new(zend_class_entry *class_type TSRMLS_D
intern->zo.ce = class_type;
zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
zend_objects_store_put(&intern->zo TSRMLS_CC);
object_properties_init(&intern->zo, class_type);
intern->zo.handlers = &reflection_object_handlers;
return (zend_object*)intern;

View file

@ -180,7 +180,6 @@ static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval *
memset(intern, 0, sizeof(spl_array_object));
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
zend_objects_store_put(&intern->std TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->ar_flags = 0;

View file

@ -157,7 +157,6 @@ static zend_object *spl_filesystem_object_new_ex(zend_class_entry *class_type TS
intern->info_class = spl_ce_SplFileInfo;
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
zend_objects_store_put(&intern->std TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->std.handlers = &spl_filesystem_object_handlers;

View file

@ -375,7 +375,6 @@ static zend_object *spl_dllist_object_new_ex(zend_class_entry *class_type, zval
intern = ecalloc(1, sizeof(spl_dllist_object));
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
zend_objects_store_put(&intern->std TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->flags = 0;

View file

@ -217,7 +217,6 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z
intern = ecalloc(1, sizeof(spl_fixedarray_object));
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
zend_objects_store_put(&intern->std TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->current = 0;

View file

@ -384,7 +384,6 @@ static zend_object *spl_heap_object_new_ex(zend_class_entry *class_type, zval *o
intern = ecalloc(1, sizeof(spl_heap_object));
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
zend_objects_store_put(&intern->std TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->flags = 0;

View file

@ -905,7 +905,6 @@ static zend_object *spl_RecursiveIteratorIterator_new_ex(zend_class_entry *class
}
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
zend_objects_store_put(&intern->std TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->std.handlers = &spl_handlers_rec_it_it;
@ -1283,14 +1282,14 @@ static union _zend_function *spl_dual_it_get_method(zval *object_ptr, zend_strin
function_handler = std_object_handlers.get_method(object_ptr, 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) {
if (Z_OBJ_HT_P(intern->inner.zobject)->get_method) {
//!!! maybe we really need a zval ** here?
//*object_ptr = &intern->inner.zobject?
object_ptr = &intern->inner.zobject;
object_ptr = intern->inner.zobject;
function_handler = Z_OBJ_HT_P(object_ptr)->get_method(object_ptr, method, key TSRMLS_CC);
}
} else {
object_ptr = &intern->inner.zobject;
object_ptr = intern->inner.zobject;
}
}
return function_handler;
@ -1520,11 +1519,11 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
zend_restore_error_handling(&error_handling TSRMLS_CC);
if (inc_refcount) {
ZVAL_COPY(&intern->inner.zobject, zobject);
} else {
ZVAL_COPY_VALUE(&intern->inner.zobject, zobject);
Z_ADDREF_P(zobject);
}
intern->inner.zobject = zobject;
intern->inner.ce = dit_type == DIT_IteratorIterator ? ce : Z_OBJCE_P(zobject);
intern->inner.object = Z_OBJ_P(zobject);
intern->inner.iterator = intern->inner.ce->get_iterator(intern->inner.ce, zobject, 0 TSRMLS_CC);
return intern;
@ -1559,8 +1558,8 @@ SPL_METHOD(dual_it, getInnerIterator)
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
if (!ZVAL_IS_UNDEF(&intern->inner.zobject)) {
RETVAL_ZVAL(&intern->inner.zobject, 1, 0);
if (intern->inner.zobject) {
RETVAL_ZVAL(intern->inner.zobject, 1, 0);
} else {
RETURN_NULL();
}
@ -1844,7 +1843,7 @@ SPL_METHOD(RecursiveFilterIterator, hasChildren)
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "haschildren", &retval);
zend_call_method_with_0_params(intern->inner.zobject, intern->inner.ce, NULL, "haschildren", &retval);
if (Z_TYPE(retval) != IS_UNDEF) {
RETURN_ZVAL(&retval, 0, 1);
} else {
@ -1865,7 +1864,7 @@ SPL_METHOD(RecursiveFilterIterator, getChildren)
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
zend_call_method_with_0_params(intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
if (!EG(exception) && Z_TYPE(retval) != IS_UNDEF) {
spl_instantiate_arg_ex1(Z_OBJCE_P(getThis()), return_value, &retval TSRMLS_CC);
}
@ -1885,7 +1884,7 @@ SPL_METHOD(RecursiveCallbackFilterIterator, getChildren)
intern = (spl_dual_it_object*)Z_OBJ_P(getThis());
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
zend_call_method_with_0_params(intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
if (!EG(exception) && Z_TYPE(retval) != IS_UNDEF) {
spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), return_value, &retval, &intern->u.cbfilter->fci.function_name TSRMLS_CC);
}
@ -1926,7 +1925,7 @@ SPL_METHOD(CallbackFilterIterator, accept)
ZVAL_COPY_VALUE(&params[0], &intern->current.data);
ZVAL_COPY_VALUE(&params[1], &intern->current.key);
ZVAL_COPY_VALUE(&params[2], &intern->inner.zobject);
ZVAL_COPY_VALUE(&params[2], intern->inner.zobject);
fci->retval = &result;
fci->param_count = 3;
@ -2182,7 +2181,7 @@ SPL_METHOD(RecursiveRegexIterator, getChildren)
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
zend_call_method_with_0_params(intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
if (!EG(exception)) {
ZVAL_STR(&regex, STR_COPY(intern->u.regex.regex));
spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), return_value, &retval, &regex TSRMLS_CC);
@ -2215,8 +2214,8 @@ static void spl_dual_it_free_storage(zend_object *_object TSRMLS_DC)
spl_dual_it_object *object = (spl_dual_it_object *)_object;
if (!ZVAL_IS_UNDEF(&object->inner.zobject)) {
zval_ptr_dtor(&object->inner.zobject);
if (object->inner.zobject) {
zval_ptr_dtor(object->inner.zobject);
}
if (object->dit_type == DIT_AppendIterator) {
@ -2229,6 +2228,7 @@ static void spl_dual_it_free_storage(zend_object *_object TSRMLS_DC)
if (object->dit_type == DIT_CachingIterator || object->dit_type == DIT_RecursiveCachingIterator) {
if (Z_TYPE(object->u.caching.zcache) != IS_UNDEF) {
zval_ptr_dtor(&object->u.caching.zcache);
ZVAL_UNDEF(&object->u.caching.zcache);
}
}
@ -2269,7 +2269,6 @@ static zend_object *spl_dual_it_new(zend_class_entry *class_type TSRMLS_DC)
intern->dit_type = DIT_Unknown;
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
zend_objects_store_put(&intern->std TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->std.handlers = &spl_handlers_dual_it;
@ -2409,7 +2408,7 @@ static inline void spl_limit_it_seek(spl_dual_it_object *intern, long pos TSRMLS
if (pos != intern->current.pos && instanceof_function(intern->inner.ce, spl_ce_SeekableIterator TSRMLS_CC)) {
ZVAL_LONG(&zpos, pos);
spl_dual_it_free(intern TSRMLS_CC);
zend_call_method_with_1_params(&intern->inner.zobject, intern->inner.ce, NULL, "seek", NULL, &zpos);
zend_call_method_with_1_params(intern->inner.zobject, intern->inner.ce, NULL, "seek", NULL, &zpos);
zval_ptr_dtor(&zpos);
if (!EG(exception)) {
intern->current.pos = pos;
@ -2561,7 +2560,7 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern TSRMLS_DC)
/* Recursion ? */
if (intern->dit_type == DIT_RecursiveCachingIterator) {
zval retval, zchildren, zflags;
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "haschildren", &retval);
zend_call_method_with_0_params(intern->inner.zobject, intern->inner.ce, NULL, "haschildren", &retval);
if (EG(exception)) {
zval_ptr_dtor(&retval);
if (intern->u.caching.flags & CIT_CATCH_GET_CHILD) {
@ -2571,7 +2570,7 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern TSRMLS_DC)
}
} else {
if (zend_is_true(&retval TSRMLS_CC)) {
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &zchildren);
zend_call_method_with_0_params(intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &zchildren);
if (EG(exception)) {
zval_ptr_dtor(&zchildren);
if (intern->u.caching.flags & CIT_CATCH_GET_CHILD) {
@ -2600,7 +2599,7 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern TSRMLS_DC)
int use_copy;
zval expr_copy;
if (intern->u.caching.flags & CIT_TOSTRING_USE_INNER) {
ZVAL_COPY_VALUE(&intern->u.caching.zstr, &intern->inner.zobject);
ZVAL_COPY_VALUE(&intern->u.caching.zstr, intern->inner.zobject);
} else {
ZVAL_COPY_VALUE(&intern->u.caching.zstr, &intern->current.data);
}
@ -3218,10 +3217,11 @@ int spl_append_it_next_iterator(spl_dual_it_object *intern TSRMLS_DC) /* {{{*/
{
spl_dual_it_free(intern TSRMLS_CC);
if (!ZVAL_IS_UNDEF(&intern->inner.zobject)) {
zval_ptr_dtor(&intern->inner.zobject);
ZVAL_UNDEF(&intern->inner.zobject);
if (intern->inner.zobject) {
zval_ptr_dtor(intern->inner.zobject);
intern->inner.zobject = NULL;
intern->inner.ce = NULL;
intern->inner.object = NULL;
if (intern->inner.iterator) {
intern->inner.iterator->funcs->dtor(intern->inner.iterator TSRMLS_CC);
intern->inner.iterator = NULL;
@ -3231,8 +3231,10 @@ int spl_append_it_next_iterator(spl_dual_it_object *intern TSRMLS_DC) /* {{{*/
zval *it;
it = intern->u.append.iterator->funcs->get_current_data(intern->u.append.iterator TSRMLS_CC);
ZVAL_COPY(&intern->inner.zobject, it);
Z_ADDREF_P(it);
intern->inner.zobject = it;
intern->inner.ce = Z_OBJCE_P(it);
intern->inner.object = Z_OBJ_P(it);
intern->inner.iterator = intern->inner.ce->get_iterator(intern->inner.ce, it, 0 TSRMLS_CC);
spl_dual_it_rewind(intern TSRMLS_CC);
return SUCCESS;
@ -3287,7 +3289,7 @@ SPL_METHOD(AppendIterator, append)
}
do {
spl_append_it_next_iterator(intern TSRMLS_CC);
} while (&intern->inner.zobject != it);
} while (intern->inner.zobject != it);
spl_append_it_fetch(intern TSRMLS_CC);
}
} /* }}} */

View file

@ -126,8 +126,9 @@ typedef struct _spl_cbfilter_it_intern {
typedef struct _spl_dual_it_object {
zend_object std;
struct {
zval zobject;
zval *zobject;
zend_class_entry *ce;
zend_object *object;
zend_object_iterator *iterator;
} inner;
struct {

View file

@ -249,7 +249,6 @@ static zend_object *spl_object_storage_new_ex(zend_class_entry *class_type, zval
intern->pos = INVALID_IDX;
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
zend_objects_store_put(&intern->std TSRMLS_CC);
object_properties_init(&intern->std, class_type);
zend_hash_init(&intern->storage, 0, NULL, spl_object_storage_dtor, 0);