]> granicus.if.org Git - php/commitdiff
Use get_gc instead of hacks of get_properties
authorDmitry Stogov <dmitry@zend.com>
Wed, 5 Dec 2012 13:58:36 +0000 (17:58 +0400)
committerDmitry Stogov <dmitry@zend.com>
Wed, 5 Dec 2012 13:58:36 +0000 (17:58 +0400)
ext/date/php_date.c
ext/simplexml/simplexml.c
ext/spl/spl_observer.c

index b87dfcbbace0cfdd5c13e848708fb44976186e50..b5882271e30e4b4b18891516d19dfc8a958aba96 100644 (file)
@@ -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);
@@ -1887,6 +1889,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);
@@ -1937,6 +1940,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;
@@ -2023,6 +2027,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;
@@ -2034,7 +2045,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;
        }
 
@@ -2168,6 +2179,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;
@@ -2179,7 +2198,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;
        }
 
index 5514f0fc897197ca9a199fb93b8b5d9135ad711a..b510786660a2d685685a0e8e25672708f100fb11 100644 (file)
@@ -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
 };
 /* }}} */
 
index 4b8be82eee78d04f090f1f3d3bf35d36a2dccca1..60c3188dd3f6ab0e9c75a1f844186e26b6aad7b8 100644 (file)
@@ -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);