Skip to content

Commit f032844

Browse files
committed
move to EG and CG
1 parent c18a585 commit f032844

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

Zend/zend_API.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2898,18 +2898,16 @@ ZEND_API void zend_add_magic_method(zend_class_entry *ce, zend_function *fptr, z
28982898
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arg_info_toString, 0, 0, IS_STRING, 0)
28992899
ZEND_END_ARG_INFO()
29002900

2901-
static HashTable *interned_type_tree = NULL;
2902-
29032901
ZEND_API void zend_type_free_interned_trees(void) {
29042902
zend_type_node *tree = NULL;
2905-
ZEND_HASH_FOREACH_PTR(interned_type_tree, tree) {
2903+
ZEND_HASH_FOREACH_PTR(CG(type_trees), tree) {
29062904
if (tree->kind != ZEND_TYPE_SIMPLE) {
29072905
pefree(tree->compound.types, 1);
29082906
}
29092907
pefree(tree, 1);
29102908
} ZEND_HASH_FOREACH_END();
2911-
pefree(interned_type_tree, 1);
2912-
interned_type_tree = NULL;
2909+
pefree(CG(type_trees), 1);
2910+
CG(type_trees) = NULL;
29132911
}
29142912

29152913
static int compare_simple_types(const zend_type a, const zend_type b) {
@@ -3051,12 +3049,12 @@ static zend_type_node *intern_type_node(zend_type_node *node) {
30513049
const zend_ulong hash = zend_type_node_hash(node);
30523050
zend_type_node *existing;
30533051

3054-
if (interned_type_tree == NULL) {
3055-
interned_type_tree = pemalloc(sizeof(HashTable), 1);
3056-
zend_hash_init(interned_type_tree, 64, NULL, NULL, 1);
3052+
if (CG(type_trees) == NULL) {
3053+
CG(type_trees) = pemalloc(sizeof(HashTable), 1);
3054+
zend_hash_init(CG(type_trees), 64, NULL, NULL, 1);
30573055
}
30583056

3059-
if ((existing = zend_hash_index_find_ptr(interned_type_tree, hash))) {
3057+
if ((existing = zend_hash_index_find_ptr(CG(type_trees), hash))) {
30603058
if (zend_type_node_equals(existing, node)) {
30613059
if (node->kind != ZEND_TYPE_SIMPLE) {
30623060
pefree(node->compound.types, 1);
@@ -3066,7 +3064,7 @@ static zend_type_node *intern_type_node(zend_type_node *node) {
30663064
}
30673065
}
30683066

3069-
zend_hash_index_add_new_ptr(interned_type_tree, hash, node);
3067+
zend_hash_index_add_new_ptr(CG(type_trees), hash, node);
30703068
return node;
30713069
}
30723070

Zend/zend_execute_API.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ void init_executor(void) /* {{{ */
148148

149149
EG(function_table) = CG(function_table);
150150
EG(class_table) = CG(class_table);
151+
EG(type_trees) = CG(type_trees);
151152

152153
EG(in_autoload) = NULL;
153154
EG(error_handling) = EH_NORMAL;

Zend/zend_globals.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct _zend_compiler_globals {
9494

9595
HashTable *function_table; /* function symbol table */
9696
HashTable *class_table; /* class table */
97+
HashTable *type_trees; /* type trees table */
9798

9899
HashTable *auto_globals;
99100

@@ -191,6 +192,7 @@ struct _zend_executor_globals {
191192
HashTable *function_table; /* function symbol table */
192193
HashTable *class_table; /* class table */
193194
HashTable *zend_constants; /* constants table */
195+
HashTable *type_trees /* type trees table */;
194196

195197
zval *vm_stack_top;
196198
zval *vm_stack_end;

ext/opcache/ZendAccelerator.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4803,6 +4803,7 @@ static zend_result accel_finish_startup_preload(bool in_child)
48034803
#endif
48044804
php_request_shutdown(NULL); /* calls zend_shared_alloc_unlock(); */
48054805
EG(class_table) = NULL;
4806+
EG(type_trees) = NULL;
48064807
EG(function_table) = NULL;
48074808
PG(report_memleaks) = orig_report_memleaks;
48084809
#ifdef ZTS

0 commit comments

Comments
 (0)