mirror of
https://github.com/php/php-src.git
synced 2024-11-28 20:34:29 +08:00
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Use get_gc instead of hacks of get_properties
This commit is contained in:
commit
bc7857169a
@ -563,7 +563,9 @@ static zend_object_value date_object_clone_interval(zval *this_ptr TSRMLS_DC);
|
||||
static zend_object_value date_object_clone_period(zval *this_ptr TSRMLS_DC);
|
||||
|
||||
static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC);
|
||||
static HashTable *date_object_get_gc(zval *object, zval ***table, int *n TSRMLS_DC);
|
||||
static HashTable *date_object_get_properties(zval *object TSRMLS_DC);
|
||||
static HashTable *date_object_get_gc_interval(zval *object, zval ***table, int *n TSRMLS_DC);
|
||||
static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC);
|
||||
|
||||
zval *date_interval_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC);
|
||||
@ -1888,6 +1890,7 @@ static void date_register_classes(TSRMLS_D)
|
||||
date_object_handlers_date.clone_obj = date_object_clone_date;
|
||||
date_object_handlers_date.compare_objects = date_object_compare_date;
|
||||
date_object_handlers_date.get_properties = date_object_get_properties;
|
||||
date_object_handlers_date.get_gc = date_object_get_gc;
|
||||
|
||||
#define REGISTER_DATE_CLASS_CONST_STRING(const_name, value) \
|
||||
zend_declare_class_constant_stringl(date_ce_date, const_name, sizeof(const_name)-1, value, sizeof(value)-1 TSRMLS_CC);
|
||||
@ -1938,6 +1941,7 @@ static void date_register_classes(TSRMLS_D)
|
||||
date_object_handlers_interval.write_property = date_interval_write_property;
|
||||
date_object_handlers_interval.get_properties = date_object_get_properties_interval;
|
||||
date_object_handlers_interval.get_property_ptr_ptr = NULL;
|
||||
date_object_handlers_interval.get_gc = date_object_get_gc_interval;
|
||||
|
||||
INIT_CLASS_ENTRY(ce_period, "DatePeriod", date_funcs_period);
|
||||
ce_period.create_object = date_object_new_period;
|
||||
@ -2024,6 +2028,13 @@ static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static HashTable *date_object_get_gc(zval *object, zval ***table, int *n TSRMLS_DC)
|
||||
{
|
||||
*table = NULL;
|
||||
*n = 0;
|
||||
return zend_std_get_properties(object TSRMLS_CC);
|
||||
}
|
||||
|
||||
static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
|
||||
{
|
||||
HashTable *props;
|
||||
@ -2035,7 +2046,7 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
|
||||
|
||||
props = zend_std_get_properties(object TSRMLS_CC);
|
||||
|
||||
if (!dateobj->time || GC_G(gc_active)) {
|
||||
if (!dateobj->time) {
|
||||
return props;
|
||||
}
|
||||
|
||||
@ -2169,6 +2180,14 @@ static zend_object_value date_object_clone_interval(zval *this_ptr TSRMLS_DC)
|
||||
return new_ov;
|
||||
}
|
||||
|
||||
static HashTable *date_object_get_gc_interval(zval *object, zval ***table, int *n TSRMLS_DC)
|
||||
{
|
||||
|
||||
*table = NULL;
|
||||
*n = 0;
|
||||
return zend_std_get_properties(object TSRMLS_CC);
|
||||
}
|
||||
|
||||
static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
|
||||
{
|
||||
HashTable *props;
|
||||
@ -2180,7 +2199,7 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
|
||||
|
||||
props = zend_std_get_properties(object TSRMLS_CC);
|
||||
|
||||
if (!intervalobj->initialized || GC_G(gc_active)) {
|
||||
if (!intervalobj->initialized) {
|
||||
return props;
|
||||
}
|
||||
|
||||
|
@ -1081,15 +1081,9 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{
|
||||
zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
}
|
||||
else if (sxe->properties) {
|
||||
if (GC_G(gc_active)) {
|
||||
return sxe->properties;
|
||||
}
|
||||
zend_hash_clean(sxe->properties);
|
||||
rv = sxe->properties;
|
||||
} else {
|
||||
if (GC_G(gc_active)) {
|
||||
return NULL;
|
||||
}
|
||||
ALLOC_HASHTABLE(rv);
|
||||
zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
sxe->properties = rv;
|
||||
@ -1201,6 +1195,16 @@ next_iter:
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static HashTable * sxe_get_gc(zval *object, zval ***table, int *n TSRMLS_DC) /* {{{ */ {
|
||||
php_sxe_object *sxe;
|
||||
sxe = php_sxe_fetch_object(object TSRMLS_CC);
|
||||
|
||||
*table = NULL;
|
||||
*n = 0;
|
||||
return sxe->properties;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static HashTable * sxe_get_properties(zval *object TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
return sxe_get_prop_hash(object, 0 TSRMLS_CC);
|
||||
@ -1966,7 +1970,9 @@ static zend_object_handlers sxe_object_handlers = { /* {{{ */
|
||||
sxe_objects_compare,
|
||||
sxe_object_cast,
|
||||
sxe_count_elements,
|
||||
sxe_get_debug_info
|
||||
sxe_get_debug_info,
|
||||
NULL,
|
||||
sxe_get_gc
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
|
@ -361,9 +361,8 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp TSRMLS_D
|
||||
/* }}} */
|
||||
|
||||
/* overriden for garbage collection
|
||||
* This is very hacky, but unfortunately the garbage collector can only query objects for
|
||||
* dependencies through get_properties */
|
||||
static HashTable *spl_object_storage_get_properties(zval *obj TSRMLS_DC) /* {{{ */
|
||||
* This is very hacky */
|
||||
static HashTable *spl_object_storage_get_gc(zval *obj, zval ***table, int *n TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(obj TSRMLS_CC);
|
||||
spl_SplObjectStorageElement *element;
|
||||
@ -374,14 +373,8 @@ static HashTable *spl_object_storage_get_properties(zval *obj TSRMLS_DC) /* {{{
|
||||
|
||||
props = std_object_handlers.get_properties(obj TSRMLS_CC);
|
||||
|
||||
if (!GC_G(gc_active)) {
|
||||
zend_hash_del(props, "\x00gcdata", sizeof("\x00gcdata"));
|
||||
return props;
|
||||
}
|
||||
|
||||
if (props->nApplyCount > 0) {
|
||||
return props;
|
||||
}
|
||||
*table = NULL;
|
||||
*n = 0;
|
||||
|
||||
/* clean \x00gcdata, as it may be out of date */
|
||||
if (zend_hash_find(props, "\x00gcdata", sizeof("\x00gcdata"), (void**) &gcdata_arr_pp) == SUCCESS) {
|
||||
@ -1316,10 +1309,10 @@ PHP_MINIT_FUNCTION(spl_observer)
|
||||
REGISTER_SPL_STD_CLASS_EX(SplObjectStorage, spl_SplObjectStorage_new, spl_funcs_SplObjectStorage);
|
||||
memcpy(&spl_handler_SplObjectStorage, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
|
||||
spl_handler_SplObjectStorage.get_properties = spl_object_storage_get_properties;
|
||||
spl_handler_SplObjectStorage.get_debug_info = spl_object_storage_debug_info;
|
||||
spl_handler_SplObjectStorage.compare_objects = spl_object_storage_compare_objects;
|
||||
spl_handler_SplObjectStorage.clone_obj = spl_object_storage_clone;
|
||||
spl_handler_SplObjectStorage.get_gc = spl_object_storage_get_gc;
|
||||
|
||||
REGISTER_SPL_IMPLEMENTS(SplObjectStorage, Countable);
|
||||
REGISTER_SPL_IMPLEMENTS(SplObjectStorage, Iterator);
|
||||
|
Loading…
Reference in New Issue
Block a user