Skip to content

Commit 1d0f553

Browse files
committed
Store incomplete_class entry as normal global
I don't see any reason why this needs to live in a thread-safe global, unlikely all other class entries.
1 parent 1c1165f commit 1d0f553

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

ext/standard/basic_functions.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ PHPAPI php_basic_globals basic_globals;
108108
#include "streamsfuncs.h"
109109
#include "basic_functions_arginfo.h"
110110

111-
static zend_class_entry *incomplete_class_entry = NULL;
112-
113111
typedef struct _user_tick_function_entry {
114112
zval *arguments;
115113
int arg_count;
@@ -220,7 +218,6 @@ static void basic_globals_ctor(php_basic_globals *basic_globals_p) /* {{{ */
220218
memset(&BG(mblen_state), 0, sizeof(BG(mblen_state)));
221219
#endif
222220

223-
BG(incomplete_class) = incomplete_class_entry;
224221
BG(page_uid) = -1;
225222
BG(page_gid) = -1;
226223
}
@@ -285,7 +282,7 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
285282
#endif
286283
#endif
287284

288-
BG(incomplete_class) = incomplete_class_entry = php_create_incomplete_class();
285+
php_register_incomplete_class();
289286

290287
REGISTER_LONG_CONSTANT("CONNECTION_ABORTED", PHP_CONNECTION_ABORTED, CONST_CS | CONST_PERSISTENT);
291288
REGISTER_LONG_CONSTANT("CONNECTION_NORMAL", PHP_CONNECTION_NORMAL, CONST_CS | CONST_PERSISTENT);

ext/standard/basic_functions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ typedef struct _php_basic_globals {
9797
char *syslog_device;
9898

9999
/* var.c */
100-
zend_class_entry *incomplete_class;
101100
unsigned serialize_lock; /* whether to use the locally supplied var_hash instead (__sleep/__wakeup) */
102101
struct {
103102
struct php_serialize_data *data;

ext/standard/incomplete_class.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"unserialize() gets called or provide an autoloader " \
2727
"to load the class definition"
2828

29+
PHPAPI zend_class_entry *php_ce_incomplete_class;
2930
static zend_object_handlers php_incomplete_object_handlers;
3031

3132
/* {{{ incomplete_class_message */
@@ -104,9 +105,9 @@ static zend_object *php_create_incomplete_object(zend_class_entry *class_type)
104105
return object;
105106
}
106107

107-
PHPAPI zend_class_entry *php_create_incomplete_class(void)
108+
PHPAPI void php_register_incomplete_class(void)
108109
{
109-
zend_class_entry incomplete_class, *incomplete_class_entry;
110+
zend_class_entry incomplete_class;
110111

111112
INIT_CLASS_ENTRY(incomplete_class, INCOMPLETE_CLASS, NULL);
112113

@@ -120,10 +121,8 @@ PHPAPI zend_class_entry *php_create_incomplete_class(void)
120121
php_incomplete_object_handlers.get_property_ptr_ptr = incomplete_class_get_property_ptr_ptr;
121122
php_incomplete_object_handlers.get_method = incomplete_class_get_method;
122123

123-
incomplete_class_entry = zend_register_internal_class(&incomplete_class);
124-
incomplete_class_entry->ce_flags |= ZEND_ACC_FINAL;
125-
126-
return incomplete_class_entry;
124+
php_ce_incomplete_class = zend_register_internal_class(&incomplete_class);
125+
php_ce_incomplete_class->ce_flags |= ZEND_ACC_FINAL;
127126
}
128127
/* }}} */
129128

ext/standard/php_incomplete_class.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919

2020
#include "ext/standard/basic_functions.h"
2121

22-
#define PHP_IC_ENTRY \
23-
BG(incomplete_class)
22+
extern PHPAPI zend_class_entry *php_ce_incomplete_class;
23+
24+
#define PHP_IC_ENTRY php_ce_incomplete_class
2425

2526
#define PHP_SET_CLASS_ATTRIBUTES(struc) \
2627
/* OBJECTS_FIXME: Fix for new object model */ \
27-
if (Z_OBJCE_P(struc) == BG(incomplete_class)) { \
28+
if (Z_OBJCE_P(struc) == php_ce_incomplete_class) { \
2829
class_name = php_lookup_class_name(Z_OBJ_P(struc)); \
2930
if (!class_name) { \
3031
class_name = zend_string_init(INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1, 0); \
@@ -48,7 +49,7 @@
4849
extern "C" {
4950
#endif
5051

51-
PHPAPI zend_class_entry *php_create_incomplete_class(void);
52+
PHPAPI void php_register_incomplete_class(void);
5253
PHPAPI zend_string *php_lookup_class_name(zend_object *object);
5354
PHPAPI void php_store_class_name(zval *object, const char *name, size_t len);
5455

0 commit comments

Comments
 (0)