@@ -55,17 +55,20 @@ ZEND_API size_t compiler_globals_offset;
55
55
ZEND_API size_t executor_globals_offset ;
56
56
static HashTable * global_function_table = NULL ;
57
57
static HashTable * global_class_table = NULL ;
58
+ static HashTable * global_module_table = NULL ;
58
59
static HashTable * global_constants_table = NULL ;
59
60
static HashTable * global_auto_globals_table = NULL ;
60
61
static HashTable * global_persistent_list = NULL ;
61
62
TSRMLS_MAIN_CACHE_DEFINE ()
62
63
# define GLOBAL_FUNCTION_TABLE global_function_table
63
64
# define GLOBAL_CLASS_TABLE global_class_table
65
+ # define GLOBAL_MODULE_TABLE global_module_table
64
66
# define GLOBAL_CONSTANTS_TABLE global_constants_table
65
67
# define GLOBAL_AUTO_GLOBALS_TABLE global_auto_globals_table
66
68
#else
67
69
# define GLOBAL_FUNCTION_TABLE CG(function_table)
68
70
# define GLOBAL_CLASS_TABLE CG(class_table)
71
+ # define GLOBAL_MODULE_TABLE CG(module_table)
69
72
# define GLOBAL_AUTO_GLOBALS_TABLE CG(auto_globals)
70
73
# define GLOBAL_CONSTANTS_TABLE EG(zend_constants)
71
74
#endif
@@ -723,6 +726,9 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{
723
726
zend_hash_init (compiler_globals -> class_table , 64 , NULL , ZEND_CLASS_DTOR , 1 );
724
727
zend_hash_copy (compiler_globals -> class_table , global_class_table , zend_class_add_ref );
725
728
729
+ compiler_globals -> module_table = (HashTable * ) malloc (sizeof (HashTable ));
730
+ zend_hash_init (compiler_globals -> module_table , 64 , NULL , NULL , 1 );
731
+
726
732
zend_set_default_compile_time_values ();
727
733
728
734
compiler_globals -> auto_globals = (HashTable * ) malloc (sizeof (HashTable ));
@@ -752,6 +758,10 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{
752
758
753
759
static void compiler_globals_dtor (zend_compiler_globals * compiler_globals ) /* {{{ */
754
760
{
761
+ if (compiler_globals -> module_table != GLOBAL_MODULE_TABLE ) {
762
+ zend_hash_destroy (compiler_globals -> module_table );
763
+ free (compiler_globals -> module_table );
764
+ }
755
765
if (compiler_globals -> function_table != GLOBAL_FUNCTION_TABLE ) {
756
766
uint32_t n = compiler_globals -> copied_functions_count ;
757
767
@@ -1005,11 +1015,13 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
1005
1015
1006
1016
GLOBAL_FUNCTION_TABLE = (HashTable * ) malloc (sizeof (HashTable ));
1007
1017
GLOBAL_CLASS_TABLE = (HashTable * ) malloc (sizeof (HashTable ));
1018
+ GLOBAL_MODULE_TABLE = (HashTable * ) malloc (sizeof (HashTable ));
1008
1019
GLOBAL_AUTO_GLOBALS_TABLE = (HashTable * ) malloc (sizeof (HashTable ));
1009
1020
GLOBAL_CONSTANTS_TABLE = (HashTable * ) malloc (sizeof (HashTable ));
1010
1021
1011
1022
zend_hash_init (GLOBAL_FUNCTION_TABLE , 1024 , NULL , ZEND_FUNCTION_DTOR , 1 );
1012
1023
zend_hash_init (GLOBAL_CLASS_TABLE , 64 , NULL , ZEND_CLASS_DTOR , 1 );
1024
+ zend_hash_init (GLOBAL_MODULE_TABLE , 64 , NULL , NULL , 1 );
1013
1025
zend_hash_init (GLOBAL_AUTO_GLOBALS_TABLE , 8 , NULL , auto_global_dtor , 1 );
1014
1026
zend_hash_init (GLOBAL_CONSTANTS_TABLE , 128 , NULL , ZEND_CONSTANT_DTOR , 1 );
1015
1027
@@ -1028,9 +1040,11 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
1028
1040
compiler_globals -> in_compilation = 0 ;
1029
1041
compiler_globals -> function_table = (HashTable * ) malloc (sizeof (HashTable ));
1030
1042
compiler_globals -> class_table = (HashTable * ) malloc (sizeof (HashTable ));
1043
+ compiler_globals -> module_table = (HashTable * ) malloc (sizeof (HashTable ));
1031
1044
1032
1045
* compiler_globals -> function_table = * GLOBAL_FUNCTION_TABLE ;
1033
1046
* compiler_globals -> class_table = * GLOBAL_CLASS_TABLE ;
1047
+ * compiler_globals -> module_table = * GLOBAL_MODULE_TABLE ;
1034
1048
compiler_globals -> auto_globals = GLOBAL_AUTO_GLOBALS_TABLE ;
1035
1049
1036
1050
zend_hash_destroy (executor_globals -> zend_constants );
@@ -1110,6 +1124,7 @@ zend_result zend_post_startup(void) /* {{{ */
1110
1124
#ifdef ZTS
1111
1125
* GLOBAL_FUNCTION_TABLE = * compiler_globals -> function_table ;
1112
1126
* GLOBAL_CLASS_TABLE = * compiler_globals -> class_table ;
1127
+ * GLOBAL_MODULE_TABLE = * compiler_globals -> module_table ;
1113
1128
* GLOBAL_CONSTANTS_TABLE = * executor_globals -> zend_constants ;
1114
1129
global_map_ptr_last = compiler_globals -> map_ptr_last ;
1115
1130
@@ -1121,6 +1136,8 @@ zend_result zend_post_startup(void) /* {{{ */
1121
1136
compiler_globals -> function_table = NULL ;
1122
1137
free (compiler_globals -> class_table );
1123
1138
compiler_globals -> class_table = NULL ;
1139
+ free (compiler_globals -> module_table );
1140
+ compiler_globals -> module_table = NULL ;
1124
1141
if (compiler_globals -> map_ptr_real_base ) {
1125
1142
free (compiler_globals -> map_ptr_real_base );
1126
1143
}
0 commit comments