@@ -735,16 +735,16 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{
735
735
compiler_globals -> map_ptr_base = ZEND_MAP_PTR_BIASED_BASE (NULL );
736
736
compiler_globals -> map_ptr_size = 0 ;
737
737
compiler_globals -> map_ptr_last = global_map_ptr_last ;
738
- compiler_globals -> internal_run_time_cache = 0 ;
739
- if (compiler_globals -> map_ptr_last ) {
738
+ compiler_globals -> internal_run_time_cache = NULL ;
739
+ if (compiler_globals -> map_ptr_last || zend_map_ptr_static_size ) {
740
740
/* Allocate map_ptr table */
741
741
compiler_globals -> map_ptr_size = ZEND_MM_ALIGNED_SIZE_EX (compiler_globals -> map_ptr_last , 4096 );
742
- void * base = pemalloc (compiler_globals -> map_ptr_size * sizeof (void * ), 1 );
742
+ void * base = pemalloc (( zend_map_ptr_static_size + compiler_globals -> map_ptr_size ) * sizeof (void * ), 1 );
743
743
compiler_globals -> map_ptr_real_base = base ;
744
744
compiler_globals -> map_ptr_base = ZEND_MAP_PTR_BIASED_BASE (base );
745
- memset (base , 0 , compiler_globals -> map_ptr_last * sizeof (void * ));
746
- zend_init_internal_run_time_cache ();
745
+ memset (base , 0 , (zend_map_ptr_static_size + compiler_globals -> map_ptr_last ) * sizeof (void * ));
747
746
}
747
+ zend_init_internal_run_time_cache ();
748
748
}
749
749
/* }}} */
750
750
@@ -789,6 +789,7 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals) /* {{
789
789
}
790
790
if (compiler_globals -> internal_run_time_cache ) {
791
791
pefree (compiler_globals -> internal_run_time_cache , 1 );
792
+ compiler_globals -> internal_run_time_cache = NULL ;
792
793
}
793
794
}
794
795
/* }}} */
@@ -1088,7 +1089,6 @@ zend_result zend_post_startup(void) /* {{{ */
1088
1089
1089
1090
zend_compiler_globals * compiler_globals = ts_resource (compiler_globals_id );
1090
1091
zend_executor_globals * executor_globals = ts_resource (executor_globals_id );
1091
- global_map_ptr_last = compiler_globals -> map_ptr_last ;
1092
1092
#endif
1093
1093
1094
1094
startup_done = true;
@@ -1119,11 +1119,12 @@ zend_result zend_post_startup(void) /* {{{ */
1119
1119
if (compiler_globals -> map_ptr_real_base ) {
1120
1120
free (compiler_globals -> map_ptr_real_base );
1121
1121
}
1122
+ compiler_globals -> map_ptr_real_base = NULL ;
1123
+ compiler_globals -> map_ptr_base = ZEND_MAP_PTR_BIASED_BASE (NULL );
1122
1124
if (compiler_globals -> internal_run_time_cache ) {
1123
1125
pefree (compiler_globals -> internal_run_time_cache , 1 );
1124
1126
}
1125
- compiler_globals -> map_ptr_real_base = NULL ;
1126
- compiler_globals -> map_ptr_base = ZEND_MAP_PTR_BIASED_BASE (NULL );
1127
+ compiler_globals -> internal_run_time_cache = NULL ;
1127
1128
if ((script_encoding_list = (zend_encoding * * )compiler_globals -> script_encoding_list )) {
1128
1129
compiler_globals_ctor (compiler_globals );
1129
1130
compiler_globals -> script_encoding_list = (const zend_encoding * * )script_encoding_list ;
@@ -1309,7 +1310,7 @@ ZEND_API void zend_activate(void) /* {{{ */
1309
1310
init_executor ();
1310
1311
startup_scanner ();
1311
1312
if (CG (map_ptr_last )) {
1312
- memset ((char * )CG (map_ptr_real_base ) + zend_map_ptr_static_size * sizeof ( void * ) , 0 , ( CG (map_ptr_last ) - zend_map_ptr_static_size ) * sizeof (void * ));
1313
+ memset ((void * * )CG (map_ptr_real_base ) + zend_map_ptr_static_size , 0 , CG (map_ptr_last ) * sizeof (void * ));
1313
1314
}
1314
1315
zend_reset_internal_run_time_cache ();
1315
1316
zend_observer_activate ();
@@ -2011,10 +2012,10 @@ ZEND_API void *zend_map_ptr_new(void)
2011
2012
if (CG (map_ptr_last ) >= CG (map_ptr_size )) {
2012
2013
/* Grow map_ptr table */
2013
2014
CG (map_ptr_size ) = ZEND_MM_ALIGNED_SIZE_EX (CG (map_ptr_last ) + 1 , 4096 );
2014
- CG (map_ptr_real_base ) = perealloc (CG (map_ptr_real_base ), CG (map_ptr_size ) * sizeof (void * ), 1 );
2015
+ CG (map_ptr_real_base ) = perealloc (CG (map_ptr_real_base ), ( zend_map_ptr_static_size + CG (map_ptr_size ) ) * sizeof (void * ), 1 );
2015
2016
CG (map_ptr_base ) = ZEND_MAP_PTR_BIASED_BASE (CG (map_ptr_real_base ));
2016
2017
}
2017
- ptr = (void * * )CG (map_ptr_real_base ) + CG (map_ptr_last );
2018
+ ptr = (void * * )CG (map_ptr_real_base ) + zend_map_ptr_static_size + CG (map_ptr_last );
2018
2019
* ptr = NULL ;
2019
2020
CG (map_ptr_last )++ ;
2020
2021
return ZEND_MAP_PTR_PTR2OFFSET (ptr );
@@ -2025,13 +2026,13 @@ ZEND_API void *zend_map_ptr_new_static(void)
2025
2026
void * * ptr ;
2026
2027
2027
2028
if (zend_map_ptr_static_last >= zend_map_ptr_static_size ) {
2028
- CG (map_ptr_last ) += 4096 ;
2029
2029
zend_map_ptr_static_size += 4096 ;
2030
2030
/* Grow map_ptr table */
2031
- CG (map_ptr_size ) = ZEND_MM_ALIGNED_SIZE_EX (CG (map_ptr_last ), 4096 );
2032
- CG (map_ptr_real_base ) = perealloc (CG (map_ptr_real_base ), CG (map_ptr_size ) * sizeof (void * ), 1 );
2033
- memmove ((char * )CG (map_ptr_real_base ) + 4096 * sizeof (void * ), CG (map_ptr_real_base ), (CG (map_ptr_last ) - 4096 ) * sizeof (void * ));
2034
- CG (map_ptr_base ) = ZEND_MAP_PTR_BIASED_BASE (CG (map_ptr_real_base ));
2031
+ void * new_base = pemalloc ((zend_map_ptr_static_size + CG (map_ptr_size )) * sizeof (void * ), 1 );
2032
+ memcpy ((char * )new_base + 4096 * sizeof (void * ), CG (map_ptr_real_base ), (CG (map_ptr_last ) + zend_map_ptr_static_size - 4096 ) * sizeof (void * ));
2033
+ pefree (CG (map_ptr_real_base ), 1 );
2034
+ CG (map_ptr_real_base ) = new_base ;
2035
+ CG (map_ptr_base ) = ZEND_MAP_PTR_BIASED_BASE (new_base );
2035
2036
}
2036
2037
ptr = (void * * )CG (map_ptr_real_base ) + (zend_map_ptr_static_last & 4095 );
2037
2038
* ptr = NULL ;
@@ -2047,10 +2048,10 @@ ZEND_API void zend_map_ptr_extend(size_t last)
2047
2048
if (last >= CG (map_ptr_size )) {
2048
2049
/* Grow map_ptr table */
2049
2050
CG (map_ptr_size ) = ZEND_MM_ALIGNED_SIZE_EX (last , 4096 );
2050
- CG (map_ptr_real_base ) = perealloc (CG (map_ptr_real_base ), CG (map_ptr_size ) * sizeof (void * ), 1 );
2051
+ CG (map_ptr_real_base ) = perealloc (CG (map_ptr_real_base ), ( zend_map_ptr_static_size + CG (map_ptr_size ) ) * sizeof (void * ), 1 );
2051
2052
CG (map_ptr_base ) = ZEND_MAP_PTR_BIASED_BASE (CG (map_ptr_real_base ));
2052
2053
}
2053
- ptr = (void * * )CG (map_ptr_real_base ) + CG (map_ptr_last );
2054
+ ptr = (void * * )CG (map_ptr_real_base ) + zend_map_ptr_static_size + CG (map_ptr_last );
2054
2055
memset (ptr , 0 , (last - CG (map_ptr_last )) * sizeof (void * ));
2055
2056
CG (map_ptr_last ) = last ;
2056
2057
}
0 commit comments