@@ -2627,7 +2627,6 @@ static void zend_reset_cache_vars(void)
26272627 ZCSG (restart_pending ) = false;
26282628 ZCSG (force_restart_time ) = 0 ;
26292629 ZCSG (map_ptr_last ) = CG (map_ptr_last );
2630- ZCSG (map_ptr_static_last ) = zend_map_ptr_static_last ;
26312630}
26322631
26332632static void accel_reset_pcre_cache (void )
@@ -2643,7 +2642,7 @@ static void accel_reset_pcre_cache(void)
26432642 } ZEND_HASH_FOREACH_END ();
26442643}
26452644
2646- ZEND_RINIT_FUNCTION ( zend_accelerator )
2645+ zend_result accel_activate ( INIT_FUNC_ARGS )
26472646{
26482647 if (!ZCG (enabled ) || !accel_startup_ok ) {
26492648 ZCG (accelerator_enabled ) = false;
@@ -2949,13 +2948,12 @@ static void accel_globals_ctor(zend_accel_globals *accel_globals)
29492948 GC_MAKE_PERSISTENT_LOCAL (accel_globals -> key );
29502949}
29512950
2951+ #ifdef ZTS
29522952static void accel_globals_dtor (zend_accel_globals * accel_globals )
29532953{
29542954 zend_string_free (accel_globals -> key );
2955- if (accel_globals -> preloaded_internal_run_time_cache ) {
2956- pefree (accel_globals -> preloaded_internal_run_time_cache , 1 );
2957- }
29582955}
2956+ #endif
29592957
29602958#ifdef HAVE_HUGE_CODE_PAGES
29612959# ifndef _WIN32
@@ -3445,8 +3443,6 @@ void accel_shutdown(void)
34453443 if (!ZCG (enabled ) || !accel_startup_ok ) {
34463444#ifdef ZTS
34473445 ts_free_id (accel_globals_id );
3448- #else
3449- accel_globals_dtor (& accel_globals );
34503446#endif
34513447 return ;
34523448 }
@@ -3463,8 +3459,6 @@ void accel_shutdown(void)
34633459
34643460#ifdef ZTS
34653461 ts_free_id (accel_globals_id );
3466- #else
3467- accel_globals_dtor (& accel_globals );
34683462#endif
34693463
34703464 if (!_file_cache_only ) {
@@ -4458,7 +4452,7 @@ static zend_persistent_script* preload_script_in_shared_memory(zend_persistent_s
44584452 return new_persistent_script ;
44594453}
44604454
4461- static void preload_load (size_t orig_map_ptr_static_last )
4455+ static void preload_load (void )
44624456{
44634457 /* Load into process tables */
44644458 zend_script * script = & ZCSG (preload_script )-> script ;
@@ -4493,42 +4487,14 @@ static void preload_load(size_t orig_map_ptr_static_last)
44934487 if (EG (class_table )) {
44944488 EG (persistent_classes_count ) = EG (class_table )-> nNumUsed ;
44954489 }
4496-
4497- size_t old_map_ptr_last = CG (map_ptr_last );
4498- if (zend_map_ptr_static_last != ZCSG (map_ptr_static_last ) || old_map_ptr_last != ZCSG (map_ptr_last )) {
4490+ if (CG (map_ptr_last ) != ZCSG (map_ptr_last )) {
4491+ size_t old_map_ptr_last = CG (map_ptr_last );
44994492 CG (map_ptr_last ) = ZCSG (map_ptr_last );
4500- CG (map_ptr_size ) = ZEND_MM_ALIGNED_SIZE_EX (ZCSG (map_ptr_last ) + 1 , 4096 );
4501- zend_map_ptr_static_last = ZCSG (map_ptr_static_last );
4502-
4503- /* Grow map_ptr table as needed, but allocate once for static + regular map_ptrs */
4504- size_t new_static_size = ZEND_MM_ALIGNED_SIZE_EX (zend_map_ptr_static_last , 4096 );
4505- if (zend_map_ptr_static_size != new_static_size ) {
4506- void * new_base = pemalloc ((new_static_size + CG (map_ptr_size )) * sizeof (void * ), 1 );
4507- if (CG (map_ptr_real_base )) {
4508- memcpy ((void * * ) new_base + new_static_size - zend_map_ptr_static_size , CG (map_ptr_real_base ), (old_map_ptr_last + zend_map_ptr_static_size ) * sizeof (void * ));
4509- pefree (CG (map_ptr_real_base ), 1 );
4510- }
4511- CG (map_ptr_real_base ) = new_base ;
4512- zend_map_ptr_static_size = new_static_size ;
4513- } else {
4514- CG (map_ptr_real_base ) = perealloc (CG (map_ptr_real_base ), (zend_map_ptr_static_size + CG (map_ptr_size )) * sizeof (void * ), 1 );
4515- }
4516-
4517- memset ((void * * ) CG (map_ptr_real_base ) + zend_map_ptr_static_size + old_map_ptr_last , 0 , (CG (map_ptr_last ) - old_map_ptr_last ) * sizeof (void * ));
4493+ CG (map_ptr_size ) = ZEND_MM_ALIGNED_SIZE_EX (CG (map_ptr_last ) + 1 , 4096 );
4494+ CG (map_ptr_real_base ) = perealloc (CG (map_ptr_real_base ), CG (map_ptr_size ) * sizeof (void * ), 1 );
45184495 CG (map_ptr_base ) = ZEND_MAP_PTR_BIASED_BASE (CG (map_ptr_real_base ));
4519- }
4520-
4521- if (orig_map_ptr_static_last != zend_map_ptr_static_last ) {
4522- /* preloaded static entries currently are all runtime cache pointers, just assign them as such */
4523- size_t runtime_cache_size = zend_internal_run_time_cache_reserved_size ();
4524- ZCG (preloaded_internal_run_time_cache_size ) = (zend_map_ptr_static_last - orig_map_ptr_static_last ) * runtime_cache_size ;
4525- char * cache = pemalloc (ZCG (preloaded_internal_run_time_cache_size ), 1 );
4526- ZCG (preloaded_internal_run_time_cache ) = cache ;
4527-
4528- for (size_t cur_static_map_ptr = orig_map_ptr_static_last ; cur_static_map_ptr < zend_map_ptr_static_last ; ++ cur_static_map_ptr ) {
4529- * ZEND_MAP_PTR_STATIC_NUM_TO_PTR (cur_static_map_ptr ) = cache ;
4530- cache += runtime_cache_size ;
4531- }
4496+ memset ((void * * ) CG (map_ptr_real_base ) + old_map_ptr_last , 0 ,
4497+ (CG (map_ptr_last ) - old_map_ptr_last ) * sizeof (void * ));
45324498 }
45334499}
45344500
@@ -4570,7 +4536,7 @@ static zend_result accel_preload(const char *config, bool in_child)
45704536 zend_file_handle file_handle ;
45714537 zend_result ret ;
45724538 char * orig_open_basedir ;
4573- size_t orig_map_ptr_last , orig_map_ptr_static_last ;
4539+ size_t orig_map_ptr_last ;
45744540 uint32_t orig_compiler_options ;
45754541
45764542 ZCG (enabled ) = false;
@@ -4581,7 +4547,6 @@ static zend_result accel_preload(const char *config, bool in_child)
45814547 accelerator_orig_compile_file = preload_compile_file ;
45824548
45834549 orig_map_ptr_last = CG (map_ptr_last );
4584- orig_map_ptr_static_last = zend_map_ptr_static_last ;
45854550
45864551 /* Compile and execute preloading script */
45874552 zend_stream_init_filename (& file_handle , (char * ) config );
@@ -4761,7 +4726,7 @@ static zend_result accel_preload(const char *config, bool in_child)
47614726 SHM_PROTECT ();
47624727 HANDLE_UNBLOCK_INTERRUPTIONS ();
47634728
4764- preload_load (orig_map_ptr_static_last );
4729+ preload_load ();
47654730
47664731 /* Store individual scripts with unlinked classes */
47674732 HANDLE_BLOCK_INTERRUPTIONS ();
@@ -5034,7 +4999,7 @@ static zend_result accel_finish_startup(void)
50344999
50355000 if (ZCSG (preload_script )) {
50365001 /* Preloading was done in another process */
5037- preload_load (zend_map_ptr_static_last );
5002+ preload_load ();
50385003 zend_shared_alloc_unlock ();
50395004 return SUCCESS ;
50405005 }
@@ -5062,7 +5027,7 @@ static zend_result accel_finish_startup(void)
50625027 }
50635028
50645029 if (ZCSG (preload_script )) {
5065- preload_load (zend_map_ptr_static_last );
5030+ preload_load ();
50665031 }
50675032
50685033 zend_shared_alloc_unlock ();
@@ -5076,12 +5041,6 @@ static zend_result accel_finish_startup(void)
50765041#endif /* ZEND_WIN32 */
50775042}
50785043
5079- static void accel_activate (void ) {
5080- if (ZCG (preloaded_internal_run_time_cache )) {
5081- memset (ZCG (preloaded_internal_run_time_cache ), 0 , ZCG (preloaded_internal_run_time_cache_size ));
5082- }
5083- }
5084-
50855044static zend_extension opcache_extension_entry = {
50865045 ACCELERATOR_PRODUCT_NAME , /* name */
50875046 PHP_VERSION , /* version */
@@ -5090,7 +5049,7 @@ static zend_extension opcache_extension_entry = {
50905049 "Copyright (c)" , /* copyright */
50915050 accel_startup , /* startup */
50925051 NULL , /* shutdown */
5093- accel_activate , /* per-script activation */
5052+ NULL , /* per-script activation */
50945053#ifdef HAVE_JIT
50955054 accel_deactivate , /* per-script deactivation */
50965055#else
0 commit comments