diff options
| author | Dmitry Stogov <dmitry@php.net> | 2010-09-15 07:38:52 +0000 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@php.net> | 2010-09-15 07:38:52 +0000 |
| commit | f2df6a4a3ee7d1cff29dfc3326b50eb9d2818a05 (patch) | |
| tree | 82cdb33028f6d6a48225c0ac47fc6539c0aafdd0 /Zend/zend_API.c | |
| parent | 3e92b2043494863a2baed87e9f04585a732f9c1b (diff) | |
| download | php-git-f2df6a4a3ee7d1cff29dfc3326b50eb9d2818a05.tar.gz | |
- Improved memory usage
. zend_function.pass_rest_by_reference is replaced by
ZEND_ACC_PASS_REST_BY_REFERENCE in zend_function.fn_flags
. zend_function.return_reference is replaced by ZEND_ACC_RETURN_REFERENCE
in zend_function.fn_flags
. zend_arg_info.required_num_args removed. it was needed only for internal
functions. Now the first arg_info for internal function (which has special
meaning) is represented by zend_internal_function_info structure.
. zend_op_array.size, size_var, size_literal, current_brk_cont,
backpatch_count moved into CG(context), because they are used only during
compilation.
. zend_op_array.start_op is moved into EG(start_op), because it's used
only for 'interactive' execution of single top-level op-array.
. zend_op_array.done_pass_two is replaced by ZEND_ACC_DONE_PASS_TWO in
zend_op_array.fn_flags.
. op_array.vars array is trimmed (reallocated) during pass_two.
. zend_class_entry.constants_updated is replaced by
ZEND_ACC_CONSTANTS_UPDATED in zend_class_entry.ce_flags
. the size of zend_class_entry is reduced by sharing the same memory space
by different information for internal and user classes.
See zend_class_inttry.info union.
Diffstat (limited to 'Zend/zend_API.c')
| -rw-r--r-- | Zend/zend_API.c | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 11dd8c701e..bc25e7f2c6 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1015,7 +1015,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destro ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { - if (!class_type->constants_updated || (!CE_STATIC_MEMBERS(class_type) && class_type->default_static_members_count)) { + if ((class_type->ce_flags & ZEND_ACC_CONSTANTS_UPDATED) == 0 || (!CE_STATIC_MEMBERS(class_type) && class_type->default_static_members_count)) { zend_class_entry **scope = EG(in_execution)?&EG(scope):&CG(active_class_entry); zend_class_entry *old_scope = *scope; int i; @@ -1070,7 +1070,7 @@ ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC } *scope = old_scope; - class_type->constants_updated = 1; + class_type->ce_flags |= ZEND_ACC_CONSTANTS_UPDATED; } } /* }}} */ @@ -1953,24 +1953,6 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio internal_function->function_name = (char*)ptr->fname; internal_function->scope = scope; internal_function->prototype = NULL; - if (ptr->arg_info) { - internal_function->arg_info = (zend_arg_info*)ptr->arg_info+1; - internal_function->num_args = ptr->num_args; - /* Currently you cannot denote that the function can accept less arguments than num_args */ - if (ptr->arg_info[0].required_num_args == -1) { - internal_function->required_num_args = ptr->num_args; - } else { - internal_function->required_num_args = ptr->arg_info[0].required_num_args; - } - internal_function->pass_rest_by_reference = ptr->arg_info[0].pass_by_reference; - internal_function->return_reference = ptr->arg_info[0].return_reference; - } else { - internal_function->arg_info = NULL; - internal_function->num_args = 0; - internal_function->required_num_args = 0; - internal_function->pass_rest_by_reference = 0; - internal_function->return_reference = 0; - } if (ptr->flags) { if (!(ptr->flags & ZEND_ACC_PPP_MASK)) { if (ptr->flags != ZEND_ACC_DEPRECATED || scope) { @@ -1983,6 +1965,32 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio } else { internal_function->fn_flags = ZEND_ACC_PUBLIC; } + if (ptr->arg_info) { + zend_internal_function_info *info = (zend_internal_function_info*)ptr->arg_info; + + internal_function->arg_info = (zend_arg_info*)ptr->arg_info+1; + internal_function->num_args = ptr->num_args; + /* Currently you cannot denote that the function can accept less arguments than num_args */ + if (info->required_num_args == -1) { + internal_function->required_num_args = ptr->num_args; + } else { + internal_function->required_num_args = info->required_num_args; + } + if (info->pass_rest_by_reference) { + if (info->pass_rest_by_reference == ZEND_SEND_PREFER_REF) { + internal_function->fn_flags |= ZEND_ACC_PASS_REST_PREFER_REF; + } else { + internal_function->fn_flags |= ZEND_ACC_PASS_REST_BY_REFERENCE; + } + } + if (info->return_reference) { + internal_function->fn_flags |= ZEND_ACC_RETURN_REFERENCE; + } + } else { + internal_function->arg_info = NULL; + internal_function->num_args = 0; + internal_function->required_num_args = 0; + } if (ptr->flags & ZEND_ACC_ABSTRACT) { if (scope) { /* This is a class that must be abstract itself. Here we set the check info. */ @@ -2353,10 +2361,10 @@ static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class class_entry->type = ZEND_INTERNAL_CLASS; zend_initialize_class_data(class_entry, 0 TSRMLS_CC); class_entry->ce_flags = ce_flags; - class_entry->module = EG(current_module); + class_entry->info.internal.module = EG(current_module); - if (class_entry->builtin_functions) { - zend_register_functions(class_entry, class_entry->builtin_functions, &class_entry->function_table, MODULE_PERSISTENT TSRMLS_CC); + if (class_entry->info.internal.builtin_functions) { + zend_register_functions(class_entry, class_entry->info.internal.builtin_functions, &class_entry->function_table, MODULE_PERSISTENT TSRMLS_CC); } zend_str_tolower_copy(lowercase_name, orig_class_entry->name, class_entry->name_length); @@ -2712,15 +2720,13 @@ get_function_via_handler: if (strict_class && ce_org->__call) { fcc->function_handler = emalloc(sizeof(zend_internal_function)); fcc->function_handler->internal_function.type = ZEND_INTERNAL_FUNCTION; - fcc->function_handler->internal_function.module = ce_org->module; + fcc->function_handler->internal_function.module = (ce_org->type == ZEND_INTERNAL_CLASS) ? ce_org->info.internal.module : NULL; fcc->function_handler->internal_function.handler = zend_std_call_user_call; fcc->function_handler->internal_function.arg_info = NULL; fcc->function_handler->internal_function.num_args = 0; fcc->function_handler->internal_function.scope = ce_org; fcc->function_handler->internal_function.fn_flags = ZEND_ACC_CALL_VIA_HANDLER; fcc->function_handler->internal_function.function_name = estrndup(mname, mlen); - fcc->function_handler->internal_function.pass_rest_by_reference = 0; - fcc->function_handler->internal_function.return_reference = ZEND_RETURN_VALUE; call_via_handler = 1; retval = 1; } else if (Z_OBJ_HT_P(fcc->object_ptr)->get_method) { |
