summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/opcache/zend_accelerator_util_funcs.c43
-rw-r--r--ext/opcache/zend_persist.c23
-rw-r--r--ext/opcache/zend_persist_calc.c11
3 files changed, 40 insertions, 37 deletions
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index ae6e8c8555..e4430bf0a2 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -158,16 +158,6 @@ void zend_accel_copy_internal_functions(void)
ZCG(internal_functions_count) = zend_hash_num_elements(&ZCG(function_table));
}
-static void zend_destroy_property_info(zval *zv)
-{
- zend_property_info *property_info = Z_PTR_P(zv);
-
- zend_string_release(property_info->name);
- if (property_info->doc_comment) {
- zend_string_release(property_info->doc_comment);
- }
-}
-
static zend_always_inline zend_string *zend_clone_str(zend_string *str)
{
zend_string *ret;
@@ -420,7 +410,7 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class
}
}
-static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_class_entry *old_ce, zend_class_entry *ce)
+static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_class_entry *old_ce)
{
uint idx;
Bucket *p, *q;
@@ -432,7 +422,7 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
ht->nNumUsed = 0;
ht->nNumOfElements = source->nNumOfElements;
ht->nNextFreeElement = source->nNextFreeElement;
- ht->pDestructor = zend_destroy_property_info;
+ ht->pDestructor = NULL;
ht->u.flags = (source->u.flags & HASH_FLAG_INITIALIZED);
ht->nInternalPointer = source->nNumOfElements ? 0 : INVALID_IDX;
@@ -463,19 +453,24 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
q->key = zend_clone_str(p->key);
/* Copy data */
- ZVAL_PTR(&q->val, ARENA_REALLOC(Z_PTR(p->val)));
- prop_info = Z_PTR(q->val);
-
- /* Copy constructor */
- prop_info->name = zend_clone_str(prop_info->name);
- if (prop_info->doc_comment) {
- if (ZCG(accel_directives).load_comments) {
- prop_info->doc_comment = zend_string_dup(prop_info->doc_comment, 0);
- } else {
- prop_info->doc_comment = NULL;
+ prop_info = ARENA_REALLOC(Z_PTR(p->val));
+ ZVAL_PTR(&q->val, prop_info);
+
+ if (prop_info->ce == old_ce || (prop_info->flags & ZEND_ACC_SHADOW)) {
+ /* Copy constructor */
+ prop_info->name = zend_clone_str(prop_info->name);
+ if (prop_info->doc_comment) {
+ if (ZCG(accel_directives).load_comments) {
+ prop_info->doc_comment = zend_string_dup(prop_info->doc_comment, 0);
+ } else {
+ prop_info->doc_comment = NULL;
+ }
}
+ prop_info->ce = ARENA_REALLOC(prop_info->ce);
+ } else if ((void*)prop_info->ce >= ZCG(current_persistent_script)->arena_mem &&
+ (void*)prop_info->ce < (void*)((char*)ZCG(current_persistent_script)->arena_mem + ZCG(current_persistent_script)->arena_size)) {
+ prop_info->ce = ARENA_REALLOC(prop_info->ce);
}
- prop_info->ce = ARENA_REALLOC(prop_info->ce);
}
}
@@ -520,7 +515,7 @@ static void zend_class_copy_ctor(zend_class_entry **pce)
ce->static_members_table = ce->default_static_members_table;
/* properties_info */
- zend_hash_clone_prop_info(&ce->properties_info, &old_ce->properties_info, old_ce, ce);
+ zend_hash_clone_prop_info(&ce->properties_info, &old_ce->properties_info, old_ce);
/* constants table */
zend_hash_clone_zval(&ce->constants_table, &old_ce->constants_table, 1);
diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c
index c0cd5b270b..fdba5069f4 100644
--- a/ext/opcache/zend_persist.c
+++ b/ext/opcache/zend_persist.c
@@ -581,12 +581,17 @@ static void zend_persist_op_array(zval *zv)
static void zend_persist_property_info(zval *zv)
{
- zend_property_info *prop;
+ zend_property_info *prop = zend_shared_alloc_get_xlat_entry(Z_PTR_P(zv));
+ if (prop) {
+ Z_PTR_P(zv) = prop;
+ return;
+ }
memcpy(ZCG(arena_mem), Z_PTR_P(zv), sizeof(zend_property_info));
zend_shared_alloc_register_xlat_entry(Z_PTR_P(zv), ZCG(arena_mem));
prop = Z_PTR_P(zv) = ZCG(arena_mem);
ZCG(arena_mem) = (void*)((char*)ZCG(arena_mem) + ZEND_ALIGNED_SIZE(sizeof(zend_property_info)));
+ prop->ce = zend_shared_alloc_get_xlat_entry(prop->ce);
zend_accel_store_interned_string(prop->name);
if (prop->doc_comment) {
if (ZCG(accel_directives).save_comments) {
@@ -714,13 +719,13 @@ static void zend_persist_class_entry(zval *zv)
}
}
-static int zend_update_property_info_ce(zval *zv)
-{
- zend_property_info *prop = Z_PTR_P(zv);
-
- prop->ce = zend_shared_alloc_get_xlat_entry(prop->ce);
- return 0;
-}
+//static int zend_update_property_info_ce(zval *zv)
+//{
+// zend_property_info *prop = Z_PTR_P(zv);
+//
+// prop->ce = zend_shared_alloc_get_xlat_entry(prop->ce);
+// return 0;
+//}
static int zend_update_parent_ce(zval *zv)
{
@@ -770,7 +775,7 @@ static int zend_update_parent_ce(zval *zv)
if (ce->__debugInfo) {
ce->__debugInfo = zend_shared_alloc_get_xlat_entry(ce->__debugInfo);
}
- zend_hash_apply(&ce->properties_info, (apply_func_t) zend_update_property_info_ce);
+// zend_hash_apply(&ce->properties_info, (apply_func_t) zend_update_property_info_ce);
return 0;
}
diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c
index 7d77d62b8d..d7fbaa272a 100644
--- a/ext/opcache/zend_persist_calc.c
+++ b/ext/opcache/zend_persist_calc.c
@@ -255,10 +255,13 @@ static void zend_persist_property_info_calc(zval *zv)
{
zend_property_info *prop = Z_PTR_P(zv);
- ADD_ARENA_SIZE(sizeof(zend_property_info));
- ADD_INTERNED_STRING(prop->name, 0);
- if (ZCG(accel_directives).save_comments && prop->doc_comment) {
- ADD_STRING(prop->doc_comment);
+ if (!zend_shared_alloc_get_xlat_entry(prop)) {
+ zend_shared_alloc_register_xlat_entry(prop, prop);
+ ADD_ARENA_SIZE(sizeof(zend_property_info));
+ ADD_INTERNED_STRING(prop->name, 0);
+ if (ZCG(accel_directives).save_comments && prop->doc_comment) {
+ ADD_STRING(prop->doc_comment);
+ }
}
}