Skip to content

Commit

Permalink
Don't use immutable classes and op_arrays in file_cache_only mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Oct 15, 2018
1 parent 8fc3169 commit 59c96eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
17 changes: 12 additions & 5 deletions ext/opcache/zend_persist.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,16 @@ static void zend_persist_op_array(zval *zv)
ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION);
op_array = Z_PTR_P(zv) = zend_shared_memdup(Z_PTR_P(zv), sizeof(zend_op_array));
zend_persist_op_array_ex(op_array, NULL);
op_array->fn_flags |= ZEND_ACC_IMMUTABLE;
ZEND_MAP_PTR_NEW(op_array->run_time_cache);
if (op_array->static_variables) {
ZEND_MAP_PTR_NEW(op_array->static_variables_ptr);
if (!ZCG(current_persistent_script)->corrupted) {
op_array->fn_flags |= ZEND_ACC_IMMUTABLE;
ZEND_MAP_PTR_NEW(op_array->run_time_cache);
if (op_array->static_variables) {
ZEND_MAP_PTR_NEW(op_array->static_variables_ptr);
}
} else {
ZEND_MAP_PTR_INIT(op_array->run_time_cache, ZCG(arena_mem));
ZCG(arena_mem) = (void*)(((char*)ZCG(arena_mem)) + ZEND_ALIGNED_SIZE(sizeof(void*)));
ZEND_MAP_PTR_SET(op_array->run_time_cache, NULL);
}
}

Expand Down Expand Up @@ -776,7 +782,8 @@ static void zend_persist_class_entry(zval *zv)

if (ce->type == ZEND_USER_CLASS) {
if ((ce->ce_flags & ZEND_ACC_LINKED)
&& (ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
&& (ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)
&& !ZCG(current_persistent_script)->corrupted) {
ZCG(is_immutable_class) = 1;
ce = Z_PTR_P(zv) = zend_shared_memdup_put(ce, sizeof(zend_class_entry));
ce->ce_flags |= ZEND_ACC_IMMUTABLE;
Expand Down
6 changes: 5 additions & 1 deletion ext/opcache/zend_persist_calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ static void zend_persist_op_array_calc(zval *zv)
ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION);
ADD_SIZE(sizeof(zend_op_array));
zend_persist_op_array_calc_ex(Z_PTR_P(zv));
if (ZCG(current_persistent_script)->corrupted) {
ADD_ARENA_SIZE(sizeof(void*));
}
}

static void zend_persist_class_method_calc(zval *zv)
Expand Down Expand Up @@ -330,7 +333,8 @@ static void zend_persist_class_entry_calc(zval *zv)
if (ce->type == ZEND_USER_CLASS) {
ZCG(is_immutable_class) =
(ce->ce_flags & ZEND_ACC_LINKED) &&
(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED);
(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED) &&
!ZCG(current_persistent_script)->corrupted;

ADD_SIZE_EX(sizeof(zend_class_entry));
ADD_INTERNED_STRING(ce->name, 0);
Expand Down

0 comments on commit 59c96eb

Please sign in to comment.