summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2014-06-18 12:09:51 +0800
committerXinchen Hui <laruence@php.net>2014-06-18 12:09:51 +0800
commit2bd14a07fe86f24392dbf594e71d336094c52f37 (patch)
tree950b60baacbbb7c9eee4cca10a4480340e91d15d
parent6288bb8ffefe9cf9648b8d2190729c087b5c2586 (diff)
parente1b18e59f7e186338f821070d515e4e8ad96f2f3 (diff)
downloadphp-git-2bd14a07fe86f24392dbf594e71d336094c52f37.tar.gz
Merge branch 'phpng' of https://git.php.net/repository/php-src into phpng
-rw-r--r--Zend/zend_API.c44
-rw-r--r--Zend/zend_arena.h100
-rw-r--r--Zend/zend_builtin_functions.c12
-rw-r--r--Zend/zend_compile.c24
-rw-r--r--Zend/zend_execute.c6
-rw-r--r--Zend/zend_globals.h3
-rw-r--r--Zend/zend_opcode.c9
-rw-r--r--ext/opcache/zend_accelerator_util_funcs.c16
-rw-r--r--ext/opcache/zend_persist.c7
9 files changed, 170 insertions, 51 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 85cf32e32c..ea333632be 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -3548,7 +3548,13 @@ ZEND_API const char *zend_get_module_version(const char *module_name) /* {{{ */
ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment TSRMLS_DC) /* {{{ */
{
- zend_property_info property_info, *property_info_ptr;
+ zend_property_info *property_info, *property_info_ptr;
+
+ if (ce->type == ZEND_INTERNAL_CLASS) {
+ property_info = pemalloc(sizeof(zend_property_info), 1);
+ } else {
+ property_info = zend_arena_alloc(&CG(arena), sizeof(zend_property_info));
+ }
if (Z_CONSTANT_P(property)) {
ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED;
@@ -3559,28 +3565,28 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z
if (access_type & ZEND_ACC_STATIC) {
if ((property_info_ptr = zend_hash_find_ptr(&ce->properties_info, name)) != NULL &&
(property_info_ptr->flags & ZEND_ACC_STATIC) != 0) {
- property_info.offset = property_info_ptr->offset;
- zval_ptr_dtor(&ce->default_static_members_table[property_info.offset]);
+ property_info->offset = property_info_ptr->offset;
+ zval_ptr_dtor(&ce->default_static_members_table[property_info->offset]);
zend_hash_del(&ce->properties_info, name);
} else {
- property_info.offset = ce->default_static_members_count++;
+ property_info->offset = ce->default_static_members_count++;
ce->default_static_members_table = perealloc(ce->default_static_members_table, sizeof(zval) * ce->default_static_members_count, ce->type == ZEND_INTERNAL_CLASS);
}
- ZVAL_COPY_VALUE(&ce->default_static_members_table[property_info.offset], property);
+ ZVAL_COPY_VALUE(&ce->default_static_members_table[property_info->offset], property);
if (ce->type == ZEND_USER_CLASS) {
ce->static_members_table = ce->default_static_members_table;
}
} else {
if ((property_info_ptr = zend_hash_find_ptr(&ce->properties_info, name)) != NULL &&
(property_info_ptr->flags & ZEND_ACC_STATIC) == 0) {
- property_info.offset = property_info_ptr->offset;
- zval_ptr_dtor(&ce->default_properties_table[property_info.offset]);
+ property_info->offset = property_info_ptr->offset;
+ zval_ptr_dtor(&ce->default_properties_table[property_info->offset]);
zend_hash_del(&ce->properties_info, name);
} else {
- property_info.offset = ce->default_properties_count++;
+ property_info->offset = ce->default_properties_count++;
ce->default_properties_table = perealloc(ce->default_properties_table, sizeof(zval) * ce->default_properties_count, ce->type == ZEND_INTERNAL_CLASS);
}
- ZVAL_COPY_VALUE(&ce->default_properties_table[property_info.offset], property);
+ ZVAL_COPY_VALUE(&ce->default_properties_table[property_info->offset], property);
}
if (ce->type & ZEND_INTERNAL_CLASS) {
switch(Z_TYPE_P(property)) {
@@ -3595,27 +3601,23 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z
}
switch (access_type & ZEND_ACC_PPP_MASK) {
case ZEND_ACC_PRIVATE: {
- property_info.name = zend_mangle_property_name(ce->name->val, ce->name->len, name->val, name->len, ce->type & ZEND_INTERNAL_CLASS);
+ property_info->name = zend_mangle_property_name(ce->name->val, ce->name->len, name->val, name->len, ce->type & ZEND_INTERNAL_CLASS);
}
break;
case ZEND_ACC_PROTECTED: {
- property_info.name = zend_mangle_property_name("*", 1, name->val, name->len, ce->type & ZEND_INTERNAL_CLASS);
+ property_info->name = zend_mangle_property_name("*", 1, name->val, name->len, ce->type & ZEND_INTERNAL_CLASS);
}
break;
case ZEND_ACC_PUBLIC:
- property_info.name = STR_COPY(name);
+ property_info->name = STR_COPY(name);
break;
}
- property_info.name = zend_new_interned_string(property_info.name TSRMLS_CC);
-
- property_info.flags = access_type;
-
- property_info.doc_comment = doc_comment;
-
- property_info.ce = ce;
-
- zend_hash_update_mem(&ce->properties_info, name, &property_info, sizeof(zend_property_info));
+ property_info->name = zend_new_interned_string(property_info->name TSRMLS_CC);
+ property_info->flags = access_type;
+ property_info->doc_comment = doc_comment;
+ property_info->ce = ce;
+ zend_hash_update_ptr(&ce->properties_info, name, property_info);
return SUCCESS;
}
diff --git a/Zend/zend_arena.h b/Zend/zend_arena.h
new file mode 100644
index 0000000000..68fb660bbb
--- /dev/null
+++ b/Zend/zend_arena.h
@@ -0,0 +1,100 @@
+/*
+ +----------------------------------------------------------------------+
+ | Zend Engine |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.00 of the Zend license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.zend.com/license/2_00.txt. |
+ | If you did not receive a copy of the Zend license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@zend.com so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Dmitry Stogov <dmitry@zend.com> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id:$ */
+
+#ifndef _ZEND_ARENA_H_
+#define _ZEND_ARENA_H_
+
+#include "zend.h"
+
+typedef struct _zend_arena zend_arena;
+
+struct _zend_arena {
+ char *ptr;
+ char *end;
+ zend_arena *prev;
+};
+
+static zend_always_inline zend_arena* zend_arena_create(size_t size)
+{
+ zend_arena *arena = (zend_arena*)emalloc(size);
+
+ arena->ptr = (char*) arena + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena));
+ arena->end = (char*) arena + size;
+ arena->prev = NULL;
+ return arena;
+}
+
+static zend_always_inline void zend_arena_destroy(zend_arena *arena)
+{
+ do {
+ zend_arena *prev = arena->prev;
+ efree(arena);
+ arena = prev;
+ } while (arena);
+}
+
+#define ZEND_ARENA_ALIGNMENT 8U
+
+static zend_always_inline void* zend_arena_alloc(zend_arena **arena_ptr, size_t size)
+{
+ zend_arena *arena = *arena_ptr;
+ char *ptr = arena->ptr;
+
+ size = ZEND_MM_ALIGNED_SIZE(size);
+
+ if (EXPECTED(size <= (arena->end - ptr))) {
+ arena->ptr = ptr + size;
+ } else {
+ size_t arena_size =
+ (UNEXPECTED(size + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena))) > (arena->end - (char*) arena)) ?
+ (size + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena))) :
+ (arena->end - (char*) arena);
+ zend_arena *new_arena = (zend_arena*)emalloc(arena_size);
+
+ ptr = (char*) new_arena + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena));
+ new_arena->ptr = (char*) new_arena + ZEND_MM_ALIGNED_SIZE(sizeof(zend_arena)) + size;
+ new_arena->end = (char*) new_arena + arena_size;
+ new_arena->prev = arena;
+ *arena_ptr = new_arena;
+ }
+
+ return (void*) ptr;
+}
+
+static zend_always_inline void* zend_arena_calloc(zend_arena **arena_ptr, size_t unit_size, size_t count)
+{
+ size_t size = ZEND_MM_ALIGNED_SIZE(unit_size) * count;
+ void *ret;
+
+ ZEND_ASSERT(size > ZEND_MM_ALIGNED_SIZE(unit_size) && size > count);
+ ret = zend_arena_alloc(arena_ptr, size);
+ memset(ret, 0, size);
+ return ret;
+}
+
+#endif /* _ZEND_ARENA_H_ */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * End:
+ */
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 6dcf6edb67..cb2205b82c 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1774,24 +1774,26 @@ ZEND_FUNCTION(create_function)
efree(eval_name);
if (retval==SUCCESS) {
- zend_op_array *new_function, *func;
+ zend_op_array *func;
+ HashTable *static_variables;
func = zend_hash_str_find_ptr(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1);
if (!func) {
zend_error(E_ERROR, "Unexpected inconsistency in create_function()");
RETURN_FALSE;
}
- new_function = emalloc(sizeof(zend_op_array));
- memcpy(new_function, func, sizeof(zend_op_array));
- function_add_ref((zend_function*)new_function);
+ (*func->refcount)++;
function_name = STR_ALLOC(sizeof("0lambda_")+MAX_LENGTH_OF_LONG, 0);
function_name->val[0] = '\0';
do {
function_name->len = snprintf(function_name->val + 1, sizeof("lambda_")+MAX_LENGTH_OF_LONG, "lambda_%d", ++EG(lambda_count)) + 1;
- } while (zend_hash_add_ptr(EG(function_table), function_name, new_function) == NULL);
+ } while (zend_hash_add_ptr(EG(function_table), function_name, func) == NULL);
+ static_variables = func->static_variables;
+ func->static_variables = NULL;
zend_hash_str_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1);
+ func->static_variables = static_variables;
RETURN_STR(function_name);
} else {
zend_hash_str_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1);
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index b48cf0dfeb..d414a46a5c 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -106,7 +106,9 @@ static void zend_push_function_call_entry(zend_function *fbc TSRMLS_DC) /* {{{ *
static zend_property_info *zend_duplicate_property_info(zend_property_info *property_info) /* {{{ */
{
- zend_property_info* new_property_info = emalloc(sizeof(zend_property_info));
+ zend_property_info* new_property_info;
+
+ new_property_info = zend_arena_alloc(&CG(arena), sizeof(zend_property_info));
memcpy(new_property_info, property_info, sizeof(zend_property_info));
STR_ADDREF(new_property_info->name);
if (new_property_info->doc_comment) {
@@ -133,7 +135,6 @@ static void zend_destroy_property_info(zval *zv) /* {{{ */
if (property_info->doc_comment) {
STR_RELEASE(property_info->doc_comment);
}
- efree(property_info);
}
/* }}} */
@@ -226,6 +227,7 @@ ZEND_API void file_handle_dtor(zend_file_handle *fh) /* {{{ */
void init_compiler(TSRMLS_D) /* {{{ */
{
+ CG(arena) = zend_arena_create(64 * 1024);
CG(active_op_array) = NULL;
memset(&CG(context), 0, sizeof(CG(context)));
zend_init_compiler_data_structures(TSRMLS_C);
@@ -248,6 +250,7 @@ void shutdown_compiler(TSRMLS_D) /* {{{ */
zend_hash_destroy(&CG(filenames_table));
zend_hash_destroy(&CG(const_filenames));
zend_stack_destroy(&CG(context_stack));
+ zend_arena_destroy(CG(arena));
}
/* }}} */
@@ -1544,7 +1547,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
lcname = STR_ALLOC(name->len, 0);
zend_str_tolower_copy(lcname->val, name->val, name->len);
lcname = zend_new_interned_string(lcname TSRMLS_CC);
- CG(active_op_array) = emalloc(sizeof(zend_op_array));
+ CG(active_op_array) = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
memcpy(CG(active_op_array), &op_array, sizeof(zend_op_array));
if (zend_hash_add_ptr(&CG(active_class_entry)->function_table, lcname, CG(active_op_array)) == NULL) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare %s::%s()", CG(active_class_entry)->name->val, name->val);
@@ -1710,7 +1713,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
opline->op2_type = IS_CONST;
LITERAL_STR(opline->op2, STR_COPY(lcname));
opline->extended_value = ZEND_DECLARE_FUNCTION;
- CG(active_op_array) = emalloc(sizeof(zend_op_array));
+ CG(active_op_array) = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
memcpy(CG(active_op_array), &op_array, sizeof(zend_op_array));
zend_hash_update_ptr(CG(function_table), Z_STR(key), CG(active_op_array));
zend_stack_push(&CG(context_stack), (void *) &CG(context));
@@ -3143,7 +3146,7 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */
new_function = pemalloc(sizeof(zend_internal_function), 1);
memcpy(new_function, function, sizeof(zend_internal_function));
} else {
- new_function = emalloc(sizeof(zend_op_array));
+ new_function = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
memcpy(new_function, function, sizeof(zend_op_array));
}
zend_hash_str_update_ptr(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1, new_function);
@@ -3199,7 +3202,7 @@ static zend_function *do_inherit_method(zend_function *old_function) /* {{{ */
new_function = pemalloc(sizeof(zend_internal_function), 1);
memcpy(new_function, old_function, sizeof(zend_internal_function));
} else {
- new_function = emalloc(sizeof(zend_op_array));
+ new_function = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
memcpy(new_function, old_function, sizeof(zend_op_array));
}
/* The class entry of the derived function intentionally remains the same
@@ -4045,6 +4048,7 @@ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zen
static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_string *key, zend_function *fn, HashTable **overriden TSRMLS_DC) /* {{{ */
{
zend_function *existing_fn = NULL;
+ zend_function *new_fn;
if ((existing_fn = zend_hash_find_ptr(&ce->function_table, key)) != NULL) {
if (existing_fn->common.scope == ce) {
@@ -4109,7 +4113,9 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
}
function_add_ref(fn);
- fn = zend_hash_update_mem(&ce->function_table, key, fn, sizeof(zend_function));
+ new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
+ memcpy(new_fn, fn, sizeof(zend_op_array));
+ fn = zend_hash_update_ptr(&ce->function_table, key, new_fn);
zend_add_magic_methods(ce, key, fn TSRMLS_CC);
}
/* }}} */
@@ -4601,7 +4607,7 @@ ZEND_API int do_bind_function(const zend_op_array *op_array, zend_op *opline, Ha
}
function = zend_hash_find_ptr(function_table, Z_STR_P(op1));
- new_function = emalloc(sizeof(zend_op_array));
+ new_function = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
memcpy(new_function, function, sizeof(zend_op_array));
if (zend_hash_add_ptr(function_table, Z_STR_P(op2), new_function) == NULL) {
int error_level = compile_time ? E_COMPILE_ERROR : E_ERROR;
@@ -5160,7 +5166,7 @@ void zend_do_begin_class_declaration(const znode *class_token, znode *class_name
efree(tmp);
}
- new_class_entry = emalloc(sizeof(zend_class_entry));
+ new_class_entry = zend_arena_alloc(&CG(arena), sizeof(zend_class_entry));
new_class_entry->type = ZEND_USER_CLASS;
new_class_entry->name = zend_new_interned_string(Z_STR(class_name->u.constant) TSRMLS_CC);
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 2044557bd8..a6f6d65d72 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1653,7 +1653,11 @@ static zend_always_inline zend_execute_data *i_create_execute_data_from_op_array
}
if (!op_array->run_time_cache && op_array->last_cache_slot) {
- op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*));
+ if (op_array->function_name) {
+ op_array->run_time_cache = zend_arena_calloc(&CG(arena), op_array->last_cache_slot, sizeof(void*));
+ } else {
+ op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*));
+ }
}
EX(run_time_cache) = op_array->run_time_cache;
diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h
index 2a29e337de..7a43e6e02f 100644
--- a/Zend/zend_globals.h
+++ b/Zend/zend_globals.h
@@ -36,6 +36,7 @@
#include "zend_modules.h"
#include "zend_float.h"
#include "zend_multibyte.h"
+#include "zend_arena.h"
/* Define ZTS if you want a thread-safe Zend */
/*#undef ZTS*/
@@ -140,6 +141,8 @@ struct _zend_compiler_globals {
zend_compiler_context context;
zend_stack context_stack;
+ zend_arena *arena;
+
zend_string *empty_string;
zend_string *one_char_string[256];
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index 2cd0a1bf7d..7ecccdaf32 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -129,7 +129,11 @@ ZEND_API void zend_function_dtor(zval *zv)
TSRMLS_FETCH();
destroy_zend_function(function TSRMLS_CC);
- pefree(function, function->type == ZEND_INTERNAL_FUNCTION);
+ if (function->type == ZEND_INTERNAL_FUNCTION) {
+ pefree(function, 1);
+ } else if (!function->common.function_name) {
+ efree(function);
+ }
}
ZEND_API void zend_cleanup_op_array_data(zend_op_array *op_array)
@@ -277,7 +281,6 @@ ZEND_API void destroy_zend_class(zval *zv)
_destroy_zend_class_traits_info(ce);
- efree(ce);
break;
case ZEND_INTERNAL_CLASS:
if (ce->default_properties_table) {
@@ -328,7 +331,7 @@ ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC)
FREE_HASHTABLE(op_array->static_variables);
}
- if (op_array->run_time_cache) {
+ if (op_array->run_time_cache && !op_array->function_name) {
efree(op_array->run_time_cache);
}
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index 92350b7a0a..93999af11f 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -237,7 +237,6 @@ static void zend_destroy_property_info(zval *zv)
if (property_info->doc_comment) {
STR_RELEASE(property_info->doc_comment);
}
- efree(property_info);
}
static inline zend_string *zend_clone_str(zend_string *str TSRMLS_DC)
@@ -448,7 +447,7 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class
ht->nNumOfElements = source->nNumOfElements;
ht->nNextFreeElement = source->nNextFreeElement;
ht->pDestructor = ZEND_FUNCTION_DTOR;
- ht->u.flags = HASH_FLAG_APPLY_PROTECTION;
+ ht->u.flags = 0;
ht->nInternalPointer = source->nNumOfElements ? 0 : INVALID_IDX;
#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
@@ -480,7 +479,7 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class
q->key = zend_clone_str(p->key TSRMLS_CC);
/* Copy data */
- ZVAL_PTR(&q->val, (void *) emalloc(sizeof(zend_op_array)));
+ ZVAL_PTR(&q->val, (void *) zend_arena_alloc(&CG(arena), sizeof(zend_op_array)));
new_entry = (zend_op_array*)Z_PTR(q->val);
*new_entry = *(zend_op_array*)Z_PTR(p->val);
@@ -527,7 +526,7 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
ht->nNumOfElements = source->nNumOfElements;
ht->nNextFreeElement = source->nNextFreeElement;
ht->pDestructor = zend_destroy_property_info;
- ht->u.flags = HASH_FLAG_APPLY_PROTECTION;
+ ht->u.flags = 0;
ht->nInternalPointer = source->nNumOfElements ? 0 : INVALID_IDX;
#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
@@ -559,7 +558,7 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
q->key = zend_clone_str(p->key TSRMLS_CC);
/* Copy data */
- ZVAL_PTR(&q->val, (void *) emalloc(sizeof(zend_property_info)));
+ ZVAL_PTR(&q->val, (void *) zend_arena_alloc(&CG(arena), sizeof(zend_property_info)));
prop_info = Z_PTR(q->val);
*prop_info = *(zend_property_info*)Z_PTR(p->val);
@@ -620,7 +619,7 @@ static void zend_class_copy_ctor(zend_class_entry **pce)
zend_function *new_func;
TSRMLS_FETCH();
- *pce = ce = emalloc(sizeof(zend_class_entry));
+ *pce = ce = zend_arena_alloc(&CG(arena), sizeof(zend_class_entry));
*ce = *old_ce;
ce->refcount = 1;
@@ -667,6 +666,7 @@ static void zend_class_copy_ctor(zend_class_entry **pce)
/* constants table */
zend_hash_clone_zval(&ce->constants_table, &old_ce->constants_table, 1);
+ ce->constants_table.u.flags &= ~HASH_FLAG_APPLY_PROTECTION;
ce->name = zend_clone_str(ce->name TSRMLS_CC);
@@ -835,8 +835,8 @@ static void zend_accel_function_hash_copy(HashTable *target, HashTable *source,
}
}
if (pCopyConstructor) {
- Z_PTR_P(t) = emalloc(sizeof(zend_function));
- memcpy(Z_PTR_P(t), Z_PTR(p->val), sizeof(zend_function));
+ Z_PTR_P(t) = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
+ memcpy(Z_PTR_P(t), Z_PTR(p->val), sizeof(zend_op_array));
pCopyConstructor(Z_PTR_P(t));
}
}
diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c
index bc88df69cf..1f76f7ca03 100644
--- a/ext/opcache/zend_persist.c
+++ b/ext/opcache/zend_persist.c
@@ -552,7 +552,7 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc
static void zend_persist_op_array(zval *zv TSRMLS_DC)
{
- zend_accel_store(Z_PTR_P(zv), sizeof(zend_op_array));
+ Z_PTR_P(zv) = zend_accel_memdup(Z_PTR_P(zv), sizeof(zend_op_array));
zend_persist_op_array_ex(Z_PTR_P(zv), NULL TSRMLS_CC);
}
@@ -560,8 +560,7 @@ static void zend_persist_property_info(zval *zv TSRMLS_DC)
{
zend_property_info *prop;
- zend_accel_store(Z_PTR_P(zv), sizeof(zend_property_info));
- prop = Z_PTR_P(zv);
+ prop = Z_PTR_P(zv) = zend_accel_memdup(Z_PTR_P(zv), sizeof(zend_property_info));
zend_accel_store_interned_string(prop->name);
if (prop->doc_comment) {
if (ZCG(accel_directives).save_comments) {
@@ -581,7 +580,7 @@ static void zend_persist_class_entry(zval *zv TSRMLS_DC)
zend_class_entry *ce = Z_PTR_P(zv);
if (ce->type == ZEND_USER_CLASS) {
- Z_PTR_P(zv) = zend_accel_store(ce, sizeof(zend_class_entry));
+ ce = Z_PTR_P(zv) = zend_accel_memdup(ce, sizeof(zend_class_entry));
zend_accel_store_interned_string(ce->name);
zend_hash_persist(&ce->function_table, zend_persist_op_array TSRMLS_CC);
#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO