Skip to content

Commit a3d92e1

Browse files
committed
Partial file cache support
Unfortunately this doesn't actually work, because the added assertions trigger. We need to figure out how we can properly persist and serialize the internal methods defined by enums.
1 parent 3ae7a00 commit a3d92e1

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

ext/opcache/zend_file_cache.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -622,12 +622,12 @@ static void zend_file_cache_serialize_func(zval *zv,
622622
zend_file_cache_metainfo *info,
623623
void *buf)
624624
{
625-
zend_op_array *op_array;
626-
625+
zend_function *func;
627626
SERIALIZE_PTR(Z_PTR_P(zv));
628-
op_array = Z_PTR_P(zv);
629-
UNSERIALIZE_PTR(op_array);
630-
zend_file_cache_serialize_op_array(op_array, script, info, buf);
627+
func = Z_PTR_P(zv);
628+
UNSERIALIZE_PTR(func);
629+
ZEND_ASSERT(func->type == ZEND_USER_FUNCTION);
630+
zend_file_cache_serialize_op_array(&func->op_array, script, info, buf);
631631
}
632632

633633
static void zend_file_cache_serialize_prop_info(zval *zv,
@@ -829,6 +829,14 @@ static void zend_file_cache_serialize_class(zval *zv,
829829
}
830830
}
831831

832+
if (ce->backed_enum_table) {
833+
HashTable *ht;
834+
SERIALIZE_PTR(ce->backed_enum_table);
835+
ht = ce->backed_enum_table;
836+
UNSERIALIZE_PTR(ht);
837+
zend_file_cache_serialize_hash(ht, script, info, buf, zend_file_cache_serialize_zval);
838+
}
839+
832840
SERIALIZE_PTR(ce->constructor);
833841
SERIALIZE_PTR(ce->destructor);
834842
SERIALIZE_PTR(ce->clone);
@@ -1408,11 +1416,11 @@ static void zend_file_cache_unserialize_func(zval *zv,
14081416
zend_persistent_script *script,
14091417
void *buf)
14101418
{
1411-
zend_op_array *op_array;
1412-
1419+
zend_function *func;
14131420
UNSERIALIZE_PTR(Z_PTR_P(zv));
1414-
op_array = Z_PTR_P(zv);
1415-
zend_file_cache_unserialize_op_array(op_array, script, buf);
1421+
func = Z_PTR_P(zv);
1422+
ZEND_ASSERT(func->type == ZEND_USER_FUNCTION);
1423+
zend_file_cache_unserialize_op_array(&func->op_array, script, buf);
14161424
}
14171425

14181426
static void zend_file_cache_unserialize_prop_info(zval *zv,
@@ -1591,6 +1599,12 @@ static void zend_file_cache_unserialize_class(zval *zv,
15911599
}
15921600
}
15931601

1602+
if (ce->backed_enum_table) {
1603+
UNSERIALIZE_PTR(ce->backed_enum_table);
1604+
zend_file_cache_unserialize_hash(
1605+
ce->backed_enum_table, script, buf, zend_file_cache_unserialize_zval, ZVAL_PTR_DTOR);
1606+
}
1607+
15941608
UNSERIALIZE_PTR(ce->constructor);
15951609
UNSERIALIZE_PTR(ce->destructor);
15961610
UNSERIALIZE_PTR(ce->clone);

0 commit comments

Comments
 (0)