Skip to content

Commit 5ae182e

Browse files
committed
Merge branch 'PHP-5.5'
* PHP-5.5: Use get_gc instead of hacks of get_properties
2 parents 73601e2 + bc78571 commit 5ae182e

File tree

3 files changed

+39
-21
lines changed

3 files changed

+39
-21
lines changed

ext/date/php_date.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,9 @@ static zend_object_value date_object_clone_interval(zval *this_ptr TSRMLS_DC);
563563
static zend_object_value date_object_clone_period(zval *this_ptr TSRMLS_DC);
564564

565565
static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC);
566+
static HashTable *date_object_get_gc(zval *object, zval ***table, int *n TSRMLS_DC);
566567
static HashTable *date_object_get_properties(zval *object TSRMLS_DC);
568+
static HashTable *date_object_get_gc_interval(zval *object, zval ***table, int *n TSRMLS_DC);
567569
static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC);
568570

569571
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)
18881890
date_object_handlers_date.clone_obj = date_object_clone_date;
18891891
date_object_handlers_date.compare_objects = date_object_compare_date;
18901892
date_object_handlers_date.get_properties = date_object_get_properties;
1893+
date_object_handlers_date.get_gc = date_object_get_gc;
18911894

18921895
#define REGISTER_DATE_CLASS_CONST_STRING(const_name, value) \
18931896
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)
19381941
date_object_handlers_interval.write_property = date_interval_write_property;
19391942
date_object_handlers_interval.get_properties = date_object_get_properties_interval;
19401943
date_object_handlers_interval.get_property_ptr_ptr = NULL;
1944+
date_object_handlers_interval.get_gc = date_object_get_gc_interval;
19411945

19421946
INIT_CLASS_ENTRY(ce_period, "DatePeriod", date_funcs_period);
19431947
ce_period.create_object = date_object_new_period;
@@ -2024,6 +2028,13 @@ static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC)
20242028
return 1;
20252029
}
20262030

2031+
static HashTable *date_object_get_gc(zval *object, zval ***table, int *n TSRMLS_DC)
2032+
{
2033+
*table = NULL;
2034+
*n = 0;
2035+
return zend_std_get_properties(object TSRMLS_CC);
2036+
}
2037+
20272038
static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
20282039
{
20292040
HashTable *props;
@@ -2035,7 +2046,7 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
20352046

20362047
props = zend_std_get_properties(object TSRMLS_CC);
20372048

2038-
if (!dateobj->time || GC_G(gc_active)) {
2049+
if (!dateobj->time) {
20392050
return props;
20402051
}
20412052

@@ -2169,6 +2180,14 @@ static zend_object_value date_object_clone_interval(zval *this_ptr TSRMLS_DC)
21692180
return new_ov;
21702181
}
21712182

2183+
static HashTable *date_object_get_gc_interval(zval *object, zval ***table, int *n TSRMLS_DC)
2184+
{
2185+
2186+
*table = NULL;
2187+
*n = 0;
2188+
return zend_std_get_properties(object TSRMLS_CC);
2189+
}
2190+
21722191
static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
21732192
{
21742193
HashTable *props;
@@ -2180,7 +2199,7 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
21802199

21812200
props = zend_std_get_properties(object TSRMLS_CC);
21822201

2183-
if (!intervalobj->initialized || GC_G(gc_active)) {
2202+
if (!intervalobj->initialized) {
21842203
return props;
21852204
}
21862205

ext/simplexml/simplexml.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,15 +1081,9 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{
10811081
zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0);
10821082
}
10831083
else if (sxe->properties) {
1084-
if (GC_G(gc_active)) {
1085-
return sxe->properties;
1086-
}
10871084
zend_hash_clean(sxe->properties);
10881085
rv = sxe->properties;
10891086
} else {
1090-
if (GC_G(gc_active)) {
1091-
return NULL;
1092-
}
10931087
ALLOC_HASHTABLE(rv);
10941088
zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0);
10951089
sxe->properties = rv;
@@ -1201,6 +1195,16 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{
12011195
}
12021196
/* }}} */
12031197

1198+
static HashTable * sxe_get_gc(zval *object, zval ***table, int *n TSRMLS_DC) /* {{{ */ {
1199+
php_sxe_object *sxe;
1200+
sxe = php_sxe_fetch_object(object TSRMLS_CC);
1201+
1202+
*table = NULL;
1203+
*n = 0;
1204+
return sxe->properties;
1205+
}
1206+
/* }}} */
1207+
12041208
static HashTable * sxe_get_properties(zval *object TSRMLS_DC) /* {{{ */
12051209
{
12061210
return sxe_get_prop_hash(object, 0 TSRMLS_CC);
@@ -1966,7 +1970,9 @@ static zend_object_handlers sxe_object_handlers = { /* {{{ */
19661970
sxe_objects_compare,
19671971
sxe_object_cast,
19681972
sxe_count_elements,
1969-
sxe_get_debug_info
1973+
sxe_get_debug_info,
1974+
NULL,
1975+
sxe_get_gc
19701976
};
19711977
/* }}} */
19721978

ext/spl/spl_observer.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,8 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp TSRMLS_D
361361
/* }}} */
362362

363363
/* overriden for garbage collection
364-
* This is very hacky, but unfortunately the garbage collector can only query objects for
365-
* dependencies through get_properties */
366-
static HashTable *spl_object_storage_get_properties(zval *obj TSRMLS_DC) /* {{{ */
364+
* This is very hacky */
365+
static HashTable *spl_object_storage_get_gc(zval *obj, zval ***table, int *n TSRMLS_DC) /* {{{ */
367366
{
368367
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(obj TSRMLS_CC);
369368
spl_SplObjectStorageElement *element;
@@ -374,14 +373,8 @@ static HashTable *spl_object_storage_get_properties(zval *obj TSRMLS_DC) /* {{{
374373

375374
props = std_object_handlers.get_properties(obj TSRMLS_CC);
376375

377-
if (!GC_G(gc_active)) {
378-
zend_hash_del(props, "\x00gcdata", sizeof("\x00gcdata"));
379-
return props;
380-
}
381-
382-
if (props->nApplyCount > 0) {
383-
return props;
384-
}
376+
*table = NULL;
377+
*n = 0;
385378

386379
/* clean \x00gcdata, as it may be out of date */
387380
if (zend_hash_find(props, "\x00gcdata", sizeof("\x00gcdata"), (void**) &gcdata_arr_pp) == SUCCESS) {
@@ -1316,10 +1309,10 @@ PHP_MINIT_FUNCTION(spl_observer)
13161309
REGISTER_SPL_STD_CLASS_EX(SplObjectStorage, spl_SplObjectStorage_new, spl_funcs_SplObjectStorage);
13171310
memcpy(&spl_handler_SplObjectStorage, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
13181311

1319-
spl_handler_SplObjectStorage.get_properties = spl_object_storage_get_properties;
13201312
spl_handler_SplObjectStorage.get_debug_info = spl_object_storage_debug_info;
13211313
spl_handler_SplObjectStorage.compare_objects = spl_object_storage_compare_objects;
13221314
spl_handler_SplObjectStorage.clone_obj = spl_object_storage_clone;
1315+
spl_handler_SplObjectStorage.get_gc = spl_object_storage_get_gc;
13231316

13241317
REGISTER_SPL_IMPLEMENTS(SplObjectStorage, Countable);
13251318
REGISTER_SPL_IMPLEMENTS(SplObjectStorage, Iterator);

0 commit comments

Comments
 (0)