Skip to content

Commit be88afb

Browse files
committed
refactor and regenerate func_infos
1 parent d90890f commit be88afb

3 files changed

Lines changed: 93 additions & 91 deletions

File tree

Zend/Optimizer/zend_func_infos.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static const func_info_t func_infos[] = {
289289
F1("opcache_get_status", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE),
290290
F1("opcache_get_configuration", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE),
291291
FN("OPcache\\volatile_fetch_array", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_NULL|MAY_BE_ARRAY_OF_FALSE|MAY_BE_ARRAY_OF_TRUE|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_DOUBLE|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_NULL),
292-
FN("OPcache\\persistent_fetch_array", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_NULL|MAY_BE_ARRAY_OF_FALSE|MAY_BE_ARRAY_OF_TRUE|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_DOUBLE|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_NULL),
292+
FN("OPcache\\pinned_fetch_array", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_NULL|MAY_BE_ARRAY_OF_FALSE|MAY_BE_ARRAY_OF_TRUE|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_DOUBLE|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_NULL),
293293
F1("openssl_x509_parse", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),
294294
F1("openssl_csr_get_subject", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),
295295
F1("openssl_pkey_get_details", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE),

ext/opcache/zend_opcache_serializer.h

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ typedef struct _zend_opcache_serializer_rbuf_t {
7979
bool skip_decoded_value_capture;
8080
} zend_opcache_serializer_rbuf_t;
8181

82+
typedef struct _zend_opcache_serializer_has_unstorable_context {
83+
HashTable *seen_arrays;
84+
HashTable *seen_objects;
85+
} zend_opcache_serializer_has_unstorable_context;
86+
87+
static zend_always_inline bool zend_opcache_serializer_encode_zval(
88+
zend_opcache_serializer_wbuf_t *wb,
89+
const zval *zv
90+
);
91+
92+
static zend_always_inline bool zend_opcache_serializer_decode_zval(
93+
zend_opcache_serializer_rbuf_t *rb,
94+
zval *dst
95+
);
96+
97+
static bool zend_opcache_serializer_value_has_unstorable_ex(
98+
const zval *value,
99+
HashTable *seen_arrays,
100+
HashTable *seen_objects
101+
);
102+
82103
static zend_always_inline void zend_opcache_serializer_capture_decoded_value(zend_opcache_serializer_rbuf_t *rb, zval *value)
83104
{
84105
if (rb->capture_decoded_value != NULL) {
@@ -415,8 +436,10 @@ static zend_always_inline zend_class_entry *zend_opcache_serializer_find_safe_di
415436
static zend_always_inline bool zend_opcache_serializer_class_magic_method_changed(zend_class_entry *ce,
416437
zend_class_entry *base_ce, const char *name, size_t name_len)
417438
{
418-
zend_function *func = zend_hash_str_find_ptr(&ce->function_table, name, name_len);
419-
zend_function *base_func = zend_hash_str_find_ptr(&base_ce->function_table, name, name_len);
439+
zend_function *func, *base_func;
440+
441+
func = zend_hash_str_find_ptr(&ce->function_table, name, name_len);
442+
base_func = zend_hash_str_find_ptr(&base_ce->function_table, name, name_len);
420443

421444
if (func == NULL) {
422445
return base_func != NULL;
@@ -453,22 +476,13 @@ static zend_always_inline bool zend_opcache_serializer_has_safe_direct_cache_ove
453476
;
454477
}
455478

456-
static bool zend_opcache_serializer_value_has_unstorable_ex(
457-
const zval *value,
458-
HashTable *seen_arrays,
459-
HashTable *seen_objects);
460-
461-
typedef struct _zend_opcache_serializer_has_unstorable_context {
462-
HashTable *seen_arrays;
463-
HashTable *seen_objects;
464-
} zend_opcache_serializer_has_unstorable_context;
465-
466479
static bool zend_opcache_serializer_safe_direct_value_has_unstorable_callback(
467480
void *context,
468481
const zval *value)
469482
{
470483
zend_opcache_serializer_has_unstorable_context *has_unstorable_context =
471-
(zend_opcache_serializer_has_unstorable_context *) context;
484+
(zend_opcache_serializer_has_unstorable_context *) context
485+
;
472486

473487
return zend_opcache_serializer_value_has_unstorable_ex(
474488
value,
@@ -509,10 +523,10 @@ static bool zend_opcache_serializer_safe_direct_state_has_unstorable(
509523
HashTable *seen_arrays,
510524
HashTable *seen_objects)
511525
{
512-
zend_class_entry *base_ce = NULL;
513526
zend_opcache_static_cache_safe_direct_state_copy_func_t copy_func;
514527
zend_opcache_static_cache_safe_direct_state_has_unstorable_func_t state_has_unstorable_func;
515528
zend_opcache_serializer_has_unstorable_context context;
529+
zend_class_entry *base_ce = NULL;
516530

517531
copy_func = zend_opcache_static_cache_safe_direct_copy_func(Z_OBJCE_P(value), &base_ce);
518532
if (copy_func == NULL ||
@@ -522,7 +536,8 @@ static bool zend_opcache_serializer_safe_direct_state_has_unstorable(
522536
}
523537

524538
state_has_unstorable_func =
525-
zend_opcache_static_cache_safe_direct_state_has_unstorable_func(Z_OBJCE_P(value));
539+
zend_opcache_static_cache_safe_direct_state_has_unstorable_func(Z_OBJCE_P(value))
540+
;
526541
if (state_has_unstorable_func == NULL) {
527542
return false;
528543
}
@@ -626,9 +641,6 @@ static zend_always_inline bool zend_opcache_serializer_hash_has_unstorable(const
626641
return result;
627642
}
628643

629-
static zend_always_inline bool zend_opcache_serializer_encode_zval(zend_opcache_serializer_wbuf_t *wb,
630-
const zval *zv);
631-
632644
static zend_always_inline bool zend_opcache_serializer_encode_property_table(zend_opcache_serializer_wbuf_t *wb,
633645
const HashTable *props)
634646
{
@@ -1328,9 +1340,11 @@ static zend_always_inline bool zend_opcache_serialize_ex(
13281340

13291341
zend_opcache_serializer_wbuf_init(&wb, 256);
13301342
ok = zend_opcache_serializer_encode_zval(&wb, value);
1343+
13311344
if (failed_unstorable != NULL) {
13321345
*failed_unstorable = wb.failed_unstorable;
13331346
}
1347+
13341348
zend_opcache_serializer_wbuf_destroy(&wb);
13351349

13361350
if (!ok) {
@@ -1409,9 +1423,6 @@ static zend_always_inline bool zend_opcache_serializer_rbuf_skip(zend_opcache_se
14091423
return true;
14101424
}
14111425

1412-
static zend_always_inline bool zend_opcache_serializer_decode_zval(zend_opcache_serializer_rbuf_t *rb,
1413-
zval *dst);
1414-
14151426
static inline bool zend_opcache_serializer_decode_zval_suppressed(zend_opcache_serializer_rbuf_t *rb, zval *dst)
14161427
{
14171428
bool result;
@@ -1478,10 +1489,10 @@ static zend_always_inline bool zend_opcache_serializer_decode_object_payload_wit
14781489
const unsigned char *arr_meta, *key_data;
14791490
const char *key_str;
14801491
zend_opcache_serializer_hdr_t arr_hdr;
1481-
zend_class_entry *base_ce = NULL;
1482-
zend_property_info *prop_info;
14831492
zend_opcache_static_cache_safe_direct_state_copy_func_t copy_func;
14841493
zend_opcache_static_cache_safe_direct_state_unserialize_func_t unserialize_func;
1494+
zend_class_entry *base_ce = NULL;
1495+
zend_property_info *prop_info;
14851496
zval props_zv, state_zv, data_arr,
14861497
val, *existing, *target, func_name, wakeup_rv;
14871498
HashTable *obj_ht;
@@ -1902,8 +1913,8 @@ static bool zend_opcache_serializer_decode_array(zend_opcache_serializer_rbuf_t
19021913

19031914
static zend_always_inline bool zend_opcache_serializer_decode_zval(zend_opcache_serializer_rbuf_t *rb, zval *dst)
19041915
{
1905-
zend_opcache_serializer_hdr_t hdr;
19061916
const void *payload;
1917+
zend_opcache_serializer_hdr_t hdr;
19071918
int64_t lval;
19081919
double dval;
19091920
bool previous_skip_decoded_value_capture, skip_decoded_value_capture;

ext/opcache/zend_static_cache_entries.c

Lines changed: 57 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,55 @@ static zend_always_inline void zend_opcache_static_cache_delete_entry_locked(zen
8080
zend_opcache_static_cache_bump_mutation_epoch_locked(header);
8181
}
8282

83+
static zend_always_inline void zend_opcache_static_cache_release_request_local_slot_context(HashTable **slots_ptr)
84+
{
85+
if (*slots_ptr == NULL) {
86+
return;
87+
}
88+
89+
zend_hash_destroy(*slots_ptr);
90+
FREE_HASHTABLE(*slots_ptr);
91+
*slots_ptr = NULL;
92+
}
93+
94+
static zend_always_inline bool zend_opcache_static_cache_is_expired(const zend_opcache_static_cache_entry *entry, uint64_t now)
95+
{
96+
return entry->state == ZEND_OPCACHE_STATIC_CACHE_ENTRY_USED && entry->expires_at != 0 && entry->expires_at <= now;
97+
}
98+
99+
static zend_always_inline bool zend_opcache_static_cache_maybe_expired(const zend_opcache_static_cache_entry *entry, uint64_t *now)
100+
{
101+
if (entry->state != ZEND_OPCACHE_STATIC_CACHE_ENTRY_USED || entry->expires_at == 0) {
102+
return false;
103+
}
104+
105+
if (*now == 0) {
106+
*now = (uint64_t) time(NULL);
107+
}
108+
109+
return zend_opcache_static_cache_is_expired(entry, *now);
110+
}
111+
112+
static zend_always_inline bool zend_opcache_static_cache_payload_can_fit_locked(size_t size)
113+
{
114+
zend_opcache_static_cache_header *header = zend_opcache_static_cache_header_ptr();
115+
size_t total_size;
116+
117+
if (!header || size == 0 || size > UINT32_MAX - sizeof(zend_opcache_static_cache_block)) {
118+
return false;
119+
}
120+
121+
total_size = ZEND_ALIGNED_SIZE(sizeof(zend_opcache_static_cache_block) + size);
122+
123+
return total_size <= UINT32_MAX && total_size <= header->data_size;
124+
}
125+
126+
static zend_always_inline void zend_opcache_static_cache_init_prepared_value(zend_opcache_static_cache_prepared_value *prepared)
127+
{
128+
memset(prepared, 0, sizeof(*prepared));
129+
prepared->value_type = ZEND_OPCACHE_STATIC_CACHE_VALUE_NULL;
130+
}
131+
83132
static void zend_opcache_static_cache_request_local_slot_dtor(zval *slot_zv)
84133
{
85134
zend_opcache_static_cache_request_local_slot *slot = Z_PTR_P(slot_zv);
@@ -231,14 +280,6 @@ static bool zend_opcache_static_cache_clone_request_local_array_ex(
231280
return true;
232281
}
233282

234-
static bool zend_opcache_static_cache_clone_request_local_array(
235-
zend_opcache_static_cache_request_local_clone_context *context,
236-
zval *dst,
237-
zval *src)
238-
{
239-
return zend_opcache_static_cache_clone_request_local_array_ex(context, dst, src, false);
240-
}
241-
242283
static bool zend_opcache_static_cache_clone_request_local_reference(
243284
zend_opcache_static_cache_request_local_clone_context *context,
244285
zval *dst,
@@ -383,12 +424,14 @@ static bool zend_opcache_static_cache_clone_request_local_safe_direct_object(
383424
zend_object *old_object,
384425
zend_object **new_object_ptr)
385426
{
386-
zend_class_entry *ce = old_object->ce, *base_ce = NULL;
387427
zend_opcache_static_cache_safe_direct_state_copy_func_t copy_func;
428+
zend_class_entry *ce, *base_ce = NULL;
388429
zend_object *new_object;
389430
zend_ulong key;
390431
zval new_zv;
391432

433+
ce = old_object->ce;
434+
392435
copy_func = zend_opcache_static_cache_safe_direct_copy_func(ce, &base_ce);
393436
if (copy_func == NULL || zend_opcache_serializer_has_safe_direct_cache_overrides(ce, base_ce)) {
394437
return false;
@@ -462,7 +505,7 @@ static bool zend_opcache_static_cache_clone_request_local_value(
462505

463506
switch (Z_TYPE_P(src)) {
464507
case IS_ARRAY:
465-
return zend_opcache_static_cache_clone_request_local_array(context, dst, src);
508+
return zend_opcache_static_cache_clone_request_local_array_ex(context, dst, src, false);
466509
case IS_OBJECT:
467510
if (!zend_opcache_static_cache_clone_request_local_object(context, Z_OBJ_P(src), &object)) {
468511
return false;
@@ -738,35 +781,6 @@ static bool zend_opcache_static_cache_fetch_finish(
738781
return true;
739782
}
740783

741-
static void zend_opcache_static_cache_release_request_local_slot_context(HashTable **slots_ptr)
742-
{
743-
if (*slots_ptr == NULL) {
744-
return;
745-
}
746-
747-
zend_hash_destroy(*slots_ptr);
748-
FREE_HASHTABLE(*slots_ptr);
749-
*slots_ptr = NULL;
750-
}
751-
752-
static bool zend_opcache_static_cache_is_expired(const zend_opcache_static_cache_entry *entry, uint64_t now)
753-
{
754-
return entry->state == ZEND_OPCACHE_STATIC_CACHE_ENTRY_USED && entry->expires_at != 0 && entry->expires_at <= now;
755-
}
756-
757-
static bool zend_opcache_static_cache_maybe_expired(const zend_opcache_static_cache_entry *entry, uint64_t *now)
758-
{
759-
if (entry->state != ZEND_OPCACHE_STATIC_CACHE_ENTRY_USED || entry->expires_at == 0) {
760-
return false;
761-
}
762-
763-
if (*now == 0) {
764-
*now = (uint64_t) time(NULL);
765-
}
766-
767-
return zend_opcache_static_cache_is_expired(entry, *now);
768-
}
769-
770784
static bool zend_opcache_static_cache_find_slot_in_header_locked(
771785
zend_opcache_static_cache_header *header,
772786
zend_string *key,
@@ -897,20 +911,6 @@ static bool zend_opcache_static_cache_expunge_expired_locked(void)
897911
return removed;
898912
}
899913

900-
static bool zend_opcache_static_cache_payload_can_fit_locked(size_t size)
901-
{
902-
zend_opcache_static_cache_header *header = zend_opcache_static_cache_header_ptr();
903-
size_t total_size;
904-
905-
if (!header || size == 0 || size > UINT32_MAX - sizeof(zend_opcache_static_cache_block)) {
906-
return false;
907-
}
908-
909-
total_size = ZEND_ALIGNED_SIZE(sizeof(zend_opcache_static_cache_block) + size);
910-
911-
return total_size <= UINT32_MAX && total_size <= header->data_size;
912-
}
913-
914914
static void zend_opcache_static_cache_handle_store_failure(const char *failure_message, bool throw_on_failure)
915915
{
916916
zend_opcache_static_cache_context *context = zend_opcache_static_cache_active_context();
@@ -927,11 +927,6 @@ static void zend_opcache_static_cache_handle_store_failure(const char *failure_m
927927
}
928928
}
929929

930-
static void zend_opcache_static_cache_handle_store_failure_locked(const char *failure_message, bool throw_on_failure)
931-
{
932-
zend_opcache_static_cache_handle_store_failure(failure_message, throw_on_failure);
933-
}
934-
935930
static bool zend_opcache_static_cache_find_unstorable_value(
936931
zval *value,
937932
HashTable *seen_arrays,
@@ -974,9 +969,11 @@ static bool zend_opcache_static_cache_find_unstorable_value(
974969
if (Z_TYPE_P(value) == IS_OBJECT) {
975970
object = Z_OBJ_P(value);
976971
key = (zend_ulong) (uintptr_t) object;
972+
977973
if (zend_hash_index_exists(seen_objects, key)) {
978974
return false;
979975
}
976+
980977
zend_hash_index_add_empty_element(seen_objects, key);
981978

982979
if (object->ce->default_properties_count != 0) {
@@ -1136,12 +1133,6 @@ static bool zend_opcache_static_cache_retry_store_after_pressure_locked(
11361133
return false;
11371134
}
11381135

1139-
static void zend_opcache_static_cache_init_prepared_value(zend_opcache_static_cache_prepared_value *prepared)
1140-
{
1141-
memset(prepared, 0, sizeof(*prepared));
1142-
prepared->value_type = ZEND_OPCACHE_STATIC_CACHE_VALUE_NULL;
1143-
}
1144-
11451136
bool zend_opcache_static_cache_clear_locked(void)
11461137
{
11471138
zend_opcache_static_cache_header *header = zend_opcache_static_cache_header_ptr();
@@ -1416,7 +1407,7 @@ bool zend_opcache_static_cache_store_prepared_locked(
14161407
goto retry_store;
14171408
}
14181409

1419-
zend_opcache_static_cache_handle_store_failure_locked("cache hash table is full", throw_on_failure);
1410+
zend_opcache_static_cache_handle_store_failure("cache hash table is full", throw_on_failure);
14201411

14211412
return false;
14221413
}
@@ -1765,7 +1756,7 @@ bool zend_opcache_static_cache_store_prepared_locked(
17651756
goto retry_store;
17661757
}
17671758

1768-
zend_opcache_static_cache_handle_store_failure_locked(failure_message, throw_on_failure);
1759+
zend_opcache_static_cache_handle_store_failure(failure_message, throw_on_failure);
17691760

17701761
return false;
17711762
}

0 commit comments

Comments
 (0)