diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-02-04 15:24:13 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-02-04 15:24:13 +0300 |
commit | 9e70d7672dd646b8c9b29ccc452e4dc5aa015437 (patch) | |
tree | 0b852db11ab8fdcab020d6f13ee631291849b6d2 | |
parent | 87377c1707beec44f35cd6d91e5822a31479f170 (diff) | |
download | php-git-9e70d7672dd646b8c9b29ccc452e4dc5aa015437.tar.gz |
Move zend_object->guards into additional slot of zend_object->properties_table[]. As result size of objects without __get/__set/__unset/__isset magic methods is reduced.
39 files changed, 95 insertions, 55 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 440e96d311..7abbf31cb2 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2086,12 +2086,16 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio __tostring = reg_function; } else if (zend_string_equals_literal(lowercase_name, ZEND_GET_FUNC_NAME)) { __get = reg_function; + scope->ce_flags |= ZEND_ACC_USE_GUARDS; } else if (zend_string_equals_literal(lowercase_name, ZEND_SET_FUNC_NAME)) { __set = reg_function; + scope->ce_flags |= ZEND_ACC_USE_GUARDS; } else if (zend_string_equals_literal(lowercase_name, ZEND_UNSET_FUNC_NAME)) { __unset = reg_function; + scope->ce_flags |= ZEND_ACC_USE_GUARDS; } else if (zend_string_equals_literal(lowercase_name, ZEND_ISSET_FUNC_NAME)) { __isset = reg_function; + scope->ce_flags |= ZEND_ACC_USE_GUARDS; } else if (zend_string_equals_literal(lowercase_name, ZEND_DEBUGINFO_FUNC_NAME)) { __debugInfo = reg_function; } else { diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index cffed9c7d4..bdd0c17583 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4130,24 +4130,28 @@ void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_boo "public visibility and cannot be static"); } ce->__get = (zend_function *) op_array; + ce->ce_flags |= ZEND_ACC_USE_GUARDS; } else if (zend_string_equals_literal(lcname, ZEND_SET_FUNC_NAME)) { if (!is_public || is_static) { zend_error(E_WARNING, "The magic method __set() must have " "public visibility and cannot be static"); } ce->__set = (zend_function *) op_array; + ce->ce_flags |= ZEND_ACC_USE_GUARDS; } else if (zend_string_equals_literal(lcname, ZEND_UNSET_FUNC_NAME)) { if (!is_public || is_static) { zend_error(E_WARNING, "The magic method __unset() must have " "public visibility and cannot be static"); } ce->__unset = (zend_function *) op_array; + ce->ce_flags |= ZEND_ACC_USE_GUARDS; } else if (zend_string_equals_literal(lcname, ZEND_ISSET_FUNC_NAME)) { if (!is_public || is_static) { zend_error(E_WARNING, "The magic method __isset() must have " "public visibility and cannot be static"); } ce->__isset = (zend_function *) op_array; + ce->ce_flags |= ZEND_ACC_USE_GUARDS; } else if (zend_string_equals_literal(lcname, ZEND_TOSTRING_FUNC_NAME)) { if (!is_public || is_static) { zend_error(E_WARNING, "The magic method __toString() must have " diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 7c82c67d6d..8a9b37cc6c 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -242,6 +242,9 @@ typedef struct _zend_try_catch_element { #define ZEND_ACC_RETURN_REFERENCE 0x4000000 #define ZEND_ACC_DONE_PASS_TWO 0x8000000 +/* class has magic methods __get/__set/__unset/__isset that use guards */ +#define ZEND_ACC_USE_GUARDS 0x1000000 + /* function has arguments with type hinting */ #define ZEND_ACC_HAS_TYPE_HINTS 0x10000000 diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 10b0ae5e84..bcbf3c7b75 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -904,7 +904,7 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent /* The verification will be done in runtime by ZEND_VERIFY_ABSTRACT_CLASS */ zend_verify_abstract_class(ce); } - ce->ce_flags |= parent_ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS; + ce->ce_flags |= parent_ce->ce_flags & (ZEND_HAS_STATIC_IN_METHODS | ZEND_ACC_USE_GUARDS); } /* }}} */ @@ -1044,14 +1044,18 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen ce->destructor = fe; fe->common.fn_flags |= ZEND_ACC_DTOR; } else if (!strncmp(mname->val, ZEND_GET_FUNC_NAME, mname->len)) { ce->__get = fe; + ce->ce_flags |= ZEND_ACC_USE_GUARDS; } else if (!strncmp(mname->val, ZEND_SET_FUNC_NAME, mname->len)) { ce->__set = fe; + ce->ce_flags |= ZEND_ACC_USE_GUARDS; } else if (!strncmp(mname->val, ZEND_CALL_FUNC_NAME, mname->len)) { ce->__call = fe; } else if (!strncmp(mname->val, ZEND_UNSET_FUNC_NAME, mname->len)) { ce->__unset = fe; + ce->ce_flags |= ZEND_ACC_USE_GUARDS; } else if (!strncmp(mname->val, ZEND_ISSET_FUNC_NAME, mname->len)) { ce->__isset = fe; + ce->ce_flags |= ZEND_ACC_USE_GUARDS; } else if (!strncmp(mname->val, ZEND_CALLSTATIC_FUNC_NAME, mname->len)) { ce->__callstatic = fe; } else if (!strncmp(mname->val, ZEND_TOSTRING_FUNC_NAME, mname->len)) { diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index f316bc81d4..7a94a3dcd3 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -482,17 +482,27 @@ static void zend_property_guard_dtor(zval *el) /* {{{ */ { static zend_long *zend_get_property_guard(zend_object *zobj, zend_string *member) /* {{{ */ { + HashTable *guards; zend_long stub, *guard; + zval tmp; - if (!zobj->guards) { - ALLOC_HASHTABLE(zobj->guards); - zend_hash_init(zobj->guards, 8, NULL, zend_property_guard_dtor, 0); - } else if ((guard = (zend_long *)zend_hash_find_ptr(zobj->guards, member)) != NULL) { - return guard; + ZEND_ASSERT(GC_FLAGS(zobj) & IS_OBJ_USE_GUARDS); + if (GC_FLAGS(zobj) & IS_OBJ_HAS_GUARDS) { + guards = Z_PTR(zobj->properties_table[zobj->ce->default_properties_count]); + ZEND_ASSERT(guards != NULL); + if ((guard = (zend_long *)zend_hash_find_ptr(guards, member)) != NULL) { + return guard; + } + } else { + ALLOC_HASHTABLE(guards); + zend_hash_init(guards, 8, NULL, zend_property_guard_dtor, 0); + ZVAL_PTR(&tmp, guards); + Z_PTR(zobj->properties_table[zobj->ce->default_properties_count]) = guards; + GC_FLAGS(zobj) |= IS_OBJ_HAS_GUARDS; } stub = 0; - return (zend_long *)zend_hash_add_mem(zobj->guards, member, &stub, sizeof(zend_ulong)); + return (zend_long *)zend_hash_add_mem(guards, member, &stub, sizeof(zend_ulong)); } /* }}} */ diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index 8ba1f5a78d..60e446b4fd 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -32,7 +32,6 @@ ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce) GC_TYPE_INFO(object) = IS_OBJECT; object->ce = ce; object->properties = NULL; - object->guards = NULL; zend_objects_store_put(object); if (EXPECTED(ce->default_properties_count != 0)) { zval *p = object->properties_table; @@ -43,16 +42,17 @@ ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce) p++; } while (p != end); } + if (ce->ce_flags & ZEND_ACC_USE_GUARDS) { + GC_FLAGS(object) |= IS_OBJ_USE_GUARDS; + ZVAL_UNDEF(&object->properties_table[ce->default_properties_count]); + Z_PTR(object->properties_table[ce->default_properties_count]) = NULL; + } } ZEND_API void zend_object_std_dtor(zend_object *object) { int i, count; - if (object->guards) { - zend_hash_destroy(object->guards); - FREE_HASHTABLE(object->guards); - } if (object->properties) { zend_array_destroy(object->properties); FREE_HASHTABLE(object->properties); @@ -61,6 +61,13 @@ ZEND_API void zend_object_std_dtor(zend_object *object) for (i = 0; i < count; i++) { i_zval_ptr_dtor(&object->properties_table[i] ZEND_FILE_LINE_CC); } + if (GC_FLAGS(object) & IS_OBJ_HAS_GUARDS) { + HashTable *guards = Z_PTR(object->properties_table[count]); + + ZEND_ASSERT(guards != NULL); + zend_hash_destroy(guards); + FREE_HASHTABLE(guards); + } } ZEND_API void zend_objects_destroy_object(zend_object *object) @@ -131,7 +138,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object) ZEND_API zend_object *zend_objects_new(zend_class_entry *ce) { - zend_object *object = emalloc(sizeof(zend_object) + sizeof(zval) * (ce->default_properties_count - 1)); + zend_object *object = emalloc(sizeof(zend_object) + zend_object_properties_size(ce)); zend_object_std_init(object, ce); object->handlers = &std_object_handlers; diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h index cffdb4876b..5bc7d774bc 100644 --- a/Zend/zend_objects_API.h +++ b/Zend/zend_objects_API.h @@ -23,6 +23,7 @@ #define ZEND_OBJECTS_API_H #include "zend.h" +#include "zend_compile.h" #define OBJ_BUCKET_INVALID (1<<0) @@ -80,6 +81,13 @@ static zend_always_inline void zend_object_release(zend_object *obj) } } +static zend_always_inline size_t zend_object_properties_size(zend_class_entry *ce) +{ + return sizeof(zval) * + (ce->default_properties_count - + ((ce->ce_flags & ZEND_ACC_USE_GUARDS) ? 0 : 1)); +} + #endif /* ZEND_OBJECTS_H */ /* diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 5c00cb133f..80e1700373 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -189,7 +189,6 @@ struct _zend_object { zend_class_entry *ce; const zend_object_handlers *handlers; HashTable *properties; - HashTable *guards; /* protects from __get/__set ... recursion */ zval properties_table[1]; }; @@ -325,6 +324,8 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) { #define IS_OBJ_APPLY_COUNT 0x07 #define IS_OBJ_DESTRUCTOR_CALLED (1<<3) #define IS_OBJ_FREE_CALLED (1<<4) +#define IS_OBJ_USE_GUARDS (1<<5) +#define IS_OBJ_HAS_GUARDS (1<<6) #define Z_OBJ_APPLY_COUNT(zval) \ (Z_GC_FLAGS(zval) & IS_OBJ_APPLY_COUNT) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index a00c4c5a94..a89636c36c 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2069,7 +2069,7 @@ static inline zend_object *date_object_new_date_ex(zend_class_entry *class_type, { php_date_obj *intern; - intern = ecalloc(1, sizeof(php_date_obj) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(php_date_obj) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->std, class_type); if (init_props) { @@ -2200,7 +2200,7 @@ static inline zend_object *date_object_new_timezone_ex(zend_class_entry *class_t { php_timezone_obj *intern; - intern = ecalloc(1, sizeof(php_timezone_obj) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(php_timezone_obj) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->std, class_type); if (init_props) { @@ -2291,7 +2291,7 @@ static inline zend_object *date_object_new_interval_ex(zend_class_entry *class_t { php_interval_obj *intern; - intern = ecalloc(1, sizeof(php_interval_obj) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(php_interval_obj) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->std, class_type); if (init_props) { @@ -2372,7 +2372,7 @@ static inline zend_object *date_object_new_period_ex(zend_class_entry *class_typ { php_period_obj *intern; - intern = ecalloc(1, sizeof(php_period_obj) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(php_period_obj) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->std, class_type); if (init_props) { diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 6797e894b5..b6b66fc507 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -1081,7 +1081,7 @@ void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xml static dom_object* dom_objects_set_class(zend_class_entry *class_type, zend_bool hash_copy) /* {{{ */ { - dom_object *intern = ecalloc(1, sizeof(dom_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + dom_object *intern = ecalloc(1, sizeof(dom_object) + zend_object_properties_size(class_type)); zend_class_entry *base_class = class_type; while (base_class->type != ZEND_INTERNAL_CLASS && base_class->parent != NULL) { @@ -1112,7 +1112,7 @@ zend_object *dom_objects_new(zend_class_entry *class_type) /* {{{ zend_object_value dom_xpath_objects_new(zend_class_entry *class_type) */ zend_object *dom_xpath_objects_new(zend_class_entry *class_type) { - dom_xpath_object *intern = ecalloc(1, sizeof(dom_xpath_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + dom_xpath_object *intern = ecalloc(1, sizeof(dom_xpath_object) + zend_object_properties_size(class_type)); ALLOC_HASHTABLE(intern->registered_phpfunctions); zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0); diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c index f9eebd0484..b4a556d57b 100644 --- a/ext/fileinfo/fileinfo.c +++ b/ext/fileinfo/fileinfo.c @@ -103,7 +103,7 @@ PHP_FILEINFO_API zend_object *finfo_objects_new(zend_class_entry *class_type) { finfo_object *intern; - intern = ecalloc(1, sizeof(finfo_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(finfo_object) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index f4742a6cce..75b157b890 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -378,8 +378,7 @@ static void gmp_free_object_storage(zend_object *obj) /* {{{ */ static inline zend_object *gmp_create_object_ex(zend_class_entry *ce, mpz_ptr *gmpnum_target) /* {{{ */ { - gmp_object *intern = emalloc(sizeof(gmp_object) - + sizeof(zval) * (ce->default_properties_count - 1)); + gmp_object *intern = emalloc(sizeof(gmp_object) + zend_object_properties_size(ce)); zend_object_std_init(&intern->std, ce); object_properties_init(&intern->std, ce); diff --git a/ext/intl/collator/collator_class.c b/ext/intl/collator/collator_class.c index 48fc368060..4fc7067708 100644 --- a/ext/intl/collator/collator_class.c +++ b/ext/intl/collator/collator_class.c @@ -58,7 +58,7 @@ zend_object *Collator_object_create(zend_class_entry *ce ) { Collator_object* intern; - intern = ecalloc(1, sizeof(Collator_object) + sizeof(zval) * (ce->default_properties_count - 1)); + intern = ecalloc(1, sizeof(Collator_object) + zend_object_properties_size(ce)); intl_error_init(COLLATOR_ERROR_P(intern)); zend_object_std_init(&intern->zo, ce ); object_properties_init(&intern->zo, ce); diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index a02edd4efe..9bba427409 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -1033,7 +1033,7 @@ static void php_converter_dtor_object(zend_object *obj) { static zend_object *php_converter_object_ctor(zend_class_entry *ce, php_converter_object **pobjval) { php_converter_object *objval; - objval = ecalloc(1, sizeof(php_converter_object) + sizeof(zval) * (ce->default_properties_count - 1)); + objval = ecalloc(1, sizeof(php_converter_object) + zend_object_properties_size(ce)); zend_object_std_init(&objval->obj, ce ); intl_error_init(&(objval->error)); diff --git a/ext/intl/dateformat/dateformat_class.c b/ext/intl/dateformat/dateformat_class.c index a10b6defc5..afdde13dec 100644 --- a/ext/intl/dateformat/dateformat_class.c +++ b/ext/intl/dateformat/dateformat_class.c @@ -61,7 +61,7 @@ zend_object *IntlDateFormatter_object_create(zend_class_entry *ce) { IntlDateFormatter_object* intern; - intern = ecalloc( 1, sizeof(IntlDateFormatter_object) + sizeof(zval) * (ce->default_properties_count - 1) ); + intern = ecalloc( 1, sizeof(IntlDateFormatter_object) + zend_object_properties_size(ce)); dateformat_data_init( &intern->datef_data ); zend_object_std_init( &intern->zo, ce ); object_properties_init(&intern->zo, ce); diff --git a/ext/intl/formatter/formatter_class.c b/ext/intl/formatter/formatter_class.c index df1086573f..287d19aaa9 100644 --- a/ext/intl/formatter/formatter_class.c +++ b/ext/intl/formatter/formatter_class.c @@ -56,7 +56,7 @@ zend_object *NumberFormatter_object_create(zend_class_entry *ce) { NumberFormatter_object* intern; - intern = ecalloc( 1, sizeof(NumberFormatter_object) + sizeof(zval) * (ce->default_properties_count - 1) ); + intern = ecalloc( 1, sizeof(NumberFormatter_object) + zend_object_properties_size(ce)); formatter_data_init( &intern->nf_data ); zend_object_std_init( &intern->zo, ce ); object_properties_init(&intern->zo, ce); diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c index bb66bb4ba1..8d464c6ca4 100644 --- a/ext/intl/msgformat/msgformat_class.c +++ b/ext/intl/msgformat/msgformat_class.c @@ -56,7 +56,7 @@ zend_object *MessageFormatter_object_create(zend_class_entry *ce) { MessageFormatter_object* intern; - intern = ecalloc( 1, sizeof(MessageFormatter_object) + sizeof(zval) * (ce->default_properties_count - 1)); + intern = ecalloc( 1, sizeof(MessageFormatter_object) + zend_object_properties_size(ce)); msgformat_data_init( &intern->mf_data ); zend_object_std_init( &intern->zo, ce ); object_properties_init(&intern->zo, ce); diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index 9ce33736bb..b8d27c940a 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -58,7 +58,7 @@ static zend_object *ResourceBundle_object_create( zend_class_entry *ce ) { ResourceBundle_object *rb; - rb = ecalloc( 1, sizeof(ResourceBundle_object) + sizeof(zval) * (ce->default_properties_count - 1) ); + rb = ecalloc( 1, sizeof(ResourceBundle_object) + zend_object_properties_size(ce)); zend_object_std_init( &rb->zend, ce ); object_properties_init( &rb->zend, ce); diff --git a/ext/intl/spoofchecker/spoofchecker_class.c b/ext/intl/spoofchecker/spoofchecker_class.c index d2f2b4c873..d93c709bd7 100644 --- a/ext/intl/spoofchecker/spoofchecker_class.c +++ b/ext/intl/spoofchecker/spoofchecker_class.c @@ -53,7 +53,7 @@ zend_object *Spoofchecker_object_create( { Spoofchecker_object* intern; - intern = ecalloc(1, sizeof(Spoofchecker_object) + sizeof(zval) * (ce->default_properties_count - 1)); + intern = ecalloc(1, sizeof(Spoofchecker_object) + zend_object_properties_size(ce)); intl_error_init(SPOOFCHECKER_ERROR_P(intern)); zend_object_std_init(&intern->zo, ce); object_properties_init(&intern->zo, ce); diff --git a/ext/intl/transliterator/transliterator_class.c b/ext/intl/transliterator/transliterator_class.c index c40c5e33ce..4395cc086a 100644 --- a/ext/intl/transliterator/transliterator_class.c +++ b/ext/intl/transliterator/transliterator_class.c @@ -121,7 +121,7 @@ static zend_object *Transliterator_object_create( { Transliterator_object* intern; - intern = ecalloc( 1, sizeof( Transliterator_object ) + sizeof(zval) * (ce->default_properties_count - 1)); + intern = ecalloc( 1, sizeof( Transliterator_object ) + zend_object_properties_size(ce)); zend_object_std_init( &intern->zo, ce ); object_properties_init( &intern->zo, ce ); diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 2debf256e2..9be31960c5 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -453,7 +453,7 @@ PHP_MYSQLI_EXPORT(zend_object *) mysqli_objects_new(zend_class_entry *class_type zend_class_entry *mysqli_base_class; zend_object_handlers *handlers; - intern = ecalloc(1, sizeof(mysqli_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(mysqli_object) + zend_object_properties_size(class_type)); mysqli_base_class = class_type; while (mysqli_base_class->type != ZEND_INTERNAL_CLASS && diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 1e282d0b43..de9a6abbdc 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -1544,7 +1544,7 @@ zend_object *pdo_dbh_new(zend_class_entry *ce) { pdo_dbh_object_t *dbh; - dbh = ecalloc(1, sizeof(pdo_dbh_object_t) + sizeof(zval) * (ce->default_properties_count - 1)); + dbh = ecalloc(1, sizeof(pdo_dbh_object_t) + zend_object_properties_size(ce)); zend_object_std_init(&dbh->std, ce); object_properties_init(&dbh->std, ce); rebuild_object_properties(&dbh->std); diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index dc1201ccda..c6ebc37ec2 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2254,7 +2254,7 @@ static zend_object *dbstmt_clone_obj(zval *zobject) pdo_stmt_t *stmt; pdo_stmt_t *old_stmt; - stmt = ecalloc(1, sizeof(pdo_stmt_t) + sizeof(zval) * (Z_OBJCE_P(zobject)->default_properties_count - 1)); + stmt = ecalloc(1, sizeof(pdo_stmt_t) + zend_object_properties_size(Z_OBJCE_P(zobject))); zend_object_std_init(&stmt->std, Z_OBJCE_P(zobject)); object_properties_init(&stmt->std, Z_OBJCE_P(zobject)); @@ -2357,7 +2357,7 @@ zend_object *pdo_dbstmt_new(zend_class_entry *ce) { pdo_stmt_t *stmt; - stmt = ecalloc(1, sizeof(pdo_stmt_t) + sizeof(zval) * (ce->default_properties_count - 1)); + stmt = ecalloc(1, sizeof(pdo_stmt_t) + zend_object_properties_size(ce)); zend_object_std_init(&stmt->std, ce); object_properties_init(&stmt->std, ce); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 9f5ad8cdd4..194c7ee99b 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -329,7 +329,7 @@ static zend_object *reflection_objects_new(zend_class_entry *class_type) /* {{{ { reflection_object *intern; - intern = ecalloc(1, sizeof(reflection_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(reflection_object) + zend_object_properties_size(class_type)); intern->zo.ce = class_type; zend_object_std_init(&intern->zo, class_type); @@ -4217,7 +4217,7 @@ ZEND_METHOD(reflection_class, getModifiers) } GET_REFLECTION_OBJECT_PTR(ce); - RETURN_LONG(ce->ce_flags & ~ZEND_ACC_CONSTANTS_UPDATED); + RETURN_LONG(ce->ce_flags & ~(ZEND_ACC_CONSTANTS_UPDATED|ZEND_ACC_USE_GUARDS)); } /* }}} */ diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index ceba129560..b125d16f71 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -2057,7 +2057,7 @@ static php_sxe_object* php_sxe_object_new(zend_class_entry *ce) zend_class_entry *parent = ce; int inherited = 0; - intern = ecalloc(1, sizeof(php_sxe_object) + sizeof(zval) * (parent->default_properties_count - 1)); + intern = ecalloc(1, sizeof(php_sxe_object) + zend_object_properties_size(parent)); intern->iter.type = SXE_ITER_NONE; intern->iter.nsprefix = NULL; diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index ab8a25b9af..930affa041 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -493,7 +493,7 @@ static zend_object *php_snmp_object_new(zend_class_entry *class_type) /* {{{ */ php_snmp_object *intern; /* Allocate memory for it */ - intern = ecalloc(1, sizeof(php_snmp_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(php_snmp_object) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 38a4aaede2..0ae066dbfb 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -181,7 +181,7 @@ static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval * zend_class_entry *parent = class_type; int inherited = 0; - intern = ecalloc(1, sizeof(spl_array_object) + sizeof(zval) * (parent->default_properties_count - 1)); + intern = ecalloc(1, sizeof(spl_array_object) + zend_object_properties_size(parent)); zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index e2a836bfa3..a7d699b635 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -143,7 +143,7 @@ static zend_object *spl_filesystem_object_new_ex(zend_class_entry *class_type) { spl_filesystem_object *intern; - intern = ecalloc(1, sizeof(spl_filesystem_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(spl_filesystem_object) + zend_object_properties_size(class_type)); /* intern->type = SPL_FS_INFO; done by set 0 */ intern->file_class = spl_ce_SplFileObject; intern->info_class = spl_ce_SplFileInfo; diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 8dbd11df22..3db7628837 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -373,7 +373,7 @@ static zend_object *spl_dllist_object_new_ex(zend_class_entry *class_type, zval zend_class_entry *parent = class_type; int inherited = 0; - intern = ecalloc(1, sizeof(spl_dllist_object) + sizeof(zval) * (parent->default_properties_count - 1)); + intern = ecalloc(1, sizeof(spl_dllist_object) + zend_object_properties_size(parent)); zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index a974a2008f..cd83a17b56 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -220,7 +220,7 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z zend_class_entry *parent = class_type; int inherited = 0; - intern = ecalloc(1, sizeof(spl_fixedarray_object) + (sizeof(zval) * parent->default_properties_count - 1)); + intern = ecalloc(1, sizeof(spl_fixedarray_object) + zend_object_properties_size(parent)); zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index 35e2806f7c..8e9f3ad66f 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -386,7 +386,7 @@ static zend_object *spl_heap_object_new_ex(zend_class_entry *class_type, zval *o zend_class_entry *parent = class_type; int inherited = 0; - intern = ecalloc(1, sizeof(spl_heap_object) + sizeof(zval) * (parent->default_properties_count - 1)); + intern = ecalloc(1, sizeof(spl_heap_object) + zend_object_properties_size(parent)); zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 80dcabb907..bb7424a395 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -948,7 +948,7 @@ static zend_object *spl_RecursiveIteratorIterator_new_ex(zend_class_entry *class { spl_recursive_it_object *intern; - intern = ecalloc(1, sizeof(spl_recursive_it_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(spl_recursive_it_object) + zend_object_properties_size(class_type)); if (init_prefix) { smart_str_appendl(&intern->prefix[0], "", 0); @@ -2377,7 +2377,7 @@ static zend_object *spl_dual_it_new(zend_class_entry *class_type) { spl_dual_it_object *intern; - intern = ecalloc(1, sizeof(spl_dual_it_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(spl_dual_it_object) + zend_object_properties_size(class_type)); intern->dit_type = DIT_Unknown; zend_object_std_init(&intern->std, class_type); diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index 929b20d5d8..9c63b448c6 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -256,7 +256,7 @@ static zend_object *spl_object_storage_new_ex(zend_class_entry *class_type, zval spl_SplObjectStorage *intern; zend_class_entry *parent = class_type; - intern = emalloc(sizeof(spl_SplObjectStorage) + sizeof(zval) * (parent->default_properties_count - 1)); + intern = emalloc(sizeof(spl_SplObjectStorage) + zend_object_properties_size(parent)); memset(intern, 0, sizeof(spl_SplObjectStorage) - sizeof(zval)); intern->pos = INVALID_IDX; diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 31b9f1aa5b..556f7861f6 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -2113,7 +2113,7 @@ static zend_object *php_sqlite3_object_new(zend_class_entry *class_type) /* {{{ php_sqlite3_db_object *intern; /* Allocate memory for it */ - intern = ecalloc(1, sizeof(php_sqlite3_db_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(php_sqlite3_db_object) + zend_object_properties_size(class_type)); /* Need to keep track of things to free */ zend_llist_init(&(intern->free_list), sizeof(php_sqlite3_free_list *), (llist_dtor_func_t)php_sqlite3_free_list_dtor, 0); @@ -2132,7 +2132,7 @@ static zend_object *php_sqlite3_stmt_object_new(zend_class_entry *class_type) /* php_sqlite3_stmt *intern; /* Allocate memory for it */ - intern = ecalloc(1, sizeof(php_sqlite3_stmt) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(php_sqlite3_stmt) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); @@ -2148,7 +2148,7 @@ static zend_object *php_sqlite3_result_object_new(zend_class_entry *class_type) php_sqlite3_result *intern; /* Allocate memory for it */ - intern = ecalloc(1, sizeof(php_sqlite3_result) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(php_sqlite3_result) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 03d8dd4b9a..b0fe2935a0 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -677,7 +677,7 @@ static zend_object *tidy_object_new(zend_class_entry *class_type, zend_object_ha { PHPTidyObj *intern; - intern = ecalloc(1, sizeof(PHPTidyObj) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(PHPTidyObj) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c index af34f08cc2..b572c85ada 100644 --- a/ext/xmlreader/php_xmlreader.c +++ b/ext/xmlreader/php_xmlreader.c @@ -385,7 +385,7 @@ zend_object *xmlreader_objects_new(zend_class_entry *class_type) { xmlreader_object *intern; - intern = ecalloc(1, sizeof(xmlreader_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(xmlreader_object) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); intern->prop_handler = &xmlreader_prop_handlers; diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c index 9e79e14ea5..f2e458f64f 100644 --- a/ext/xmlwriter/php_xmlwriter.c +++ b/ext/xmlwriter/php_xmlwriter.c @@ -141,7 +141,7 @@ static zend_object *xmlwriter_object_new(zend_class_entry *class_type) { ze_xmlwriter_object *intern; - intern = ecalloc(1, sizeof(ze_xmlwriter_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(ze_xmlwriter_object) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); intern->std.handlers = &xmlwriter_object_handlers; diff --git a/ext/xsl/php_xsl.c b/ext/xsl/php_xsl.c index 0f665c937e..793c0fc6db 100644 --- a/ext/xsl/php_xsl.c +++ b/ext/xsl/php_xsl.c @@ -114,7 +114,7 @@ zend_object *xsl_objects_new(zend_class_entry *class_type) { xsl_object *intern; - intern = ecalloc(1, sizeof(xsl_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(xsl_object) + zend_object_properties_size(class_type)); intern->securityPrefs = XSL_SECPREF_DEFAULT; zend_object_std_init(&intern->std, class_type); diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 927e66e794..e90ee9f979 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1014,7 +1014,7 @@ static zend_object *php_zip_object_new(zend_class_entry *class_type) /* {{{ */ { ze_zip_object *intern; - intern = ecalloc(1, sizeof(ze_zip_object) + sizeof(zval) * (class_type->default_properties_count - 1)); + intern = ecalloc(1, sizeof(ze_zip_object) + zend_object_properties_size(class_type)); intern->prop_handler = &zip_prop_handlers; zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); |