Cleanup (at persistence stage we may get only "user" functions; regular op_arrays can't be referenced from different places)

This commit is contained in:
Dmitry Stogov 2018-01-12 12:05:18 +03:00
parent 36961661d5
commit 2223f04304
2 changed files with 32 additions and 21 deletions

View File

@ -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;

View File

@ -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;