@@ -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+
83132static 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-
242283static 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-
770784static 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-
914914static 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-
935930static 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-
11451136bool 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