Skip to content

Commit 33428b6

Browse files
committed
Implement file cache for hooks
1 parent a9ba0b9 commit 33428b6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

ext/opcache/zend_file_cache.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ static void zend_file_cache_serialize_op_array(zend_op_array *op_arra
485485
SERIALIZE_ATTRIBUTES(op_array->attributes);
486486
SERIALIZE_PTR(op_array->try_catch_array);
487487
SERIALIZE_PTR(op_array->prototype);
488+
SERIALIZE_PTR(op_array->prop_info);
488489
return;
489490
}
490491
zend_shared_alloc_register_xlat_entry(op_array->opcodes, op_array->opcodes);
@@ -636,6 +637,7 @@ static void zend_file_cache_serialize_op_array(zend_op_array *op_arra
636637
SERIALIZE_ATTRIBUTES(op_array->attributes);
637638
SERIALIZE_PTR(op_array->try_catch_array);
638639
SERIALIZE_PTR(op_array->prototype);
640+
SERIALIZE_PTR(op_array->prop_info);
639641
}
640642
}
641643

@@ -672,6 +674,20 @@ static void zend_file_cache_serialize_prop_info(zval *zv,
672674
SERIALIZE_STR(prop->doc_comment);
673675
}
674676
SERIALIZE_ATTRIBUTES(prop->attributes);
677+
SERIALIZE_PTR(prop->prototype);
678+
if (prop->hooks) {
679+
SERIALIZE_PTR(prop->hooks);
680+
zend_function **hooks = prop->hooks;
681+
UNSERIALIZE_PTR(hooks);
682+
for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) {
683+
if (hooks[i]) {
684+
SERIALIZE_PTR(hooks[i]);
685+
zend_function *hook = hooks[i];
686+
UNSERIALIZE_PTR(hook);
687+
zend_file_cache_serialize_op_array(&hook->op_array, script, info, buf);
688+
}
689+
}
690+
}
675691
zend_file_cache_serialize_type(&prop->type, script, info, buf);
676692
}
677693
}
@@ -1346,6 +1362,7 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
13461362
UNSERIALIZE_ATTRIBUTES(op_array->attributes);
13471363
UNSERIALIZE_PTR(op_array->try_catch_array);
13481364
UNSERIALIZE_PTR(op_array->prototype);
1365+
UNSERIALIZE_PTR(op_array->prop_info);
13491366
return;
13501367
}
13511368

@@ -1480,6 +1497,7 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
14801497
UNSERIALIZE_ATTRIBUTES(op_array->attributes);
14811498
UNSERIALIZE_PTR(op_array->try_catch_array);
14821499
UNSERIALIZE_PTR(op_array->prototype);
1500+
UNSERIALIZE_PTR(op_array->prop_info);
14831501
}
14841502
}
14851503

@@ -1512,6 +1530,16 @@ static void zend_file_cache_unserialize_prop_info(zval *zv,
15121530
UNSERIALIZE_STR(prop->doc_comment);
15131531
}
15141532
UNSERIALIZE_ATTRIBUTES(prop->attributes);
1533+
UNSERIALIZE_PTR(prop->prototype);
1534+
if (prop->hooks) {
1535+
UNSERIALIZE_PTR(prop->hooks);
1536+
for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) {
1537+
if (prop->hooks[i]) {
1538+
UNSERIALIZE_PTR(prop->hooks[i]);
1539+
zend_file_cache_unserialize_op_array(&prop->hooks[i]->op_array, script, buf);
1540+
}
1541+
}
1542+
}
15151543
zend_file_cache_unserialize_type(&prop->type, prop->ce, script, buf);
15161544
}
15171545
}

0 commit comments

Comments
 (0)