com php-src: Cleanup (at persistence stage we may get only "user" functions; regular op_arrays can't be referenced fr om different places):
ext/opcache/zend_persist.c ext/opcache/zend_persist_calc.c

From: Date: Fri, 12 Jan 2018 09:05:18 +0000
Subject: com php-src: Cleanup (at persistence stage we may get only "user" functions; regular op_arrays can't be referenced fr om different places):
ext/opcache/zend_persist.c ext/opcache/zend_persist_calc.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-100847@lists.php.net to get a copy of this message
Commit: 2223f043047db07db7b11f75b6b918826c4a6573 Author: Dmitry Stogov <dmitry@zend.com> Fri, 12 Jan 2018 12:05:18 +0300 Parents: 36961661d582dc64966906c37a198618c9004a32 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2223f043047db07db7b11f75b6b918826c4a6573 Log: Cleanup (at persistence stage we may get only "user" functions; regular op_arrays can't be referenced from different places) Changed paths: M ext/opcache/zend_persist.c M ext/opcache/zend_persist_calc.c Diff: diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index fd4bbd0..e9aece7 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -338,10 +338,6 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc zend_op *persist_ptr; zval *orig_literals = NULL; - if (op_array->type != ZEND_USER_FUNCTION) { - return; - } - if (op_array->refcount && --(*op_array->refcount) == 0) { efree(op_array->refcount); } @@ -588,7 +584,21 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc static void zend_persist_op_array(zval *zv) { zend_op_array *op_array = Z_PTR_P(zv); - zend_op_array *old_op_array = zend_shared_alloc_get_xlat_entry(op_array); + + ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION); + memcpy(ZCG(arena_mem), Z_PTR_P(zv), sizeof(zend_op_array)); + Z_PTR_P(zv) = ZCG(arena_mem); + ZCG(arena_mem) = (void*)((char*)ZCG(arena_mem) + ZEND_ALIGNED_SIZE(sizeof(zend_op_array))); + zend_persist_op_array_ex(Z_PTR_P(zv), NULL); +} + +static void zend_persist_class_method(zval *zv) +{ + zend_op_array *op_array = Z_PTR_P(zv); + zend_op_array *old_op_array; + + ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION); + old_op_array = zend_shared_alloc_get_xlat_entry(op_array); if (old_op_array) { Z_PTR_P(zv) = old_op_array; if (op_array->refcount && --(*op_array->refcount) == 0) { @@ -673,7 +683,7 @@ static void zend_persist_class_entry(zval *zv) ce = Z_PTR_P(zv) = ZCG(arena_mem); ZCG(arena_mem) = (void*)((char*)ZCG(arena_mem) + ZEND_ALIGNED_SIZE(sizeof(zend_class_entry))); zend_accel_store_interned_string(ce->name); - zend_hash_persist(&ce->function_table, zend_persist_op_array); + zend_hash_persist(&ce->function_table, zend_persist_class_method); if (ce->default_properties_table) { int i; diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c index abf17b7..a99a800 100644 --- a/ext/opcache/zend_persist_calc.c +++ b/ext/opcache/zend_persist_calc.c @@ -153,10 +153,6 @@ static void zend_persist_zval_calc(zval *z) static void zend_persist_op_array_calc_ex(zend_op_array *op_array) { - if (op_array->type != ZEND_USER_FUNCTION) { - return; - } - if (op_array->static_variables) { if (!zend_shared_alloc_get_xlat_entry(op_array->static_variables)) { HashTable *old = op_array->static_variables; @@ -262,19 +258,24 @@ static void zend_persist_op_array_calc(zval *zv) { zend_op_array *op_array = Z_PTR_P(zv); - if (op_array->type == ZEND_USER_FUNCTION/* && - (!op_array->refcount || *(op_array->refcount) > 1)*/) { - zend_op_array *old_op_array = zend_shared_alloc_get_xlat_entry(op_array); - if (old_op_array) { - Z_PTR_P(zv) = old_op_array; - } else { - ADD_ARENA_SIZE(sizeof(zend_op_array)); - zend_persist_op_array_calc_ex(Z_PTR_P(zv)); - zend_shared_alloc_register_xlat_entry(op_array, Z_PTR_P(zv)); - } + ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION); + ADD_ARENA_SIZE(sizeof(zend_op_array)); + zend_persist_op_array_calc_ex(Z_PTR_P(zv)); +} + +static void zend_persist_class_method_calc(zval *zv) +{ + zend_op_array *op_array = Z_PTR_P(zv); + zend_op_array *old_op_array; + + ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION); + old_op_array = zend_shared_alloc_get_xlat_entry(op_array); + if (old_op_array) { + Z_PTR_P(zv) = old_op_array; } else { ADD_ARENA_SIZE(sizeof(zend_op_array)); zend_persist_op_array_calc_ex(Z_PTR_P(zv)); + zend_shared_alloc_register_xlat_entry(op_array, Z_PTR_P(zv)); } } @@ -314,7 +315,7 @@ static void zend_persist_class_entry_calc(zval *zv) if (ce->type == ZEND_USER_CLASS) { ADD_ARENA_SIZE(sizeof(zend_class_entry)); ADD_INTERNED_STRING(ce->name, 0); - zend_hash_persist_calc(&ce->function_table, zend_persist_op_array_calc); + zend_hash_persist_calc(&ce->function_table, zend_persist_class_method_calc); if (ce->default_properties_table) { int i;

« previous php.cvs (#100847) next »